transformers.AutoTokenizer.from_pretrained( ... use_Fast=False) fails with 'TypeError: not a string' for some tokenizers
Author: Jeronymous
Pull request: no

### System Info

- `transformers` version: 4.37.2
- Platform: Linux-5.15.133.1-microsoft-standard-WSL2-x86_64-with-glibc2.35       
- Python version: 3.10.12
- Huggingface_hub version: 0.19.4
- Safetensors version: 0.4.1
- Accelerate version: not installed
- Accelerate config: not found
- PyTorch version (GPU?): 2.1.2+cu121 (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?: <fill in>
- Using distributed or parallel set-up in script?: <fill in>

Also I tried the following versions:
- `tokenizers` version: 0.15.0 and 0.15.2 (latest)
- `sentencepiece` version: 0.1.99 and 0.2.0 (latest)

### Who can help?

[ArthurZucker](https://github.com/ArthurZucker)

### Information

- [X] The official example scripts
- [ ] My own modified scripts

### Tasks

- [X] An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...)
- [ ] My own task or dataset (give details below)

### Reproduction

(that may be a duplicate of https://github.com/huggingface/transformers/issues/27845)

```
import transformers
tokenizer = transformers.AutoTokenizer.from_pretrained("croissantllm/CroissantLLMBase", use_fast=False)
```
This fails with
```
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-1-9fe531439285> in <module>
      1 import transformers
----> 2 tokenizer = transformers.AutoTokenizer.from_pretrained("croissantllm/CroissantLLMBase", use_fast=False)

~/.local/lib/python3.10/site-packages/transformers/models/auto/tokenization_auto.py in from_pretrained(cls, pretrained_model_name_or_path, *inputs, **kwargs)
    812                     f"Tokenizer class {tokenizer_class_candidate} does not exist or is not currently imported."
    813                 )
--> 814             return tokenizer_class.from_pretrained(pretrained_model_name_or_path, *inputs, **kwargs)
    815
    816         # Otherwise we have to be creative.

~/.local/lib/python3.10/site-packages/transformers/tokenization_utils_base.py in from_pretrained(cls, pretrained_model_name_or_path, cache_dir, force_download, local_files_only, token, revision, *init_inputs, **kwargs)
   2027                 logger.info(f"loading file {file_path} from cache at {resolved_vocab_files[file_id]}")
   2028
-> 2029         return cls._from_pretrained(
   2030             resolved_vocab_files,
   2031             pretrained_model_name_or_path,

~/.local/lib/python3.10/site-packages/transformers/tokenization_utils_base.py in _from_pretrained(cls, resolved_vocab_files, pretrained_model_name_or_path, init_configuration, token, cache_dir, local_files_only, _commit_hash, _is_local, *init_inputs, **kwargs)
   2259         # Instantiate the tokenizer.
   2260         try:
-> 2261             tokenizer = cls(*init_inputs, **init_kwargs)
   2262         except OSError:
   2263             raise OSError(

~/.local/lib/python3.10/site-packages/transformers/models/llama/tokenization_llama.py in __init__(self, vocab_file, unk_token, bos_token, eos_token, pad_token, sp_model_kwargs, add_bos_token, add_eos_token, clean_up_tokenization_spaces, use_default_system_prompt, spaces_between_special_tokens, legacy, **kwargs)
    176         self.add_eos_token = add_eos_token
    177         self.use_default_system_prompt = use_default_system_prompt
--> 178         self.sp_model = self.get_spm_processor(kwargs.pop("from_slow", False))
    179
    180         super().__init__(

~/.local/lib/python3.10/site-packages/transformers/models/llama/tokenization_llama.py in get_spm_processor(self, from_slow)
    201         tokenizer = spm.SentencePieceProcessor(**self.sp_model_kwargs)
    202         if self.legacy or from_slow:  # no dependency on protobuf
--> 203             tokenizer.Load(self.vocab_file)
    204             return tokenizer
    205

/usr/local/lib/python3.10/dist-packages/sentencepiece/__init__.py in Load(self, model_file, model_proto)
    903       if model_proto:
    904         return self.LoadFromSerializedProto(model_proto)
--> 905       return self.LoadFromFile(model_file)
    906
    907

/usr/local/lib/python3.10/dist-packages/sentencepiece/__init__.py in LoadFromFile(self, arg)
    308
    309     def LoadFromFile(self, arg):
--> 310         return _sentencepiece.SentencePieceProcessor_LoadFromFile(self, arg)
    311
    312     def _EncodeAsIds(self, text, enable_sampling, nbest_size, alpha, add_bos, add_eos, reverse, emit_unk_piece):

TypeError: not a string
```


### Expected behavior

I would expect that tokenizer to load.

(Note: I had this error while investigating why the fast tokenizer does not scale well with the text length, but this is another issue)

Comments:
cc @ArthurZucker 

Hey! Thanks for reporting. 
`tokenizer.Load(self.vocab_file)` seems to be the issue here. If you check the repo it does not have the `tokenizer.model` .
You should raise the issue there! 


Thanks @ArthurZucker 👍 

a quick follow up question, I found that `tokenizer = AutoTokenizer.from_pretrained("meta-llama/Meta-Llama-3-8B-Instruct", revision="c9231f6", use_fast=False)` actually worked. but this model has no tokenizer.model, too. Is this expected?

This still loads a `fast` tokenizer 😉 

(if you print the class of the tokenizer, it should be a PreTrainedTokenizerFast instance as that's the only class supported by llama-3, and that's what is defined in the tokenizer's config.json)

What is use_fast=False means?  

```
        self.tokenizer = AutoTokenizer.from_pretrained(
           'facebook/MobileLLM-350M', model_max_length=self.llm_max_length, token=hf_token, padding_side="right"
        )
```
But failed,  self.tokenizer is a bool False.  It is because `use_fast=False`.

Ok I learned it in https://huggingface.co/learn/nlp-course/chapter6/3  .