LM evaluation harness

swaleio/lm-eval

Category: Machine learning & AI Latest version 0.4.13-r1 · 2026-11-30 View versions

LM evaluation harness

Runs the EleutherAI lm-evaluation-harness (lm_eval) against a model, using the bundled vLLM engine as the inference backend with --batch_size auto. Evaluate a checkpoint fine-tuned earlier in the run, or a base model straight off the Hub, on standard benchmarks such as mmlu, gsm8k, hellaswag, arc_challenge, or winogrande. Benchmark datasets are downloaded from the Hub at run time.

Inputs

Input Required Default Description
model_dir yes — Full path of a local model directory (e.g. from hf-download), or a Hugging Face repo id.
tasks yes — Comma-separated lm-eval task names, e.g. mmlu,gsm8k — passed as one value, no word-splitting.
output_path yes — Absolute path the results are written under. Point it at the mounted workspace (e.g. ${{env.WORKFLOW_STORAGE}}/eval) to share them with later tasks.
token no — HF access token for gated/private models (pass a secret).
prefix_caching no false Whether vLLM reuses prompt text it already processed. false keeps repeated runs' scores close to identical; true can be faster on multiple-choice tasks, but scores can vary slightly between runs.

prefix_caching stays false so that evaluating the same model twice gives the same scores. With it on, vLLM reuses prompt text it has already processed, which can speed up multiple-choice tasks, since they repeat each question for every answer option. The cost is small numeric differences that can change a close answer, and with it the score.

Outputs

None declared. lm_eval writes its results under output_path: current harness versions create a per-model subdirectory there containing results_<timestamp>.json. Pass a workspace path so a later task can parse, compare, or publish the results.

Compute

GPU required. The model is loaded through vLLM, so the GPU's VRAM must fit it: roughly 2 GB per billion parameters for bf16 weights plus KV-cache headroom, so a 7–8B model wants a 24 GB+ GPU. This task's fixed command line keeps vLLM's default engine settings (no tensor parallelism), so size the compute type so that one GPU fits the model. The workflow selects the compute type via compute_type; on a CPU compute type the task fails at runtime with CUDA errors.

Reusing downloaded weights

model_dir accepts the full path of a local model directory. Point it at the output of an hf-download task (e.g. ${{tasks.<id>.outputs.path}}) to avoid re-downloading multi-gigabyte weights from the Hub on every run.

Gated and private models

When model_dir is a gated or private Hub repo id, pass a Hugging Face access token via token (as a secret) — the definition's exec.env delivers it to the harness as HF_TOKEN (an omitted token resolves to an empty value, which the Hugging Face stack treats as no token).

Example

name: LM evaluation harness example
compute_type: cpu-4
entry_point: main

blocks:
  main:
    tasks:
      weights:
        name: Fetch weights
        uses: swaleio/hf-download
        args:
          repo: Qwen/Qwen2.5-7B-Instruct
          include: "*.safetensors,*.json,tokenizer.*"
          dest: ${{env.WORKFLOW_STORAGE}}/qwen
      eval:
        name: Evaluate
        uses: swaleio/lm-eval
        start_on:
          - weights
        compute_type: a100-1   # any GPU compute type whose VRAM fits the model
        args:
          model_dir: ${{tasks.weights.outputs.path}}
          tasks: "mmlu,gsm8k"
          output_path: ${{env.WORKFLOW_STORAGE}}/eval

The harness evaluates the downloaded checkpoint without re-fetching it and writes the results JSON under ${{env.WORKFLOW_STORAGE}}/eval, where a later task can read it — for example to gate a deployment on a minimum benchmark score.


For the workflow syntax these examples use, see the workflow definition reference in the Swale documentation.

Licensed under the MIT License.