@@ -31,6 +31,7 @@ static void print_usage_information(const char * argv0) {
31
31
printf (" -p PROMPT, --prompt PROMPT read prompt from the argument.\n " );
32
32
printf (" --stdin read prompt from standard input.\n " );
33
33
printf (" --no-bos do not ever add a BOS token to the prompt, even if normally the model uses a BOS token.\n " );
34
+ printf (" --no-escape do not escape input (such as \\ n, \\ t, etc.).\n " );
34
35
printf (" --no-parse-special do not parse control tokens.\n " );
35
36
printf (" --log-disable disable logs. Makes stderr quiet when loading the model.\n " );
36
37
printf (" --show-count print the total number of tokens.\n " );
@@ -198,6 +199,7 @@ int main(int raw_argc, char ** raw_argv) {
198
199
// variables where to put any arguments we see.
199
200
bool printing_ids = false ;
200
201
bool no_bos = false ;
202
+ bool no_escape = false ;
201
203
bool no_parse_special = false ;
202
204
bool disable_logging = false ;
203
205
bool show_token_count = false ;
@@ -233,6 +235,9 @@ int main(int raw_argc, char ** raw_argv) {
233
235
else if (arg == " --no-bos" ) {
234
236
no_bos = true ;
235
237
}
238
+ else if (arg == " --no-escape" ) {
239
+ no_escape = true ;
240
+ }
236
241
else if (arg == " --no-parse-special" ) {
237
242
no_parse_special = true ;
238
243
}
@@ -363,6 +368,11 @@ int main(int raw_argc, char ** raw_argv) {
363
368
const bool model_wants_add_bos = llama_add_bos_token (model);
364
369
const bool add_bos = model_wants_add_bos && !no_bos;
365
370
const bool parse_special = !no_parse_special;
371
+ const bool escape = !no_escape;
372
+
373
+ if (escape) {
374
+ string_process_escapes (prompt);
375
+ }
366
376
367
377
std::vector<llama_token> tokens;
368
378
tokens = common_tokenize (model, prompt, add_bos, parse_special);
0 commit comments