Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tokenize : escape the prompt #11058

Merged
merged 2 commits into from
Jan 6, 2025
Merged

tokenize : escape the prompt #11058

merged 2 commits into from
Jan 6, 2025

Conversation

ggerganov
Copy link
Owner

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
Collaborator

@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
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