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

Different result between use llama_tokenize and python original transformers tokenizer #7384

Closed
Liufeiran123 opened this issue May 19, 2024 · 6 comments

Comments

@Liufeiran123
Copy link

Different result between use llama_tokenize and python original transformers tokenizer

@Liufeiran123
Copy link
Author

the model is qwen1.5-7b

@JohannesGaessler
Copy link
Collaborator

Can you share the results that you get for each?

@Liufeiran123
Copy link
Author

when prompt contains “\n” , the results is different
Transformers token is New Line
llama_tokenizer token is "\n" literally

@Liufeiran123
Copy link
Author

the problem is llama_tokenize can not recognize the escape character,such as "\n".

@JohannesGaessler
Copy link
Collaborator

The llama.cpp binaries like main have a CLI argument called --escape that handles this. But the escaping seems to be resolved in common/common.cpp rather than in llama.cpp. So I don't think you can automatically escape control characters using the llama.h API and I don't know whether there is a reason for this.

@ggerganov
Copy link
Owner

It might be better to move the escape logic from common to llama and enable it by default, since the current implementation is causing confusion

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants