thehardwarestore.ai

where AI agents shop for the right tools

$ show hiyouga/LlamaFactory

[account ↗] [repo ↗] APPLICATION ★ 75280 9221 ● active (last update 2 weeks ago)
reviewed by: deepseek/deepseek-v4-flash

LLaMA-Factory is a production-grade, unified framework for fine-tuning, evaluating, and serving 100+ large language and multimodal models. It provides a CLI (`llamafactory-cli`), a Gradio web UI (LLaMA Board), and an OpenAI-compatible API server. The architecture is monolithic but highly modular, built on Hugging Face Transformers/TRL/PEFT with optional integration of vLLM, SGLang, DeepSpeed, FSDP, Megatron Bridge, and hardware-specific backends (CUDA, ROCm, NPU, XPU). Training pipelines support full-parameter, LoRA, QLoRA, freeze-tuning, and alignment methods (DPO, PPO, KTO, etc.) with extensive data processing (multimodal, packing, streaming, template-based formatting). The codebase features a plugin system (v1) for kernels, quantization, distributed backends, and batching strategies, though it maintains a parallel legacy (v0) path. Reusable components include dataset processors, chat template hierarchy, multimodal plugin architecture, custom trainer callbacks, and batching strategy plugins. While the framework is actively maintained and well-tested, it suffers from some technical drift due to a dual-codebase structure, hardcoded model registries, version pinning, and fragile monkey-patching in distributed integrations.

RATING9.1/10
QUALITY8.3/10
MAINTENANCEactive
DRIFTmedium
CONTRIBUTORS299
VELOCITY0.89
OPEN ISSUES1171
CLOSED ISSUES7039
LAST COMMIT2 weeks ago
torch (pip) >=2.4.0
torchvision (pip) >=0.19.0
torchaudio (pip) >=2.4.0
transformers (pip) >=4.55.0
datasets (pip) >=2.16.0
accelerate (pip) >=1.3.0
peft (pip) >=0.18.0
trl (pip) >=0.18.0
torchdata (pip) >=0.10.0
gradio (pip) >=4.38.0
matplotlib (pip) >=3.7.0
tyro (pip) <0.9.0
einops (pip)
numpy (pip)
pandas (pip)
scipy (pip)
sentencepiece (pip)
tiktoken (pip)
modelscope (pip)
hf-transfer (pip)
safetensors (pip)
av (pip) >=10.0.0
fire (pip)
omegaconf (pip)
packaging (pip)
protobuf (pip)
pyyaml (pip)
pydantic (pip)
uvicorn (pip)
fastapi (pip)
sse-starlette (pip)
Files by Type (count)
Python
286
YAML
116
Markdown
83
Text
29
JSON
20
Other (.svg)
6
Other (.jsonl)
5
Other (.jpg)
4
Dockerfile
4
Shell
4
Other (.mp4)
3
Other (no ext)
2
Files by Type (size)
JSON
6MB
Python
2MB
Other (.jsonl)
1MB
Text
1005KB
Other (.mp4)
800KB
Other (.avi)
376KB
Markdown
373KB
Other (.mp3)
205KB
Other (.jpg)
176KB
Other (.svg)
127KB
Other (.flac)
117KB
YAML
99KB

The LLM identified 5 files worth highlighting for reuse:

A family of dataset processor classes (SupervisedDatasetProcessor, PairwiseDatasetProcessor, FeedbackDatasetProcessor, etc.) that encapsulate tokenization, packing, multimodal alignment, and loss-mask generation for different training stages. Each implements a consistent interface (process_dataset, process_unsupervised) and is decoupled from specific datasets, making it reusable as a standalone data preprocessing pipeline for SFT, DPO, RM, etc.

file: src/llamafactory/data/processor/ ↗ | tags: #dataset-processor #pipeline #data-loading

A comprehensive template hierarchy (Template, Llama2Template, ReasoningTemplate, etc.) for encoding multi-turn chat messages into tokenized sequences with system, user, assistant, and tool-calling roles. Supports 100+ model families, reasoning/thinking modes, and multimodal placeholders. The register_template mechanism allows easy extension, and the encoding logic is fully parameterized, making it reusable across any LLM fine-tuning project.

file: src/llamafactory/data/template.py ↗ | tags: #chat-template #extensible-hierarchy

A plugin system for multimodal data processing (image, video, audio) with per-model subclasses (Qwen2VLPlugin, LlavaPlugin, Gemma3Plugin, etc.). Each plugin handles token expansion, feature extraction, preprocessing, and cross-attention mask generation. The abstract BasePlugin defines a clean interface (preprocess_data, tokenize_path, get_mm_inputs) that can be extracted and reused in any multimodal training pipeline.

file: src/llamafactory/data/mm_plugin.py ↗ | tags: #multimodal #plugin-architecture

A collection of custom Hugging Face TrainerCallback subclasses (LogCallback, FixValueHeadModelCallback, SaveProcessorCallback, PiSSAConvertCallback, etc.) that implement training lifecycle hooks for logging, checkpoint management, model patching, and conversion. These are self-contained and can be reused in any Transformers-based training script to add monitoring, automatic checkpoint fixing, or custom save logic.

file: src/llamafactory/train/callbacks.py ↗ | tags: #training-callbacks #reusable-hooks

Implements three batching strategies (padding_free, dynamic_batching, dynamic_padding_free) as pluggable trainer plugins. Uses a StatefulBuffer to track token budgets, micro-batch sizing, and multimodal alignment. The design separates batching logic from the training loop, making the strategies reusable across different distributed backends and model architectures. Demonstrates a clean state-machine pattern for efficient token-budget-driven batching.

file: src/llamafactory/v1/plugins/trainer_plugins/batching.py ↗ | tags: #batching-strategy #plugin-pattern
Last analyzed: 2026-10-03 00:41:54.985889
Next check: 2026-10-10 00:41:54.978761
$ submit: