LLaMA-Factory
LLaMA-Factory copied to clipboard
Phi-3-small Different Chat Template
Reminder
- [X] I have read the README and searched the existing issues.
System Info
llamafactoryversion: 0.8.2- Platform: Linux-5.15.0-1040-azure-x86_64-with-glibc2.17
- Python version: 3.8.19
- PyTorch version: 2.3.1 (GPU)
- Transformers version: 4.41.2
- Datasets version: 2.19.2
- Accelerate version: 0.31.0
- PEFT version: 0.11.1
- TRL version: 0.9.4
- GPU type: NVIDIA A100 80GB PCIe
- DeepSpeed version: 0.14.2
Reproduction
command
CUDA_VISIBLE_DEVICES=0 llamafactory-cli chat examples/inference/phi3-small.yaml
phi3-small.yaml
model_name_or_path: microsoft/Phi-3-small-8k-instruct
template: phi
Expected behavior
When interacting with phi-3-small, the model does not predict the stop word token, or it breaks after 2-3 turns (shown in images below). This problem does not exist for phi-3-mini as it uses a different chat template and tokenizer. Can we fix the template for phi-3-small? Or is it because of another problem?
Others
microsoft/Phi-3-small-8k-instruct is a different model from all the other phi3 models (e.g. microsoft/Phi-3-mini-4k-instruct). As a result, it is using a different chat template. Phi-3-small-8k-instruct is also the only Phi-3 model that does not support using system messages.
Phi-3-small-8k-instruct Template
<|endoftext|><|user|>
I am going to Paris, what should I see?<|end|>
<|assistant|>
Paris, the capital of France, is known for its stunning architecture, art museums, historical landmarks, and romantic atmosphere. Here are some of the top attractions to see in Paris:\n\n1. The Eiffel Tower: The iconic Eiffel Tower is one of the most recognizable landmarks in the world and offers breathtaking views of the city.\n2. The Louvre Museum: The Louvre is one of the world's largest and most famous museums, housing an impressive collection of art and artifacts, including the Mona Lisa.\n3. Notre-Dame Cathedral: This beautiful cathedral is one of the most famous landmarks in Paris and is known for its Gothic architecture and stunning stained glass windows.\n\nThese are just a few of the many attractions that Paris has to offer. With so much to see and do, it's no wonder that Paris is one of the most popular tourist destinations in the world."<|end|>
<|user|>
What is so great about #1?<|end|>
<|assistant|>
Phi-3-mini-4k-instruct Template
<|system|>
You are a helpful travel assistant.<|end|>
<|user|>
I am going to Paris, what should I see?<|end|>
<|assistant|>
Paris, the capital of France, is known for its stunning architecture, art museums, historical landmarks, and romantic atmosphere. Here are some of the top attractions to see in Paris:\n\n1. The Eiffel Tower: The iconic Eiffel Tower is one of the most recognizable landmarks in the world and offers breathtaking views of the city.\n2. The Louvre Museum: The Louvre is one of the world's largest and most famous museums, housing an impressive collection of art and artifacts, including the Mona Lisa.\n3. Notre-Dame Cathedral: This beautiful cathedral is one of the most famous landmarks in Paris and is known for its Gothic architecture and stunning stained glass windows.\n\nThese are just a few of the many attractions that Paris has to offer. With so much to see and do, it's no wonder that Paris is one of the most popular tourist destinations in the world."<|end|>
<|user|>
What is so great about #1?<|end|>
<|assistant|>
This issue might also be the cause of #3881