Instructions to use asfahanjaved126/sentiment-classifier-v1 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use asfahanjaved126/sentiment-classifier-v1 with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen2.5-3B-Instruct") model = PeftModel.from_pretrained(base_model, "asfahanjaved126/sentiment-classifier-v1") - Notebooks
- Google Colab
- Kaggle
Sentiment Classifier v1
A LoRA fine-tuned adapter for Qwen2.5-3B-Instruct that classifies text as positive or negative sentiment. Trained on Amazon product review data.
Model Details
- Base model: Qwen/Qwen2.5-3B-Instruct
- Fine-tuning method: LoRA (Low-Rank Adaptation), rank 16, alpha 32
- Target modules: q_proj, k_proj, v_proj, o_proj
- Task: Binary sentiment classification (positive / negative)
- Training data: 2,400 examples from Amazon product reviews
- Trainable parameters: 7.4M (0.24% of total model parameters)
Performance
Evaluated on a held-out test set of 300 examples:
| Metric | Score |
|---|---|
| Accuracy | 97% |
| Weighted F1 | 0.97 |
| Positive precision / recall | 0.98 / 0.96 |
| Negative precision / recall | 0.97 / 0.98 |
How to Use
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
import torch
base_model = AutoModelForCausalLM.from_pretrained(
"Qwen/Qwen2.5-3B-Instruct",
torch_dtype=torch.float16,
device_map="auto"
)
model = PeftModel.from_pretrained(base_model, "asfahanjaved126/sentiment-classifier-v1")
tokenizer = AutoTokenizer.from_pretrained("asfahanjaved126/sentiment-classifier-v1")
messages = [
{"role": "system", "content": "Classify as positive or negative. One word only."},
{"role": "user", "content": "This product completely changed how I work, love it!"}
]
prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
output = model.generate(**inputs, max_new_tokens=5, temperature=0.0, do_sample=False)
result = tokenizer.decode(output[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True)
print(result)
Intended Use
This model is designed for classifying customer reviews, feedback, and similar short-form text into positive/negative sentiment categories. Suitable for e-commerce review analysis, customer feedback triage, and similar use cases.
Limitations
- Trained only on binary sentiment (positive/negative); does not currently classify neutral sentiment.
- Trained on Amazon product review data; may perform differently on other domains without further fine-tuning.
- English language only.
Training Procedure
Fine-tuned using QLoRA (4-bit quantization) on a single T4 GPU via Google Colab. Training used the TRL SFTTrainer with completion-only loss masking, cosine learning rate schedule, and 3 epochs over the training set.
- Downloads last month
- 40