microsoft / Phi-3CookBook

This is a Phi-3 book for getting started with Phi-3. Phi-3, a family of open sourced AI models developed by Microsoft. Phi-3 models are the most capable and cost-effective small language models (SLMs) available, outperforming models of the same size and next size up across a variety of language, reasoning, coding, and math benchmarks.
MIT License
2.51k stars 260 forks source link

Wrong LoRA Fine-tuning Code #199

Closed MaginaDai closed 2 weeks ago

MaginaDai commented 2 months ago

This issue is for the phi3 LoRA fine-tuning code you share.

- I follow the fine-tuning code you share to test the saved fine-tuned lora model. But the model won't output anything on the test set and the rouge scores are always zero.

<img width="631" alt="image" src="https://github.com/user-attachments/assets/588870b1-de12-4f63-b014-f20d385704d3">

The reason is the tokenizer appends EOS token to every sentence/word it encodes, which leads to early termination of the answer generation process. 

To fix this problem, we may set add_eos_token=False during the test.

tokenizer = AutoTokenizer.from_pretrained(merged_model, add_eos_token=False)