Skip to content

Custom tokenizer no longer compatible with transformers 4.34 #26777

@dakinggg

Description

@dakinggg

System Info

  • transformers version: 4.34.0
  • Platform: macOS-13.5-arm64-arm-64bit
  • Python version: 3.10.12
  • Huggingface_hub version: 0.17.3
  • Safetensors version: 0.4.0
  • Accelerate version: 0.20.3
  • Accelerate config: not found
  • PyTorch version (GPU?): 2.1.0 (False)
  • Tensorflow version (GPU?): not installed (NA)
  • Flax version (CPU?/GPU?/TPU?): not installed (NA)
  • Jax version: not installed
  • JaxLib version: not installed

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

In [1]: import transformers

In [2]: replitt = transformers.AutoTokenizer.from_pretrained('replit/replit-code-v1-3b', trust_remote_code=True)

...

File ~/.cache/huggingface/modules/transformers_modules/replit/replit-code-v1-3b/cc0a4f17a8d72b71d62ea53cb0e23e4dac352067/replit_lm_tokenizer.py:76, in ReplitLMTokenizer.get_vocab(self)
75 def get_vocab(self):
---> 76 vocab = {self.convert_ids_to_tokens(i): i for i in range(self.vocab_size)}
77 vocab.update(self.added_tokens_encoder)
78 return vocab

File ~/.cache/huggingface/modules/transformers_modules/replit/replit-code-v1-3b/cc0a4f17a8d72b71d62ea53cb0e23e4dac352067/replit_lm_tokenizer.py:73, in ReplitLMTokenizer.vocab_size(self)
71 @Property
72 def vocab_size(self):
---> 73 return self.sp_model.get_piece_size()

AttributeError: 'ReplitLMTokenizer' object has no attribute 'sp_model'

Expected behavior

I don't actually know if it is expected to work or not, but maybe you can advise on the fix.

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