Instructions to use asfahanjaved126/reasoning-sentiment-classifier-v1 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use asfahanjaved126/reasoning-sentiment-classifier-v1 with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen2.5-7B-Instruct") model = PeftModel.from_pretrained(base_model, "asfahanjaved126/reasoning-sentiment-classifier-v1") - Notebooks
- Google Colab
- Kaggle
Reasoning Sentiment Classifier v1
A LoRA fine-tuned adapter for Qwen2.5-7B-Instruct that classifies text sentiment and explains its reasoning โ not just a label, but the specific phrase or reason behind the classification.
Example
Input: "This blender is absolutely terrible. It broke after one day."
Output:
Model Details
- Base model: Qwen/Qwen2.5-7B-Instruct
- Fine-tuning method: LoRA (Low-Rank Adaptation), rank 16, alpha 32
- Target modules: q_proj, k_proj, v_proj, o_proj
- Task: Sentiment classification with generated reasoning (positive / negative + explanation)
- Training data: 2,400 Amazon product reviews, with reasons extracted via rule-based key-phrase identification
- Trainable parameters: 10.1M (0.13% of total model parameters)
Performance
Evaluated on a held-out test set (sample of 50 examples):
| Metric | Score |
|---|---|
| Sentiment classification accuracy | 94% |
How to Use
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
import torch
base_model = AutoModelForCausalLM.from_pretrained(
"Qwen/Qwen2.5-7B-Instruct",
torch_dtype=torch.float16,
device_map={"": 0}
)
model = PeftModel.from_pretrained(base_model, "asfahanjaved126/reasoning-sentiment-classifier-v1")
tokenizer = AutoTokenizer.from_pretrained("asfahanjaved126/reasoning-sentiment-classifier-v1")
system_prompt = "Classify the sentiment as positive or negative, and give one brief reason why. Format your answer as:\nSentiment: <label>\nReason: <reason>"
messages = [
{"role": "system", "content": system_prompt},
{"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=60, 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 businesses that need not just sentiment classification but actionable insight into customer feedback โ identifying specific recurring complaint themes or praise points across large volumes of reviews, without manually reading each one.
Suitable for:
- Automated review analysis with explainability
- Customer feedback triage with reasoning for prioritization
- Building complaint-theme reports from raw review text
Limitations
- Trained only on binary sentiment (positive/negative); does not currently classify neutral sentiment.
- Reasoning was generated via rule-based key-phrase extraction during training data creation, not human-written explanations โ reasoning quality reflects this approach and may occasionally extract a less-central sentence from longer reviews.
- 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 Kaggle's free T4 GPU. Training used the TRL SFTTrainer with completion-only loss masking, cosine learning rate schedule, over 3 epochs. This checkpoint reflects training through 425 of 450 total steps (94%) due to a session interruption near the end of the final epoch.
- Downloads last month
- 36