Skip to content

Phi-4 & Bug Fixes

Latest
Compare
Choose a tag to compare
@danielhanchen danielhanchen released this 10 Jan 22:43
· 2 commits to main since this release
b4c48d9
  • Please update Unsloth if you're seeing significant or unusual loss results—the latest update fixes an issue caused by the new transformers version. See our new updating instructions here

Phi-4 is now supported! We also fixed a few bugs in Phi-4 including:

  1. EOS token should not be <|endoftext|> but rather <|im_end|>
  2. Chat template did not have a add_generation_prompt
  3. Pad token should not be <|endoftext|> but rather <|dummy_87|>

Try Phi-4 finetuning out in our Colab Notebook for conversational workloads.

We also llama-fied Phi-4 (converted to Llama arch), and uploaded all fixed versions and GGUFs to https://huggingface.co/unsloth

Using Hugging Face's Open LLM Leaderboard, we can see our fixes and changes do work, and sometimes increase accuracy vs Microsoft's original Phi-4 model!
Phi

Other community members show our fixes do in fact work:

More details on bug fixes here: https://unsloth.ai/blog/phi4

We also uploaded dynamic 4bit quants as well, with error plots here:
Error

Bug Fixes

  • Gradient accumulation bug fix was not applied on Llama 3.2 Vision
  • Fix attention backwards performance regression for T4s, V100s for Xformers < 0.0.29
  • Enable gradients without make_inputs_require_grad - ie not just on model.get_input_embeddings() - this meant only language models had correctly applied requires_grad_(True), and all vision models had their PEFT modules on the vision part essentially be untrained.
  • Fix train_on_responses_only for Phi-4

New features

  • Auto enable gradient accumulation fixes for all models
  • Windows support via Triton Windows and Xformers for Windows
  • Xformers==0.0.29 support makes H100 training 10% faster
  • Updated all notebooks to use Github links

Update instructions

Please update Unsloth with no dependency updates via

pip install --upgrade --force-reinstall --no-deps --no-cache-dir unsloth unsloth_zoo

To get the latest Unsloth version, go to https://pypi.org/project/unsloth/ or do:

pip install unsloth

What's Changed

New Contributors