axolotl-ai-cloud/axolotl

GitHub: axolotl-ai-cloud/axolotl

Axolotl 是一个开源的 LLM 后训练与微调框架,简化多模型、多模态训练与高效部署流程。

Stars: 11686 | Forks: 1308

## 🎉 最新更新 - 2026/03: - 已为 Axolotl 添加对新模型的支持,包括 [Mistral Small 4](https://github.com/axolotl-ai-cloud/axolotl/tree/main/examples/mistral4)、[Qwen3.5、Qwen3.5 MoE](https://github.com/axolotl-ai-cloud/axolotl/tree/main/examples/qwen3.5)、[GLM-4.7-Flash](https://github.com/axolotl-ai-cloud/axolotl/tree/main/examples/glm47-flash)、[GLM-4.6V](https://github.com/axolotl-ai-cloud/axolotl/tree/main/examples/glm46v) 和 [GLM-4.5-Air](https://github.com/axolotl-ai-cloud/axolotl/tree/main/examples/glm45)。 - 支持 [MoE 专家量化](https://docs.axolotl.ai/docs/expert_quantization.html)(通过 `quantize_moe_experts: true`),在训练 MoE 模型时可大幅减少显存占用(兼容 FSDP2)。 - 2026/02: - 支持 [ScatterMoE LoRA](https://github.com/axolotl-ai-cloud/axolotl/pull/3410)。使用自定义 Triton 内核直接在 MoE 专家权重上进行 LoRA 微调。 - Axolotl 现支持 [SageAttention](https://github.com/axolotl-ai-cloud/axolotl/pull/2823) 和 [GDPO](https://github.com/axolotl-ai-cloud/axolotl/pull/3353)(广义 DPO)。 - 2026/01: - 新增 [EAFT](https://github.com/axolotl-ai-cloud/axolotl/pull/3366)(熵感知聚焦训练)集成,通过 top-k 对数分布熵加权损失,以及 [Scalable Softmax](https://github.com/axolotl-ai-cloud/axolotl/pull/3338),提升长上下文注意力性能。 - 2025/12: - Axolotl 现在支持 [Kimi-Linear](https://docs.axolotl.ai/docs/models/kimi-linear.html)、[Plano-Orchestrator](https://docs.axolotl.ai/docs/models/plano.html)、[MiMo](https://docs.axolotl.ai/docs/models/mimo.html)、[InternVL 3.5](https://docs.axolotl.ai/docs/models/internvl3_5.html)、[Olmo3](https://docs.axolotl.ai/docs/models/olmo3.html)、[Trinity](https://docs.axolotl.ai/docs/models/trinity.html) 和 [Ministral3](https://docs.axolotl.ai/docs/models/ministral3.html)。 - 已添加 [分布式 Muon 优化器](https://github.com/axolotl-ai-cloud/axolotl/pull/3264) 支持,用于 FSDP2 预训练。 - 2025/10: 新模型支持已添加到 Axolotl,包括:[Qwen3 Next](https://docs.axolotl.ai/docs/models/qwen3-next.html)、[Qwen2.5-vl、Qwen3-vl](https://github.com/axolotl-ai-cloud/axolotl/tree/main/examples/qwen2_5-vl)、[Qwen3、Qwen3MoE](https://docs.axolotl.ai/docs/models/qwen3.html)、[Granite 4](https://docs.axolotl.ai/docs/models/granite4.html)、[HunYuan](https://docs.axolotl.ai/docs/models/hunyuan.html)、[Magistral 2509](https://docs.axolotl.ai/docs/models/magistral/vision.html)、[Apertus](https://docs.axolotl.ai/docs/models/apertus.html) 和 [Seed-OSS](https://docs.axolotl.ai/docs/models/seed-oss.html)。
展开旧版更新 - 2025/09: Axolotl 现支持文本扩散训练。详情见[此处](https://github.com/axolotl-ai-cloud/axolotl/tree/main/src/axolotl/integrations/diffusion)。 - 2025/08: QAT 已更新以包含 NVFP4 支持。参见 [PR](https://github.com/axolotl-ai-cloud/axolotl/pull/3107)。 - 2025/07: - 已添加 ND Parallelism 支持。Axolotl 中可在单节点或多节点内组合上下文并行(CP)、张量并行(TP)和完全分片数据并行(FSDP)。更多详情请查看 [博客文章](https://huggingface.co/blog/accelerate-nd-parallel)。 - Axolotl 新增模型:[GPT-OSS](https://docs.axolotl.ai/docs/models/gpt-oss.html)、[Gemma 3n](https://docs.axolotl.ai/docs/models/gemma3n.html)、[Liquid Foundation Model 2 (LFM2)](https://docs.axolotl.ai/docs/models/LiquidAI.html) 和 [Arcee Foundation Models (AFM)](https://docs.axolotl.ai/docs/models/arcee.html)。 - 通过 `torchao`,现在可以在 Axolotl 中进行 FP8 微调(使用 fp8 gather 操作)。立即开始 [这里](https://docs.axolotl.ai/docs/mixed_precision.html#sec-fp8)! - 已集成 [Voxtral](https://docs.axolotl.ai/docs/models/voxtral.html)、[Magistral 1.1](https://docs.axolotl.ai/docs/models/magistral.html) 和 [Devstral](https://docs.axolotl.ai/docs/models/devstral.html)(支持 mistral-common tokenizer)到 Axolotl! - 已添加对单 GPU 到多 GPU 训练的 TiledMLP 支持(支持 DDP、DeepSpeed 和 FSDP),用于 Arctic Long Sequence Training (ALST)。请参考 [示例](https://github.com/axolotl-ai-cloud/axolotl/tree/main/examples/alst)了解如何在 Axolotl 中使用 ALST! - 2025/06: 已添加对支持 mistral-common tokenizer 的 Magistral 的支持。请参考 [文档](https://docs.axolotl.ai/docs/models/magistral.html) 开始使用 Axolotl 训练自己的 Magistral 模型! - 2025/05: 已添加量化感知训练(QAT)支持。请参考 [文档](https://docs.axolotl.ai/docs/qat.html) 了解详情! - 2025/04: 已在 Axolotl 中添加 Llama 4 支持。请参考 [文档](https://docs.axolotl.ai/docs/models/llama-4.html) 开始使用 Axolotl 的线性化版本训练自己的 Llama 4 模型! - 2025/03: Axolotl 已实现序列并行(SP)支持。请参考 [博客](https://huggingface.co/blog/axolotl-ai-co/long-context-with-sequence-parallelism-in-axolotl) 和 [文档](https://docs.axolotl.ai/docs/sequence_parallelism.html) 了解如何在微调时扩展上下文长度。 - 2025/03: (Beta)现在支持在 Axolotl 中微调多模态模型。请参考 [文档](https://docs.axolotl.ai/docs/multimodal.html) 微调你自己的模型! - 2025/02: Axolotl 已添加 LoRA 优化以减少内存使用并提升单 GPU 和多 GPU 训练(DDP 和 DeepSpeed)的速度。请参考 [文档](https://docs.axolotl.ai/docs/lora_optims.html) 尝试使用! - 2025/02: Axolotl 已添加 GRPO 支持。请参考我们的 [博客](https://huggingface.co/blog/axolotl-ai-co/training-llms-w-interpreter-feedback-wasm) 和 [GRPO 示例](https://github.com/axolotl-ai-cloud/grpo_code) 体验一下! - 2025/01: Axolotl 已添加奖励建模 / 过程奖励建模微调支持。请参考 [文档](https://docs.axolotl.ai/docs/reward_modelling.html)。
## ✨ 概述 Axolotl 是一个免费且开源的工具,旨在简化最新大型语言模型(LLM)的后训练与微调。 功能特性: - **多模型支持**:支持训练 GPT-OSS、LLaMA、Mistral、Mixtral、Pythia 等多种模型,以及 Hugging Face Hub 上的更多模型。 - **多模态训练**:支持对视觉-语言模型(VLM)进行微调,包括 LLaMA-Vision、Qwen2-VL、Pixtral、LLaVA、SmolVLM2、GLM-4.6V、InternVL 3.5、Gemma 3n 以及 Voxtral 等音频模型(支持图像、视频和音频)。 - **训练方法**:支持全量微调、LoRA、QLoRA、GPTQ、QAT、偏好微调(DPO、IPO、KTO、ORPO)、强化学习(GRPO、GDPO)以及奖励建模(RM)/过程奖励建模(PRM)。 - **配置便捷**:可在整个微调流水线中复用一个 YAML 配置文件,涵盖数据集预处理、训练、评估、量化与推理。 - **性能优化**:[多包(Multipacking)](https://docs.axolotl.ai/docs/multipack.html)、[Flash Attention 2/3/4](https://docs.axolotl.ai/docs/attention.html#flash-attention)、[Xformers](https://docs.axolotl.ai/docs/attention.html#xformers)、[Flex Attention](https://docs.axolotl.ai/docs/attention.html#flex-attention)、[SageAttention](https://docs.axolotl.ai/docs/attention.html#sageattention)、[Liger Kernel](https://docs.axolotl.ai/docs/custom_integrations.html#liger-kernels)、[Cut Cross Entropy](https://docs.axolotl.ai/docs/custom_integrations.html#cut-cross-entropy)、[ScatterMoE](https://docs.axolotl.ai/docs/custom_integrations.html#kernels-integration)、[序列并行(SP)](https://docs.axolotl.ai/docs/sequence_parallelism.html)、[LoRA 优化](https://docs.axolotl.ai/docs/lora_optims.html)、[多 GPU 训练(FSDP1、FSDP2、DeepSpeed)](https://docs.axolotl.ai/docs/multi-gpu.html)、[多节点训练(Torchrun、Ray)](https://docs.axolotl.ai/docs/multi-node.html),以及更多! - **灵活的数据集处理**:支持从本地、HuggingFace 以及云(S3、Azure、GCP、OCI)加载数据集。 - **云端就绪**:提供 [Docker 镜像](https://hub.docker.com/u/axolotlai) 并支持 [PyPI 包](https://pypi.org/project/axolotl/),适用于云平台与本地硬件 ## 🚀 快速起步 - 几分钟完成 LLM 微调 **系统要求**: - NVIDIA GPU(Ampere 或更新架构,支持 `bf16` 和 Flash Attention)或 AMD GPU - Python >=3.11(推荐 3.12) - PyTorch ≥2.9.1 ### Google Colab [![在 Colab 中打开](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/axolotl-ai-cloud/axolotl/blob/main/examples/colab-notebooks/colab-axolotl-example.ipynb#scrollTo=msOCO4NRmRLa) ### 安装 #### 使用 uv(推荐) ``` # 安装 uv(如果尚未安装) curl -LsSf https://astral.sh/uv/install.sh | sh source $HOME/.local/bin/env # CUDA 12.8.1 倾向于具有更好的软件包兼容性 export UV_TORCH_BACKEND=cu128 # 创建新的虚拟环境 uv venv --python 3.12 source .venv/bin/activate uv pip install torch==2.10.0 torchvision uv pip install --no-build-isolation axolotl[deepspeed] # 推荐 - 安装 cut-cross-entropy uv pip install "cut-cross-entropy[transformers] @ git+https://github.com/axolotl-ai-cloud/ml-cross-entropy.git@main" # (可选)- 预取 flash-attn2 和 causal-conv1d 内核 uv run --python 3.12 python -c "from kernels import get_kernel; get_kernel('kernels-community/flash-attn2'); get_kernel('kernels-community/causal-conv1d')" # 下载示例 axolotl 配置文件、deepspeed 配置文件 axolotl fetch examples axolotl fetch deepspeed_configs # OPTIONAL ``` #### 使用 pip ``` pip3 install -U packaging==26.0 setuptools==75.8.0 wheel ninja pip3 install --no-build-isolation axolotl[flash-attn,deepspeed] # 下载示例 axolotl 配置文件、deepspeed 配置文件 axolotl fetch examples axolotl fetch deepspeed_configs # OPTIONAL ``` #### 使用 Docker 使用 Docker 安装比在本地环境中安装更不容易出错。 ``` docker run --gpus '"all"' --rm -it axolotlai/axolotl:main-latest ``` 其他安装方法请参考[此处](https://docs.axolotl.ai/docs/installation.html)。 #### 云服务提供商
### 首个微调任务 ``` # 获取 axolotl 示例 axolotl fetch examples # 或者,指定自定义路径 axolotl fetch examples --dest path/to/folder # 使用 LoRA 训练模型 axolotl train examples/llama-3/lora-1b.yml ``` 搞定!请查阅我们的 [快速入门指南](https://docs.axolotl.ai/docs/getting-started.html) 获取更详细的逐步说明。 ## 📚 文档 - [安装选项](https://docs.axolotl.ai/docs/installation.html) - 不同环境的详细设置说明 - [配置指南](https://docs.axolotl.ai/docs/config-reference.html) - 完整的配置选项与示例 - [数据集加载](https://docs.axolotl.ai/docs/dataset_loading.html) - 从多种来源加载数据集 - [数据集指南](https://docs.axolotl.ai/docs/dataset-formats/) - 支持的格式及使用方法 - [多 GPU 训练](https://docs.axolotl.ai/docs/multi-gpu.html) - [多节点训练](https://docs.axolotl.ai/docs/multi-node.html) - [多包(Multipacking)](https://docs.axolotl.ai/docs/multipack.html) - [API 参考](https://docs.axolotl.ai/docs/api/) - 自动生成的代码文档 - [常见问题解答](https://docs.axolotl.ai/docs/faq.html) - 常见问题 ## 🤖 AI 代理支持 Axolotl 内置了针对 AI 编码代理(Claude Code、Cursor、Copilot 等)优化的文档。这些文档随 pip 包一起提供,无需克隆仓库即可使用。 ``` # 显示概览和可用训练方法 axolotl agent-docs # 主题特定参考 axolotl agent-docs sft # supervised fine-tuning axolotl agent-docs grpo # GRPO online RL axolotl agent-docs preference_tuning # DPO, KTO, ORPO, SimPO axolotl agent-docs reward_modelling # outcome and process reward models axolotl agent-docs pretraining # continual pretraining axolotl agent-docs --list # list all topics # 转储配置模式以供程序使用 axolotl config-schema axolotl config-schema --field adapter ``` 如果你使用的是源代码仓库,代理文档也可在 `docs/agents/` 中找到,项目概览位于 `AGENTS.md`。 ## 🤝 获取帮助 - 加入我们的 [Discord 社区](https://discord.gg/HhrNrHJPRb) 获取支持 - 浏览我们的 [示例目录](https://github.com/axolotl-ai-cloud/axolotl/tree/main/examples/) - 阅读我们的 [调试指南](https://docs.axolotl.ai/docs/debugging.html) - 如需专属支持,请通过 [✉️wing@axolotl.ai](mailto:wing@axolotl.ai) 联系我们了解选项 ## 🌟 贡献 ## 📈 遥测 Axolotl 提供可选的遥测功能,帮助我们了解项目的使用情况并优先改进。我们会收集基本的系统信息、模型类型和错误率,**绝不会收集个人数据或文件路径**。遥测默认启用。如需关闭,请设置 `AXOLOTL_DO_NOT_TRACK=1`。更多详情请参考我们的 [遥测文档](https://docs.axolotl.ai/docs/telemetry.html)。 ## ❤️ 赞助商 ## 📝 引用 Axolotl 如果你在研究或项目中使用 Axolotl,请按如下方式引用: ``` @software{axolotl, title = {Axolotl: Open Source LLM Post-Training}, author = {{Axolotl maintainers and contributors}}, url = {https://github.com/axolotl-ai-cloud/axolotl}, license = {Apache-2.0}, year = {2023} } ``` ## 📜 许可证 本项目采用 Apache 2.0 许可证授权 - 详细信息请参考 [LICENSE](LICENSE) 文件。
标签:AI训练框架, Axolotl, EAFT, FSDP2, GDPO, GLM-4.5-Air, GLM-4.6V, GLM-4.7-Flash, InternVL 3.5, Kimi-Linear, LoRA, MiMo, Ministral3, Mistral Small 4, MoE, Olmo3, Plano-Orchestrator, Qwen3.5, SageAttention, Trinity, Triton kernels, 专家量化, 凭据扫描, 分布式优化器, 可扩展Softmax, 多模态模型, 大模型训练, 日志审计, 模型量化, 熵感知聚焦训练, 训练优化, 请求拦截, 逆向工具, 长上下文注意力