# LoRA and Parameter-Efficient Fine-Tuning

> Fine-tune open-weight models on a single GPU with LoRA, QLoRA and the Hugging Face ecosystem. Free notes, key concepts, resources and a mini project.

Canonical: https://www.internhack.in/roadmaps/tracks/ai-engineer/lora-peft
Last updated: 2026-11-28

Fine-tune open-weight models on a single GPU with LoRA, QLoRA and the Hugging Face ecosystem.

Advanced · about 8 hours · difficulty 4/5

Learn first: [Preparing Fine-Tuning Datasets](https://www.internhack.in/roadmaps/tracks/ai-engineer/fine-tuning-data), [Running Open-Weight Models Locally](https://www.internhack.in/roadmaps/tracks/ai-engineer/open-weight-models)

Updating every weight of a multi-billion parameter model needs huge GPU memory. **Parameter-efficient fine-tuning (PEFT)** trains a small number of extra parameters instead, making fine-tuning practical on one consumer or cloud GPU.

### How LoRA works

**LoRA** (Low-Rank Adaptation) freezes the base model and adds small low-rank matrices to selected layers, usually the attention projections. Only those matrices are trained. The result is an **adapter** of a few megabytes to a few hundred megabytes that you load on top of the base model or merge into it.

- **Rank (r)**: the size of the adapter. Higher rank means more capacity and more memory.
- **Alpha**: a scaling factor for the adapter's contribution.
- **Target modules**: which layers get adapters.

### QLoRA

**QLoRA** loads the frozen base model in 4-bit precision and trains LoRA adapters on top, cutting memory further so mid-sized models fit on a single GPU.

### Tooling

- **Hugging Face Transformers, PEFT and TRL** (with its SFTTrainer and DPO trainer) are the standard stack.
- **Unsloth** and **Axolotl** wrap these with faster kernels and config-driven training.
- Free notebook GPUs are enough to learn on small models.

### After training

Evaluate against the base model on your held-out set, merge or serve the adapter (vLLM and others can serve many LoRA adapters on one base model), and export to formats like GGUF for local runtimes if needed.

### Good enough to move on

You can fine-tune a small open-weight model with QLoRA in a notebook, evaluate it, and load the adapter for inference.

## Key concepts

- **Full fine-tuning vs PEFT**
- **LoRA rank, alpha and targets**
- **QLoRA and 4-bit loading**
- **Transformers, PEFT and TRL**
- **Unsloth / Axolotl**
- **Merging and serving adapters**
- **Exporting to GGUF**

## Mini project

Use QLoRA on a free notebook GPU to fine-tune a small open model to convert plain English into SQL for your own schema, and compare accuracy with the base model on 50 held-out questions.

## Check yourself

Why can a LoRA adapter be only a few megabytes when the base model is many gigabytes?

## Free resources

- [Hugging Face PEFT documentation](https://huggingface.co/docs/peft) (Hugging Face)
- [Hugging Face TRL documentation](https://huggingface.co/docs/trl) (Hugging Face)
- [LoRA: Low-Rank Adaptation of Large Language Models](https://arxiv.org/abs/2106.09685) (arXiv)
- [Unsloth documentation](https://docs.unsloth.ai/) (Unsloth)

Previous: [Hosted Fine-Tuning Services](https://www.internhack.in/roadmaps/tracks/ai-engineer/hosted-fine-tuning) · Next: [Distillation and Small Models](https://www.internhack.in/roadmaps/tracks/ai-engineer/distillation)

## More in Fine-Tuning and Model Customization

- [Prompting vs RAG vs Fine-Tuning](https://www.internhack.in/roadmaps/tracks/ai-engineer/when-to-fine-tune)
- [Preparing Fine-Tuning Datasets](https://www.internhack.in/roadmaps/tracks/ai-engineer/fine-tuning-data)
- [Hosted Fine-Tuning Services](https://www.internhack.in/roadmaps/tracks/ai-engineer/hosted-fine-tuning)
- [LoRA and Parameter-Efficient Fine-Tuning](https://www.internhack.in/roadmaps/tracks/ai-engineer/lora-peft)
- [Distillation and Small Models](https://www.internhack.in/roadmaps/tracks/ai-engineer/distillation)

## Related

- [Roadmaps](https://www.internhack.in/roadmaps)
- [AI Engineer Roadmap](https://www.internhack.in/roadmaps/tracks/ai-engineer)
