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
Finetune Yi model: RuntimeError: Unsloth: Extra special token <|startoftext|> with id=64000 exceeds the maximum vocabulary size of 64000 #61
I saw unsloth support finetune qlora model of Yi. So I tried using below script to finetune Yi-34B-Chat. Then I encountered blow error.
Could you please tell me how to fix it?
[INFO|tokenization_utils_base.py:2024] 2024-01-03 12:45:42,955 >> loading file tokenizer.model
[INFO|tokenization_utils_base.py:2024] 2024-01-03 12:45:42,956 >> loading file tokenizer.json
[INFO|tokenization_utils_base.py:2024] 2024-01-03 12:45:42,956 >> loading file added_tokens.json
[INFO|tokenization_utils_base.py:2024] 2024-01-03 12:45:42,956 >> loading file special_tokens_map.json
[INFO|tokenization_utils_base.py:2024] 2024-01-03 12:45:42,956 >> loading file tokenizer_config.json
Traceback (most recent call last):
File "/root/LLaMA-Factory/src/train_bash.py", line 14, in
main()
File "/root/LLaMA-Factory/src/train_bash.py", line 5, in main
run_exp()
File "/root/LLaMA-Factory/src/llmtuner/train/tuner.py", line 26, in run_exp
run_sft(model_args, data_args, training_args, finetuning_args, generating_args, callbacks)
File "/root/LLaMA-Factory/src/llmtuner/train/sft/workflow.py", line 29, in run_sft
model, tokenizer = load_model_and_tokenizer(model_args, finetuning_args, training_args.do_train)
File "/root/LLaMA-Factory/src/llmtuner/model/loader.py", line 75, in load_model_and_tokenizer
model, _ = FastLlamaModel.from_pretrained(**unsloth_kwargs)
File "/root/.local/conda/envs/cpp/lib/python3.10/site-packages/unsloth/models/llama.py", line 717, in from_pretrained
check_tokenizer(model, tokenizer)
File "/root/.local/conda/envs/cpp/lib/python3.10/site-packages/unsloth/models/_utils.py", line 131, in check_tokenizer
raise RuntimeError(
RuntimeError: Unsloth: Extra special token <|startoftext|> with id=64000 exceeds the maximum vocabulary size of 64000. You must fix the tokenizer or else out of bounds memory accesses will occur.
[2024-01-03 12:45:50,260] [INFO] [launch.py:315:sigkill_handler] Killing subprocess 27792
The model I'm trying to finetune is Yi-34B-Chat, not Yi-34B. I saw they have different tokenizer config. will this cause the issue I encountered?
Thank you!
@IvoryTower800@AIlaowong Just solved it with the latest patch! It'll be cool if you can try it out! It turns out using a FastTokenizer broke some of the chat models, so instead of an error, I use a SlowTokenizer to bypass the error.
Activity
danielhanchen commentedon Jan 3, 2024
@IvoryTower800 Maybe updating Unsloth might work?
For me it works fine for Yi-34b
IvoryTower800 commentedon Jan 3, 2024
@danielhanchen Thank you for your reply. I was running the same version of unsloth with you (I installed with pip install "unsloth[cu118] @ git+https://github.com/unslothai/unsloth.git").
Also, I tried create a new virtual environment with python 3.10+torch 2.1.0 + unsloth (pip install "unsloth[cu118] @ git+https://github.com/unslothai/unsloth.git"). the error still exists.
The model I'm trying to finetune is Yi-34B-Chat, not Yi-34B. I saw they have different tokenizer config. will this cause the issue I encountered?
Thank you!
danielhanchen commentedon Jan 3, 2024
@IvoryTower800 Oh yes that could be the reason - let me check the Chat version and get back to you
AIlaowong commentedon Jan 4, 2024
After updating today, I also encountered this issue when training yi-6b-chat.
danielhanchen commentedon Jan 4, 2024
@IvoryTower800 @AIlaowong Just solved it with the latest patch! It'll be cool if you can try it out! It turns out using a
FastTokenizerbroke some of the chat models, so instead of an error, I use aSlowTokenizerto bypass the error.Hope it works!
IvoryTower800 commentedon Jan 4, 2024
@danielhanchen Thank you so much. I just tried with latest code. It works! no errors any more!
danielhanchen commentedon Jan 5, 2024
@IvoryTower800 Yay!
danielhanchen commentedon Jan 6, 2024
Closing since solved!
Bug fixes (unslothai#61)
Bug fixes (unslothai#61)
Bug fixes (unslothai#61)
Merge pull request unslothai#61 from unslothai/feature/training-front…
Studio sd.cpp: pin the prebuilt resynced with upstream master-1056 (u…