Downloads · 30 days
11
15% of all-time downloads
asfahanjaved126/sentiment-classifier-v1
sentiment-classifier-v1 is a text classification model from asfahanjaved126. Use it when you need a label for a piece of text. It is set up for peft. The card lists the license as apache-2.0.
A LoRA fine-tuned adapter for Qwen2.5-3B-Instruct that classifies text as positive or negative sentiment. Trained on Amazon product review data.
Downloads · 30 days
11
15% of all-time downloads
All-time downloads
72
Public
Repo size
41 MB
Likes
0
Public
Click a slice to open those files.
.safetensors29.5 MB · 72%
From the Hugging Face model README
A LoRA fine-tuned adapter for Qwen2.5-3B-Instruct that classifies text as positive or negative sentiment. Trained on Amazon product review data.
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 |
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)
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.
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.