← back to projects

generative ai · fine-tuning

LLM fine-tuning

I fine-tuned DeepSeek-R1 (1.5B parameters) to answer practical "how do I…?" questions in Spanish, training it with QLoRA on a single GPU, and served it through a Telegram bot. A two-person university project.

~106K
Spanish Q&A pairs
4-bit
quantization to fit one GPU
3.04 → 2.80
evaluation loss

Method

  • Data: ~152K pairs in chat format; trained on 106K (90% train, 10% eval).
  • QLoRA: the base model is loaded 4-bit quantized (NF4) and only small LoRA adapters are trained (r=8), so training fits a consumer GPU.
  • Training: 3 epochs, effective batch size 32, gradient checkpointing and fp16; the best checkpoint by eval loss is kept.
  • Serving: a Telegram bot loads the base model + adapter, applies the chat template and strips the <think> reasoning block before replying.

Results

2.802.903.001004008001200step
Evaluation loss per training step. Best checkpoint: step 1600 (2.801).

Loss drops steadily and levels off by the end of the third epoch, with no sign of overfitting.

What I learned

While documenting the project I found two typos in the layers LoRA targets ("k,proj" and "0_proj"). PEFT silently ignores them, so the published adapter was only trained on two of the four attention projections. I fixed the code and documented it: retraining on all four should improve the result. The lesson: check the trainable parameters (print_trainable_parameters) against what you expect before burning GPU hours.

Stack

  • PyTorch
  • Hugging Face
  • PEFT / QLoRA
  • bitsandbytes
  • python-telegram-bot