llamafactory
БесплатноБез исполняемых скриптовНе проверенFine-tunes open large language and vision-language models from YAML config files, with LoRA, QLoRA or full training, through the llamafactory-cli command. Use…
от TerminalSkills★ 221 звезда на GitHubОб этом скилле
LlamaFactory — Config-driven fine-tuning for 100+ LLMs and VLMs
Overview
LlamaFactory (LLaMA-Factory on GitHub, llamafactory on PyPI) wraps Hugging Face Transformers and PEFT behind one command, llamafactory-cli. A training run is described by a flat YAML file: the base model, the method (sft, dpo, kto, rm, pt), the tuning type (lora, full, freeze), the dataset names and the hyper-parameters. The same tool then chats with the result, merges the adapter into the base weights, and serves an OpenAI-style API. There is also a Gradio web UI (LLaMA Board).
This skill was written from the repository at release v0.9.5 (PyPI llamafactory 0.9.5, May 2026, requires Python 3.11+): the README, data/README.md and the files in examples/. Training needs a GPU, so none of the commands below were run while writing it. Verify with llamafactory-cli help on the machine you use.
Instructions
Installation
The README marks installation as mandatory and recommends installing from source so that the examples/ and data/ folders are on disk:
git clone --depth 1 https://github.com/hiyouga/LlamaFactory.git
cd LlamaFactory
python -m venv .venv
.venv/bin/pip install -e .
.venv/bin/pip install -r requirements/metrics.txt
.venv/bin/llamafactory-cli version
pip install llamafactory also works and installs the same llamafactory-cli (alias lmf), but then you must write your own YAML files and your own dataset_info.json. Install a CUDA build of PyTorch first if the default one does not see your GPU: python -c "import torch; print(torch.cuda.is_available())" must print True. Gated models such as Llama need huggingface-cli login first.
Register a dataset
Datasets are looked up by name in data/dataset_info.json (folder set by dataset_dir, default ./data). Two formats are supported: alpaca (default) and sharegpt. For alpaca, each record has instruction, optional input, and output; optional system and history columns exist.
{
"support_replies": {
"file_name": "support_replies.json"
}
}
Merge this entry into the existing dataset_info.json (keep the demo entries identity and alpaca_en_demo) and put support_replies.json next to it. For other column names add a columns map, e.g. "columns": {"prompt": "question", "response": "answer"}. For sharegpt-style chat data set "formatting": "sharegpt", with turns in a conversations list using from (human, gpt) and value. Hub datasets use hf_hub_url instead of file_name.
Train with LoRA
Copy the README's reference file examples/train_lora/qwen3_lora_sft.yaml and change the dataset, template and output folder:
### model
model_name_or_path: Qwen/Qwen3-4B-Instruct-2507
trust_remote_code: true
### method
stage: sft
do_train: true
finetuning_type: lora
lora_rank: 8
lora_target: all
### dataset
dataset: support_replies
template: qwen3_nothink
cutoff_len: 2048
max_samples: 1000
### output
output_dir: saves/qwen3-4b/lora/support
logging_steps: 10
save_steps: 500
plot_loss: true
overwrite_output_dir: true
report_to: none
### train
per_device_train_batch_size: 1
gradient_accumulation_steps: 8
learning_rate: 1.0e-4
num_train_epochs: 3.0
lr_scheduler_type: cosine
warmup_ratio: 0.1
bf16: true
llamafactory-cli train configs/qwen3_support_lora.yaml
The template must match the model family (qwen3_nothink, llama3, ...); use the template the README model table lists for your model. Any YAML key can be overridden with key=value after the YAML path, for example llamafactory-cli train configs/qwen3_support_lora.yaml num_train_epochs=1. Checkpoints and a loss plot are written to output_dir. To hold out data for evaluation, add val_size: 0.1, per_device_eval_batch_size: 1, eval_strategy: steps and eval_steps: 500.
QLoRA (quantized base model)
Add on-the-fly quantization to the model section of the LoRA file (from examples/train_qlora/qwen3_lora_sft_otfq.yaml):
quantization_bit: 4 # 8 or 4 with bnb; 3 and 2 need hqq
quantization_method: bnb # bnb, hqq or eetq
Pre-quantized GPTQ/AWQ/AQLM models are also covered by files in examples/train_qlora/. On Windows, bitsandbytes needs a pre-built wheel (see the README).
Chat, merge, serve
Inference and export use small YAML files that point at the adapter:
# configs/infer_support.yaml
model_name_or_path: Qwen/Qwen3-4B-Instruct-2507
adapter_name_or_path: saves/qwen3-4b/lora/support
template: qwen3_nothink
infer_backend: huggingface # huggingface, vllm, sglang or ktransformers
trust_remote_code: true
# configs/merge_support.yaml
### Do not use a quantized model or quantization_bit when merging
model_name_or_path: Qwen/Qwen3-4B-Instruct-2507
adapter_name_or_path: saves/qwen3-4b/lora/support
template: qwen3_nothink
trust_remote_code: true
export_dir: saves/qwen3_support_merged
export_size: 5
export_device: cpu
export_legacy_format: fals
Установить llamafactory в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл llamafactory?
Fine-tunes open large language and vision-language models from YAML config files, with LoRA, QLoRA or full training, through the llamafactory-cli command. Use when someone asks to "fine-tune Qwen with LoRA", "train a model on my own instruction dataset", "merge a LoRA adapter", "chat with my fine-tuned model", "serve a tuned model over an OpenAI-compatible API", or "use LLaMA-Factory". Covers dataset_info.json registration, the train/chat/export/api/webui commands, QLoRA quantization and multi-GPU launches.
Как установить скилл llamafactory?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл llamafactory запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic