# facebookresearch/simuleval architecture

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

- Interactive diagram: https://gitdiagram.com/facebookresearch/simuleval
- Repository: https://github.com/facebookresearch/simuleval

## Overview

1. **What this repository is**
   SimulEval is a Python package for evaluating simultaneous translation systems, especially **text-to-text, speech-to-text, and speech-to-speech** setups. Its core role is not training models, but **driving incremental evaluation** of an agent against source/target data and computing latency/quality metrics.

2. **Top-level execution path**
   The main entry point is the **`simuleval` CLI** (`simuleval/cli.py`), configured by `simuleval/options.py`. A typical run reads source data, loads an agent, runs an evaluation loop, and produces scores and optional visualizations.

3. **Agent boundary**
   The `simuleval/agents` package defines the contract for systems under test:
   - `agent.py` defines the base agent interface.
   - `states.py` and `actions.py` model the agent’s incremental state and decisions.
   - `pipeline.py` supports pipeline-style agents.
   - `service.py` suggests a service/remote-agent mode.
   
   This is the key boundary between the framework and the translation/speech model being evaluated.

4. **Input data layer**
   `simuleval/data` contains the abstractions for feeding evaluation instances:
   - `dataloader/` provides loaders for different modalities, including **text-to-text** and **speech-to-text**.
   - `segments.py` represents source/target segments and incremental chunks.
   
   The data layer converts files like `source.txt`, `target.txt`, and audio inputs into a stream the evaluator can consume step by step.

5. **Evaluation engine**
   The core runtime lives in `simuleval/evaluator`:
   - `evaluator.py` coordinates the evaluation loop.
   - `instance.py` represents a single evaluated sample/stream.
   - `remote.py` supports distributed or remote execution.
   
   This layer orchestrates the interaction between dataloader, agent, and scorers, maintaining the simultaneous setting where source arrives gradually and outputs are produced incrementally.

6. **Metrics and scoring**
   `simuleval/evaluator/scorers` separates metric computation from the run loop:
   - `quality_scorer.py` handles translation/output quality.
   - `latency_scorer.py` handles delay/latency metrics.
   
   This separation matters architecturally because the evaluator produces behavior traces, and scorers turn those traces into the final assessment.

7. **Analysis and visualization**
   `simuleval/analysis/curve.py` and `simuleval/utils/visualize.py` indicate post-evaluation analysis, likely for plotting latency-quality tradeoffs or policy curves. This is a downstream layer: it consumes evaluation outputs rather than participating in the online decision loop.

8. **Utilities and environment helpers**
   `simuleval/utils` contains supporting infrastructure:
   - `arguments.py` and `functional.py` for shared plumbing.
   - `agent.py` for agent-related helpers.
   - `slurm.py` for batch/HPC execution support.
   
   These are cross-cutting utilities rather than core domain logic.

9. **Examples as architecture documentation**
   The `examples/` tree is substantial and shows intended usage patterns:
   - `quick_start/` demonstrates a minimal wait-k style agent and CLI invocation.
   - `speech_to_text/` and `speech_to_speech/` show modality-specific evaluation.
   - `*_demo/` and `speech_to_speech_text/` show pipeline-based variants.
   
   The examples reveal that the framework is designed around **pluggable agents** rather than a fixed model architecture.

10. **Tests define the supported contracts**
   The test suite in `simuleval/test` covers agent behavior, pipeline integration, evaluator behavior, remote evaluation, speech-to-text, speech-to-speech, and visualization. This suggests the most important system boundaries are:
   - agent API compatibility,
   - evaluator/instance orchestration,
   - modality-specific dataloading,
   - scoring correctness,
   - remote execution behavior.

11. **Documentation and release pipeline**
   `docs/` contains user guides and tutorials for agents, dataloaders, evaluators, and remote evaluation, while GitHub Actions workflows handle CI and PyPI publishing. These are operationally important but sit outside the runtime architecture.

12. **Overall data flow**
   In diagram form, the main flow is:
   **source/target inputs or audio → dataloader/segments → evaluator/instance loop → agent state/actions → incremental outputs → quality + latency scorers → reports/visualization**.
   
   The main architectural boundary is between the framework and the user-provided agent, with modality-specific dataloaders and scorers adapting the same evaluation engine to text and speech tasks.

