# huggingface/lighteval architecture

> Architecture diagram of the GitHub repository huggingface/lighteval, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/huggingface/lighteval
- Repository: https://github.com/huggingface/lighteval

## Overview

Lighteval is a flexible toolkit for evaluating language models against a broad catalog of standard and custom benchmarks. Users select tasks and a model backend through CLI entry points or the Python API; the pipeline prepares task samples, requests model outputs, computes metrics, and records results. Its major product areas include task and prompt definition, inference backends, metric computation, and result tracking. The workflow is documented in the README and partially visible in the excerpts; links among unsampled subsystems are omitted where their runtime wiring is not shown.

Main entry points: [`src/lighteval/pipeline.py`](https://github.com/huggingface/lighteval/blob/main/src/lighteval/pipeline.py) (Evaluation pipeline), [`src/lighteval/models/model_output.py`](https://github.com/huggingface/lighteval/blob/main/src/lighteval/models/model_output.py) (Model responses), [`src/lighteval/tasks/registry.py`](https://github.com/huggingface/lighteval/blob/main/src/lighteval/tasks/registry.py) (Task registry), [`src/lighteval/tasks/lighteval_task.py`](https://github.com/huggingface/lighteval/blob/main/src/lighteval/tasks/lighteval_task.py) (Task runtime)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflow["Evaluation workflow"]
  node_cli["CLI entry points<br/>[__main__.py]"]
  node_pipeline["Evaluation pipeline<br/>[pipeline.py]"]
end

subgraph group_tasks["Tasks and prompts"]
  node_task_registry["Task registry<br/>[registry.py]"]
  node_task_defs["Benchmark definitions"]
  node_multilingual["Multilingual tasks"]
  node_task_runtime["Task runtime<br/>[lighteval_task.py]"]
  node_prompting["Prompt preparation<br/>[prompt_manager.py]"]
  node_request_data["Evaluation documents<br/>[requests.py]"]
end

subgraph group_models["Model inference"]
  node_transformers["Transformers backend"]
  node_vllm["vLLM backend<br/>[vllm_model.py]"]
  node_nanotron["Nanotron backend<br/>[nanotron_model.py]"]
  node_endpoint["Endpoint backends<br/>[endpoint_model.py]"]
  node_model_output["Model responses<br/>[model_output.py]"]
end

subgraph group_metrics["Metrics"]
  node_metric_catalog["Metric catalog<br/>[metrics.py]"]
  node_sample_metrics["Sample metrics<br/>[metrics_sample.py]"]
  node_metric_runtime["Metric execution<br/>[metric_utils.py]"]
  node_corpus_metrics["Corpus metrics<br/>[metrics_corpus.py]"]
end

subgraph group_results["Results and support"]
  node_tracker["Evaluation tracker"]
  node_cache[("Sample cache")]
  node_parallelism["Parallel execution<br/>[parallelism.py]"]
end

node_user(("Evaluator"))
node_hf_hub(("Hugging Face Hub"))
node_inference_service(("Inference services"))

node_user -->|"runs evaluation"| node_cli
node_user -->|"configures API"| node_pipeline
node_cli -.->|"starts evaluation"| node_pipeline
node_pipeline -.->|"loads tasks"| node_task_registry
node_task_registry -.->|"registers benchmarks"| node_task_defs
node_task_registry -.->|"registers benchmarks"| node_multilingual
node_pipeline -->|"evaluates tasks"| node_task_runtime
node_task_runtime -.->|"prepares prompts"| node_prompting
node_task_runtime -.->|"creates documents"| node_request_data
node_pipeline -.->|"dispatches inference"| node_transformers
node_pipeline -.->|"dispatches inference"| node_vllm
node_pipeline -.->|"dispatches inference"| node_nanotron
node_pipeline -.->|"dispatches inference"| node_endpoint
node_transformers -->|"returns responses"| node_model_output
node_vllm -->|"returns responses"| node_model_output
node_nanotron -->|"returns responses"| node_model_output
node_endpoint -.->|"queries service"| node_inference_service
node_pipeline -->|"collects responses"| node_model_output
node_pipeline -.->|"selects metrics"| node_metric_catalog
node_metric_catalog -->|"defines computations"| node_sample_metrics
node_metric_runtime -->|"computes samples"| node_sample_metrics
node_metric_runtime -->|"aggregates results"| node_corpus_metrics
node_pipeline -->|"records results"| node_tracker
node_pipeline -.->|"caches samples"| node_cache
node_pipeline -.->|"coordinates workers"| node_parallelism
node_tracker -->|"pushes results"| node_hf_hub

click node_cli "https://github.com/huggingface/lighteval/blob/main/src/lighteval/__main__.py"
click node_pipeline "https://github.com/huggingface/lighteval/blob/main/src/lighteval/pipeline.py"
click node_task_registry "https://github.com/huggingface/lighteval/blob/main/src/lighteval/tasks/registry.py"
click node_task_defs "https://github.com/huggingface/lighteval/tree/main/src/lighteval/tasks/tasks"
click node_multilingual "https://github.com/huggingface/lighteval/tree/main/src/lighteval/tasks/multilingual/tasks"
click node_task_runtime "https://github.com/huggingface/lighteval/blob/main/src/lighteval/tasks/lighteval_task.py"
click node_prompting "https://github.com/huggingface/lighteval/blob/main/src/lighteval/tasks/prompt_manager.py"
click node_request_data "https://github.com/huggingface/lighteval/blob/main/src/lighteval/tasks/requests.py"
click node_transformers "https://github.com/huggingface/lighteval/blob/main/src/lighteval/models/transformers/transformers_model.py"
click node_vllm "https://github.com/huggingface/lighteval/blob/main/src/lighteval/models/vllm/vllm_model.py"
click node_nanotron "https://github.com/huggingface/lighteval/blob/main/src/lighteval/models/nanotron/nanotron_model.py"
click node_endpoint "https://github.com/huggingface/lighteval/blob/main/src/lighteval/models/endpoints/endpoint_model.py"
click node_model_output "https://github.com/huggingface/lighteval/blob/main/src/lighteval/models/model_output.py"
click node_metric_catalog "https://github.com/huggingface/lighteval/blob/main/src/lighteval/metrics/metrics.py"
click node_sample_metrics "https://github.com/huggingface/lighteval/blob/main/src/lighteval/metrics/metrics_sample.py"
click node_metric_runtime "https://github.com/huggingface/lighteval/blob/main/src/lighteval/metrics/utils/metric_utils.py"
click node_corpus_metrics "https://github.com/huggingface/lighteval/blob/main/src/lighteval/metrics/metrics_corpus.py"
click node_tracker "https://github.com/huggingface/lighteval/blob/main/src/lighteval/logging/evaluation_tracker.py"
click node_cache "https://github.com/huggingface/lighteval/blob/main/src/lighteval/utils/cache_management.py"
click node_parallelism "https://github.com/huggingface/lighteval/blob/main/src/lighteval/utils/parallelism.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cli,node_pipeline toneBlue
class node_task_registry,node_task_defs,node_multilingual,node_task_runtime,node_prompting,node_request_data toneAmber
class node_transformers,node_vllm,node_nanotron,node_endpoint,node_model_output toneMint
class node_metric_catalog,node_sample_metrics,node_metric_runtime,node_corpus_metrics toneRose
class node_tracker,node_cache,node_parallelism,node_user,node_hf_hub,node_inference_service toneIndigo
```

## Components

### Evaluation workflow

- [CLI entry points](https://github.com/huggingface/lighteval/blob/main/src/lighteval/__main__.py): `src/lighteval/__main__.py`
- [Evaluation pipeline](https://github.com/huggingface/lighteval/blob/main/src/lighteval/pipeline.py): `src/lighteval/pipeline.py`

### Tasks and prompts

- [Task registry](https://github.com/huggingface/lighteval/blob/main/src/lighteval/tasks/registry.py): `src/lighteval/tasks/registry.py`
- [Benchmark definitions](https://github.com/huggingface/lighteval/tree/main/src/lighteval/tasks/tasks): `src/lighteval/tasks/tasks`
- [Multilingual tasks](https://github.com/huggingface/lighteval/tree/main/src/lighteval/tasks/multilingual/tasks): `src/lighteval/tasks/multilingual/tasks`
- [Task runtime](https://github.com/huggingface/lighteval/blob/main/src/lighteval/tasks/lighteval_task.py): `src/lighteval/tasks/lighteval_task.py`
- [Prompt preparation](https://github.com/huggingface/lighteval/blob/main/src/lighteval/tasks/prompt_manager.py): `src/lighteval/tasks/prompt_manager.py`
- [Evaluation documents](https://github.com/huggingface/lighteval/blob/main/src/lighteval/tasks/requests.py): `src/lighteval/tasks/requests.py`

### Model inference

- [Transformers backend](https://github.com/huggingface/lighteval/blob/main/src/lighteval/models/transformers/transformers_model.py): `src/lighteval/models/transformers/transformers_model.py`
- [vLLM backend](https://github.com/huggingface/lighteval/blob/main/src/lighteval/models/vllm/vllm_model.py): `src/lighteval/models/vllm/vllm_model.py`
- [Nanotron backend](https://github.com/huggingface/lighteval/blob/main/src/lighteval/models/nanotron/nanotron_model.py): `src/lighteval/models/nanotron/nanotron_model.py`
- [Endpoint backends](https://github.com/huggingface/lighteval/blob/main/src/lighteval/models/endpoints/endpoint_model.py): `src/lighteval/models/endpoints/endpoint_model.py`
- [Model responses](https://github.com/huggingface/lighteval/blob/main/src/lighteval/models/model_output.py): `src/lighteval/models/model_output.py`

### Metrics

- [Metric catalog](https://github.com/huggingface/lighteval/blob/main/src/lighteval/metrics/metrics.py): `src/lighteval/metrics/metrics.py`
- [Sample metrics](https://github.com/huggingface/lighteval/blob/main/src/lighteval/metrics/metrics_sample.py): `src/lighteval/metrics/metrics_sample.py`
- [Metric execution](https://github.com/huggingface/lighteval/blob/main/src/lighteval/metrics/utils/metric_utils.py): `src/lighteval/metrics/utils/metric_utils.py`
- [Corpus metrics](https://github.com/huggingface/lighteval/blob/main/src/lighteval/metrics/metrics_corpus.py): `src/lighteval/metrics/metrics_corpus.py`

### Results and support

- [Evaluation tracker](https://github.com/huggingface/lighteval/blob/main/src/lighteval/logging/evaluation_tracker.py): `src/lighteval/logging/evaluation_tracker.py`
- [Sample cache](https://github.com/huggingface/lighteval/blob/main/src/lighteval/utils/cache_management.py): `src/lighteval/utils/cache_management.py`
- [Parallel execution](https://github.com/huggingface/lighteval/blob/main/src/lighteval/utils/parallelism.py): `src/lighteval/utils/parallelism.py`

### Other components

- **Evaluator**
- **Hugging Face Hub**
- **Inference services**

## Connections

- Evaluator → CLI entry points: runs evaluation (evidence: `README.md`)
- Evaluator → Evaluation pipeline: configures API (evidence: `README.md`)
- CLI entry points → Evaluation pipeline: starts evaluation
- Evaluation pipeline → Task registry: loads tasks (evidence: `src/lighteval/pipeline.py`)
- Task registry → Benchmark definitions: registers benchmarks
- Task registry → Multilingual tasks: registers benchmarks
- Evaluation pipeline → Task runtime: evaluates tasks (evidence: `README.md`)
- Task runtime → Prompt preparation: prepares prompts (evidence: `src/lighteval/tasks/lighteval_task.py`)
- Task runtime → Evaluation documents: creates documents (evidence: `src/lighteval/tasks/lighteval_task.py`)
- Evaluation pipeline → Transformers backend: dispatches inference
- Evaluation pipeline → vLLM backend: dispatches inference
- Evaluation pipeline → Nanotron backend: dispatches inference (evidence: `src/lighteval/pipeline.py`)
- Evaluation pipeline → Endpoint backends: dispatches inference
- Transformers backend → Model responses: returns responses (evidence: `src/lighteval/models/transformers/transformers_model.py`)
- vLLM backend → Model responses: returns responses (evidence: `src/lighteval/models/vllm/vllm_model.py`)
- Nanotron backend → Model responses: returns responses (evidence: `src/lighteval/models/nanotron/nanotron_model.py`)
- Endpoint backends → Inference services: queries service
- Evaluation pipeline → Model responses: collects responses (evidence: `src/lighteval/pipeline.py`)
- Evaluation pipeline → Metric catalog: selects metrics
- Metric catalog → Sample metrics: defines computations (evidence: `src/lighteval/metrics/metrics.py`)
- Metric execution → Sample metrics: computes samples (evidence: `src/lighteval/metrics/utils/metric_utils.py`)
- Metric execution → Corpus metrics: aggregates results (evidence: `src/lighteval/metrics/utils/metric_utils.py`)
- Evaluation pipeline → Evaluation tracker: records results (evidence: `README.md`)
- Evaluation pipeline → Sample cache: caches samples
- Evaluation pipeline → Parallel execution: coordinates workers (evidence: `src/lighteval/pipeline.py`)
- Evaluation tracker → Hugging Face Hub: pushes results (evidence: `README.md`)
