lm-evaluation-harness

A unified framework to test generative language models on a large number of different evaluation tasks.

Verified

On this page

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
Verified

Main features

  1. The project implements over 60 standard academic benchmarks for LLMs, with hundreds of subtasks and variants.

  2. It supports local models and benchmarks.

  3. The README says that evaluation with publicly available prompts ensures reproducibility and comparability between papers.

  4. The CLI has subcommands run, ls and validate, and supports YAML config files through a config flag.

  5. Providing an output path saves the evaluation results.

  6. The log samples flag logs model responses for post-hoc analysis.

  7. A cache directory can be given to cache evaluation results and skip previously evaluated samples when resuming runs of the same (model, task) pairs.

  8. To push results and samples to the Hugging Face Hub, first ensure that an access token with write access is set in the HF_TOKEN environment variable.

  9. The check integrity flag verifies the data integrity of the tasks being run, in addition to running the tasks themselves.

Getting started

  1. The base package no longer includes transformers or torch.

  2. To use the HuggingFace backend, the hf extra of lm_eval must be installed first.

  3. The hf extra corresponds to HuggingFace Transformers, covering torch, transformers, accelerate and peft.

  4. The help flag lists available options, and the same flag on the run subcommand lists evaluation options.

  5. The README shows how to list the available tasks.

  6. The HuggingFace backend example evaluates the model GPT-J-6B, hosted on the HuggingFace Hub, on hellaswag, and assumes a CUDA-compatible GPU.

  7. Additional arguments can be provided to the model constructor through the model_args flag.

  8. The model_args flag supports using the revisions feature on the Hub to store partially trained checkpoints, or specifying the datatype for running a model.

  9. Batch size selection can be automated by setting the batch size flag to auto.

  10. This performs automatic detection of the largest batch size that fits on the device.

  11. 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.

From the README
Shell
pip install "lm_eval[hf]"
From the README
Shell
lm-eval ls tasks
From the README
Shell
lm_eval --model hf \
    --model_args pretrained=EleutherAI/gpt-j-6B \
    --tasks hellaswag \
    --device cuda:0 \
    --batch_size 8
From the README
Shell
lm_eval --model hf \
    --model_args pretrained=EleutherAI/pythia-160m,revision=step100000,dtype="float" \
    --tasks lambada_openai,hellaswag \
    --device cuda:0 \
    --batch_size 8
From the README
Shell
lm_eval --model hf \
    --model_args pretrained=EleutherAI/pythia-160m,revision=step100000,dtype="float" \
    --tasks lambada_openai,hellaswag \
    --device cuda:0 \
    --batch_size auto:4

Who 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.

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.