unslothai / unsloth

Finetune Llama 3.1, Mistral, Phi & Gemma LLMs 2-5x faster with 80% less memory
https://unsloth.ai
Apache License 2.0
15.87k stars 1.07k forks source link

How to prevent trained model answering outside of domain #831

Open MuhammadBilal848 opened 1 month ago

MuhammadBilal848 commented 1 month ago

I have trained Llama3.1 and it is performing well but when I ask it a question outside of the domain it is answering it instead of avoiding the question.

Is there any workaround to this?

danielhanchen commented 1 month ago

If it's outside of domain, but you did not finetune it on anything, sadly it might have overfit - you could try averaging the finetuned weights with the general instruct model which might reduce this issue

Ammar-Alnagar commented 1 month ago

I suggest prompting it to avoid answering question outside your desired domain and provide an alternate response if asked about anything not related to the domain , you can also tell it to answer based only on the training data and try messing around with temperature value