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

Token mis-manipulation for Chinese Characters #108

Open
yytang220 opened this issue May 24, 2024 · 4 comments
Open

Token mis-manipulation for Chinese Characters #108

yytang220 opened this issue May 24, 2024 · 4 comments

Comments

@yytang220
Copy link

Code is here https://github.com/noamgat/lm-format-enforcer/blob/main/lmformatenforcer/integrations/transformers.py#L69
image

This line will affect generation for chinese character. Use
cleaned = decoded will temporarily solve this problem.

Since I don't know the whole logic, seeking permenant solution.

@noamgat
Copy link
Owner

noamgat commented May 25, 2024

Can you give a code sample of a reproduction of a problematic scenario that this line change solves?

@yytang220
Copy link
Author

Can you give a code sample of a reproduction of a problematic scenario that this line change solves?

before:
image
after:
image

per-token decode using different decode_fn
top: with rstrip, bottom: without rstrip
image

@noamgat
Copy link
Owner

noamgat commented May 31, 2024

Hi, thanks for the detailed example.
In order to reproduce it in code, can you share the model + prompt + schema that you are using in order to generate text?
Alternatively, the tokenizer + token sequence (numbers, not letters) that you get.

@yytang220
Copy link
Author

Hi, thanks for the detailed example. In order to reproduce it in code, can you share the model + prompt + schema that you are using in order to generate text? Alternatively, the tokenizer + token sequence (numbers, not letters) that you get.

token_list : [19788,818,2828,440,13501,4202,8798, 697, 121, 2256]
tokenizer: deepseek-coder (https://huggingface.co/deepseek-ai/deepseek-coder-6.7b-base)

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

2 participants