{
 "schema_version": 1,
 "generated": "2026-10-31",
 "id": "huggingface-peft--fine-tune-a-small-llm-with-lora",
 "repo": "huggingface/peft",
 "repo_url": "https://github.com/huggingface/peft",
 "repo_slug": "huggingface-peft",
 "title": "Fine-tune a small LLM with LoRA on one GPU",
 "page_title": "How to fine-tune a small LLM with LoRA on one GPU with Peft",
 "summary": "Wrap a base model with a LoRA config so you train only a tiny fraction of its parameters.",
 "who": "A developer who wants a model that speaks in their product's style without renting a GPU cluster.",
 "problem": "Full fine-tuning of even a 3B model needs a lot of GPU memory and produces huge checkpoints.",
 "outcome": "A small LoRA adapter saved to disk, trained on your data, with the base model untouched.",
 "steps": [
  "Install with `pip install peft`",
  "Load a base model such as Qwen/Qwen2.5-3B-Instruct with Transformers",
  "Create a `LoraConfig` with r=16 and lora_alpha=32 for a causal LM and wrap the model with `get_peft_model`",
  "Call `model.print_trainable_parameters()` to confirm only about 0.12% of parameters are trainable",
  "Train with the Transformers Trainer, then save with `model.save_pretrained(\"qwen2.5-3b-lora\")`"
 ],
 "agent_prompt": "Using huggingface/peft, fine-tune Qwen/Qwen2.5-3B-Instruct with LoRA (r=16, lora_alpha=32) on <dataset> using the Transformers Trainer. Print the trainable parameter count first, save the adapter, and report training loss.",
 "agents": [
  "claude-code",
  "codex",
  "cursor"
 ],
 "difficulty": "Intermediate",
 "time": "2 hours",
 "basis": "readme",
 "caveat": "Training time and memory depend on your GPU, sequence length and dataset size.",
 "category": "Software and DevOps",
 "tags": [
  "Software and DevOps"
 ],
 "lang": "python",
 "requirements": [
  "Python with PyTorch and Transformers",
  "A GPU with enough memory for the base model (the README shows a 3B model on far less memory with LoRA)",
  "A dataset for your task"
 ],
 "risk": "none",
 "seen_in_the_wild": false,
 "mentioned_publicly": false,
 "risks": [],
 "best": true,
 "score": 1.0,
 "evidence": [],
 "url": "https://dedupedai.com/use-cases/huggingface-peft/fine-tune-a-small-llm-with-lora/",
 "md": "https://dedupedai.com/use-cases/huggingface-peft/fine-tune-a-small-llm-with-lora/index.md",
 "disclaimer": "Deduped lists open-source repositories that belong to other people. We do not own, maintain, audit, or vouch for any of them, and a repo appearing here is not an endorsement or a safety check. The use cases, steps, and prompts are written by AI and may be incomplete, outdated, or just wrong. Where a use case is marked \"Seen in the wild\", we link to public posts where someone described something similar, but we have not verified those posts and the use case itself is still our AI's own write-up. Use all of this at your own risk. Only run code, commands, or agents on systems and accounts you are authorized to use, and read the code and every command before you run it, especially anything that touches credentials, files, or the network. Nothing here is professional, security, legal, or financial advice. All trademarks and project names belong to their respective owners, and their use here does not imply affiliation. Content is provided as is, without warranties of any kind. Found a mistake, a safety problem, or something you want removed? Email hello@dedupedai.com and we will look at it promptly.",
 "api": "https://dedupedai.com/api/v1/usecases/huggingface-peft--fine-tune-a-small-llm-with-lora.json",
 "api_version": "v1"
}
