Qwen 2.5 0.5B - Distilled Tweet Emotion Classifier
An ultra-compact 494M parameter model fine-tuned on 4,041 Chain-of-Thought (CoT) reasoning traces distilled from GLM 5.3 Flash for Twitter emotion classification (cardiffnlp/tweet_eval).
Quick Usage
Using Apple MLX (Metal Accelerated)
mlx_lm.generate \
--model im-shashank-bhardwaj/Qwen2.5-0.5B-Distilled-Emotion \
--prompt "Analyze the sentiment of this tweet: 'So proud of our team today! We fought hard and won!'.
The possible labels are: anger, joy, optimism, sadness.
First, provide concise 2-3 sentence reasoning. Then on a new line output exactly: Final Label: <label>"
Using Transformers
from transformers import AutoModelForCausalLM, AutoTokenizer
model_id = "im-shashank-bhardwaj/Qwen2.5-0.5B-Distilled-Emotion"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id, device_map="auto")
prompt = """Analyze the sentiment of this tweet: 'So proud of our team today! We fought hard and won!'.
The possible labels are: anger, joy, optimism, sadness.
First, provide concise 2-3 sentence reasoning. Then on a new line output exactly: Final Label: <label>"""
messages = [{"role": "user", "content": prompt}]
input_text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer(input_text, return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=256)
print(tokenizer.decode(outputs[0][inputs.input_ids.shape[1]:], skip_special_tokens=True))
1. Experiment Objective
This experiment aims to investigate whether the reasoning capabilities and decision boundaries of a cloud-scale large language model (GLM-4 5.3 Flash, hosted serverless via Fireworks.ai) can be effectively transferred into an ultra-compact edge model (Qwen 2.5 0.5B) on social media emotion classification (cardiffnlp/tweet_eval). Rather than standard label imitation, the core objective is to transfer step-by-step Chain-of-Thought (CoT) rationales generated across 4,041 training instances so that a sub-billion parameter model running entirely on local consumer hardware (Apple Silicon) can bridge double-digit accuracy deficits, eliminate schema parsing failures, and rival cloud LLM performance with zero inference cost and sub-second latency.
2. Parameter Efficiency & Training Configurations
Training was executed natively on Apple Silicon using the Apple MLX framework (mlx-lm) with Low-Rank Adaptation (LoRA) to adapt the base Qwen/Qwen2.5-0.5B-Instruct model across two parameter scale configurations:
| Parameter Category | Base Model | Config A: LoRA Rank 8 | Config B: High-Rank LoRA 32 |
|---|---|---|---|
| Total Base Parameters | 494,033,000 (100%) | 494,033,000 | 494,033,000 |
| Trainable LoRA Parameters | — | 2,932,736 (~2.93M) | 11,730,944 (~11.73M) |
| Percentage Tuned | 0.0% | 0.594% | 2.375% ($4\times$ capacity) |
| Frozen Parameters | 494,033,000 (100%) | 491,100,264 (99.406%) | 482,302,056 (97.625%) |
3. Benchmark Results (506 Held-Out Test Samples)
Table 1: End-to-End Model Performance Comparison
| Metric | Teacher (glm-5p3-flash) |
Qwen 2.5 0.5B (Baseline) | Qwen 2.5 0.5B (Distilled $r=8$) | Qwen 2.5 0.5B (Distilled $r=32$) | $\Delta$ (Rank 32 vs Baseline) |
|---|---|---|---|---|---|
| Model Size | Cloud Large | 494M | 494M (2.93M tuned) | 494M (11.73M tuned) | — |
| Accuracy | 76.88% (389/506) | 61.66% (312/506) | 72.92% (369/506) | 74.90% (379/506) | +13.24% |
| Macro F1-Score | 0.7155 | 0.5937 | 0.6783 | 0.6880 | +0.0943 (+15.9%) |
| Weighted F1-Score | 0.7705 | 0.6268 | 0.7278 | 0.7423 | +0.1155 (+18.4%) |
| Unparseable Outputs | 1 (0.2%) | 7 (1.4%) | 0 (0.0%) | 0 (0.0%) | 100% valid format |
| Teacher Deficit | Benchmark | -15.22% | -3.96% | -1.98% | 87.0% deficit closed |
Table 2: Per-Class F1-Score Comparison
| Class | Support | Baseline F1 | Distilled $r=8$ F1 | Distilled $r=32$ F1 | Teacher F1 | Highlight |
|---|---|---|---|---|---|---|
| Anger | 212 | 0.6667 | 0.7887 | 0.8072 | 0.8510 | +14.05 pts over baseline |
| Joy | 117 | 0.6912 | 0.8198 | 0.8069 | 0.7490 | Both distilled students beat Teacher by +5.8 to +7.1 pts |
| Sadness | 133 | 0.5644 | 0.6407 | 0.6717 | 0.7447 | +10.73 pts over baseline (Recall up to 66.9%) |
| Optimism | 44 | 0.4524 | 0.4694 | 0.4638 | 0.5169 | Precision reached 0.6400 (vs 0.4259 in $r=8$) |