CloudCodeTree LogoCloudCodeTree
AI NewsTutorialsAbout
CloudCodeTree Logo
CloudCodeTree
  • AI News
  • Tutorials
  • About
← Back to AI News
Fine-Tune Any LLM Without Writing Training Code: Axolotl's Single-YAML Approach

Photo: panumas nikhomkhai / Pexels

Fine-Tune Any LLM Without Writing Training Code: Axolotl's Single-YAML Approach

Chris Harper

3 min read

Jul 16, 2026 · 12:03 UTC

AI
Tutorial
Fine-Tuning
HuggingFace
Best Practices

Axolotl turns fine-tuning into a single YAML config — pick your model from HuggingFace Hub, your dataset, your training method (SFT, LoRA, QLoRA, DPO, GRPO), and the framework handles quantization, tokenization, training, and evaluation without you writing a training loop.

What you'll be able to do after this:

  • Write a single YAML config that controls everything: base model, LoRA rank/alpha, dataset path and format, batch size, and training method
  • Run SFT, LoRA, and QLoRA jobs with two shell commands — no Python boilerplate
  • Switch to DPO or GRPO alignment training by adding three lines to the same config

The previous teachable posts covered LoRA theory, QLoRA on Colab with Unsloth, DPO, and GRPO. Axolotl is the framework that wraps all of it into a reproducible, version-controlled pipeline used by serious fine-tuning teams.

Why Axolotl instead of raw PEFT/TRL?

Wiring fine-tuning from scratch means assembling: model loader, quantization (BitsAndBytes/GGUF), PEFT adapter config, tokenizer setup, dataset formatting, training loop, evaluation, and checkpointing. Axolotl handles every layer. You write YAML; the framework runs the pipeline. The config is version-controlled, shareable, and repeatable — change one value (e.g., LoRA rank from 32 to 64), commit, and compare runs.

Minimal SFT + LoRA config

base_model: NousResearch/Llama-3.2-1B
load_in_4bit: true   # QLoRA when paired with adapter: lora
adapter: lora

lora_r: 32
lora_alpha: 16
lora_dropout: 0.05
lora_target_modules:
  - q_proj
  - v_proj

datasets:
  - path: mhenrichsen/alpaca_data_cleaned
    type: alpaca

output_dir: ./lora-output
sequence_len: 2048
micro_batch_size: 4
num_epochs: 3
learning_rate: 2.0e-4
warmup_steps: 100

Save this as config.yml. Any HuggingFace Hub model ID works as base_model.

Two commands to train

pip install axolotl

# Tokenize and cache the dataset (run once; reuse across experiments)
axolotl preprocess config.yml

# Train — Axolotl auto-detects GPU count
axolotl train config.yml

After training, run inference from the same config:

axolotl inference config.yml --lora-model-dir=./lora-output
# --gradio flag opens a browser chat UI

Or merge the LoRA adapter into the base model for a standalone checkpoint:

axolotl merge-lora config.yml --lora-model-dir=./lora-output

Switching to DPO alignment in three lines

Add these to your existing config — the rest stays the same:

rl: dpo
dpo_beta: 0.1
datasets:
  - path: your-preference-dataset
    type: chat_template.default
    chat_template: llama3

Axolotl dispatches to TRL's DPO trainer internally. You don't rewrite the training loop — you change the config.

Scaling to multi-GPU

For 70B+ models or faster iteration, add two lines:

deepspeed: zero2    # ZeRO stage 2 sharding across GPUs
num_processes: 4    # number of GPUs

Run with accelerate launch — Axolotl handles the rest via its DeepSpeed/DDP integration.

Unsloth vs Axolotl: Unsloth (covered in an earlier post) is fastest on consumer single-GPU hardware and excellent for Colab experimentation. Axolotl is the right choice when you want a reproducible, config-file-driven pipeline you can commit, share, and extend to multi-GPU or multiple training methods from the same base config.

Sources: Axolotl Fine-Tuning Tutorial: Train LLMs with a Single YAML Config — YouTube · Axolotl Quickstart — Official Docs · Axolotl GitHub