翻篇收录说明
翻篇网页快照

Fine-Tune a Small LLM Locally with Soup: A YAML Tutorial

https://www.analyticsvidhya.com/blog/2026/11/fine-tune-small-llm-locally-with-soup/

最近抓取:2026-12-04 05:44:06(北京时间)

最近内容变化:2026-12-01 04:06:55(北京时间)

这是最近一次有效抓取的文本快照,不含网页脚本、图片和动态交互内容。实际网页可能已更新。

访问原网页

页面简介

Learn to fine-tune a small LLM locally using Soup, one YAML file, and LoRA. Train Qwen2.5-0.5B on Apple Silicon and compare results.

正文摘录

India's Most Futuristic AI Conference Is Back – Bigger, Sharper, Bolder d : h : m : s Get Details Interview PrepCareerGenAIPrompt EnggChatGPTLLMLangchainRAGAI AgentsMachine LearningDeep LearningGenAI ToolsLLMOpsPythonNLPSQLAIML Projects Reading list Introduction to Generative AIWhat is Generative AI? Introduction to Generative AI applicationsOverview of generative AI applications and their impact No-code Generative AI app developmentIntroduction to No-code AI Development Code-focused Generative AI App DevelopmentIntroduction to LangChain, ChatGPT and Gemini Pro Introduction to Responsible AIIntroduction to Responsible AI LLMSWhat are Large Language Models?GPT modelsMistralLlamaGeminiHow to build diffferent LLM AppIications? Prompt EngineeringIntroduction to Prompt EngineeringBest Practices and Guidelines for Prompt EngineeringN shot promptingChain of ThoughtTree of ThoughtsSkeleton of ThoughtsChain of Emotion Finetuning LLMsIntroduction to Finetuning LLMsParameter-Efficient Finetuning (PEFT)LORAQLORAusing Unslothusing Huggingface Training LLMs from ScratchWhat do you mean by Training LLMs from Scratch? LangchainIntro to the LangChain EcosystemCore Components of LangChainApplications of LCEL ChainsRAG using LangChainLangGraphLangSmith RAGIntroduction to RAG systemsEvaluation of RAG systems LlamaIndexGetting Started with LlamaIndexComponents of LlamaIndexAdvanced approaches for powerful RAG system Stable DiffusionIntroduction to Stable DiffusionGenerating image using Stable diffusionDiffusion modelsPrompt Engineering Concepts for Stable DiffusionMidJourneyUnderstanding Dalle 3 Soup: Fine-Tune a Small LLM with One YAML File Harsh Mishra Last Updated : 24 Nov, 2026 10 min read Imagine an engineer writes this in the team channel during an outage: “checkout failing on some requests, digging into gateway logs, no ETA yet.” Your team wants every status update in the same shape: one line for the status, one for the impact and one for the next step. And it must never invent a cause or a time. You can write that rule in a prompt. But if you want a small model that follows the habit by itself, on your own laptop, you can fine-tune it: you show the model examples, and it learns the pattern. Soup is an open-source tool that makes this shorter. You give it a dataset and one YAML recipe, run one command, and test the result. I ran every step on a MacBook with Apple Silicon (M5, 24 GB). Table of contentsHow Soup Works, in Plain WordsHands-on: Train an Incident Update WriterPart 1: Install SoupPart 2: Create the training dataPart 3: Write the recipe and trainPart 4: Test the model against the originalWant Better Results? Train LongerWhat This Lab Does and Does Not ProveConclusionFrequently Asked Questions How Soup Works, in Plain Words For this kind of training (supervised fine-tuning), Soup reads examples that pair a request with the answer you want. It loads a base model and trains it with a method called LoRA. Instead of changing the whole model, LoRA trains a tiny extra file, called an adapter, and keeps the base model frozen. LoRA comes from a 2021 research paper, not from Soup. WordWhat it means hereBase modelA public model, Qwen2.5-0.5B-Instruct (Apache-2.0 licence).AdapterThe small file of learned numbers. Mine is 2.1 MB.EpochOne full pass over the training examples.LossA score for how wrong the model is. Lower is better. Soup is not the only tool of this kind. Axolotl, LLaMA-Factory and Unsloth also help with fine-tuning, each with its own strengths. Soup’s appeal is one simple command-line tool for the whole path. Which tool is best depends on your hardware and workflow. Hands-on: Train an Incident Update Writer Our goal is small: teach a model to turn a rough incident note into three lines (STATUS, IMPACT, NEXT) without inventing anything. The notes and labels are invented for this tutorial. What you need: Python 3.11 to 3.13, about 2.5 GB of free disk, and internet for the first run. No API key. The base model is public, and Soup downloads it automatically the first time you train. You will see that in Part 3. Mac or NVIDIA? Soup’s main path in its docs is for NVIDIA GPUs. My Mac has none, so I used Soup’s Apple Silicon (MLX) path, which is what you see below. For an NVIDIA GPU, install soup-cli[train] instead and delete the backend: mlx line from the recipe. I did not run the NVIDIA path. Part 1: Install Soup Create a Python environment, install Soup and check the version. I used uv, but python -m venv and pip also work. I pinned the version so that you get the same Soup as me. $ uv venv --python 3.12 .venv $ source .venv/bin/activate $ uv pip install "soup-cli[mlx,train]==0.77.2" $ soup --version You are done with Part 1 when soup --version prints a version number. Part 2: Create the training data Make a project folder. Then create make_data.py. It writes 12 examples to a file. Each example has three fields: instruction (the task), input (a rough note) and output (the three-line update we want). This is called the Alpaca format, and Soup understands it. $ mkdir soup-incident-demo $ cd soup-incident-demo File: make_data.py # make_data.py - writes 12 original training examples to data/train.jsonl import json from pathlib import Path instruction = ("Turn note into exactly three lines: STATUS, IMPACT, NEXT. " "Use only supplied facts. Never invent ETA or cause.") # Each row: rough note | STATUS | IMPACT | NEXT rows = """Checkout errors up; investigating; checking gateway logs.|Investigating|Checkout errors elevated|Check gateway logs Login delays reported; investigating; checking auth traces.|Investigating|Login is delayed|Check auth traces Search sometimes times out; investigating; sampling requests.|Investigating|Search requests time out|Sample failed requests Payment retries high; investigating; inspect provider errors.|Investigating|Payment retries increased|Inspect provider errors Checkout recovered; monitoring; watch error rates.|Monitoring|Checkout has recovered|Watch error rates Search latency normal again; monitoring; track p95.|Monitoring|Search latency is normal|Track p95 latency Login stable after fix; monitoring; watch sign-ins.|Monitoring|Login is stable after a fix|Watch sign-ins Order backlog clearing; monitoring; inspect queue depth.|Monitoring|Order backlog is clearing|Inspect queue depth API incident resolved; errors normal; close ticket.|Resolved|API errors are normal|Close incident ticket Checkout incident resolved; payments healthy; publish recap.|Resolved|Payments are healthy|Publish incident recap Login issue resolved; sign-ins normal; share summary.|Resolved|Sign-ins are normal|Share incident summary Search issue resolved; timeouts gone; update timeline.|Resolved|Search timeouts are gone|Update incident timeline""".splitlines() path = Path("data/train.jsonl") path.parent.mkdir(parents=True, exist_ok=True) with path.open("w", encoding="utf-8") as f: for line in rows: note, status, impact, next_step = line.split("|") example = {"instruction": instruction, "input": note, "output": f"STATUS: {status}\nIMPACT: {impact}\nNEXT: {next_step}"} f.write(json.dumps(example, ensure_ascii=False) + "\n") print(f"Saved {len(rows)} examples to {path}") Run it, and ask Soup to check the file: $ python make_data.py $ soup data validate data/train.jsonl You are done with Part 2 when Soup reports that the rows are valid. Part 3: Write the recipe and train Create soup.yaml in the same folder. This one file is the whole recipe: File: soup.yaml base: Qwen/Qwen2.5-0.5B-Instruct task: sft backend: mlx # Apple Silicon only. Remove this line on an NVIDIA GPU. data: train: ./data/train.jsonl format: alpaca val_split: 0.2 max_length: 256 training: epochs: 3 lr: 0.0002 batch_size: 1 lora: r: 8 alpha: 16 quantization: none output: ./output You only need to understand four lines: base: the model to start from. Soup will download it. val_split: 0.2: keeps 3 of the 12 examples aside, to measure the model on data it did not train on. epochs: 3: three passes over the data. A small toy value. backend: mlx: Apple Silicon only. Delete this line on an NVIDIA GPU. Now train. Soup shows a setup box and asks you to confirm. In a normal terminal, you can just answer the question. I added --yes so that it also works in scripts. $ soup train --config soup.yaml --yes The model download happens here, by itself. On my first run, Soup fetched 7 files (about 950 MB) from Hugging Face. It took 1 minute 12 seconds on my connection. Later runs reuse the saved copy, so they are much faster. After that, training starts. This is the result of the run: How to read this output: Loaded: 9 train samples. 12 rows minus the 3 kept for validation. Loss: 1.3162 → 0.6749. The loss went down, so the model fits the examples better. Val loss: 1.0636. The score on the 3 held-out rows. It is higher than the training loss, which is normal. Output: output. The folder now has the 2.1 MB adapter. The two messages about target_modules and warmup are only notes. They are not errors. You are done with Part 3 when you see “Training Complete!”. Part 4: Test the model against the original Training is not the result. The test is. We will give the same four notes to the original model and to our tuned model, and compare. One note comes from the story above, and three are new to the model. Create make_prompts.py: File: make_prompts.py # make_prompts.py - writes 4 test notes into prompts.jsonl import json INSTRUCTION = ("Turn note into exactly three lines: STATUS, IMPACT, NEXT. " "Use only supplied facts. Never invent ETA or cause.") notes = [ "Billing dashboard loads slowly for some users. Team is investigating. Checking database reads. No ETA has been confirmed.", "Search requests failing; investigating; logs under review.", "Upload service recovered; monitoring; watch queue size.", "No confirmed status for notifications; team checking delivery logs.", ] with open("prompts.jsonl", "w", encoding="utf-8") as f: for note in notes: f.write(json.dumps({"prompt": INSTRUCTION + "\n