OA0
OA0 是一个探索 AI 的社区
现在注册
已注册用户请  登录
OA0  ›  代码  ›  LitGPT — 轻量且适合研究的 LLM 训练与微调实现

LitGPT — 轻量且适合研究的 LLM 训练与微调实现

 
  frog ·  2026-03-30 11:00:26 · 6 次点击  · 0 条评论  
# ⚡ LitGPT **20+ 个高性能 LLM,提供规模化预训练、微调和部署的完整方案。**
✅ 从零实现                  ✅ 无抽象层              ✅ 新手友好
✅ Flash Attention          ✅ FSDP                 ✅ LoRA, QLoRA, Adapter
✅ 降低 GPU 内存 (fp4/8/16/32) ✅ 支持 1-1000+ GPU/TPU   ✅ 20+ 种 LLM
--- ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/pytorch-lightning) ![cpu-tests](https://github.com/lightning-AI/lit-stablelm/actions/workflows/cpu-tests.yml/badge.svg) [![license](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://github.com/Lightning-AI/lit-stablelm/blob/master/LICENSE) [![Discord](https://img.shields.io/discord/1077906959069626439)](https://discord.gg/VptPCZkGNa)

快速开始模型微调部署所有工作流特性配方 (YAML)Lightning AI教程

  Get started  

需要 GPU?

超过 340,000 名开发者使用专为 PyTorch 和 PyTorch Lightning 构建的 Lightning Cloud
- GPU 低至 $0.19。
- 集群:前沿的训练/推理集群。
- AI Studio (氛围训练):AI 助你调试、调优和氛围训练的工作空间。
- AI Studio (氛围部署):AI 助你优化和部署模型的工作空间。
- Notebooks:持久的 GPU 工作空间,AI 助你编码和分析。
- 推理:将模型部署为推理 API。

闪电般快速地进行 LLM 微调、预训练和推理 ⚡⚡

每个 LLM 都是从零开始实现,无抽象层完全可控,使其在企业级规模下具有极快的速度、极简的代码和卓越的性能。

企业就绪 - Apache 2.0 许可证,支持无限企业使用。

开发者友好 - 无抽象层,单文件实现,易于调试。

性能优化 - 模型设计旨在最大化性能、降低成本并加速训练。

成熟配方 - 经过企业级规模测试的高度优化的训练/微调配方。

 

快速开始

安装 LitGPT

pip install 'litgpt[extra]'

加载并使用 20+ 种 LLM 中的任意一个:

from litgpt import LLM

llm = LLM.load("microsoft/phi-2")
text = llm.generate("Fix the spelling: Every fall, the family goes to the mountains.")
print(text)
# Corrected Sentence: Every fall, the family goes to the mountains.

 

✅ 为快速推理优化

✅ 量化

✅ 可在低内存 GPU 上运行

✅ 无内部抽象层

✅ 为生产规模优化

高级安装选项 从源码安装:
git clone https://github.com/Lightning-AI/litgpt
cd litgpt
# 如果使用 uv
uv sync --all-extras
# 如果使用 pip
pip install -e ".[extra,compiler,test]"

探索完整的 Python API 文档

 


从 20+ 种 LLM 中选择

每个模型都从零编写,以最大化性能并移除抽象层:

模型 模型大小 作者 参考
Llama 3, 3.1, 3.2, 3.3 1B, 3B, 8B, 70B, 405B Meta AI Meta AI 2024
Code Llama 7B, 13B, 34B, 70B Meta AI Rozière et al. 2023
CodeGemma 7B Google Google Team, Google Deepmind
Gemma 2 2B, 9B, 27B Google Google Team, Google Deepmind
Phi 4 14B Microsoft Research Abdin et al. 2024
Qwen2.5 0.5B, 1.5B, 3B, 7B, 14B, 32B, 72B Alibaba Group Qwen Team 2024
Qwen2.5 Coder 0.5B, 1.5B, 3B, 7B, 14B, 32B Alibaba Group Hui, Binyuan et al. 2024
R1 Distill Llama 8B, 70B DeepSeek AI DeepSeek AI 2025
... ... ... ...
查看完整的 20+ 种 LLM 列表   #### 所有模型 | 模型 | 模型大小 | 作者 | 参考 | |----|----|----|----| | CodeGemma | 7B | Google | [Google Team, Google Deepmind](https://ai.google.dev/gemma/docs/codegemma) | | Code Llama | 7B, 13B, 34B, 70B | Meta AI | [Rozière et al. 2023](https://arxiv.org/abs/2308.12950) | | Falcon | 7B, 40B, 180B | TII UAE | [TII 2023](https://falconllm.tii.ae) | | Falcon 3 | 1B, 3B, 7B, 10B | TII UAE | [TII 2024](https://huggingface.co/blog/falcon3) | | FreeWilly2 (Stable Beluga 2) | 70B | Stability AI | [Stability AI 2023](https://stability.ai/blog/stable-beluga-large-instruction-fine-tuned-models) | | Function Calling Llama 2 | 7B | Trelis | [Trelis et al. 2023](https://huggingface.co/Trelis/Llama-2-7b-chat-hf-function-calling-v2) | | Gemma | 2B, 7B | Google | [Google Team, Google Deepmind](https://storage.googleapis.com/deepmind-media/gemma/gemma-report.pdf) | | Gemma 2 | 9B, 27B | Google | [Google Team, Google Deepmind](https://storage.googleapis.com/deepmind-media/gemma/gemma-2-report.pdf) | | Gemma 3 | 1B, 4B, 12B, 27B | Google | [Google Team, Google Deepmind](https://arxiv.org/pdf/2503.19786) | | Llama 2 | 7B, 13B, 70B | Meta AI | [Touvron et al. 2023](https://arxiv.org/abs/2307.09288) | | Llama 3.1 | 8B, 70B | Meta AI | [Meta AI 2024](https://github.com/meta-llama/llama3) | | Llama 3.2 | 1B, 3B | Meta AI | [Meta AI 2024](https://ai.meta.com/blog/llama-3-2-connect-2024-vision-edge-mobile-devices/) | | Llama 3.3 | 70B | Meta AI | [Meta AI 2024](https://huggingface.co/meta-llama/Llama-3.3-70B-Instruct) | | Mathstral | 7B | Mistral AI | [Mistral AI 2024](https://mistral.ai/news/mathstral/) | | MicroLlama | 300M | Ken Wang | [MicroLlama repo](https://github.com/keeeeenw/MicroLlama) | | Mixtral MoE | 8x7B | Mistral AI | [Mistral AI 2023](https://mistral.ai/news/mixtral-of-experts/) | | Mistral | 7B, 123B | Mistral AI | [Mistral AI 2023](https://mistral.ai/news/announcing-mistral-7b/) | | Mixtral MoE | 8x22B | Mistral AI | [Mistral AI 2024](https://mistral.ai/news/mixtral-8x22b/) | | OLMo | 1B, 7B | Allen Institute for AI (AI2) | [Groeneveld et al. 2024](https://aclanthology.org/2024.acl-long.841/) | | OpenLLaMA | 3B, 7B, 13B | OpenLM Research | [Geng & Liu 2023](https://github.com/openlm-research/open_llama) | | Phi 1.5 & 2 | 1.3B, 2.7B | Microsoft Research | [Li et al. 2023](https://arxiv.org/abs/2309.05463) | | Phi 3 | 3.8B | Microsoft Research | [Abdin et al. 2024](https://arxiv.org/abs/2404.14219) | | Phi 4 | 14B | Microsoft Research | [Abdin et al. 2024](https://arxiv.org/abs/2412.08905) | | Phi 4 Mini Instruct | 3.8B | Microsoft Research | [Microsoft 2025](https://arxiv.org/abs/2503.01743) | | Phi 4 Mini Reasoning | 3.8B | Microsoft Research | [Xu, Peng et al. 2025](https://arxiv.org/abs/2504.21233) | | Phi 4 Reasoning | 3.8B | Microsoft Research | [Abdin et al. 2025](https://arxiv.org/abs/2504.21318) | | Phi 4 Reasoning Plus | 3.8B | Microsoft Research | [Abdin et al. 2025](https://arxiv.org/abs/2504.21318) | | Platypus | 7B, 13B, 70B | Lee et al. | [Lee, Hunter, and Ruiz 2023](https://arxiv.org/abs/2308.07317) | | Pythia | {14,31,70,160,410}M, {1,1.4,2.8,6.9,12}B | EleutherAI | [Biderman et al. 2023](https://arxiv.org/abs/2304.01373) | | Qwen2.5 | 0.5B, 1.5B, 3B, 7B, 14B, 32B, 72B | Alibaba Group | [Qwen Team 2024](https://qwenlm.github.io/blog/qwen2.5/) | | Qwen2.5 Coder | 0.5B, 1.5B, 3B, 7B, 14B, 32B | Alibaba Group | [Hui, Binyuan et al. 2024](https://arxiv.org/abs/2409.12186) | | Qwen2.5 1M (Long Context) | 7B, 14B | Alibaba Group | [Qwen Team 2025](https://qwenlm.github.io/blog/qwen2.5-1m/) | | Qwen2.5 Math | 1.5B, 7B, 72B | Alibaba Group | [An, Yang et al. 2024](https://arxiv.org/abs/2409.12122) | | QwQ | 32B | Alibaba Group | [Qwen Team 2025](https://qwenlm.github.io/blog/qwq-32b/) | | QwQ-Preview | 32B | Alibaba Group | [Qwen Team 2024](https://qwenlm.github.io/blog/qwq-32b-preview/) | | Qwen3 | 0.6B, 1.7B, 4B{Hybrid, Thinking-2507, Instruct-2507}, 8B, 14B, 32B | Alibaba Group | [Qwen Team 2025](https://arxiv.org/abs/2505.09388/) | | Qwen3 MoE | 30B{Hybrid, Thinking-2507, Instruct-2507}, 235B{Hybrid, Thinking-2507, Instruct-2507} | Alibaba Group | [Qwen Team 2025](https://arxiv.org/abs/2505.09388/) | | R1 Distill Llama | 8B, 70B | DeepSeek AI | [DeepSeek AI 2025](https://github.com/deepseek-ai/DeepSeek-R1/blob/main/DeepSeek_R1.pdf) | | SmolLM2 | 135M, 360M, 1.7B | Hugging Face | [Hugging Face 2024](https://github.com/huggingface/smollm) | | Salamandra | 2B, 7B | Barcelona Supercomputing Centre | [BSC-LTC 2024](https://github.com/BSC-LTC/salamandra) | | StableCode | 3B | Stability AI | [Stability AI 2023](https://stability.ai/blog/stablecode-llm-generative-ai-coding) | | StableLM | 3B, 7B | Stability AI | [Stability AI 2023](https://github.com/Stability-AI/StableLM) | | StableLM Zephyr | 3B | Stability AI | [Stability AI 2023](https://stability.ai/blog/stablecode-llm-generative-ai-coding) | | TinyLlama | 1.1B | Zhang et al. | [Zhang et al. 2023](https://github.com/jzhang38/TinyLlama) | **提示**:你可以通过运行 `litgpt download list` 命令列出所有可用模型。

 


工作流

微调预训练继续预训练评估部署测试

 

使用命令行界面运行高级工作流,例如在自有数据上进行预训练或微调。

所有工作流

安装 LitGPT 后,选择要运行的模型和工作流(微调、预训练、评估、部署

6 次点击  ∙  0 人收藏  
登录后收藏  
0 条回复
关于 ·  帮助 ·  PING ·  隐私 ·  条款   
OA0 - Omni AI 0 一个探索 AI 的社区
沪ICP备2024103595号-2
耗时 19 ms
Developed with Cursor