[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-9688":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":16,"stars7d":17,"stars30d":18,"stars90d":16,"forks30d":16,"starsTrendScore":19,"compositeScore":20,"rankGlobal":10,"rankLanguage":10,"license":21,"archived":22,"fork":22,"defaultBranch":23,"hasWiki":22,"hasPages":24,"topics":25,"createdAt":10,"pushedAt":10,"updatedAt":33,"readmeContent":34,"aiSummary":35,"trendingCount":16,"starSnapshotCount":16,"syncStatus":36,"lastSyncTime":37,"discoverSource":38},9688,"litgpt","Lightning-AI\u002Flitgpt","Lightning-AI","20+ high-performance LLMs with recipes to pretrain, finetune and deploy at scale.","https:\u002F\u002Flightning.ai",null,"Python",13418,1455,118,234,0,18,70,5,44.49,"Apache License 2.0",false,"main",true,[26,27,28,29,30,31,32],"ai","artificial-intelligence","deep-learning","large-language-models","llm","llm-inference","llms","2026-06-12 02:02:11","\u003Cdiv align=\"center\">\n\n\n# ⚡ LitGPT\n\n**20+ high-performance LLMs with recipes to pretrain, finetune, and deploy at scale.**\n\n\u003Cpre>\n✅ From scratch implementations      ✅ No abstractions         ✅ Beginner friendly\n   ✅ Flash attention                   ✅ FSDP                    ✅ LoRA, QLoRA, Adapter\n✅ Reduce GPU memory (fp4\u002F8\u002F16\u002F32)   ✅ 1-1000+ GPUs\u002FTPUs       ✅ 20+ LLMs         \n\u003C\u002Fpre>\n\n\n---\n\n\n![PyPI - Python Version](https:\u002F\u002Fimg.shields.io\u002Fpypi\u002Fpyversions\u002Fpytorch-lightning)\n![cpu-tests](https:\u002F\u002Fgithub.com\u002Flightning-AI\u002Flit-stablelm\u002Factions\u002Fworkflows\u002Fcpu-tests.yml\u002Fbadge.svg) [![license](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FLicense-Apache%202.0-blue.svg)](https:\u002F\u002Fgithub.com\u002FLightning-AI\u002Flit-stablelm\u002Fblob\u002Fmaster\u002FLICENSE) [![Discord](https:\u002F\u002Fimg.shields.io\u002Fdiscord\u002F1077906959069626439)](https:\u002F\u002Fdiscord.gg\u002FVptPCZkGNa)\n\n\u003Cp align=\"center\">\n  \u003Ca href=\"#quick-start\">Quick start\u003C\u002Fa> •\n  \u003Ca href=\"#choose-from-20-llms\">Models\u003C\u002Fa> •\n  \u003Ca href=\"#finetune-an-llm\">Finetune\u003C\u002Fa> •\n  \u003Ca href=\"#deploy-an-llm\">Deploy\u003C\u002Fa> •\n  \u003Ca href=\"#all-workflows\">All workflows\u003C\u002Fa> •\n  \u003Ca href=\"#state-of-the-art-features\">Features\u003C\u002Fa> •\n  \u003Ca href=\"#training-recipes\">Recipes (YAML)\u003C\u002Fa> •\n  \u003Ca href=\"https:\u002F\u002Flightning.ai\u002F\">Lightning AI\u003C\u002Fa> •\n    \u003Ca href=\"#tutorials\">Tutorials\u003C\u002Fa>\n\u003C\u002Fp>\n\n&nbsp;\n\n\u003Ca target=\"_blank\" href=\"https:\u002F\u002Flightning.ai\u002Flightning-ai\u002Fstudios\u002Flitgpt-quick-start\">\n  \u003Cimg src=\"https:\u002F\u002Fpl-bolts-doc-images.s3.us-east-2.amazonaws.com\u002Fapp-2\u002Fget-started-badge.svg\" height=\"36px\" alt=\"Get started\"\u002F>\n\u003C\u002Fa>\n\n&nbsp;\n\n\u003C\u002Fdiv>\n\n# Looking for GPUs?\nOver 340,000 developers use [Lightning Cloud](https:\u002F\u002Flightning.ai\u002F?utm_source=litgpt_readme&utm_medium=referral&utm_campaign=litgpt_readme) - purpose-built for PyTorch and PyTorch Lightning. \n- [GPUs](https:\u002F\u002Flightning.ai\u002Fpricing?utm_source=litgpt_readme&utm_medium=referral&utm_campaign=litgpt_readme) from $0.19.   \n- [Clusters](https:\u002F\u002Flightning.ai\u002Fclusters?utm_source=litgpt_readme&utm_medium=referral&utm_campaign=litgpt_readme): frontier-grade training\u002Finference clusters.   \n- [AI Studio (vibe train)](https:\u002F\u002Flightning.ai\u002Fstudios?utm_source=litgpt_readme&utm_medium=referral&utm_campaign=litgpt_readme): workspaces where AI helps you debug, tune and vibe train.\n- [AI Studio (vibe deploy)](https:\u002F\u002Flightning.ai\u002Fstudios?utm_source=litgpt_readme&utm_medium=referral&utm_campaign=litgpt_readme): workspaces where AI helps you optimize, and deploy models.     \n- [Notebooks](https:\u002F\u002Flightning.ai\u002Fnotebooks?utm_source=litgpt_readme&utm_medium=referral&utm_campaign=litgpt_readme): Persistent GPU workspaces where AI helps you code and analyze.\n- [Inference](https:\u002F\u002Flightning.ai\u002Fdeploy?utm_source=litgpt_readme&utm_medium=referral&utm_campaign=litgpt_readme): Deploy models as inference APIs.\n\n# Finetune, pretrain, and inference LLMs Lightning fast ⚡⚡\nEvery LLM is implemented from scratch with **no abstractions** and **full control**, making them blazing fast, minimal, and performant at enterprise scale.\n\n✅ **Enterprise ready -** Apache 2.0 for unlimited enterprise use.\u003C\u002Fbr>\n✅ **Developer friendly -** Easy debugging with no abstraction layers and single file implementations.\u003C\u002Fbr>\n✅ **Optimized performance -** Models designed to maximize performance, reduce costs, and speed up training.\u003C\u002Fbr>\n✅ **Proven recipes -** Highly-optimized training\u002Ffinetuning recipes tested at enterprise scale.\u003C\u002Fbr>\n\n&nbsp;\n\n# Quick start\nInstall LitGPT\n```\npip install 'litgpt[extra]'\n```\n\nLoad and use any of the [20+ LLMs](#choose-from-20-llms):\n```python\nfrom litgpt import LLM\n\nllm = LLM.load(\"microsoft\u002Fphi-2\")\ntext = llm.generate(\"Fix the spelling: Every fall, the family goes to the mountains.\")\nprint(text)\n# Corrected Sentence: Every fall, the family goes to the mountains.\n```\n\n&nbsp;\n\n✅ Optimized for fast inference\u003C\u002Fbr>\n✅ Quantization\u003C\u002Fbr>\n✅ Runs on low-memory GPUs\u003C\u002Fbr>\n✅ No layers of internal abstractions\u003C\u002Fbr>\n✅ Optimized for production scale\u003C\u002Fbr>\n\n\u003Cdetails>\n  \u003Csummary>Advanced install options\u003C\u002Fsummary>\n\nInstall from source:\n\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002FLightning-AI\u002Flitgpt\ncd litgpt\n# if using uv\nuv sync --all-extras\n# if using pip\npip install -e \".[extra,compiler,test]\"\n```\n\u003C\u002Fdetails>\n\n[Explore the full Python API docs](tutorials\u002Fpython-api.md).\n\n&nbsp;\n\n---\n# Choose from 20+ LLMs\nEvery model is written from scratch to maximize performance and remove layers of abstraction:\n\n| Model | Model size | Author | Reference |\n|----|----|----|----|\n| Llama 3, 3.1, 3.2, 3.3 | 1B, 3B, 8B, 70B, 405B | Meta AI | [Meta AI 2024](https:\u002F\u002Fgithub.com\u002Fmeta-llama\u002Fllama3)                                           |\n| Code Llama | 7B, 13B, 34B, 70B | Meta AI | [Rozière et al. 2023](https:\u002F\u002Farxiv.org\u002Fabs\u002F2308.12950)                                       |\n| CodeGemma | 7B | Google | [Google Team, Google Deepmind](https:\u002F\u002Fai.google.dev\u002Fgemma\u002Fdocs\u002Fcodegemma)                                     |\n| Gemma 2 | 2B, 9B, 27B | Google | [Google Team, Google Deepmind](https:\u002F\u002Fstorage.googleapis.com\u002Fdeepmind-media\u002Fgemma\u002Fgemma-2-report.pdf)  |\n| Phi 4 | 14B | Microsoft Research | [Abdin et al. 2024](https:\u002F\u002Farxiv.org\u002Fabs\u002F2412.08905)                                                                            |\n| Qwen2.5 | 0.5B, 1.5B, 3B, 7B, 14B, 32B, 72B | Alibaba Group | [Qwen Team 2024](https:\u002F\u002Fqwenlm.github.io\u002Fblog\u002Fqwen2.5\u002F)                                               |\n| Qwen2.5 Coder | 0.5B, 1.5B, 3B, 7B, 14B, 32B | Alibaba Group | [Hui, Binyuan et al. 2024](https:\u002F\u002Farxiv.org\u002Fabs\u002F2409.12186)                                          |\n| R1 Distill Llama | 8B, 70B | DeepSeek AI | [DeepSeek AI 2025](https:\u002F\u002Fgithub.com\u002Fdeepseek-ai\u002FDeepSeek-R1\u002Fblob\u002Fmain\u002FDeepSeek_R1.pdf)                                                                                 |\n| ... | ... | ... | ...   |\n\n\u003Cdetails>\n  \u003Csummary>See full list of 20+ LLMs\u003C\u002Fsummary>\n\n&nbsp;\n\n#### All models\n\n| Model | Model size | Author | Reference |\n|----|----|----|----|\n| CodeGemma | 7B | Google | [Google Team, Google Deepmind](https:\u002F\u002Fai.google.dev\u002Fgemma\u002Fdocs\u002Fcodegemma)                                                                 |\n| Code Llama | 7B, 13B, 34B, 70B | Meta AI | [Rozière et al. 2023](https:\u002F\u002Farxiv.org\u002Fabs\u002F2308.12950)                                                                   |\n| Falcon | 7B, 40B, 180B | TII UAE | [TII 2023](https:\u002F\u002Ffalconllm.tii.ae)                                                                                              |\n| Falcon 3 | 1B, 3B, 7B, 10B | TII UAE | [TII 2024](https:\u002F\u002Fhuggingface.co\u002Fblog\u002Ffalcon3)                                                                                              |\n| FreeWilly2 (Stable Beluga 2) | 70B | Stability AI | [Stability AI 2023](https:\u002F\u002Fstability.ai\u002Fblog\u002Fstable-beluga-large-instruction-fine-tuned-models)                 |\n| Function Calling Llama 2 | 7B | Trelis | [Trelis et al. 2023](https:\u002F\u002Fhuggingface.co\u002FTrelis\u002FLlama-2-7b-chat-hf-function-calling-v2)                                  |\n| Gemma | 2B, 7B | Google | [Google Team, Google Deepmind](https:\u002F\u002Fstorage.googleapis.com\u002Fdeepmind-media\u002Fgemma\u002Fgemma-report.pdf)                                       |\n| Gemma 2 | 9B, 27B | Google | [Google Team, Google Deepmind](https:\u002F\u002Fstorage.googleapis.com\u002Fdeepmind-media\u002Fgemma\u002Fgemma-2-report.pdf)                                  |\n| Gemma 3 | 1B, 4B, 12B, 27B | Google | [Google Team, Google Deepmind](https:\u002F\u002Farxiv.org\u002Fpdf\u002F2503.19786)                                  |\n| Llama 2 | 7B, 13B, 70B | Meta AI | [Touvron et al. 2023](https:\u002F\u002Farxiv.org\u002Fabs\u002F2307.09288)                                                                           |\n| Llama 3.1 | 8B, 70B | Meta AI | [Meta AI 2024](https:\u002F\u002Fgithub.com\u002Fmeta-llama\u002Fllama3)                                                                                 |\n| Llama 3.2 | 1B, 3B | Meta AI | [Meta AI 2024](https:\u002F\u002Fai.meta.com\u002Fblog\u002Fllama-3-2-connect-2024-vision-edge-mobile-devices\u002F)                                           |\n| Llama 3.3 | 70B | Meta AI | [Meta AI 2024](https:\u002F\u002Fhuggingface.co\u002Fmeta-llama\u002FLlama-3.3-70B-Instruct)                                                                                 |\n| Mathstral | 7B | Mistral AI | [Mistral AI 2024](https:\u002F\u002Fmistral.ai\u002Fnews\u002Fmathstral\u002F)                                                                                  |\n| MicroLlama | 300M | Ken Wang | [MicroLlama repo](https:\u002F\u002Fgithub.com\u002Fkeeeeenw\u002FMicroLlama)                                                                             |\n| Mixtral MoE | 8x7B | Mistral AI | [Mistral AI 2023](https:\u002F\u002Fmistral.ai\u002Fnews\u002Fmixtral-of-experts\u002F)                                                                     |\n| Mistral | 7B, 123B | Mistral AI | [Mistral AI 2023](https:\u002F\u002Fmistral.ai\u002Fnews\u002Fannouncing-mistral-7b\u002F)                                                                  |\n| Mixtral MoE | 8x22B | Mistral AI | [Mistral AI 2024](https:\u002F\u002Fmistral.ai\u002Fnews\u002Fmixtral-8x22b\u002F)                                                                         |\n| OLMo | 1B, 7B | Allen Institute for AI (AI2) | [Groeneveld et al. 2024](https:\u002F\u002Faclanthology.org\u002F2024.acl-long.841\u002F)    |\n| OpenLLaMA | 3B, 7B, 13B | OpenLM Research | [Geng & Liu 2023](https:\u002F\u002Fgithub.com\u002Fopenlm-research\u002Fopen_llama)                                                         |\n| Phi 1.5 & 2 | 1.3B, 2.7B | Microsoft Research  | [Li et al. 2023](https:\u002F\u002Farxiv.org\u002Fabs\u002F2309.05463)                                                                  |\n| Phi 3 | 3.8B | Microsoft Research | [Abdin et al. 2024](https:\u002F\u002Farxiv.org\u002Fabs\u002F2404.14219)                                                                            |\n| Phi 4 | 14B | Microsoft Research | [Abdin et al. 2024](https:\u002F\u002Farxiv.org\u002Fabs\u002F2412.08905)                                                                            |\n| Phi 4 Mini Instruct | 3.8B | Microsoft Research | [Microsoft 2025](https:\u002F\u002Farxiv.org\u002Fabs\u002F2503.01743)                                           |\n| Phi 4 Mini Reasoning | 3.8B | Microsoft Research | [Xu, Peng et al. 2025](https:\u002F\u002Farxiv.org\u002Fabs\u002F2504.21233)                                           |\n| Phi 4 Reasoning | 3.8B | Microsoft Research | [Abdin et al. 2025](https:\u002F\u002Farxiv.org\u002Fabs\u002F2504.21318)                                           |\n| Phi 4 Reasoning Plus | 3.8B | Microsoft Research | [Abdin et al. 2025](https:\u002F\u002Farxiv.org\u002Fabs\u002F2504.21318)                                           |\n| Platypus | 7B, 13B, 70B |  Lee et al. | [Lee, Hunter, and Ruiz 2023](https:\u002F\u002Farxiv.org\u002Fabs\u002F2308.07317)                                                               |\n| Pythia | {14,31,70,160,410}M, {1,1.4,2.8,6.9,12}B | EleutherAI | [Biderman et al. 2023](https:\u002F\u002Farxiv.org\u002Fabs\u002F2304.01373)                                            |\n| Qwen2.5 | 0.5B, 1.5B, 3B, 7B, 14B, 32B, 72B | Alibaba Group | [Qwen Team 2024](https:\u002F\u002Fqwenlm.github.io\u002Fblog\u002Fqwen2.5\u002F)                                               |\n| Qwen2.5 Coder | 0.5B, 1.5B, 3B, 7B, 14B, 32B | Alibaba Group | [Hui, Binyuan et al. 2024](https:\u002F\u002Farxiv.org\u002Fabs\u002F2409.12186)                                          |\n| Qwen2.5 1M (Long Context) | 7B, 14B | Alibaba Group | [Qwen Team 2025](https:\u002F\u002Fqwenlm.github.io\u002Fblog\u002Fqwen2.5-1m\u002F)                                          |\n| Qwen2.5 Math | 1.5B, 7B, 72B | Alibaba Group | [An, Yang et al. 2024](https:\u002F\u002Farxiv.org\u002Fabs\u002F2409.12122)                                          |\n| QwQ | 32B | Alibaba Group | [Qwen Team 2025](https:\u002F\u002Fqwenlm.github.io\u002Fblog\u002Fqwq-32b\u002F)                                                                         |\n| QwQ-Preview | 32B | Alibaba Group | [Qwen Team 2024](https:\u002F\u002Fqwenlm.github.io\u002Fblog\u002Fqwq-32b-preview\u002F)                                                                         |\n| Qwen3 | 0.6B, 1.7B, 4B{Hybrid, Thinking-2507, Instruct-2507}, 8B, 14B, 32B | Alibaba Group | [Qwen Team 2025](https:\u002F\u002Farxiv.org\u002Fabs\u002F2505.09388\u002F)                                                                         |\n| Qwen3 MoE | 30B{Hybrid, Thinking-2507, Instruct-2507}, 235B{Hybrid, Thinking-2507, Instruct-2507} | Alibaba Group | [Qwen Team 2025](https:\u002F\u002Farxiv.org\u002Fabs\u002F2505.09388\u002F)                                                                         |\n| R1 Distill Llama | 8B, 70B | DeepSeek AI | [DeepSeek AI 2025](https:\u002F\u002Fgithub.com\u002Fdeepseek-ai\u002FDeepSeek-R1\u002Fblob\u002Fmain\u002FDeepSeek_R1.pdf)                                                                                 |\n| SmolLM2 | 135M, 360M, 1.7B | Hugging Face | [Hugging Face 2024](https:\u002F\u002Fgithub.com\u002Fhuggingface\u002Fsmollm)                                                               |\n| Salamandra | 2B, 7B | Barcelona Supercomputing Centre | [BSC-LTC 2024](https:\u002F\u002Fgithub.com\u002FBSC-LTC\u002Fsalamandra)                                                                         |\n| StableCode | 3B | Stability AI | [Stability AI 2023](https:\u002F\u002Fstability.ai\u002Fblog\u002Fstablecode-llm-generative-ai-coding)                                                  |\n| StableLM  | 3B, 7B | Stability AI | [Stability AI 2023](https:\u002F\u002Fgithub.com\u002FStability-AI\u002FStableLM)                                                                    |\n| StableLM Zephyr | 3B | Stability AI | [Stability AI 2023](https:\u002F\u002Fstability.ai\u002Fblog\u002Fstablecode-llm-generative-ai-coding)                                             |\n| TinyLlama | 1.1B | Zhang et al. | [Zhang et al. 2023](https:\u002F\u002Fgithub.com\u002Fjzhang38\u002FTinyLlama)                                                                         |\n\n\n**Tip**: You can list all available models by running the `litgpt download list` command.\n\n\n\u003C\u002Fdetails>\n\n&nbsp;\n\n---\n\n# Workflows\n\n\u003Cp align=\"center\">\n  \u003Ca href=\"#finetune-an-llm\">Finetune\u003C\u002Fa> •\n  \u003Ca href=\"#pretrain-an-llm\">Pretrain\u003C\u002Fa> •\n  \u003Ca href=\"#continue-pretraining-an-llm\">Continued pretraining\u003C\u002Fa> •\n    \u003Ca href=\"#evaluate-an-llm\">Evaluate\u003C\u002Fa> •\n    \u003Ca href=\"#deploy-an-llm\">Deploy\u003C\u002Fa> •\n    \u003Ca href=\"#test-an-llm\">Test\u003C\u002Fa>\n\u003C\u002Fp>\n\n&nbsp;\n\nUse the command line interface to run advanced workflows such as pretraining or finetuning on your own data.\n\n\n## All workflows\nAfter installing LitGPT, select the model and workflow to run (finetune, pretrain, evaluate, deploy, etc...):\n\n```bash\n# litgpt [action] [model]\nlitgpt  serve     meta-llama\u002FLlama-3.2-3B-Instruct\nlitgpt  finetune  meta-llama\u002FLlama-3.2-3B-Instruct\nlitgpt  pretrain  meta-llama\u002FLlama-3.2-3B-Instruct\nlitgpt  chat      meta-llama\u002FLlama-3.2-3B-Instruct\nlitgpt  evaluate  meta-llama\u002FLlama-3.2-3B-Instruct\n```\n\n&nbsp;\n\n----\n\n## Finetune an LLM\n\n\u003Cdiv align=\"center\">\n\u003Ca target=\"_blank\" href=\"https:\u002F\u002Flightning.ai\u002Flightning-ai\u002Fstudios\u002Flitgpt-finetune\">\n  \u003Cimg src=\"https:\u002F\u002Fpl-bolts-doc-images.s3.us-east-2.amazonaws.com\u002Fapp-2\u002Frun-on-studio.svg\" height=\"36px\" alt=\"Run on Studios\"\u002F>\n\u003C\u002Fa>\n\u003C\u002Fdiv>\n\n&nbsp;\n\nFinetuning is the process of taking a pretrained AI model and further training it on a smaller, specialized dataset tailored to a specific task or application.\n\n\n&nbsp;\n\n```bash\n# 0) setup your dataset\ncurl -L https:\u002F\u002Fhuggingface.co\u002Fdatasets\u002Fksaw008\u002Ffinance_alpaca\u002Fresolve\u002Fmain\u002Ffinance_alpaca.json -o my_custom_dataset.json\n\n# 1) Finetune a model (auto downloads weights)\nlitgpt finetune microsoft\u002Fphi-2 \\\n  --data JSON \\\n  --data.json_path my_custom_dataset.json \\\n  --data.val_split_fraction 0.1 \\\n  --out_dir out\u002Fcustom-model\n\n# 2) Test the model\nlitgpt chat out\u002Fcustom-model\u002Ffinal\n\n# 3) Deploy the model\nlitgpt serve out\u002Fcustom-model\u002Ffinal\n```\n\n[Read the full finetuning docs](tutorials\u002Ffinetune.md)\n\n&nbsp;\n\n----\n\n## Deploy an LLM\n\n\u003Cdiv align=\"center\">\n\u003Ca target=\"_blank\" href=\"https:\u002F\u002Flightning.ai\u002Flightning-ai\u002Fstudios\u002Flitgpt-serve\">\n  \u003Cimg src=\"https:\u002F\u002Fpl-bolts-doc-images.s3.us-east-2.amazonaws.com\u002Fapp-2\u002Fdeploy-on-studios.svg\" height=\"36px\" alt=\"Deploy on Studios\"\u002F>\n\u003C\u002Fa>\n\u003C\u002Fdiv>\n\n&nbsp;\n\nDeploy a pretrained or finetune LLM to use it in real-world applications. Deploy, automatically sets up a web server that can be accessed by a website or app.\n\n```bash\n# deploy an out-of-the-box LLM\nlitgpt serve microsoft\u002Fphi-2\n\n# deploy your own trained model\nlitgpt serve path\u002Fto\u002Fmicrosoft\u002Fphi-2\u002Fcheckpoint\n```\n\n\u003Cdetails>\n  \u003Csummary>Show code to query server:\u003C\u002Fsummary>\n\n&nbsp;\n\nTest the server in a separate terminal and integrate the model API into your AI product:\n```python\n# 3) Use the server (in a separate Python session)\nimport requests, json\nresponse = requests.post(\n    \"http:\u002F\u002F127.0.0.1:8000\u002Fpredict\",\n    json={\"prompt\": \"Fix typos in the following sentence: Example input\"}\n)\nprint(response.json()[\"output\"])\n```\n\u003C\u002Fdetails>\n\n[Read the full deploy docs](tutorials\u002Fdeploy.md).\n\n&nbsp;\n\n----\n\n## Evaluate an LLM\nEvaluate an LLM to test its performance on various tasks to see how well it understands and generates text. Simply put, we can evaluate things like how well would it do in college-level chemistry, coding, etc... (MMLU, Truthful QA, etc...)\n\n```bash\nlitgpt evaluate microsoft\u002Fphi-2 --tasks 'truthfulqa_mc2,mmlu'\n```\n\n[Read the full evaluation docs](tutorials\u002Fevaluation.md).\n\n&nbsp;\n\n----\n\n##  Test an LLM\n\n\u003Cdiv align=\"center\">\n\u003Ca target=\"_blank\" href=\"https:\u002F\u002Flightning.ai\u002Flightning-ai\u002Fstudios\u002Flitgpt-chat\">\n  \u003Cimg src=\"https:\u002F\u002Fpl-bolts-doc-images.s3.us-east-2.amazonaws.com\u002Fapp-2\u002Frun-on-studio.svg\" height=\"36px\" alt=\"Run on Studios\"\u002F>\n\u003C\u002Fa>\n\u003C\u002Fdiv>\n\n&nbsp;\n\nTest how well the model works via an interactive chat. Use the `chat` command to chat, extract embeddings, etc...\n\nHere's an example showing how to use the Phi-2 LLM:\n```bash\nlitgpt chat microsoft\u002Fphi-2\n\n>> Prompt: What do Llamas eat?\n```\n\n\u003Cdetails>\n  \u003Csummary>Full code:\u003C\u002Fsummary>\n\n&nbsp;\n\n```bash\n# 1) List all supported LLMs\nlitgpt download list\n\n# 2) Use a model (auto downloads weights)\nlitgpt chat microsoft\u002Fphi-2\n\n>> Prompt: What do Llamas eat?\n```\n\nThe download of certain models requires an additional access token. You can read more about this in the [download](tutorials\u002Fdownload_model_weights.md#specific-models-and-access-tokens) documentation.\n\n\u003C\u002Fdetails>\n\n[Read the full chat docs](tutorials\u002Finference.md).\n\n&nbsp;\n\n----\n\n## Pretrain an LLM\n\n\u003Cdiv align=\"center\">\n\u003Ca target=\"_blank\" href=\"https:\u002F\u002Flightning.ai\u002Flightning-ai\u002Fstudios\u002Flitgpt-pretrain\">\n  \u003Cimg src=\"https:\u002F\u002Fpl-bolts-doc-images.s3.us-east-2.amazonaws.com\u002Fapp-2\u002Frun-on-studio.svg\" height=\"36px\" alt=\"Run on Studios\"\u002F>\n\u003C\u002Fa>\n\u003C\u002Fdiv>\n\n&nbsp;\n\nPretraining is the process of teaching an AI model by exposing it to a large amount of data before it is fine-tuned for specific tasks.\n\n\u003Cdetails>\n  \u003Csummary>Show code:\u003C\u002Fsummary>\n\n&nbsp;\n\n```bash\nmkdir -p custom_texts\ncurl https:\u002F\u002Fwww.gutenberg.org\u002Fcache\u002Fepub\u002F24440\u002Fpg24440.txt --output custom_texts\u002Fbook1.txt\ncurl https:\u002F\u002Fwww.gutenberg.org\u002Fcache\u002Fepub\u002F26393\u002Fpg26393.txt --output custom_texts\u002Fbook2.txt\n\n# 1) Download a tokenizer\nlitgpt download EleutherAI\u002Fpythia-160m \\\n  --tokenizer_only True\n\n# 2) Pretrain the model\nlitgpt pretrain EleutherAI\u002Fpythia-160m \\\n  --tokenizer_dir EleutherAI\u002Fpythia-160m \\\n  --data TextFiles \\\n  --data.train_data_path \"custom_texts\u002F\" \\\n  --train.max_tokens 10_000_000 \\\n  --out_dir out\u002Fcustom-model\n\n# 3) Test the model\nlitgpt chat out\u002Fcustom-model\u002Ffinal\n```\n\u003C\u002Fdetails>\n\n[Read the full pretraining docs](tutorials\u002Fpretrain.md)\n\n&nbsp;\n\n----\n\n## Continue pretraining an LLM\n\n\u003Cdiv align=\"center\">\n\u003Ca target=\"_blank\" href=\"https:\u002F\u002Flightning.ai\u002Flightning-ai\u002Fstudios\u002Flitgpt-continue-pretraining\">\n  \u003Cimg src=\"https:\u002F\u002Fpl-bolts-doc-images.s3.us-east-2.amazonaws.com\u002Fapp-2\u002Frun-on-studio.svg\" height=\"36px\" alt=\"Run on Studios\"\u002F>\n\u003C\u002Fa>\n\u003C\u002Fdiv>\n\n&nbsp;\n\nContinued pretraining is another way of finetuning that specializes an already pretrained model by training on custom data:\n\n\u003Cdetails>\n  \u003Csummary>Show code:\u003C\u002Fsummary>\n\n&nbsp;\n\n```bash\nmkdir -p custom_texts\ncurl https:\u002F\u002Fwww.gutenberg.org\u002Fcache\u002Fepub\u002F24440\u002Fpg24440.txt --output custom_texts\u002Fbook1.txt\ncurl https:\u002F\u002Fwww.gutenberg.org\u002Fcache\u002Fepub\u002F26393\u002Fpg26393.txt --output custom_texts\u002Fbook2.txt\n\n# 1) Continue pretraining a model (auto downloads weights)\nlitgpt pretrain EleutherAI\u002Fpythia-160m \\\n  --tokenizer_dir EleutherAI\u002Fpythia-160m \\\n  --initial_checkpoint_dir EleutherAI\u002Fpythia-160m \\\n  --data TextFiles \\\n  --data.train_data_path \"custom_texts\u002F\" \\\n  --train.max_tokens 10_000_000 \\\n  --out_dir out\u002Fcustom-model\n\n# 2) Test the model\nlitgpt chat out\u002Fcustom-model\u002Ffinal\n```\n\n\u003C\u002Fdetails>\n\n[Read the full continued pretraining docs](tutorials\u002Fpretrain.md#continued-pretraining-on-custom-data)\n\n&nbsp;\n\n----\n\n# State-of-the-art features\n\n✅ State-of-the-art optimizations: Flash Attention v2, multi-GPU support via fully-sharded data parallelism, [optional CPU offloading](tutorials\u002Foom.md#do-sharding-across-multiple-gpus), and [TPU and XLA support](extensions\u002Fxla).\u003C\u002Fbr>\n✅ [Pretrain](tutorials\u002Fpretrain.md), [finetune](tutorials\u002Ffinetune.md), and [deploy](tutorials\u002Finference.md)\u003C\u002Fbr>\n✅ Reduce compute requirements with low-precision settings: FP16, BF16, and FP16\u002FFP32 mixed.\u003C\u002Fbr>\n✅ Lower memory requirements with [quantization](tutorials\u002Fquantize.md): 4-bit floats, 8-bit integers, and double quantization.\u003C\u002Fbr>\n✅ [Configuration files](config_hub) for great out-of-the-box performance.\u003C\u002Fbr>\n✅ Parameter-efficient finetuning: [LoRA](tutorials\u002Ffinetune_lora.md), [QLoRA](tutorials\u002Ffinetune_lora.md), [Adapter](tutorials\u002Ffinetune_adapter.md), and [Adapter v2](tutorials\u002Ffinetune_adapter.md).\u003C\u002Fbr>\n✅ [Exporting](tutorials\u002Fconvert_lit_models.md) to other popular model weight formats.\u003C\u002Fbr>\n✅ Many popular datasets for [pretraining](tutorials\u002Fpretrain.md) and [finetuning](tutorials\u002Fprepare_dataset.md), and [support for custom datasets](tutorials\u002Fprepare_dataset.md#preparing-custom-datasets-for-instruction-finetuning).\u003C\u002Fbr>\n✅ Readable and easy-to-modify code to experiment with the latest research ideas.\u003C\u002Fbr>\n\n&nbsp;\n\n---\n\n# Training recipes\n\nLitGPT comes with validated recipes (YAML configs) to train models under different conditions.  We've generated these recipes based on the parameters we found to perform the best for different training conditions.\n\nBrowse all training recipes [here](config_hub).\n\n### Example\n\n```bash\nlitgpt finetune \\\n  --config https:\u002F\u002Fraw.githubusercontent.com\u002FLightning-AI\u002Flitgpt\u002Fmain\u002Fconfig_hub\u002Ffinetune\u002Fllama-2-7b\u002Flora.yaml\n```\n\u003Cdetails>\n  \u003Csummary>✅ Use configs to customize training\u003C\u002Fsummary>\n\nConfigs let you customize training for all granular parameters like:\n\n```yaml\n# The path to the base model's checkpoint directory to load for finetuning. (type: \u003Cclass 'Path'>, default: checkpoints\u002Fstabilityai\u002Fstablelm-base-alpha-3b)\ncheckpoint_dir: checkpoints\u002Fmeta-llama\u002FLlama-2-7b-hf\n\n# Directory in which to save checkpoints and logs. (type: \u003Cclass 'Path'>, default: out\u002Flora)\nout_dir: out\u002Ffinetune\u002Fqlora-llama2-7b\n\n# The precision to use for finetuning. Possible choices: \"bf16-true\", \"bf16-mixed\", \"32-true\". (type: Optional[str], default: null)\nprecision: bf16-true\n\n...\n```\n\u003C\u002Fdetails>\n\n\u003Cdetails>\n  \u003Csummary>✅ Example: LoRA finetuning config\u003C\u002Fsummary>\n\n&nbsp;\n\n```yaml\n# The path to the base model's checkpoint directory to load for finetuning. (type: \u003Cclass 'Path'>, default: checkpoints\u002Fstabilityai\u002Fstablelm-base-alpha-3b)\ncheckpoint_dir: checkpoints\u002Fmeta-llama\u002FLlama-2-7b-hf\n\n# Directory in which to save checkpoints and logs. (type: \u003Cclass 'Path'>, default: out\u002Flora)\nout_dir: out\u002Ffinetune\u002Fqlora-llama2-7b\n\n# The precision to use for finetuning. Possible choices: \"bf16-true\", \"bf16-mixed\", \"32-true\". (type: Optional[str], default: null)\nprecision: bf16-true\n\n# If set, quantize the model with this algorithm. See ``tutorials\u002Fquantize.md`` for more information. (type: Optional[Literal['nf4', 'nf4-dq', 'fp4', 'fp4-dq', 'int8-training']], default: null)\nquantize: bnb.nf4\n\n# How many devices\u002FGPUs to use. (type: Union[int, str], default: 1)\ndevices: 1\n\n# How many nodes to use. (type: int, default: 1)\nnum_nodes: 1\n\n# The LoRA rank. (type: int, default: 8)\nlora_r: 32\n\n# The LoRA alpha. (type: int, default: 16)\nlora_alpha: 16\n\n# The LoRA dropout value. (type: float, default: 0.05)\nlora_dropout: 0.05\n\n# Whether to apply LoRA to the query weights in attention. (type: bool, default: True)\nlora_query: true\n\n# Whether to apply LoRA to the key weights in attention. (type: bool, default: False)\nlora_key: false\n\n# Whether to apply LoRA to the value weights in attention. (type: bool, default: True)\nlora_value: true\n\n# Whether to apply LoRA to the output projection in the attention block. (type: bool, default: False)\nlora_projection: false\n\n# Whether to apply LoRA to the weights of the MLP in the attention block. (type: bool, default: False)\nlora_mlp: false\n\n# Whether to apply LoRA to output head in GPT. (type: bool, default: False)\nlora_head: false\n\n# Data-related arguments. If not provided, the default is ``litgpt.data.Alpaca``.\ndata:\n  class_path: litgpt.data.Alpaca2k\n  init_args:\n    mask_prompt: false\n    val_split_fraction: 0.05\n    prompt_style: alpaca\n    ignore_index: -100\n    seed: 42\n    num_workers: 4\n    download_dir: data\u002Falpaca2k\n\n# Training-related arguments. See ``litgpt.args.TrainArgs`` for details\ntrain:\n\n  # Number of optimizer steps between saving checkpoints (type: Optional[int], default: 1000)\n  save_interval: 200\n\n  # Number of iterations between logging calls (type: int, default: 1)\n  log_interval: 1\n\n  # Number of samples between optimizer steps across data-parallel ranks (type: int, default: 128)\n  global_batch_size: 8\n\n  # Number of samples per data-parallel rank (type: int, default: 4)\n  micro_batch_size: 2\n\n  # Number of iterations with learning rate warmup active (type: int, default: 100)\n  lr_warmup_steps: 10\n\n  # Number of epochs to train on (type: Optional[int], default: 5)\n  epochs: 4\n\n  # Total number of tokens to train on (type: Optional[int], default: null)\n  max_tokens:\n\n  # Limits the number of optimizer steps to run (type: Optional[int], default: null)\n  max_steps:\n\n  # Limits the length of samples (type: Optional[int], default: null)\n  max_seq_length: 512\n\n  # Whether to tie the embedding weights with the language modeling head weights (type: Optional[bool], default: null)\n  tie_embeddings:\n\n  #   (type: float, default: 0.0003)\n  learning_rate: 0.0002\n\n  #   (type: float, default: 0.02)\n  weight_decay: 0.0\n\n  #   (type: float, default: 0.9)\n  beta1: 0.9\n\n  #   (type: float, default: 0.95)\n  beta2: 0.95\n\n  #   (type: Optional[float], default: null)\n  max_norm:\n\n  #   (type: float, default: 6e-05)\n  min_lr: 6.0e-05\n\n# Evaluation-related arguments. See ``litgpt.args.EvalArgs`` for details\neval:\n\n  # Number of optimizer steps between evaluation calls (type: int, default: 100)\n  interval: 100\n\n  # Number of tokens to generate (type: Optional[int], default: 100)\n  max_new_tokens: 100\n\n  # Number of iterations (type: int, default: 100)\n  max_iters: 100\n\n# The name of the logger to send metrics to. (type: Literal['wandb', 'tensorboard', 'csv'], default: csv)\nlogger_name: csv\n\n# The random seed to use for reproducibility. (type: int, default: 1337)\nseed: 1337\n```\n\u003C\u002Fdetails>\n\n\u003Cdetails>\n  \u003Csummary>✅ Override any parameter in the CLI:\u003C\u002Fsummary>\n\n```bash\nlitgpt finetune \\\n  --config https:\u002F\u002Fraw.githubusercontent.com\u002FLightning-AI\u002Flitgpt\u002Fmain\u002Fconfig_hub\u002Ffinetune\u002Fllama-2-7b\u002Flora.yaml \\\n  --lora_r 4\n```\n\u003C\u002Fdetails>\n\n&nbsp;\n\n----\n\n# Project highlights\n\nLitGPT powers many great AI projects, initiatives, challenges and of course enterprises. Please submit a pull request to be considered for a feature.\n\n\u003Cdetails>\n  \u003Csummary>📊 SAMBA: Simple Hybrid State Space Models for Efficient Unlimited Context Language Modeling\u003C\u002Fsummary>\n\nThe [Samba](https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FSamba) project by researchers at Microsoft is built on top of the LitGPT code base and combines state space models with sliding window attention, which outperforms pure state space models.\n\n\u003C\u002Fdetails>\n\n\u003Cdetails>\n  \u003Csummary>🏆 NeurIPS 2023 Large Language Model Efficiency Challenge: 1 LLM + 1 GPU + 1 Day\u003C\u002Fsummary>\n\nThe LitGPT repository was the official starter kit for the [NeurIPS 2023 LLM Efficiency Challenge](https:\u002F\u002Fllm-efficiency-challenge.github.io), which is a competition focused on finetuning an existing non-instruction tuned LLM for 24 hours on a single GPU.\n\n\u003C\u002Fdetails>\n\n\u003Cdetails>\n  \u003Csummary>🦙 TinyLlama: An Open-Source Small Language Model\u003C\u002Fsummary>\n\n\nLitGPT powered the [TinyLlama project](https:\u002F\u002Fgithub.com\u002Fjzhang38\u002FTinyLlama) and [TinyLlama: An Open-Source Small Language Model](https:\u002F\u002Farxiv.org\u002Fabs\u002F2401.02385) research paper.\n\n\u003C\u002Fdetails>\n\n\u003Cdetails>\n  \u003Csummary>🍪 MicroLlama: MicroLlama-300M\u003C\u002Fsummary>\n\n[MicroLlama](https:\u002F\u002Fgithub.com\u002Fkeeeeenw\u002FMicroLlama) is a 300M Llama model pretrained on 50B tokens powered by TinyLlama and LitGPT.\n\u003C\u002Fdetails>\n\n\u003Cdetails>\n  \u003Csummary>🔬 Pre-training Small Base LMs with Fewer Tokens\u003C\u002Fsummary>\n\nThe research paper [\"Pre-training Small Base LMs with Fewer Tokens\"](https:\u002F\u002Farxiv.org\u002Fabs\u002F2404.08634), which utilizes LitGPT, develops smaller base language models by inheriting a few transformer blocks from larger models and training on a tiny fraction of the data used by the larger models. It demonstrates that these smaller models can perform comparably to larger models despite using significantly less training data and resources.\n\n\u003C\u002Fdetails>\n\n&nbsp;\n\n----\n\n# Community\n\nWe welcome all individual contributors, regardless of their level of experience or hardware. Your contributions are valuable, and we are excited to see what you can accomplish in this collaborative and supportive environment.\n\n- [Request a feature](https:\u002F\u002Fgithub.com\u002FLightning-AI\u002Flitgpt\u002Fissues)\n- [Submit your first contribution](https:\u002F\u002Flightning.ai\u002Fpages\u002Fcommunity\u002Ftutorial\u002Fhow-to-contribute-to-litgpt\u002F)\n- [Join our Discord](https:\u002F\u002Fdiscord.gg\u002FVptPCZkGNa)\n\n&nbsp;\n\n# Tutorials\n\n🚀 [Get started](tutorials\u002F0_to_litgpt.md)\u003C\u002Fbr>\n⚡️ [Finetuning, incl. LoRA, QLoRA, and Adapters](tutorials\u002Ffinetune.md)\u003C\u002Fbr>\n🤖 [Pretraining](tutorials\u002Fpretrain.md)\u003C\u002Fbr>\n💬 [Model evaluation](tutorials\u002Fevaluation.md)\u003C\u002Fbr>\n📘 [Supported and custom datasets](tutorials\u002Fprepare_dataset.md)\u003C\u002Fbr>\n🧹 [Quantization](tutorials\u002Fquantize.md)\u003C\u002Fbr>\n🤯 [Tips for dealing with out-of-memory (OOM) errors](tutorials\u002Foom.md)\u003C\u002Fbr>\n🧑🏽‍💻 [Using cloud TPUs](extensions\u002Fxla)\u003C\u002Fbr>\n\n&nbsp;\n\n----\n\n### Acknowledgments\n\nThis implementation extends on [Lit-LLaMA](https:\u002F\u002Fgithub.com\u002Flightning-AI\u002Flit-llama) and [nanoGPT](https:\u002F\u002Fgithub.com\u002Fkarpathy\u002FnanoGPT), and it's **powered by [Lightning Fabric](https:\u002F\u002Flightning.ai\u002Fdocs\u002Ffabric\u002Fstable\u002F) ⚡**.\n\n- [@karpathy](https:\u002F\u002Fgithub.com\u002Fkarpathy) for [nanoGPT](https:\u002F\u002Fgithub.com\u002Fkarpathy\u002FnanoGPT)\n- [@EleutherAI](https:\u002F\u002Fgithub.com\u002FEleutherAI) for [GPT-NeoX](https:\u002F\u002Fgithub.com\u002FEleutherAI\u002Fgpt-neox) and the [Evaluation Harness](https:\u002F\u002Fgithub.com\u002FEleutherAI\u002Flm-evaluation-harness)\n- [@TimDettmers](https:\u002F\u002Fgithub.com\u002FTimDettmers) for [bitsandbytes](https:\u002F\u002Fgithub.com\u002FTimDettmers\u002Fbitsandbytes)\n- [@Microsoft](https:\u002F\u002Fgithub.com\u002Fmicrosoft) for [LoRA](https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FLoRA)\n- [@tridao](https:\u002F\u002Fgithub.com\u002Ftridao) for [Flash Attention 2](https:\u002F\u002Fgithub.com\u002FDao-AILab\u002Fflash-attention)\n\n### License\n\nLitGPT is released under the [Apache 2.0](https:\u002F\u002Fgithub.com\u002FLightning-AI\u002Flitgpt\u002Fblob\u002Fmain\u002FLICENSE) license.\n\n### Citation\n\nIf you use LitGPT in your research, please cite the following work:\n\n```bibtex\n@misc{litgpt-2023,\n  author       = {Lightning AI},\n  title        = {LitGPT},\n  howpublished = {\\url{https:\u002F\u002Fgithub.com\u002FLightning-AI\u002Flitgpt}},\n  year         = {2023},\n}\n```\n\n&nbsp;\n","LitGPT 是一个包含20多种高性能大规模语言模型的项目，提供了从头训练、微调到大规模部署的一整套方案。其核心功能包括支持Flash Attention、FSDP等先进技术以减少GPU内存占用并提高计算效率，同时兼容多种硬件配置（如1-1000+ GPU\u002FTPU）。此外，该项目还支持LoRA、QLoRA及Adapter等微调技术，使得用户能够灵活地调整模型以适应特定需求。适合需要快速搭建或优化大模型应用的企业和个人开发者使用，在保证性能的同时也提供了良好的初学者友好性。",2,"2026-06-11 03:24:14","top_topic"]