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

Difference between AutoTiktokenizer and HF AutoTokenizer #22

Open
amogkam opened this issue Jan 11, 2025 · 0 comments
Open

Difference between AutoTiktokenizer and HF AutoTokenizer #22

amogkam opened this issue Jan 11, 2025 · 0 comments

Comments

@amogkam
Copy link

amogkam commented Jan 11, 2025

Seems that AutoTiktokenizer is handling newline characters differently than Huggingface.

from autotiktokenizer import AutoTikTokenizer
from transformers import AutoTokenizer

text = "This is an \nexample"

hf_tokenizer = AutoTokenizer.from_pretrained("meta-llama/Meta-Llama-3-8B-Instruct")
auto_tokenizer = AutoTikTokenizer.from_pretrained("meta-llama/Meta-Llama-3-8B-Instruct")

hf_tokens = hf_tokenizer.encode(text, add_special_tokens=False)
auto_tokens = auto_tokenizer.encode(text)

assert hf_tokens == auto_tokens # This fails.
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

1 participant