<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/how-to-customize-an-llm-for-ai-agents-using-sft-and-qlora-jeancs7na" -->

---
title: How to Customize an LLM for AI Agents using SFT and QLoRA
description: A step-by-step tutorial on fine-tuning a Qwen 1.5B instruction model for AI agent use cases using supervised fine-tuning (SFT) with QLoRA. The workflow uses...
canonical: https://daily.dev/posts/how-to-customize-an-llm-for-ai-agents-using-sft-and-qlora-jeancs7na
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: How to Customize an LLM for AI Agents using SFT and QLoRA | daily.dev
og:description: A step-by-step tutorial on fine-tuning a Qwen 1.5B instruction model for AI agent use cases using supervised fine-tuning (SFT) with QLoRA. The workflow uses...
og:url: https://daily.dev/posts/how-to-customize-an-llm-for-ai-agents-using-sft-and-qlora-jeancs7na
og:image: https://api.daily.dev/og/posts/JeanCs7na.png
og:image:alt: How to Customize an LLM for AI Agents using SFT and QLoRA
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# How to Customize an LLM for AI Agents using SFT and QLoRA

**[freeCodeCamp](https://daily.dev/sources/freecodecamp)** · 15 min read · 0 upvotes · 0 comments

## Summary

A step-by-step tutorial on fine-tuning a Qwen 1.5B instruction model for AI agent use cases using supervised fine-tuning (SFT) with QLoRA. The workflow uses Unsloth and the Hugging Face ecosystem to load the model in 4-bit quantized form, attach LoRA adapters to attention and MLP layers, train only those adapter weights on a small customer support dataset, and save the resulting adapter files locally. The full training run completes in ~35 seconds using ~2.6 GB of memory, with loss dropping from 3.9 to 0.06 across 30 steps. Inference code demonstrates the before/after difference in response quality and role alignment. The tutorial also briefly compares fine-tuning to prompt engineering and distillation.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.freecodecamp.org/news/how-to-customize-an-llm-for-ai-agents-using-sft-and-qlora>

## Questions this post answers

### How do I fine-tune a Qwen2.5-1.5B model using QLoRA and Unsloth?

Load unsloth/Qwen2.5-1.5B-Instruct in 4-bit mode with FastLanguageModel, attach LoRA adapters (rank 16) to q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, and down_proj layers, format chat examples with the tokenizer's chat template, then train with SFTTrainer using 8-bit AdamW, gradient accumulation, and Unsloth gradient checkpointing before saving only the adapter weights.

_daily.dev surfaces practical fine-tuning walkthroughs for developers building custom AI agents._

### How much GPU memory and time does QLoRA fine-tuning of a small model take?

Fine-tuning Qwen2.5-1.5B-Instruct with QLoRA and Unsloth for 30 training steps completed in about 35.6 seconds while peaking at roughly 2.6 GB of memory, using an effective batch size of 8 (2 per device times 4 gradient accumulation steps). Only about 4% of the model's parameters (18.4 million of 456.7 million) were trainable via the LoRA adapters, keeping the process lightweight enough to run on a MacBook Pro without a dedicated GPU.

_Developers evaluating hardware needs for LLM fine-tuning can find real benchmark numbers like these on daily.dev._

### What is the practical difference between prompt engineering, fine-tuning, and distillation for customizing LLM behavior?

Prompt engineering changes model behavior at inference time by adjusting instructions and is the fastest, cheapest starting point; fine-tuning trains the model on labeled examples so it learns desired patterns more consistently and is the typical next step when stronger task alignment is needed; distillation trains a smaller model to imitate a stronger one and matters most when efficiency becomes the priority.

_daily.dev helps developers weighing prompt engineering against fine-tuning or distillation compare the trade-offs._

## Similar posts on daily.dev

- [How to Fine-Tune an LLM: An End-to-End Guide](https://daily.dev/posts/how-to-fine-tune-an-llm-an-end-to-end-guide-dgv3ruc1u) · Towards Data Science · 0 upvotes · 0 comments
- [Fine-Tune Local LLMs 2026](https://daily.dev/posts/fine-tune-local-llms-2026-kgpwp0kbx) · SitePoint · 1 upvotes · 0 comments
- [How to Customize a Model to Learn New Tricks](https://daily.dev/posts/how-to-customize-a-model-to-learn-new-tricks-jdilpyuft) · ByteByteGo · 1 upvotes · 1 comments

---

Tags: [#llm](https://daily.dev/tags/llm), [#ai-agents](https://daily.dev/tags/ai-agents)

[View this post on daily.dev](https://daily.dev/posts/how-to-customize-an-llm-for-ai-agents-using-sft-and-qlora-jeancs7na)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"How to Customize an LLM for AI Agents using SFT and QLoRA","url":"https://daily.dev/posts/how-to-customize-an-llm-for-ai-agents-using-sft-and-qlora-jeancs7na","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/how-to-customize-an-llm-for-ai-agents-using-sft-and-qlora-jeancs7na"},"datePublished":"2026-08-07T01:02:48.583Z","dateModified":"2026-09-13T18:30:38.311Z","description":"A step-by-step tutorial on fine-tuning a Qwen 1.5B instruction model for AI agent use cases using supervised fine-tuning (SFT) with QLoRA. The workflow uses...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/bae7d7f0016b39a0aed54134555be49c?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/bae7d7f0016b39a0aed54134555be49c?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"freeCodeCamp","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"freeCodeCamp","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1628412854/logos/freecodecamp","url":"https://daily.dev/sources/freecodecamp"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/how-to-customize-an-llm-for-ai-agents-using-sft-and-qlora-jeancs7na","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"llm,ai-agents","timeRequired":"PT15M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"freeCodeCamp","item":"https://daily.dev/sources/freecodecamp"},{"@type":"ListItem","position":3,"name":"How to Customize an LLM for AI Agents using SFT and QLoRA"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/how-to-customize-an-llm-for-ai-agents-using-sft-and-qlora-jeancs7na#faq","mainEntity":[{"@type":"Question","name":"How do I fine-tune a Qwen2.5-1.5B model using QLoRA and Unsloth?","acceptedAnswer":{"@type":"Answer","text":"Load unsloth/Qwen2.5-1.5B-Instruct in 4-bit mode with FastLanguageModel, attach LoRA adapters (rank 16) to q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, and down_proj layers, format chat examples with the tokenizer's chat template, then train with SFTTrainer using 8-bit AdamW, gradient accumulation, and Unsloth gradient checkpointing before saving only the adapter weights. daily.dev surfaces practical fine-tuning walkthroughs for developers building custom AI agents."}},{"@type":"Question","name":"How much GPU memory and time does QLoRA fine-tuning of a small model take?","acceptedAnswer":{"@type":"Answer","text":"Fine-tuning Qwen2.5-1.5B-Instruct with QLoRA and Unsloth for 30 training steps completed in about 35.6 seconds while peaking at roughly 2.6 GB of memory, using an effective batch size of 8 (2 per device times 4 gradient accumulation steps). Only about 4% of the model's parameters (18.4 million of 456.7 million) were trainable via the LoRA adapters, keeping the process lightweight enough to run on a MacBook Pro without a dedicated GPU. Developers evaluating hardware needs for LLM fine-tuning can find real benchmark numbers like these on daily.dev."}},{"@type":"Question","name":"What is the practical difference between prompt engineering, fine-tuning, and distillation for customizing LLM behavior?","acceptedAnswer":{"@type":"Answer","text":"Prompt engineering changes model behavior at inference time by adjusting instructions and is the fastest, cheapest starting point; fine-tuning trains the model on labeled examples so it learns desired patterns more consistently and is the typical next step when stronger task alignment is needed; distillation trains a smaller model to imitate a stronger one and matters most when efficiency becomes the priority. daily.dev helps developers weighing prompt engineering against fine-tuning or distillation compare the trade-offs."}}]}
```

