Skip to content

tokenize : escape the prompt - #11058

Merged
ggerganov merged 2 commits into
masterfrom
gg/tokenize-escape
Jan 6, 2025
Merged

ggerganov merged 2 commits into
masterfrom
gg/tokenize-escape

Conversation

@ggerganov

Copy link
Copy Markdown
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'

@danbev danbev left a comment

Copy link
Copy Markdown
Member

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
@ggerganov
ggerganov deleted the gg/tokenize-escape branch January 6, 2025 08:54
arthw pushed a commit to arthw/llama.cpp that referenced this pull request Feb 26, 2025
* tokenize : escape the prompt

* tokenize : update help
Seunghhon pushed a commit to Seunghhon/llama.cpp that referenced this pull request Apr 26, 2026
* tokenize : escape the prompt

* tokenize : update help
ljubomirj pushed a commit to ljubomirj/llama.cpp that referenced this pull request May 6, 2026
* tokenize : escape the prompt

* tokenize : update help
my-other-github-account pushed a commit to my-other-github-account/llama.cpp that referenced this pull request May 15, 2026
* tokenize : escape the prompt

* tokenize : update help
AlexiAlp pushed a commit to minghaop/llama.cpp that referenced this pull request Jun 2, 2026
* tokenize : escape the prompt

* tokenize : update help
AlexiAlp pushed a commit to minghaop/llama.cpp that referenced this pull request Jun 2, 2026
* tokenize : escape the prompt

* tokenize : update help
fukuro-kun pushed a commit to fukuro-kun/fukuro-llama-cpp-turboquant that referenced this pull request Jul 5, 2026
* tokenize : escape the prompt

* tokenize : update help
zommiommy pushed a commit to zommiommy/llama.cpp that referenced this pull request Aug 18, 2026
* tokenize : escape the prompt

* tokenize : update help
frostyautumnleaf pushed a commit to frostyautumnleaf/llama.cpp that referenced this pull request Oct 5, 2026
* 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

2 participants