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

Inconsistency between fast and slow codellama tokenizers #26455

Closed
2 of 4 tasks
UniverseFly opened this issue Sep 28, 2023 · 2 comments · Fixed by #26678
Closed
2 of 4 tasks

Inconsistency between fast and slow codellama tokenizers #26455

UniverseFly opened this issue Sep 28, 2023 · 2 comments · Fixed by #26678

Comments

@UniverseFly
Copy link

UniverseFly commented Sep 28, 2023

System Info

  • transformers version: 4.33.2
  • Platform: Linux-5.15.0-82-generic-x86_64-with-glibc2.35
  • Python version: 3.10.12
  • Huggingface_hub version: 0.16.4
  • Safetensors version: 0.3.3
  • Accelerate version: 0.22.0
  • Accelerate config: not found
  • PyTorch version (GPU?): 2.0.1+cu117 (True)
  • Tensorflow version (GPU?): not installed (NA)
  • Flax version (CPU?/GPU?/TPU?): not installed (NA)
  • Jax version: not installed
  • JaxLib version: not installed
  • Using GPU in script?: no
  • Using distributed or parallel set-up in script?: no

Who can help?

@ArthurZucker

Information

  • The official example scripts
  • My own modified scripts

Tasks

  • An officially supported task in the examples folder (such as GLUE/SQuAD, ...)
  • My own task or dataset (give details below)

Reproduction

A simple reproduce:

from transformers import AutoTokenizer

t_fast = AutoTokenizer.from_pretrained("codellama/codellama-7B-Instruct-Hf", use_fast=True)
t_slow = AutoTokenizer.from_pretrained("codellama/codellama-7B-Instruct-Hf", use_fast=False)

ids_fast = t_fast.encode("<s>[INST]", add_special_tokens=False)
ids_slow = t_slow.encode("<s>[INST]", add_special_tokens=False)

assert ids_fast == ids_slow, f"Fast: {ids_fast}, Slow: {ids_slow}"
# AssertionError: Fast: [1, 518, 25580, 29962], Slow: [1, 25580, 29962]

Expected behavior

I'm not sure which one is correct. Actually decoding the fast tokenizer outputs will get '<s> [INST]', while the slow tokenizer '<s>INST]', both not same as the original string.

@ArthurZucker
Copy link
Collaborator

Hey! This was already reported and is a duplicate of #25881 and related to #26318 as well. Will be fixed in tokenizers soon!

@ArthurZucker
Copy link
Collaborator

The PR is looking good, had a few delays but was able to reproduce 1-1 with fast but also with sentencepiece actual token addition.

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

Successfully merging a pull request may close this issue.

2 participants