hiyouga / LLaMA-Factory

Efficiently Fine-Tune 100+ LLMs in WebUI (ACL 2024)
https://arxiv.org/abs/2403.13372
Apache License 2.0
29.71k stars 3.65k forks source link

Phi-3-small Different Chat Template #4712

Open maksimstw opened 1 month ago

maksimstw commented 1 month ago

Reminder

System Info

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?

image image image

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|>
maksimstw commented 1 month ago

This issue might also be the cause of #3881