Skip to content

Conversation

@ggerganov
Copy link
Member

fix #11054

Escape

make -j && ./bin/llama-tokenize -m ../models/llama-8b-v3-instruct/ggml-model-q4_0.gguf -p "<|im_start|>user\nhello who are you?<|im_end|>\n<|im_start|>assistant\n"

128000 -> '<|begin_of_text|>'
    27 -> '<'
    91 -> '|'
   318 -> 'im'
  5011 -> '_start'
    91 -> '|'
    29 -> '>'
   882 -> 'user'
   198 -> '
'
 15339 -> 'hello'
   889 -> ' who'
   527 -> ' are'
   499 -> ' you'
 76514 -> '?<'
    91 -> '|'
   318 -> 'im'
  6345 -> '_end'
    91 -> '|'
   397 -> '>
'
    27 -> '<'
    91 -> '|'
   318 -> 'im'
  5011 -> '_start'
    91 -> '|'
    29 -> '>'
 78191 -> 'assistant'
   198 -> '
'

No escape

make -j && ./bin/llama-tokenize -m ../models/llama-8b-v3-instruct/ggml-model-q4_0.gguf -p "<|im_start|>user\nhello who are you?<|im_end|>\n<|im_start|>assistant\n" --no-escape

128000 -> '<|begin_of_text|>'
    27 -> '<'
    91 -> '|'
   318 -> 'im'
  5011 -> '_start'
    91 -> '|'
    29 -> '>'
   882 -> 'user'
  1734 -> '\n'
 15339 -> 'hello'
   889 -> ' who'
   527 -> ' are'
   499 -> ' you'
 76514 -> '?<'
    91 -> '|'
   318 -> 'im'
  6345 -> '_end'
    91 -> '|'
  8616 -> '>\'
    77 -> 'n'
    27 -> '<'
    91 -> '|'
   318 -> 'im'
  5011 -> '_start'
    91 -> '|'
    29 -> '>'
 78191 -> 'assistant'
  1734 -> '\n'

Copy link
Member

@danbev danbev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps print_usage_information should be updated to add this new option as well?

@ggerganov ggerganov merged commit 3e6e7a6 into master Jan 6, 2025
4 checks passed
@ggerganov ggerganov deleted the gg/tokenize-escape branch January 6, 2025 08:54
tinglou pushed a commit to tinglou/llama.cpp that referenced this pull request Feb 13, 2025
* tokenize : escape the prompt

* tokenize : update help
arthw pushed a commit to arthw/llama.cpp that referenced this pull request Feb 26, 2025
* tokenize : escape the prompt

* tokenize : update help
mglambda pushed a commit to mglambda/llama.cpp that referenced this pull request Mar 8, 2025
* tokenize : escape the prompt

* tokenize : update help
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Eval bug: Output token sequence cannot match with AutoTokenizer

3 participants