LLMBox is a comprehensive implementation library for large language models (LLMs), providing a unified training pipeline and comprehensive model evaluation capabilities, with the design goal of becoming a one-stop solution for training and using LLMs. Through practical library design, it achieves high flexibility and efficiency in both the training and usage stages.
Main Capabilities
Training
- Diverse training strategies: supports supervised fine-tuning (SFT), pretraining (PT), PPO, and DPO.
- Comprehensive SFT datasets: supports 9 SFT datasets as training input.
- Tokenizer vocabulary merging: supports tokenizer merging functionality to expand the vocabulary.
- Data construction strategies: supports merging multiple datasets for training, and provides Self-Instruct and Evol-Instruct to process datasets.
- Parameter-efficient fine-tuning: supports LoRA and QLoRA in SFT or PT.
- Efficient training: supports Flash Attention and Deepspeed.
Usage and Evaluation
- Ultra-fast inference: by managing the prefix KV Cache or using vLLM, local inference speed can be increased by up to 6 times.
- Comprehensive evaluation: covers 59+ commonly used datasets and benchmarks for evaluating LLMs.
- Evaluation methods: can accurately reproduce the results of the original papers of models such as OpenAI, LLaMA, and Mistral.
- In-context learning (ICL): supports multiple ICL strategies, including KATE, GlobalE, and APE.
- Chain-of-thought (CoT): supports three CoT evaluations for some datasets: base, least-to-most, and pal.
- Quantization: supports BitsAndBytes and GPTQ quantization.
- Easy to use: provides detailed results, making it convenient for users to debug or integrate new models/datasets/CoT.
Usage
Installation
If only evaluating OpenAI (or OpenAI-compatible such as DeepSeek, Perplexity) models, the minimal dependency requirements-openai.txt can be installed. For installation issues, refer to the troubleshooting documentation. Currently, LLMBox can be updated by pulling the latest repository from GitHub; if merge conflicts are encountered, local changes can first be dropped, stashed, or committed.
Training Quick Start
Based on LLaMA-2 (7B), deep can be usedspeed3 Start training the SFT model. Training supports multiple training strategies and dataset construction strategies, as well as some modules for improving efficiency. You can also use preset bash scripts to train the model.
Quick Start
To use a model or evaluate an existing model, you can run the corresponding command. By default, the OpenAI GPT 3.5 turbo model is run in a zero-shot manner on the CoPA dataset.
Tokenizer Merging
If you want to pretrain a model on a language or token corpus that the original language model (such as LLaMA) does not support well, you can use the tokenizer merging feature to extend the vocabulary based on the corpus through sentencepiece. See merge_tokenizer.py and the pretraining guide for details.
Dataset Merging
If you want to train a model with a mixture of multiple datasets, you can pass a list of dataset files or names to LLMBox. LLMBox will convert each file or name into a PTDataset or SFTDataset and merge them to construct a combined dataset. You can also set the merging ratio of each dataset by passing a list of floating-point numbers. See the merged dataset guide for details.
Self-Instruct and Evol-Instruct
Because manually creating high-quality instruction data to train models is very time-consuming and labor-intensive, Self-Instruct and Evol-Instruct were proposed to use LLMs instead of humans to create large amounts of instruction data of varying complexity. LLMBox supports both to enhance input data files. See the relevant guides for details.
Model Support
Broad support for Huggingface models (such as LLaMA-3, Mistral, or models the user is building), OpenAI, Anthropic, QWen, and other OpenAI-compatible models. See the documentation for the complete list of model backends.
Dataset Support
Currently, a total of 59+ commonly used datasets are supported, including HellaSwag, MMLU, GSM8K, GPQA, AGIEval, CEval, and CMMLU, among others. See the documentation for the complete dataset list. Support for imbue_code, imbue_public, and imbue_private was recently added.
Efficient Evaluation
Prefix caching is enabled by default for efficient evaluation, and vLLM is also supported. You can use the corresponding command to enable vllm or quantized evaluation.
Evaluation Methods
Multiple evaluation methods are supported:
- Generation based on source text: for example, ARC-Challenge (extracting option characters such as A, B, C, D from model generation), GSM8K, HumanEval. Note that vLLM is usually faster at generation than transformers, but the default parameters are different, and users may need to adjust sampling parameters such as temperature and length_penalty to obtain the best results.
- Computing the perplexity of option text based on source text (that is, computing the log-likelihood of the suffix): for example, WinoGrande, BoolQ. Note that some datasets (such as ARC, OpenbookQA, RACE) use normalized accuracy when evaluated with the get_ppl method.
- Obtaining the probability of each option label (that is, based on option characters): for example, MMLU, ARC-Challenge.
You can use --instruction to pass in a jinja template to override the default instruction. By default, the get_ppl method is used with the ppl_no_option ranking type for MultipleChoiceDataset, and the generation method is used for GenerationDataset. You can also use the get_prob method or the ppl variant of get_ppl. Some datasets also support in-context learning and chain-of-thought evaluation.
Applicable Scenarios
LLMBox is suitable for researchers and developers who need to train, fine-tune, evaluate, and use large language models, and is especially suitable for scenarios where they want to uniformly manage the training process and evaluation benchmarks, reproduce paper results, perform parameter-efficient fine-tuning, or conduct quantized evaluation.
Limitations
The materials do not provide more information about charges, pricing, platform limitations, or specific performance guarantees. Please refer to the official documentation and troubleshooting guide before use.