This project demonstrates fine-tuning and inference using the Qwen2.5-Coder
model with the unsloth
library.
- Install required libraries:
pip install unsloth transformers datasets trl peft
- Authenticate Hugging Face:
Set your Hugging Face token:
from google.colab import userdata HF_TOKEN = userdata.get('HF_TOKEN')
The script loads the model and tokenizer with LoRA adapters for efficient fine-tuning.
It uses an Alpaca-style dataset for training (iamtarun/python_code_instructions_18k_alpaca
).
The fine-tuning process is configured to run for 2 epochs with a batch size of 2.
After training:
- Optionally push it to the Hugging Face Hub.
Use the model to generate responses for custom instructions. Example:
results = Inference.run_inference(
model, tokenizer,
"Write a function for a merge interval.", ""
)
print(results[0])
- Ensure CUDA is enabled for better performance.
- Update
ORG_NAME
andMODEL
to use your Hugging Face repository.
That's it! You can now fine-tune.