You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[TEMP FIX] Ollama / llama.cpp: cannot find tokenizer merges in model file [duplicate] #1062
If you're installing Unsloth right from git like !pip install "unsloth[colab-new] @ git+https://github.com/unslothai/unsloth.git" it will just install the latest version of transformers as it's specifically requiring 4.45.
And then I installed Unsloth using the commit hash for the September 2024 release: !pip install "unsloth[colab-new] @ git+https://github.com/unslothai/unsloth.git@fb77505f8429566f5d21d6ea5318c342e8a67991" # Version: September-2024
The September 24 release of Unsloth is only requiring Transformers 4.44, so it does not attempt to upgrade the installation of Transformers installed in the first step.
my version in notebook -> transformers 4.44.2 (the same as the last week, when was working), but I had the same problem.
If you're installing Unsloth right from git like !pip install "unsloth[colab-new] @ git+https://github.com/unslothai/unsloth.git" it will just install the latest version of transformers as it's specifically requiring 4.45.
And then I installed Unsloth using the commit hash for the September 2024 release: !pip install "unsloth[colab-new] @ git+https://github.com/unslothai/unsloth.git@fb77505f8429566f5d21d6ea5318c342e8a67991" # Version: September-2024
The September 24 release of Unsloth is only requiring Transformers 4.44, so it does not attempt to upgrade the installation of Transformers installed in the first step.
But in this case you need to perform a new training or you only have to regenerate gguf?
But in this case you need to perform a new training or you only have to regenerate gguf?
It looks like its a problem with the tokenizer thats being exported by unsloth :(
---------------------------------------------------------------------------
Exception Traceback (most recent call last)
[<ipython-input-4-e8d6395b404e>](https://localhost:8080/#) in <cell line: 8>()
6 load_in_4bit = False # Use 4bit quantization to reduce memory usage. Can be False.
7
----> 8 model, _tokenizer = FastLanguageModel.from_pretrained(
9 model_name = "simmo/llama3.2-pyfim-3b",
10 max_seq_length = max_seq_length,
7 frames
[/usr/local/lib/python3.10/dist-packages/transformers/tokenization_utils_fast.py](https://localhost:8080/#) in __init__(self, *args, **kwargs)
113 elif fast_tokenizer_file is not None and not from_slow:
114 # We have a serialization from tokenizers which let us directly build the backend
--> 115 fast_tokenizer = TokenizerFast.from_file(fast_tokenizer_file)
116 elif slow_tokenizer is not None:
117 # We need to convert a slow tokenizer to build the backend
Exception: data did not match any variant of untagged enum ModelWrapper at line 1251003 column 3
Does the merged F16 version work, either raw or gguf?
My workflow involves saving the model using model.save_pretrained_merged("drive/MyDrive/my/path/here/", tokenizer, save_method = "merged_16bit",) and the using convert_hf_to_gguf.py on my Mac to generate the GGUF (first 16-bit then any quantizations I want) from the safe tensors created by Unsloth.
This has been working fine for me with my workaround to lock down the version of Unsloth to the September release.
Do be sure you're also manually installing Transformers, and specifying version 4.44.2. Otherwise if you just pip install transformers or let Unsloth install it for you, you'll end up with the latest version which is the root cause of this error.
EDIT:
If it helps, here is the full text of the first cell of my notebook:
%%capture
# Mount Google Drive for larger data sets / output
from google.colab import drive
drive.mount('/content/drive')
!pip install --upgrade --force-reinstall "transformers==4.44.2" "numpy==2.0.2" # https://github.com/unslothai/unsloth/issues/1062
!pip install "unsloth[colab-new] @ git+https://github.com/unslothai/unsloth.git@fb77505f8429566f5d21d6ea5318c342e8a67991" # Version: September-2024
!pip install --no-deps xformers trl peft accelerate bitsandbytes triton
It's the combination of manually installing Transformers and installing Unsloth from a specific hash, that are the keys to working around this for the time being.
I just communicated with the Hugging Face team - they will upstream updates to llama.cpp later in the week. It seems like tokenizers>=0.20.0 is the culprit.
I re-uploaded all Llama-3.2 models and as a temporary fix, Unsloth will use transformers==4.44.2.
Please try again and see if it works! This unfortunately means you need to re-finetune the model if you did not save the 16bit merged weights or LoRAs. Extreme apologies if you did, update unsloth then reload them and save them to GGUF.
Thanks @danielhanchen, and sorry for the disturbances; to give the context as to what is happening here, we updated the format of merges serialization in tokenizers to be much more flexible (this was done in this commit):
The change was done to be backwards-compatible : tokenizers and all libraries that depend on it will keep the ability to load merge files which were serialized in the old way.
However, it could not be forwards-compatible: if a file is serialized with the new format, older versions of tokenizers will not be able to load it.
This is why we're seeing this issue: new files are serialized using the new version, and these files are not loadable in llama.cpp, yet. We're updating all other codepaths (namely llama.cpp) to adapt to the new version. Once that is shipped, all your trained checkpoints will be directly loadable as usual. We're working with llama.cpp to ship this as fast as possible.
Hi, I have the same error as the guys above. I’ve tried different methods to fix this error, but nothing helps.
Training and inference in the notebook work just fine, but when I try to convert the model to GGUF and use it in Jan or llama.cpp, I get this error: error loading model vocabulary: cannot find tokenizer merges in model file.
This issue should be fixed now - sorry on the delay - please update with uv pip install --upgrade unsloth unsloth_zoo --force-reinstall --no-cache-dir - if the issue is still there, please open another issue - appreciate it again!
Activity
DiLiuNEUexpresscompany commentedon Sep 26, 2024
The interface on Colab looks correct, and I can successfully import the guff file in Jan, but I'm unable to use the model for generation.


danielhanchen commentedon Sep 27, 2024
Oh yep the issue is on transformers 4.45 - I'm communicating with them to fix the problem
laoc81 commentedon Sep 27, 2024
my version in notebook -> transformers 4.44.2 (the same as the last week, when was working), but I had the same problem.
jwhitehorn commentedon Sep 27, 2024
If you're installing Unsloth right from git like
!pip install "unsloth[colab-new] @ git+https://github.com/unslothai/unsloth.git"it will just install the latest version of transformers as it's specifically requiring 4.45.Here is how I worked around this bug:
First I manually installed Transformers:
!pip install --upgrade --force-reinstall "transformers==4.44.2" "numpy==2.0.2" # https://github.com/unslothai/unsloth/issues/1062And then I installed Unsloth using the commit hash for the September 2024 release:
!pip install "unsloth[colab-new] @ git+https://github.com/unslothai/unsloth.git@fb77505f8429566f5d21d6ea5318c342e8a67991" # Version: September-2024The September 24 release of Unsloth is only requiring Transformers 4.44, so it does not attempt to upgrade the installation of Transformers installed in the first step.
avvRobertoAlma commentedon Sep 27, 2024
But in this case you need to perform a new training or you only have to regenerate gguf?
xmaayy commentedon Sep 27, 2024
It looks like its a problem with the tokenizer thats being exported by unsloth :(
Mukunda-Gogoi commentedon Sep 28, 2024
Is there any workaround for this ? I am blocked. It was working fine just 3 days ago.
nullnuller commentedon Sep 29, 2024
I also tried your suggestion but it still fails
Does the merged F16 version work, either raw or gguf?
jwhitehorn commentedon Sep 29, 2024
My workflow involves saving the model using
model.save_pretrained_merged("drive/MyDrive/my/path/here/", tokenizer, save_method = "merged_16bit",)and the usingconvert_hf_to_gguf.pyon my Mac to generate the GGUF (first 16-bit then any quantizations I want) from the safe tensors created by Unsloth.This has been working fine for me with my workaround to lock down the version of Unsloth to the September release.
Do be sure you're also manually installing Transformers, and specifying version 4.44.2. Otherwise if you just
pip install transformersor let Unsloth install it for you, you'll end up with the latest version which is the root cause of this error.EDIT:
If it helps, here is the full text of the first cell of my notebook:
It's the combination of manually installing Transformers and installing Unsloth from a specific hash, that are the keys to working around this for the time being.
nullnuller commentedon Sep 30, 2024
Thanks, this worked. I hope they fix it properly.
danielhanchen commentedon Sep 30, 2024
Extreme apologies on the delay - was out for a few days - will get to the bottom of this and fix this asap - apologies again!
Mukunda-Gogoi commentedon Sep 30, 2024
@danielhanchen thank you. eagerly waiting for your fix to resume my work. <3
danielhanchen commentedon Sep 30, 2024
So it seems #1065 and this are identical as well - I will update both threads
danielhanchen commentedon Sep 30, 2024
I just communicated with the Hugging Face team - they will upstream updates to
llama.cpplater in the week. It seems liketokenizers>=0.20.0is the culprit.I re-uploaded all
Llama-3.2models and as a temporary fix, Unsloth will usetransformers==4.44.2.Please try again and see if it works! This unfortunately means you need to re-finetune the model if you did not save the 16bit merged weights or LoRAs. Extreme apologies if you did, update unsloth then reload them and save them to GGUF.
Update Unsloth via:
I will update everyone once the Hugging Face team resolves the issue! Sorry again!
Pinging: @jwhitehorn @xmaayy @avvRobertoAlma @nullnuller @DiLiuNEUexpresscompany @laoc81 @Mukunda-Gogoi
[-]Llama 3.1 Finetuning - GGUF errors[/-][+][TEMP FIX] Ollama / llama.cpp: cannot find tokenizer merges in model file [duplicate][/+]drsanta-1337 commentedon Sep 30, 2024
thanks @danielhanchen ! let me try it out!
danielhanchen commentedon Sep 30, 2024
@drsanta-1337 If you already updated - you might have to do it again sorry!! I just pushed changes into main
drsanta-1337 commentedon Sep 30, 2024
no probs!
LysandreJik commentedon Sep 30, 2024
Thanks @danielhanchen, and sorry for the disturbances; to give the context as to what is happening here, we updated the format of merges serialization in
tokenizersto be much more flexible (this was done in this commit):The change was done to be backwards-compatible :
tokenizersand all libraries that depend on it will keep the ability to load merge files which were serialized in the old way.However, it could not be forwards-compatible: if a file is serialized with the new format, older versions of
tokenizerswill not be able to load it.This is why we're seeing this issue: new files are serialized using the new version, and these files are not loadable in llama.cpp, yet. We're updating all other codepaths (namely llama.cpp) to adapt to the new version. Once that is shipped, all your trained checkpoints will be directly loadable as usual. We're working with llama.cpp to ship this as fast as possible.
Thank you!
Issue tracker in llama.cpp: ggml-org/llama.cpp#9692
drsanta-1337 commentedon Sep 30, 2024
@danielhanchen The fix is working now thanks, I fine-tuned, generated Q5_KM GGUF of llama-3.2-1B-Instruct and ran it using ollama
thanks a lot I'm unblocked now!
EduardChernikh commentedon Jan 28, 2025
Hi, I have the same error as the guys above. I’ve tried different methods to fix this error, but nothing helps.
Training and inference in the notebook work just fine, but when I try to convert the model to GGUF and use it in Jan or llama.cpp, I get this error: error loading model vocabulary: cannot find tokenizer merges in model file.
Any ideas?
danielhanchen commentedon Jun 17, 2026
This issue should be fixed now - sorry on the delay - please update with
uv pip install --upgrade unsloth unsloth_zoo --force-reinstall --no-cache-dir- if the issue is still there, please open another issue - appreciate it again!