unsloth
unsloth copied to clipboard
Add Phi-3 chat template
I'd like to fine tune the new Phi-3 model added yesterday, but it looks like the chat template file hasn't been updated to support it
There is now an example for it: https://colab.research.google.com/drive/1NvkBmkHfucGO3Ve9s1NKZvMNlw5p83ym?usp=sharing
@molbal this example doesn't show how to use the chat template with the Phi-3 model and the https://github.com/unslothai/unsloth/blob/main/unsloth/chat_templates.py file doesn't include it
I don't know that unfortunately.. Maybe its somewhere in here? https://github.com/unslothai/unsloth/pull/397 Or someone on the Discord server could help
in my tries it used it thus https://github.com/CrispStrobe/unsloth/blob/main/Phi3_ORPO_Unsloth.ipynb but now you can adapt to the non-llamafied model ofc
Oh very good point on the phi-3 template - will add one in
Any update @danielhanchen ?
@djannot Oh sorry! I actually added it in already - sorry guys forgot to update you all!
# Phi-3
phi3_template = \
"{{ bos_token }}"\
"{% for message in messages %}"\
"{{'<|' + message['role'] + '|>\n' + message['content'] + '<|end|>\n'}}"\
"{% endfor %}"\
"{% if add_generation_prompt %}"\
"{{ '<|assistant|>\n' }}"\
"{% endif %}"
phi3_template_eos_token = "<|end|>"
CHAT_TEMPLATES["phi-3"] = (phi3_template, phi3_template_eos_token,)
Use "phi-3" I might also allow "phi3"
Thanks !
I suppose it also works for Phi3 medium?