lm-evaluation-harness
A unified framework to test generative language models on a large number of different evaluation tasks.
What it is · Main features · Getting started
What it is
lm-evaluation-harness is a unified framework to test generative language models on a large number of different evaluation tasks. The base installation provides the core evaluation framework.
Core facts
Read by a script from the official API, not rewritten by a model.
- License
- MIT
- Languages
- Python
- Maintainer
- EleutherAI
- Homepage
- https://www.eleuther.ai
- Verified
Main features
The project implements over 60 standard academic benchmarks for LLMs, with hundreds of subtasks and variants.
It supports local models and benchmarks.
The README says that evaluation with publicly available prompts ensures reproducibility and comparability between papers.
The CLI has subcommands run, ls and validate, and supports YAML config files through a config flag.
Providing an output path saves the evaluation results.
The log samples flag logs model responses for post-hoc analysis.
A cache directory can be given to cache evaluation results and skip previously evaluated samples when resuming runs of the same (model, task) pairs.
To push results and samples to the Hugging Face Hub, first ensure that an access token with write access is set in the
HF_TOKENenvironment variable.The check integrity flag verifies the data integrity of the tasks being run, in addition to running the tasks themselves.
Getting started
The base package no longer includes transformers or torch.
To use the HuggingFace backend, the hf extra of lm_eval must be installed first.
The hf extra corresponds to HuggingFace Transformers, covering torch, transformers, accelerate and peft.
The help flag lists available options, and the same flag on the run subcommand lists evaluation options.
The README shows how to list the available tasks.
The HuggingFace backend example evaluates the model GPT-J-6B, hosted on the HuggingFace Hub, on hellaswag, and assumes a CUDA-compatible GPU.
Additional arguments can be provided to the model constructor through the
model_argsflag.The
model_argsflag supports using the revisions feature on the Hub to store partially trained checkpoints, or specifying the datatype for running a model.Batch size selection can be automated by setting the batch size flag to auto.
This performs automatic detection of the largest batch size that fits on the device.
The README says that on tasks with a large difference between the longest and shortest example, recomputing the largest batch size periodically can be helpful to gain a further speedup.
pip install "lm_eval[hf]"lm-eval ls taskslm_eval --model hf \
--model_args pretrained=EleutherAI/gpt-j-6B \
--tasks hellaswag \
--device cuda:0 \
--batch_size 8lm_eval --model hf \
--model_args pretrained=EleutherAI/pythia-160m,revision=step100000,dtype="float" \
--tasks lambada_openai,hellaswag \
--device cuda:0 \
--batch_size 8lm_eval --model hf \
--model_args pretrained=EleutherAI/pythia-160m,revision=step100000,dtype="float" \
--tasks lambada_openai,hellaswag \
--device cuda:0 \
--batch_size auto:4Who it is for
Caching is rank-dependent, so after an interruption restart with the same GPU count. The hf model type does not natively support multi-node evaluation.
Sources
This page is written from the official sources below. Open them to check the original text.
- GitHub READMEhttps://github.com/EleutherAI/lm-evaluation-harnessFetched
Verified ·
This page is written by AI from the official sources above and checked automatically. This site has not tested it. Found a mistake? Tell us.