Skip to content

Inconsistency between fast and slow codellama tokenizers #26455

Description

@UniverseFly

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions