Skip to content

Fine-tuned the Llama-3-8B-Instruct model to transform it from a generalist model into a decent sentiment classifier.

Notifications You must be signed in to change notification settings

LoyumM/Finetuning_llama3_8B_lora

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 

Repository files navigation

Fine-Tuning Llama 3 8B for High-Accuracy Sentiment Analysis

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

Performance: Before vs. After

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

Key Components:

  • 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.

About

Fine-tuned the Llama-3-8B-Instruct model to transform it from a generalist model into a decent sentiment classifier.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published