An Extensible Toolkit for Finetuning and Inference of Large Foundation Models. Large Models for All.
An Extensible Toolkit for Finetuning and Inference of Large Foundation Models. Large Models for All.
English | 简体中文 | Español | 日本語 | 한국어 | हिंदी
An extensible, convenient, and efficient toolbox for finetuning large machine learning models, designed to be user-friendly, speedy and reliable, and accessible to the entire community.
[!IMPORTANT]
- :exclamation: [2025-07-09] We have a major update to LMFlow with full Accelerate support and extensive streamlining. If you're looking for the previous version, please use
git checkout v0.0.10, or check out the v0.0.10 branch. View all releases here.
chatml (see all templates here), and we are working on adding more preset templates. Adding corresponding --conversation_template in the shell script and you are all set! :rocket:[2024-03-27] Support LISA, enabling 7B training in 24G memory without offloading!
[2023-09-11] Support speculative decoding. Check out speculative_decoding for the usage and acceleration details.
[2023-08-14] Support long context inference with position interpolation (Linear & NTK scaling ) for LLaMA models. Check out postion_interpolation for more details.
[2023-08-07] Support Flash Attention-2. Check out flash_attention for more details.
[2023-07-23] LMFlow multimodal chatbot is now available! Support multimodal inputs of images and texts. Online Demo is also provided (We hold the service on a single GPU, hence one may experience "queuing" or "application busy" sometimes when multiple users are accessing at the same time, please wait and attempt again later when such event happens)
[2023-06-22] LMFlow paper is out! Check out our implementation details at https://arxiv.org/abs/2306.12420
[2023-06-16] Our finetuned Robin-33B-V2 scored an impressive 64.1 on the Huggingface LLM leaderboard in our offline evaluation, outperforming major open-source LLMs! All checkpoints (7B, 13B, 33B, and 65B) are released! Checkout the performance here.
[2023-06-07] LMFlow is now officially available on PyPI! Install it with pip install lmflow-finetune!
[2023-05-30] Release Robin-13B-v2 and Robin-33B-v2!
[2023-05-15] Release LMFlow-data, the training dataset of Robin-7B-v2. A new test data is also released.
[2023-05-09] Release Robin-7B-v2, achieving competitive performance on chitchat, commonsense reasoning and instruction-following tasks. Refer to our comprehensive study.
[2023-05-08] Release LMFlow Benchmark, an automatic evaluation framework for open-source chat-style LLMs. Benchmark results on 31 popular models are reported. Participate in LMFlow Benchmark.
[2023-04-21] Release Robin-7B (based on LLaMA-7B), and two models for commercial use: Parakeets-2.7B (based on GPT-NEO-2.7B) and Cokatoo-7B (based on StableLM-7B) Download here
[2023-04-15] Inference: Support streaming output and ChatGLM.
[2023-04-10] We propose a new alignment algorithm: Reward rAnked FineTuning (RAFT), which is more efficient than conventional (PPO-based) RLHF. [Paper]
[2023-04-02] Web service is online!
[2023-04-01] Release three instruction-tuned checkpoints and three medical checkpoints in model zoo: LLaMA-7B-tuned, LLaMA-13B-tuned, LLaMA-33B-tuned, LLaMA-7B-medical, LLaMA-13B-medical, and LLaMA-33B-medical.
[2023-03-27] Support full tuning and lora tuning for all decoder models.
[2023-03-27] Tasked tuned model beats ChatGPT on medical domain.
[2023-03-27] Release code and checkpoints - version 0.0.1! Our tasked-tuned model beats ChatGPT on medical domain.
Our package has been tested on Linux OS (Ubuntu 20.04). Other OS platforms (MacOS, Windows) are not fully tested, where you may encounter unexpected errors. If you are using LMFlow for the first time, we recommend you to try on a Linux machine or Google Colab.
git clone -b v1.0.0 https://github.com/OptimalScale/LMFlow.git
cd LMFlow
conda create -n lmflow python=3.9 -y
conda activate lmflow
conda install mpi4py
pip install -e .The base install above is enough for full / LoRA / LISA finetuning and HF-backend inference. Features below are gated behind extras — install only what you need:
| Extra | Enables | Install |
|---|---|---|
vllm |
vLLM-backed inference and iterative DPO | pip install -e ".[vllm]" |
sglang |
SGLang-backed inference and iterative DPO | pip install -e ".[sglang]" |
trl |
DPO / iterative DPO training | pip install -e ".[trl]" |
deepspeed |
DeepSpeed integration | pip install -e ".[deepspeed]" |
flash_attn |
Flash Attention 2 | pip install -e ".[flash_attn]" |
ray |
Distributed reward-model inference | pip install -e ".[ray]" |
multimodal |
Multimodal models | pip install -e ".[multimodal]" |
gradio |
Gradio chatbot UI | pip install -e ".[gradio]" |
flask |
Flask deployment | pip install -e ".[flask]" |
Multiple extras can be combined: pip install -e ".[vllm,trl]" for iterative DPO with vLLM, or ".[sglang,trl]" for the SGLang variant.
Looking for a previous version?[!IMPORTANT] vLLM and SGLang depend on incompatible CUDA / PyTorch versions and should not be installed into the same environment. If you need both, create separate conda envs (e.g.
lmflow-vllmandlmflow-sglang).
git clone -b v0.0.10 https://github.com/OptimalScale/LMFlow.git
cd LMFlow
conda create -n lmflow python=3.9 -y
conda activate lmflow
conda install mpi4py
pip install -e .git clone -b v0.0.5 https://github.com/OptimalScale/LMFlow.git
cd LMFlow
conda create -n lmflow python=3.9 -y
conda activate lmflow
conda install mpi4py
pip install -e .[!TIP] We use WandB to track and visualize the training process by default. Before running the training scripts, users may need to log in to WandB using the command:
wandb loginFor detailed instructions, refer to the WandB Quickstart Guide. Step 1 (registration) and Step 2 (login using your WandB API key) should be sufficient to set up your environment.
Disabling wandbOne can disable wandb by either:
- Adding environment variable before running the training command.
export WANDB_MODE=disabled
- OR, specifying the integrations to report the results and logs to. In the training script, add:
--report_to none \
Please refer to our doc.
| Method | 0.5B | 3B | 7B | 14B | 30B | 70B | xB |
|---|---|---|---|---|---|---|---|
Full bf16/fp16 |
9GB | 55GB | 120GB | 240GB | 600GB | 1200GB | 18xGB |
| LoRA | 1GB | 6GB | 16GB | 32GB | 64GB | 160GB | 2xGB |
| QLo |
Use `dtype` instead of deprecated `torch_dtype` for transformers >= 4.56
[Roadmap] LMFlow Roadmap
Security: request for a private disclosure contact
Documentation Enhancement Suggestion
[BUG] Incompatible Package Versions
[BUG]Connecting to lmflow.org (lmflow.org)|107.23.182.175|:5000... failed: Connection timed out.
Connection time out
Don't understand LISA
Some question on code of LISA
[BUG]