Downloads · 30 days
65
45% of all-time downloads
sarimahsan101/Qwen2.5-0.5B-HiddenDistilled-LoRA
Qwen2.5-0.5B-HiddenDistilled-LoRA is a text generation model from sarimahsan101. Use it when you need the model to write or continue text. It is set up for peft. The card lists the license as apache-2.0.
This model repository contains the LoRA adapter weights for Qwen2.5-0.5B-Instruct distilled from the teacher model Qwen2.5-3B-Instruct. The distillation objective integrates SFT cross-entropy loss, logit-level Kullbac…
Downloads · 30 days
65
45% of all-time downloads
All-time downloads
143
Public
Repo size
81.9 MB
Likes
0
Public
Click a slice to open those files.
.safetensors70.4 MB · 86%
From the Hugging Face model README
This model repository contains the LoRA adapter weights for Qwen2.5-0.5B-Instruct distilled from the teacher model Qwen2.5-3B-Instruct. The distillation objective integrates SFT cross-entropy loss, logit-level Kullback-Leibler (KL) divergence, and linear projection-based hidden state matching.
These metrics were recorded during a trial run on a single NVIDIA Tesla T4 (16GB) GPU for 1 epoch on a subset of Alpaca, Dolly, and Ultrachat:
| Metric | Before Distillation | After Distillation | Change | Status |
|---|---|---|---|---|
| Validation Perplexity | 5.0924 | 5.2620 | +0.1696 | ✗ |
| Teacher-Student KL Divergence | 2.7913 | 1.9637 | -0.8276 | ✓ |
| Hidden State Cosine Similarity | 0.0075 | 0.0054 | -0.0021 | ✗ |
To load and use this adapter, run:
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
base_model_name = "Qwen/Qwen2.5-0.5B-Instruct"
adapter_name = "sarimahsan101/Qwen2.5-0.5B-HiddenDistilled-LoRA"
# Load tokenizer and base model
tokenizer = AutoTokenizer.from_pretrained(base_model_name, trust_remote_code=True)
base_model = AutoModelForCausalLM.from_pretrained(
base_model_name,
torch_dtype=torch.bfloat16,
device_map="auto",
trust_remote_code=True
)
# Load LoRA adapter
model = PeftModel.from_pretrained(base_model, adapter_name)
model.eval()
# Inference example
messages = [{"role": "user", "content": "Explain gravity in one sentence."}]
text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer(text, return_tensors="pt").to(model.device)
with torch.no_grad():
outputs = model.generate(**inputs, max_new_tokens=50)
print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:], skip_special_tokens=True))
bitsandbytes)