Main entry points: [`simuleval/evaluator/evaluator.py`](https://github.com/facebookresearch/simuleval/blob/main/simuleval/evaluator/evaluator.py) (Evaluator), [`simuleval/agents/agent.py`](https://github.com/facebookresearch/simuleval/blob/main/simuleval/agents/agent.py) (Agent base), [`simuleval/data/dataloader/dataloader.py`](https://github.com/facebookresearch/simuleval/blob/main/simuleval/data/dataloader/dataloader.py) (Data loader), [`simuleval/analysis/curve.py`](https://github.com/facebookresearch/simuleval/blob/main/simuleval/analysis/curve.py) (Curves)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_core["Core runtime"]
  node_cli["CLI<br/>entrypoint<br/>[cli.py]"]
  node_options["Options<br/>config parsing<br/>[options.py]"]
  node_evaluator["Evaluator<br/>runtime coordinator<br/>[evaluator.py]"]
  node_instance["Instance<br/>stream state<br/>[instance.py]"]
  node_remote_eval["Remote exec<br/>distributed runtime<br/>[remote.py]"]
  node_quality["Quality scorer<br/>metric<br/>[quality_scorer.py]"]
  node_latency["Latency scorer<br/>metric<br/>[latency_scorer.py]"]
end

subgraph group_contracts["Agent contracts"]
  node_agent_base["Agent base<br/>interface<br/>[agent.py]"]
  node_agent_states["States<br/>agent state<br/>[states.py]"]
  node_agent_actions["Actions<br/>agent decision<br/>[actions.py]"]
  node_pipeline_agent["Pipeline agent<br/>agent wrapper<br/>[pipeline.py]"]
  node_service_agent["Service agent<br/>agent wrapper<br/>[service.py]"]
end

subgraph group_data["Input data"]
  node_data_loader["Data loader<br/>input adapter<br/>[dataloader.py]"]
  node_t2t_loader["Text loader<br/>modal loader<br/>[t2t_dataloader.py]"]
  node_s2t_loader["Speech loader<br/>modal loader<br/>[s2t_dataloader.py]"]
  node_segments["Segments<br/>stream chunks<br/>[segments.py]"]
end

subgraph group_post["Post-run analysis"]
  node_curve["Curves<br/>analysis<br/>[curve.py]"]
  node_visualize["Visualize<br/>reporting<br/>[visualize.py]"]
end

subgraph group_examples["Examples"]
  node_quick_start["Quick start<br/>example set"]
  node_s2t_examples["Speech-to-text<br/>example set"]
  node_s2s_examples["Speech-to-speech<br/>example set"]
end

node_cli -->|"reads"| node_options
node_cli -->|"starts"| node_evaluator
node_evaluator -->|"consumes"| node_data_loader
node_data_loader -->|"specializes"| node_t2t_loader
node_data_loader -->|"specializes"| node_s2t_loader
node_data_loader -->|"emits"| node_segments
node_evaluator -->|"manages"| node_instance
node_instance -->|"invokes"| node_agent_base
node_agent_base -->|"uses"| node_agent_states
node_agent_base -->|"returns"| node_agent_actions
node_agent_base -->|"extends"| node_pipeline_agent
node_agent_base -->|"extends"| node_service_agent
node_evaluator -->|"optionally delegates"| node_remote_eval
node_evaluator -->|"scores"| node_quality
node_evaluator -->|"scores"| node_latency
node_quality -->|"feeds"| node_curve
node_latency -->|"feeds"| node_curve
node_curve -->|"renders"| node_visualize
node_quick_start -->|"demonstrates"| node_agent_base
node_s2t_examples -->|"demonstrates"| node_s2t_loader
node_s2s_examples -->|"demonstrates"| node_service_agent

click node_cli "https://github.com/facebookresearch/simuleval/blob/main/simuleval/cli.py"
click node_options "https://github.com/facebookresearch/simuleval/blob/main/simuleval/options.py"
click node_evaluator "https://github.com/facebookresearch/simuleval/blob/main/simuleval/evaluator/evaluator.py"
click node_instance "https://github.com/facebookresearch/simuleval/blob/main/simuleval/evaluator/instance.py"
click node_remote_eval "https://github.com/facebookresearch/simuleval/blob/main/simuleval/evaluator/remote.py"
click node_quality "https://github.com/facebookresearch/simuleval/blob/main/simuleval/evaluator/scorers/quality_scorer.py"
click node_latency "https://github.com/facebookresearch/simuleval/blob/main/simuleval/evaluator/scorers/latency_scorer.py"
click node_agent_base "https://github.com/facebookresearch/simuleval/blob/main/simuleval/agents/agent.py"
click node_agent_states "https://github.com/facebookresearch/simuleval/blob/main/simuleval/agents/states.py"
click node_agent_actions "https://github.com/facebookresearch/simuleval/blob/main/simuleval/agents/actions.py"
click node_pipeline_agent "https://github.com/facebookresearch/simuleval/blob/main/simuleval/agents/pipeline.py"
click node_service_agent "https://github.com/facebookresearch/simuleval/blob/main/simuleval/agents/service.py"
click node_data_loader "https://github.com/facebookresearch/simuleval/blob/main/simuleval/data/dataloader/dataloader.py"
click node_t2t_loader "https://github.com/facebookresearch/simuleval/blob/main/simuleval/data/dataloader/t2t_dataloader.py"
click node_s2t_loader "https://github.com/facebookresearch/simuleval/blob/main/simuleval/data/dataloader/s2t_dataloader.py"
click node_segments "https://github.com/facebookresearch/simuleval/blob/main/simuleval/data/segments.py"
click node_curve "https://github.com/facebookresearch/simuleval/blob/main/simuleval/analysis/curve.py"
click node_visualize "https://github.com/facebookresearch/simuleval/blob/main/simuleval/utils/visualize.py"
click node_quick_start "https://github.com/facebookresearch/simuleval/tree/main/examples/quick_start"
click node_s2t_examples "https://github.com/facebookresearch/simuleval/tree/main/examples/speech_to_text"
click node_s2s_examples "https://github.com/facebookresearch/simuleval/tree/main/examples/speech_to_speech"

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_options,node_evaluator,node_instance,node_remote_eval,node_quality,node_latency toneBlue
class node_agent_base,node_agent_states,node_agent_actions,node_pipeline_agent,node_service_agent toneAmber
class node_data_loader,node_t2t_loader,node_s2t_loader,node_segments toneMint
class node_curve,node_visualize toneRose
class node_quick_start,node_s2t_examples,node_s2s_examples toneIndigo
```

## Components

### Core runtime

CLI, options, evaluation loop, scoring, and remote execution.

- [CLI](https://github.com/facebookresearch/simuleval/blob/main/simuleval/cli.py): entrypoint · Command-line entrypoint for running evaluations. · `simuleval/cli.py`
- [Options](https://github.com/facebookresearch/simuleval/blob/main/simuleval/options.py): config parsing · Parses and normalizes runtime settings for the CLI. · `simuleval/options.py`
- [Evaluator](https://github.com/facebookresearch/simuleval/blob/main/simuleval/evaluator/evaluator.py): runtime coordinator · Main loop that drives incremental evaluation. · `simuleval/evaluator/evaluator.py`
- [Instance](https://github.com/facebookresearch/simuleval/blob/main/simuleval/evaluator/instance.py): stream state · Represents one evaluated sample or stream. · `simuleval/evaluator/instance.py`
- [Remote exec](https://github.com/facebookresearch/simuleval/blob/main/simuleval/evaluator/remote.py): distributed runtime · Supports remote or distributed evaluation execution. · `simuleval/evaluator/remote.py`
- [Quality scorer](https://github.com/facebookresearch/simuleval/blob/main/simuleval/evaluator/scorers/quality_scorer.py): metric · Computes output quality metrics. · `simuleval/evaluator/scorers/quality_scorer.py`
- [Latency scorer](https://github.com/facebookresearch/simuleval/blob/main/simuleval/evaluator/scorers/latency_scorer.py): metric · Computes delay and latency metrics. · `simuleval/evaluator/scorers/latency_scorer.py`

### Agent contracts

Framework interfaces and agent-side runtime abstractions.

- [Agent base](https://github.com/facebookresearch/simuleval/blob/main/simuleval/agents/agent.py): interface · Base contract for user-provided agents. · `simuleval/agents/agent.py`
- [States](https://github.com/facebookresearch/simuleval/blob/main/simuleval/agents/states.py): agent state · Incremental state tracked by an agent. · `simuleval/agents/states.py`
- [Actions](https://github.com/facebookresearch/simuleval/blob/main/simuleval/agents/actions.py): agent decision · Agent decisions in the incremental loop. · `simuleval/agents/actions.py`
- [Pipeline agent](https://github.com/facebookresearch/simuleval/blob/main/simuleval/agents/pipeline.py): agent wrapper · Pipeline-style agent composition support. · `simuleval/agents/pipeline.py`
- [Service agent](https://github.com/facebookresearch/simuleval/blob/main/simuleval/agents/service.py): agent wrapper · Remote or service-based agent mode. · `simuleval/agents/service.py`

### Input data

Dataloaders and segment representations for incremental evaluation.

- [Data loader](https://github.com/facebookresearch/simuleval/blob/main/simuleval/data/dataloader/dataloader.py): input adapter · Common loader interface for evaluation inputs. · `simuleval/data/dataloader/dataloader.py`
- [Text loader](https://github.com/facebookresearch/simuleval/blob/main/simuleval/data/dataloader/t2t_dataloader.py): modal loader · Loads text-to-text evaluation streams. · `simuleval/data/dataloader/t2t_dataloader.py`
- [Speech loader](https://github.com/facebookresearch/simuleval/blob/main/simuleval/data/dataloader/s2t_dataloader.py): modal loader · Loads speech-to-text evaluation streams. · `simuleval/data/dataloader/s2t_dataloader.py`
- [Segments](https://github.com/facebookresearch/simuleval/blob/main/simuleval/data/segments.py): stream chunks · Source and target segment abstractions for incremental feeding. · `simuleval/data/segments.py`

### Post-run analysis

Visualization and curve analysis after evaluation completes.

- [Curves](https://github.com/facebookresearch/simuleval/blob/main/simuleval/analysis/curve.py): analysis · Post-evaluation curve analysis for tradeoffs. · `simuleval/analysis/curve.py`
- [Visualize](https://github.com/facebookresearch/simuleval/blob/main/simuleval/utils/visualize.py): reporting · Utility for plotting or rendering evaluation results. · `simuleval/utils/visualize.py`

### Examples

Representative usage patterns for text and speech evaluation.

- [Quick start](https://github.com/facebookresearch/simuleval/tree/main/examples/quick_start): example set · Minimal agent and CLI examples for text evaluation. · `examples/quick_start`
- [Speech-to-text](https://github.com/facebookresearch/simuleval/tree/main/examples/speech_to_text): example set · Speech-to-text evaluation examples and demos. · `examples/speech_to_text`
- [Speech-to-speech](https://github.com/facebookresearch/simuleval/tree/main/examples/speech_to_speech): example set · Speech-to-speech evaluation examples and demos. · `examples/speech_to_speech`

## Connections

- CLI → Options: reads · CLI uses parsed options to configure a run.
- CLI → Evaluator: starts · CLI launches the evaluation engine.
- Evaluator → Data loader: consumes · Evaluation is driven by input streams from loaders.
- Data loader → Text loader: specializes · Text-to-text loader is one modality implementation.
- Data loader → Speech loader: specializes · Speech-to-text loader is one modality implementation.
- Data loader → Segments: emits · Loaders produce incremental segments.
- Evaluator → Instance: manages · The evaluator tracks one or more instances.
- Instance → Agent base: invokes · Each instance queries the evaluated agent.
- Agent base → States: uses · Agents maintain incremental state.
- Agent base → Actions: returns · Agents produce incremental actions or decisions.
- Agent base → Pipeline agent: extends · Pipeline agents implement the base contract.
- Agent base → Service agent: extends · Service agents implement the base contract.
- Evaluator → Remote exec: optionally delegates · Evaluation can run through a remote execution layer.
- Evaluator → Quality scorer: scores · Quality metrics are computed from evaluation traces.
- Evaluator → Latency scorer: scores · Latency metrics are computed from evaluation traces.
- Quality scorer → Curves: feeds · Quality results can be analyzed as curves.
- Latency scorer → Curves: feeds · Latency results can be analyzed as curves.
- Curves → Visualize: renders · Analysis outputs are visualized downstream.
- Quick start → Agent base: demonstrates · Shows minimal agent implementations.
- Speech-to-text → Speech loader: demonstrates · Shows speech-to-text data and agent setup.
- Speech-to-speech → Service agent: demonstrates · Shows speech-to-speech and pipeline variants.
