@@ -29,6 +29,7 @@ static void print_usage_information(const char * argv0, FILE * stream) {
29
29
fprintf (stream, " -p PROMPT, --prompt PROMPT read prompt from the argument.\n " );
30
30
fprintf (stream, " --stdin read prompt from standard input.\n " );
31
31
fprintf (stream, " --no-bos do not ever add a BOS token to the prompt, even if normally the model uses a BOS token.\n " );
32
+ fprintf (stream, " --no-parse-special do not parse control tokens.\n " );
32
33
fprintf (stream, " --log-disable disable logs. Makes stderr quiet when loading the model.\n " );
33
34
fprintf (stream, " --show-count print the total number of tokens.\n " );
34
35
}
@@ -195,6 +196,7 @@ int main(int raw_argc, char ** raw_argv) {
195
196
// variables where to put any arguments we see.
196
197
bool printing_ids = false ;
197
198
bool no_bos = false ;
199
+ bool no_parse_special = false ;
198
200
bool disable_logging = false ;
199
201
bool show_token_count = false ;
200
202
const char * model_path = NULL ;
@@ -229,6 +231,9 @@ int main(int raw_argc, char ** raw_argv) {
229
231
else if (arg == " --no-bos" ) {
230
232
no_bos = true ;
231
233
}
234
+ else if (arg == " --no-parse-special" ) {
235
+ no_parse_special = true ;
236
+ }
232
237
else if (arg == " -p" || arg == " --prompt" ) {
233
238
if (prompt_set) {
234
239
fprintf (stderr, " Error: -p or --prompt specified multiple times.\n " );
@@ -359,9 +364,10 @@ int main(int raw_argc, char ** raw_argv) {
359
364
360
365
const bool model_wants_add_bos = llama_should_add_bos_token (model);
361
366
const bool add_bos = model_wants_add_bos && !no_bos;
367
+ const bool parse_special = !no_parse_special;
362
368
363
369
std::vector<llama_token> tokens;
364
- tokens = ::llama_tokenize (model, prompt, add_bos, true );
370
+ tokens = ::llama_tokenize (model, prompt, add_bos, parse_special );
365
371
366
372
if (printing_ids) {
367
373
printf (" [" );
0 commit comments