Skip to content

[TEMP FIX] Ollama / llama.cpp: cannot find tokenizer merges in model file #1065

Closed

Description

@thackmann

Thank you for developing this useful resource. The Ollama notebook reports

{"error":"llama runner process has terminated: error loading modelvocabulary: cannot find tokenizer merges in model file"}

This is the notebook with the error. It is a copy of the original notebook.

This seems similar to the issue reported in #1062.

Activity

  1. laoc81 commented on Sep 27, 2024

    @laoc81

    Thank you for miraculous "unsloth"!! IT was working very well las week.

    Now, i am having the same problem that @thackmann:

    My notebook -> transformers 4.44.2 (the same last week).

    Error: llama runner process has terminated: error loading model: error loading model vocabulary: cannot find tokenizer merges in model file

  2. xmaayy commented on Sep 27, 2024

    @xmaayy

    Same issue!

  3. ThaisBarrosAlvim commented on Sep 28, 2024

    @ThaisBarrosAlvim

    Same issue!

  4. kingabzpro commented on Sep 28, 2024

    @kingabzpro

    same issue.

  5. Mukunda-Gogoi commented on Sep 28, 2024

    @Mukunda-Gogoi

    facing similar issues is there a fix?? I m blocked!

  6. Saber120 commented on Sep 28, 2024

    @Saber120

    same issue with llama3.2 3B , any solution please

  7. shimmyshimmer commented on Sep 28, 2024

    @shimmyshimmer
    Member

    Hey guys working on a fix. The new transformers version kind of broke everything

  8. adampetr commented on Sep 28, 2024

    @adampetr

    Same issue .. anyone have an idea where the problem is located.

  9. kingabzpro commented on Sep 28, 2024

    @kingabzpro

    same issue with llama3.2 3B , any solution please

    Yes. I tried to work around. Using llama.cpp but it didnt worked. The issues arise when we fine-tune and save the model.

  10. williamzebrowskI commented on Sep 28, 2024

    @williamzebrowskI

    Same issue. Huge bummer - literally spent hours fine tuning and uploading to HF to get these error the past couple of days thinking it was me.

  11. Franky-W commented on Sep 29, 2024

    @Franky-W

    same issue here.

    thank you @shimmyshimmer for working on the fix!

  12. mahiatlinux commented on Sep 29, 2024

    @mahiatlinux
    Contributor

    Hey guys. Yes, this is a current issue. But the boys are working to fix it. If you saved LORA, you might not have to rerun training.

  13. williamzebrowskI commented on Sep 29, 2024

    @williamzebrowskI

    There is a workaround that was posted here and it worked for me.

    #1062 (comment)

  14. kingabzpro commented on Sep 29, 2024

    @kingabzpro

    There is a workaround that was posted here and it worked for me.

    #1062 (comment)

    This will not work for Llama 3.2 models.

  15. gianmarcoalessio commented on Sep 29, 2024

    @gianmarcoalessio

    same issue!!

  16. 20 remaining items

  17. kingabzpro commented on Sep 30, 2024

    @kingabzpro

    The fix is not working on Kaggle.

  18. FotieMConstant commented on Sep 30, 2024

    @FotieMConstant

    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 HF weights or the LoRA weights - extreme apologiesnif you saved them, simply update Unsloth then reload them and convert to GGUF.

    Update Unsloth via:

    pip uninstall unsloth -y
    pip install --upgrade --no-cache-dir "unsloth[colab-new] @ git+https://github.com/unslothai/unsloth.git"
    

    I will update everyone once the Hugging Face team resolves the issue! Sorry again!

    Pinging everyone (and apologies for the issues and inconvenience again!!) @xmaayy @avvRobertoAlma @thackmann @kingabzpro @williamzebrowskI @FotieMConstant @laoc81 @gianmarcoalessio @ThaisBarrosAlvim @Franky-W @Saber120 @adampetr @David33706 @Mukunda-Gogoi

    image I get this error when i run the collab after applying the changes, seems to be an issue
  19. danielhanchen commented on Oct 1, 2024

    @danielhanchen
    Member

    @kingabzpro I just updated pypi so pip install unsloth should have the temporary fixes - you might have to restart Kaggle

  20. kingabzpro commented on Oct 1, 2024

    @kingabzpro

    @kingabzpro I just updated pypi so pip install unsloth should have the temporary fixes - you might have to restart Kaggle

    It is working on Kaggle now. Thank you.

  21. unpinned this issue on Oct 19, 2024
  22. lastrei commented on Dec 12, 2024

    @lastrei

    i'm sorry , but in still error in Version: 2024.12.4
    i install unsloth with pip install "unsloth[cu121-torch240] @ git+https://github.com/unslothai/unsloth.git"
    the transformer version is

    Name: transformers
    Version: 4.46.3
    

    numpy version is

    Name: numpy
    Version: 1.26.4
    

    i have save the adapter model,and convert to gguf ,when i run it in ollama ,it's still the same error:

    Error: llama runner process has terminated: error loading model: error loading model vocabulary: cannot find tokenizer merges in model file

  23. danielhanchen commented on Dec 12, 2024

    @danielhanchen
    Member

    @lastrei Apologies - do you know which model exactly?

  24. lastrei commented on Dec 13, 2024

    @lastrei

    @lastrei Apologies - do you know which model exactly?

    thanks danielhanchen,
    the model is unsloth/meta-llama-3.1-8b-instruct-bnb-4bit
    btw:
    I used llama-cpp to manually convert apater to gguf, which can be used in ollama with basemodel. This transformer upgrade brought a lot of troubles, and there are also corresponding llama-cpp problems:#748

  25. ethanelasky commented on Dec 13, 2024

    @ethanelasky

    I am getting a similar issue with the model meta-llama/Llama-3.1-8B-Instruct and the same numpy and transformers versions as @lastrei.

    Torch: 2.5.1, Cuda toolkit 12.1

  26. JohnWangCH commented on Dec 13, 2024

    @JohnWangCH

    I encountered the same problem a few hours ago.
    The problem has been solved with the following steps on my end:

    • Rebuild llama.cpp with the follow commands:
    cd llama.cpp
    git checkout git checkout a6744e43e80f4be6398fc7733a01642c846dce1d
    git submodule update --init --recursive
    make clean
    make all -j
    
    • Call model.save_pretrained_gguf again
    if True: model.save_pretrained_gguf("model", tokenizer,)
    

    Then, ollama can run the model w/o problems. FYR.

    My env:
    model_name = "unsloth/Llama-3.2-3B-Instruct",

    Name: numpy
    Version: 1.26.4

    Name: transformers
    Version: 4.46.3

    Name: unsloth
    Version: 2024.12.4

  27. lastrei commented on Dec 14, 2024

    @lastrei

    I encountered the same problem a few hours ago. The problem has been solved with the following steps on my end:

    • Rebuild llama.cpp with the follow commands:
    cd llama.cpp
    git checkout git checkout a6744e43e80f4be6398fc7733a01642c846dce1d
    git submodule update --init --recursive
    make clean
    make all -j
    
    • Call model.save_pretrained_gguf again
    if True: model.save_pretrained_gguf("model", tokenizer,)
    

    Then, ollama can run the model w/o problems. FYR.

    My env: model_name = "unsloth/Llama-3.2-3B-Instruct",

    Name: numpy Version: 1.26.4

    Name: transformers Version: 4.46.3

    Name: unsloth Version: 2024.12.4

    thanks JohnWangCH,i will try it


    it's works!

  28. phiwi commented on Mar 7, 2025

    @phiwi

    I am also experiencing the same error.

    transformers==4.46.3
    

    I saved and pushed a model finetuned with unsloth (derived from unsloth/Meta-Llama-3.1-8B):

      model.save_pretrained_gguf(
          f"{modelname}.GGUF",
          tokenizer,
      )
    
      model.push_to_hub_gguf(
          f"{username}/{modelname}, tokenizer, token=hf_key
      )
    

    When running Ollama (in Docker)

    ollama run hf.co/username/modelname
    

    I get

    Error: llama runner process has terminated: error loading model: error loading model vocabulary: cannot find tokenizer merges in model file
    
    llama_model_load_from_file_impl: failed to load model
    

    I tried the rollback from #1065 (comment) , saving, pushing and running via Ollama again, no improvements.

  29. manu-one commented on Jul 30, 2025

    @manu-one

    Ran into the same problem today.

    transformers 4.54.1
    unsloth 2025.7.11
    unsloth-zoo 2025.7.11

    ollama[193]: llama_model_load: error loading model: error loading model vocabulary: cannot find tokenizer merges in model file
    ollama[193]: llama_model_load_from_file_impl: failed to load model
    

    I tried the downgrade transformers fix but that caused the finetuning to fail entirely due to incompatiblity.

  30. danielhanchen commented on Jun 17, 2026

    @danielhanchen
    Member

    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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    URGENT BUGfixed - pending confirmation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions