Skip to content

KeyError: '__EOS_TOKEN__' #953

Closed
Closed

Description

@zs856

Wehn I was executing GGUF / llama.cpp conversion, I got this error:

INFO:gguf.vocab:Setting chat_template to {% if 'role' in messages[0] %}{% if messages[0]['role'] == 'system' %}{% if messages[1]['role'] == 'user' %}{{ '[INST] ' + messages[0]['content'] + ' ' + messages[1]['content'] + ' [/INST]' }}{% set loop_messages = messages[2:] %}{% else %}{{ '[INST] ' + messages[0]['content'] + ' [/INST]' }}{% set loop_messages = messages[1:] %}{% endif %}{% else %}{% set loop_messages = messages %}{% endif %}{% for message in loop_messages %}{% if message['role'] == 'user' %}{{ '[INST] ' + message['content'] + ' [/INST]' }}{% elif message['role'] == 'assistant' %}{{ message['content'] + eos_token }}{% else %}{{ raise_exception('Only user and assistant roles are supported!') }}{% endif %}{% endfor %}{% else %}{% if messages[0]['from'] == 'system' %}{% if messages[1]['from'] == 'human' %}{{ '[INST] ' + messages[0]['value'] + ' ' + messages[1]['value'] + ' [/INST]' }}{% set loop_messages = messages[2:] %}{% else %}{{ '[INST] ' + messages[0]['value'] + ' [/INST]' }}{% set loop_messages = messages[1:] %}{% endif %}{% else %}{% set loop_messages = messages %}{% endif %}{% for message in loop_messages %}{% if message['from'] == 'human' %}{{ '[INST] ' + message['value'] + ' [/INST]' }}{% elif message['from'] == 'gpt' %}{{ message['value'] + eos_token }}{% else %}{{ raise_exception('Only user and assistant roles are supported!') }}{% endif %}{% endfor %}{% endif %}
INFO:hf-to-gguf:Set model quantization version
INFO:gguf.gguf_writer:Writing the following files:
INFO:gguf.gguf_writer:nemo_model/unsloth.F16.gguf: n_tensors = 363, total_size = 24.5G
Writing: 100%|██████████| 24.5G/24.5G [00:56<00:00, 433Mbyte/s]
INFO:hf-to-gguf:Model successfully exported to nemo_model/unsloth.F16.gguf
Unsloth: Conversion completed! Output location: ./nemo_model/unsloth.F16.gguf
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
Cell In[18], line 8
      5 if False: model.push_to_hub_gguf("hf/model", tokenizer, token = "")
      7 # Save to 16bit GGUF
----> 8 if True: model.save_pretrained_gguf("nemo_model", tokenizer, quantization_method = "f16")
      9 if False: model.push_to_hub_gguf("hf/model", tokenizer, quantization_method = "f16", token = "")
     11 # Save to q4_k_m GGUF

File /luxshare-finetune/unsloth/unsloth/save.py:1643, in unsloth_save_pretrained_gguf(self, save_directory, tokenizer, quantization_method, first_conversion, push_to_hub, token, private, is_main_process, state_dict, save_function, max_shard_size, safe_serialization, variant, save_peft_format, tags, temporary_location, maximum_memory_usage)
   1638 all_file_locations = save_to_gguf(model_type, model_dtype, is_sentencepiece_model, 
   1639     new_save_directory, quantization_method, first_conversion, makefile,
   1640 )
   1642 # Save Ollama modelfile
-> 1643 modelfile = create_ollama_modelfile(tokenizer, all_file_locations[0])
   1644 modelfile_location = None
   1645 if modelfile is not None:

File /luxshare-finetune/unsloth/unsloth/save.py:1492, in create_ollama_modelfile(tokenizer, gguf_location)
   1489 modelfile = getattr(tokenizer, "_ollama_modelfile", None)
   1490 if modelfile is None: return None
-> 1492 modelfile = modelfile\
   1493     .replace("{{", "⚫@✅#🦥")\
   1494     .replace("}}", "⚡@🦥#⛵")\
   1495     .format(
   1496         __FILE_LOCATION__  = gguf_location,
   1497     )\
   1498     .replace("⚫@✅#🦥", "{{")\
   1499     .replace("⚡@🦥#⛵", "}}")\
   1500     .rstrip()
   1501 pass
   1503 return modelfile

KeyError: '__EOS_TOKEN__'

Unsloth version: Phi3.5 release
Python Version: 3.10

[tool.poetry.dependencies]
python = "^3.10"
unsloth = {path = "unsloth", extras = ["colab-new"], develop = true}
trl = "<0.9.0"
peft = "^0.12.0"
accelerate = "^0.33.0"
bitsandbytes = "^0.43.3"
polars = "^1.3.0"
torch = {version = "^2.4.0+cu124", source = "pytorch-gpu-src"}
torchvision = {version = "^0.19.0+cu124", source = "pytorch-gpu-src"}
torchaudio = {version = "^2.4.0+cu124", source = "pytorch-gpu-src"}
xformers = "^0.0.27.post2"

model: unsloth/Mistral-Nemo-Instruct-2407

Activity

  1. danielhanchen commented on Aug 23, 2024

    @danielhanchen
    Member

    Will fix this ASAP!!

  2. zs856 commented on Aug 27, 2024

    @zs856
    Author

    Will fix this ASAP!!

    Thank you for your prompt response!

  3. danielhanchen commented on Aug 27, 2024

    @danielhanchen
    Member

    Should just be fixed! Please update Unsloth via

    pip uninstall unsloth -y
    pip install --upgrade --no-cache-dir "unsloth[colab-new] @ git+https://github.com/unslothai/unsloth.git"
  4. zs856 commented on Aug 29, 2024

    @zs856
    Author

    Should just be fixed! Please update Unsloth via

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

    Yesterday, I used mistral-nemo and, after using the mistral template, confirmed that there were no more errors. I am deeply grateful for your support and assistance.

  5. added 2 commits that reference this issue on Jul 28, 2026
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

    currently fixing

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions