You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/runner_build.md
+23-17Lines changed: 23 additions & 17 deletions
Original file line number
Diff line number
Diff line change
@@ -1,11 +1,11 @@
1
1
# Native Execution
2
2
3
-
While Python offers a great environment for training models and experimentation and research with models, developers
4
-
often are looking to use a native execution environment, either to achieve a certain performance level, or when
3
+
While Python offers a great environment for training models and experimentation and research with models, developers
4
+
often are looking to use a native execution environment, either to achieve a certain performance level, or when
5
5
including a Python is undesirable (e.g., in a game application that wants to use an LLM for user interaction) or impossible (devices
6
6
with limited functionality and memory capacity).
7
7
8
-
The 'llama runner' is a native standalone application capable of running a model exported and compiled ahead-of-time with either Executorch (ET) or AOT Inductor (AOTI). Which model format to use depends on your requirements and preferences. Executorch modelsare optimized for portability across a range of decices, including mobile and edge devices. AOT Inductor models are optimized for a particular target architecture, which may result in better performance and efficiency.
8
+
The 'llama runner' is a native standalone application capable of running a model exported and compiled ahead-of-time with either Executorch (ET) or AOT Inductor (AOTI). Which model format to use depends on your requirements and preferences. Executorch modelsare optimized for portability across a range of decices, including mobile and edge devices. AOT Inductor models are optimized for a particular target architecture, which may result in better performance and efficiency.
9
9
10
10
Building the runners is straightforward with the included cmake build files and is covered in the next sections. We will showcase the runners using ~~stories15M~~ llama2 7B and llama3.
11
11
@@ -31,14 +31,16 @@ The runners accept the following command-line arguments:
31
31
32
32
```
33
33
Options:
34
-
-t <float> temperature in [0,inf], default 1.0
35
-
-p <float> p value in top-p (nucleus) sampling in [0,1] default 0.9
36
-
-s <int> random seed, default time(NULL)
37
-
-n <int> number of steps to run for, default 256. 0 = max_seq_len
./cmake-out/et_run ./model.pte -z ./tokenizer.bin -i "Once upon a time"
107
+
./cmake-out/et_run ./model.pte -z ./tokenizer.bin -l 2 -i "Once upon a time"
104
108
```
105
109
110
+
The `-l 2` indicates that the model and tokenizer use the llama2 architecture. If your model is based on llama3, use `-l 3`.
111
+
106
112
## Appendix: Llama runner tokenizers
107
113
108
-
Tokenizers are essential tools in Natural Language Processing (NLP) that convert text into smaller units, such as words or phrases, known as tokens. Two popular tokenizers are SentencePiece and Tiktoken. [SentencePiece](https://github.com/google/sentencepiece) is an unsupervised text tokenizer and detokenizer mainly for Neural Network-based text generation systems where the vocabulary size is predetermined prior to the neural model training. Llama2-style models typically use the SentencePiece tokenizer. Tiktoken is a newer tokenizer originally developed by OpenAI that allows you to see how many tokens a text string will use without making an API call. Llama3 uses the Tiktoken tokenizer.
109
-
Torchchat includes both Python and C/C++ implementations of both the SentencePiece and Tiktoken tokenizers that may be used with the Python and native execution environments, respectively.
114
+
Tokenizers are essential tools in Natural Language Processing (NLP) that convert text into smaller units, such as words or phrases, known as tokens. Two popular tokenizers are SentencePiece and Tiktoken. [SentencePiece](https://github.com/google/sentencepiece) is an unsupervised text tokenizer and detokenizer mainly for Neural Network-based text generation systems where the vocabulary size is predetermined prior to the neural model training. Llama2-style models typically use the SentencePiece tokenizer. Tiktoken is a newer tokenizer originally developed by OpenAI that allows you to see how many tokens a text string will use without making an API call. Llama3 uses the Tiktoken tokenizer.
115
+
Torchchat includes both Python and C/C++ implementations of both the SentencePiece and Tiktoken tokenizers that may be used with the Python and native execution environments, respectively.
110
116
111
117
The SentencePiece tokenizer implementations for Python (developed by Google) and the C/C++ implementation (developed by Andrej Karpathy) use different input formats. The Python implementation reads a tokenizer specification in `tokenizer.model` format. The C/C++ tokenizer that reads the tokenizer instructions from a file in `tokenizer.bin` format. We include Andrej's SentencePiece converter which translates a SentencePiece tokenizer in `tokenizer.model` format to `tokenizer.bin` in the utils subdirectory:
112
118
```
@@ -120,4 +126,4 @@ Both can be achieved with the Python environment. All torchchat Python comands
120
126
121
127
The `eval` tool evaluates model quality using metrics such as 'perplexity' that are commonly used in the NLP community to evaluate output quality. Load your model exported model to evaluate quality metrics for exported models. You can find an introduction to the eval tool in the [README](../README.md) file.
122
128
123
-
The `generate`, `chat` and `browser` tools enable you to verify that the exported model works correctly, as a debugging aid if you are developing your own native execution environment based on the llama runner provided with torchchat.
129
+
The `generate`, `chat` and `browser` tools enable you to verify that the exported model works correctly, as a debugging aid if you are developing your own native execution environment based on the llama runner provided with torchchat.
0 commit comments