OpenLM is an open-source codebase for medium-sized language model research, designed to simplify the research workflow while maintaining high performance. Its core modeling code relies only on PyTorch, XFormers, or Triton, with fewer dependencies than repositories such as Megatron. Its performance has been officially validated to scale to 7B parameters and 256 GPUs.
Main capabilities include:
- Data preprocessing: provides scripts to download and tokenize data (using the GPT-NeoX-20B tokenizer by default), with support for storing sharded data locally or on S3.
- Model training: distributed training via torchrun, supporting multiple model sizes (from 11M to 7B parameters), configurable data sampling (with or without replacement), and support for WandB and TensorBoard logging.
- Model evaluation: requires installing LLM Foundry, and evaluates trained checkpoints via configuration files.
- Text generation: provides generation scripts with parameters similar to evaluation.
- Pretrained models: released OpenLM 1B (about 1 billion parameters, trained on a 1.6T token mixed dataset including RedPajama, Pile, S2ORC, etc.) and intermediate checkpoints of OpenLM 7B (1.25T tokens). Note: these models use head_rotary positional embeddings, so --positional-embedding-type head_rotary must be specified during evaluation or generation.
Usage:
- Environment requirements: Python >=3.9, install PyTorch and other dependencies (pip install -r requirements.txt), then install open_lm in editable mode (pip install --editable .).
- Data preparation: use open_lm/datapreprocess/wiki_download.py to download data, then tokenize and chunk via datapreprocess/make_2048.py.
- Training: run open_lm/main.py, specifying parameters such as train-data, model, and train-num-samples.
- Evaluation: install llm-foundry, configure eval/in_memory_hf_eval.yaml, and run the evaluation script.
- Generation: use scripts/generate.py.
Use cases: suitable for researchers studying medium-sized language models who need a flexible, lightweight training framework, and for developers who want to fine-tune or evaluate based on pretrained models.
Limitations: the official documentation does not provide detailed minimum hardware configurations, training time, pricing information, etc.; OpenLM 7B has not yet completed training; when using the pretrained models, note the special setting for the positional embedding type.