This project documents the process of fine-tuning the meta-llama/Meta-Llama-3-8B-Instruct model to transform it from a general-purpose instruction model into a specialized sentiment analysis classifier.The baseline model exhibited significant weaknesses, including a strong positive bias and poor instruction adherence. Through targeted fine-tuning using QLoRA, this project successfully corrected these flaws, resulting in a robust and accurate model.
Fine-Tuned Model on Hugging Face HubThe final LoRA adapters for this project are publicly available on the Hugging Face Hub. You can access and use it here
The primary goal of this project was to demonstrably improve upon the zero-shot performance of the base model. The results show a dramatic increase in both accuracy and the model's ability to correctly classify negative sentiment.
- Baseline (Zero-Shot):
- Overall Accuracy: 50.95%
- F1-Score (Negative): 0.01
- Fine-Tuned (QLoRA):
- Overall Accuracy: 82.30%
- F1-Score (Negative): 0.78
- Model: meta-llama/Meta-Llama-3-8B-Instruct
- Dataset: A 5,000-sample subset of the Amazon Polarity dataset.
- Fine-Tuning Technique: QLoRA (Quantized Low-Rank Adaptation) to train the model in 4-bit precision.
- Optimization Library: Unsloth, which provided a speedup and significant memory savings over standard Hugging Face libraries.
- Evaluation: An evaluation pipeline was built to parse the models' outputs and compare the baseline performance against the final fine-tuned version on a 1,000-sample hold-out test set.