Downloads · 30 days
6
16% of all-time downloads
yennj12/distilgpt2-lora-fact
distilgpt2-lora-fact is a text generation model from yennj12. 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.
A deliberately tiny LoRA adapter, trained as a teaching example. It teaches distilgpt2 one narrow behaviour: answer a Q: prompt with a single-line statement that begins with Fact:.
Downloads · 30 days
6
16% of all-time downloads
All-time downloads
38
Public
Repo size
591 KB
Likes
0
Public
Click a slice to open those files.
.safetensors591 KB · 99%
From the Hugging Face model README
A deliberately tiny LoRA adapter, trained as a teaching example. It teaches
distilgpt2 one narrow behaviour: answer a Q: prompt with a single-line
statement that begins with Fact:.
Trained on 8 hand-written examples in about 7 seconds on an Apple MPS laptop. It is not useful for anything real — it is useful for seeing what the moving parts of LoRA actually do.
| Prompt | Base distilgpt2 | With this adapter |
|---|---|---|
Q: What is LoRA?\nA: | "LoRA is a very simple, simple, simple, simple…" | "Fact: LoRA freezes the base weights and trains two small matrices A and B." |
Q: What does a low-rank matrix do?\nA: (held out) | "It's a matrix that is a matrix that is a matrix…" | "Fact: low-rank sets the weights of the edges, q_proj and v_proj first." |
The first answer is memorised verbatim from the training set. The second
prompt was never trained on: the Fact: style transferred, but the content is
wrong — low-rank matrices do not "set the weights of the edges". That gap is
the honest lesson of an 8-example fine-tune. LoRA transferred style, not
knowledge.
from peft import PeftModel
from transformers import AutoModelForCausalLM, AutoTokenizer
tok = AutoTokenizer.from_pretrained("distilgpt2")
base = AutoModelForCausalLM.from_pretrained("distilgpt2")
model = PeftModel.from_pretrained(base, "yennj12/distilgpt2-lora-fact").eval()
inputs = tok("Q: What is LoRA?\nA:", return_tensors="pt")
print(tok.decode(model.generate(**inputs, max_new_tokens=24,
do_sample=False,
pad_token_id=tok.eos_token_id)[0]))
Call model.merge_and_unload() to fold the adapter into the base weights for
zero inference overhead.
| Base model | distilgpt2 (82M params) |
| Trainable params | 147,456 (0.18%) |
| Adapter size | ~584 KB, vs 313 MB for the base |
| Config | r=8, lora_alpha=16 (scaling 2.0), lora_dropout=0.05 |
| Target modules | c_attn — GPT-2's fused q/k/v projection, in all 6 blocks |
| Optimiser | AdamW, lr 2e-3, 60 full-batch epochs |
| Loss | 5.16 -> 0.51 |
| Hardware | Apple Silicon (MPS), ~7 s |
| Seed | torch.manual_seed(0) — reproducible |
The learning rate is ~100x a typical full fine-tuning LR. That is normal for LoRA: you are training freshly initialised matrices, not nudging pretrained weights.
Everything about this model is a limitation. It was overfit on purpose to 8 sentences about LoRA, so it will state confident falsehoods on any prompt outside that set, and it inherits all of distilgpt2's biases underneath. Use it to learn how adapters work, not for generation.
Training code and a from-scratch (no-PEFT) reimplementation of the same arithmetic: see the repository this adapter was trained from. Follows the Fine-Tuning with LoRA & QLoRA lesson from AI Engineering from Scratch.