[Paper Review] LMFlow: An Extensible Toolkit for Finetuning and Inference of Large Foundation Models
LMFlow is an extensible, lightweight toolkit that simplifies fine-tuning and inference of large foundation models, supporting continuous pretraining, instruction tuning, parameter-efficient adaptation (LoRA), and a novel RLHF method (RAFT). It enables training a 7B-parameter LLaMA model on a single 3090 GPU in five hours, achieving performance comparable to or better than ChatGPT on specialized tasks.
Foundation models have demonstrated a great ability to achieve general human-level intelligence far beyond traditional approaches. As the technique keeps attracting attention from the AI community, an increasing number of foundation models are becoming publicly accessible. However, a significant shortcoming of most of these models lies in their performance in specialized-domain and task-specific applications, necessitating domain- and task-aware fine-tuning to develop effective scientific language models. As the number of available foundation models and specialized tasks keeps growing, the job of training scientific language models becomes highly nontrivial. In this paper, we initiate steps to tackle this issue. We introduce an extensible and lightweight toolkit, LMFlow, which aims to simplify the domain- and task-aware finetuning of general foundation models. LMFlow offers a complete finetuning workflow for a foundation model to support specialized training with limited computing resources. Furthermore, it supports continuous pretraining, instruction tuning, parameter-efficient finetuning, alignment tuning, inference acceleration, long context generalization, model customization, and even multimodal finetuning, along with carefully designed and extensible APIs. This toolkit has been thoroughly tested and is available at https://github.com/OptimalScale/LMFlow.
Motivation & Objective
- To address the growing complexity of fine-tuning large foundation models across diverse specialized tasks.
- To provide a unified, extensible, and resource-efficient toolkit for researchers and developers with limited computing resources.
- To streamline the full fine-tuning pipeline, including continuous pretraining, instruction tuning, and reinforcement learning with human feedback (RLHF).
- To enable personalized model training for tasks such as question-answering, translation, and expert consultation using minimal hardware.
- To offer a simple, extensible API and automated evaluation framework to improve reproducibility and accessibility.
Proposed method
- LMFlow implements a four-stage fine-tuning workflow: domain adaptation, task adaptation, instruction tuning, and reinforcement learning with human feedback (RLHF).
- It supports parameter-efficient fine-tuning via Low-Rank Adaptation (LoRA), reducing computational and memory costs.
- A novel RLHF algorithm, RAFT (Reward rAnked FineTuning), simplifies the RLHF pipeline by using reward ranking instead of reward modeling.
- The toolkit uses a standardized JSON-based data format with types like 'text_only' and 'text2text' to support diverse training data.
- It includes a simplified inference framework and integrates with Hugging Face models for seamless deployment.
- Evaluation is performed using negative log-likelihood (NLL), which is shown to correlate strongly with downstream task accuracy and avoids biases inherent in perplexity (PPL).
Experimental results
Research questions
- RQ1Can a lightweight, extensible toolkit streamline the fine-tuning of large foundation models across diverse specialized tasks?
- RQ2How effective is the RAFT algorithm in simplifying and improving the RLHF process for generative models?
- RQ3To what extent can parameter-efficient fine-tuning with LoRA achieve performance comparable to full fine-tuning on limited hardware?
- RQ4Can NLL serve as a reliable, automated metric for evaluating model capabilities without human annotation?
- RQ5What is the practical performance ceiling of fine-tuned LLaMA models when trained on a single GPU with limited resources?
Key findings
- Training a 7-billion-parameter LLaMA model with personalized fine-tuning on a single NVIDIA 3090 GPU takes only five hours, demonstrating high efficiency on limited hardware.
- The toolkit successfully supports continuous pretraining, instruction tuning, parameter-efficient fine-tuning (LoRA), and RLHF, enabling full customization of foundation models.
- A 33-billion-parameter LLaMA model fine-tuned with LMFlow achieves performance comparable to or better than ChatGPT on specific benchmarks.
- The NLL metric shows a strong correlation with commonsense question-answering accuracy, validating its use as a reliable, automated evaluation metric.
- RAFT-based RLHF significantly simplifies the reinforcement learning pipeline while maintaining strong performance on instruction-following and dialogue tasks.
- The released model weights for 7B, 13B, 33B, and 65B LLaMA variants are publicly available for academic use, enabling immediate deployment for question-answering services.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.