# facebookresearch/parlai architecture

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

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

## Overview

ParlAI is a research framework for training and evaluating dialogue and multimodal agents against a shared catalog of tasks, as well as connecting agents to human participants. A typical workflow configures a run, loads a task and agent, exchanges observations and actions in a world, and evaluates model output. Core abstractions support that workflow; separate subsystems provide retrieval, pretrained models, crowdsourcing, and live chat. The relationships shown are limited to README statements and SOURCE INDEX references; unsampled components are represented at their existing directory paths.

Main entry points: [`parlai/core/agents.py`](https://github.com/facebookresearch/parlai/blob/main/parlai/core/agents.py) (Agent lifecycle), [`parlai/chat_service/core/chat_service_manager.py`](https://github.com/facebookresearch/parlai/blob/main/parlai/chat_service/core/chat_service_manager.py) (Chat service manager), [`parlai/core/params.py`](https://github.com/facebookresearch/parlai/blob/main/parlai/core/params.py) (Argument parsing), [`parlai/agents`](https://github.com/facebookresearch/parlai/tree/main/parlai/agents) (Reference agents)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_config["Run configuration"]
  node_params["Argument parsing<br/>[params.py]"]
  node_options["Run options<br/>[opt.py]"]
end

subgraph group_framework["Core framework"]
  node_tasks["Task catalog"]
  node_teachers["Dataset teachers<br/>[teachers.py]"]
  node_worlds["Dialogue worlds<br/>[worlds.py]"]
  node_messages["Observations and actions<br/>[message.py]"]
  node_agent_api["Agent lifecycle<br/>[agents.py]"]
  node_torch_agent["Torch agent base<br/>[torch_agent.py]"]
  node_dictionary["Token dictionary<br/>[dict.py]"]
  node_metrics["Evaluation metrics<br/>[metrics.py]"]
end

subgraph group_models["Agents and retrieval"]
  node_agent_families["Reference agents"]
  node_rag["RAG dialogue model<br/>[rag.py]"]
  node_retrievers["Retrieval backends<br/>[retrievers.py]"]
  node_tfidf["TF-IDF retrieval<br/>[tfidf_retriever.py]"]
  node_model_zoo[("Pretrained models")]
end

subgraph group_human["Human interaction"]
  node_crowdsourcing["Crowdsourcing tasks"]
  node_chat_service["Chat service manager"]
  node_chat_channels["Chat channels"]
end

node_researcher(("Researcher"))
node_human_user(("Human participant"))

node_researcher -->|"configures run"| node_params
node_params -->|"builds options"| node_options
node_params -->|"loads task options"| node_tasks
node_researcher -->|"selects dataset"| node_tasks
node_tasks -.->|"provides datasets"| node_teachers
node_teachers -.->|"supplies examples"| node_worlds
node_worlds -.->|"runs agents"| node_agent_api
node_agent_api -->|"observes and acts"| node_messages
node_agent_api -->|"loads model options"| node_options
node_agent_api -->|"uses dictionary"| node_dictionary
node_researcher -->|"chooses model"| node_agent_families
node_agent_families -.->|"extends agent base"| node_torch_agent
node_torch_agent -.->|"tracks evaluation"| node_metrics
node_agent_families -.->|"loads pretrained weights"| node_model_zoo
node_rag -->|"uses retrieval"| node_retrievers
node_retrievers -->|"supports TF-IDF"| node_tfidf
node_researcher -->|"runs human evaluation"| node_crowdsourcing
node_researcher -->|"connects agent"| node_chat_service
node_chat_service -.->|"serves channels"| node_chat_channels
node_human_user -.->|"sends messages"| node_chat_channels
node_chat_service -->|"creates agents"| node_agent_api
node_chat_service -->|"runs worlds"| node_worlds

click node_params "https://github.com/facebookresearch/parlai/blob/main/parlai/core/params.py"
click node_options "https://github.com/facebookresearch/parlai/blob/main/parlai/core/opt.py"
click node_tasks "https://github.com/facebookresearch/parlai/tree/main/parlai/tasks"
click node_teachers "https://github.com/facebookresearch/parlai/blob/main/parlai/core/teachers.py"
click node_worlds "https://github.com/facebookresearch/parlai/blob/main/parlai/core/worlds.py"
click node_messages "https://github.com/facebookresearch/parlai/blob/main/parlai/core/message.py"
click node_agent_api "https://github.com/facebookresearch/parlai/blob/main/parlai/core/agents.py"
click node_torch_agent "https://github.com/facebookresearch/parlai/blob/main/parlai/core/torch_agent.py"
click node_dictionary "https://github.com/facebookresearch/parlai/blob/main/parlai/core/dict.py"
click node_metrics "https://github.com/facebookresearch/parlai/blob/main/parlai/core/metrics.py"
click node_agent_families "https://github.com/facebookresearch/parlai/tree/main/parlai/agents"
click node_rag "https://github.com/facebookresearch/parlai/blob/main/parlai/agents/rag/rag.py"
click node_retrievers "https://github.com/facebookresearch/parlai/blob/main/parlai/agents/rag/retrievers.py"
click node_tfidf "https://github.com/facebookresearch/parlai/blob/main/parlai/agents/tfidf_retriever/tfidf_retriever.py"
click node_model_zoo "https://github.com/facebookresearch/parlai/tree/main/parlai/zoo"
click node_crowdsourcing "https://github.com/facebookresearch/parlai/tree/main/parlai/crowdsourcing"
click node_chat_service "https://github.com/facebookresearch/parlai/blob/main/parlai/chat_service/core/chat_service_manager.py"
click node_chat_channels "https://github.com/facebookresearch/parlai/tree/main/parlai/chat_service/services"

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_params,node_options toneBlue
class node_tasks,node_teachers,node_worlds,node_messages,node_agent_api,node_torch_agent,node_dictionary,node_metrics toneAmber
class node_agent_families,node_rag,node_retrievers,node_tfidf,node_model_zoo toneMint
class node_crowdsourcing,node_chat_service,node_chat_channels toneRose
class node_researcher,node_human_user toneIndigo
```

## Components

### Run configuration

- [Argument parsing](https://github.com/facebookresearch/parlai/blob/main/parlai/core/params.py): `parlai/core/params.py`
- [Run options](https://github.com/facebookresearch/parlai/blob/main/parlai/core/opt.py): `parlai/core/opt.py`

### Core framework

- [Task catalog](https://github.com/facebookresearch/parlai/tree/main/parlai/tasks): `parlai/tasks`
- [Dataset teachers](https://github.com/facebookresearch/parlai/blob/main/parlai/core/teachers.py): `parlai/core/teachers.py`
- [Dialogue worlds](https://github.com/facebookresearch/parlai/blob/main/parlai/core/worlds.py): `parlai/core/worlds.py`
- [Observations and actions](https://github.com/facebookresearch/parlai/blob/main/parlai/core/message.py): `parlai/core/message.py`
- [Agent lifecycle](https://github.com/facebookresearch/parlai/blob/main/parlai/core/agents.py): `parlai/core/agents.py`
- [Torch agent base](https://github.com/facebookresearch/parlai/blob/main/parlai/core/torch_agent.py): `parlai/core/torch_agent.py`
- [Token dictionary](https://github.com/facebookresearch/parlai/blob/main/parlai/core/dict.py): `parlai/core/dict.py`
- [Evaluation metrics](https://github.com/facebookresearch/parlai/blob/main/parlai/core/metrics.py): `parlai/core/metrics.py`

### Agents and retrieval

- [Reference agents](https://github.com/facebookresearch/parlai/tree/main/parlai/agents): `parlai/agents`
- [RAG dialogue model](https://github.com/facebookresearch/parlai/blob/main/parlai/agents/rag/rag.py): `parlai/agents/rag/rag.py`
- [Retrieval backends](https://github.com/facebookresearch/parlai/blob/main/parlai/agents/rag/retrievers.py): `parlai/agents/rag/retrievers.py`
- [TF-IDF retrieval](https://github.com/facebookresearch/parlai/blob/main/parlai/agents/tfidf_retriever/tfidf_retriever.py): `parlai/agents/tfidf_retriever/tfidf_retriever.py`
- [Pretrained models](https://github.com/facebookresearch/parlai/tree/main/parlai/zoo): `parlai/zoo`

### Human interaction

- [Crowdsourcing tasks](https://github.com/facebookresearch/parlai/tree/main/parlai/crowdsourcing): `parlai/crowdsourcing`
- [Chat service manager](https://github.com/facebookresearch/parlai/blob/main/parlai/chat_service/core/chat_service_manager.py): `parlai/chat_service/core/chat_service_manager.py`
- [Chat channels](https://github.com/facebookresearch/parlai/tree/main/parlai/chat_service/services): `parlai/chat_service/services`

### Other components

- **Researcher**
- **Human participant**

## Connections

- Researcher → Argument parsing: configures run (evidence: `README.md`)
- Argument parsing → Run options: builds options (evidence: `parlai/core/params.py`)
- Argument parsing → Task catalog: loads task options (evidence: `parlai/core/params.py`)
- Researcher → Task catalog: selects dataset (evidence: `README.md`)
- Task catalog → Dataset teachers: provides datasets (evidence: `README.md`)
- Dataset teachers → Dialogue worlds: supplies examples (evidence: `README.md`)
- Dialogue worlds → Agent lifecycle: runs agents (evidence: `README.md`)
- Agent lifecycle → Observations and actions: observes and acts (evidence: `parlai/core/agents.py`)
- Agent lifecycle → Run options: loads model options (evidence: `parlai/core/agents.py`)
- Agent lifecycle → Token dictionary: uses dictionary (evidence: `parlai/core/agents.py`)
- Researcher → Reference agents: chooses model (evidence: `README.md`)
- Reference agents → Torch agent base: extends agent base (evidence: `parlai/agents/rag/rag.py`)
- Torch agent base → Evaluation metrics: tracks evaluation
- Reference agents → Pretrained models: loads pretrained weights (evidence: `README.md`)
- RAG dialogue model → Retrieval backends: uses retrieval (evidence: `parlai/agents/rag/rag.py`)
- Retrieval backends → TF-IDF retrieval: supports TF-IDF (evidence: `parlai/agents/rag/retrievers.py`)
- Researcher → Crowdsourcing tasks: runs human evaluation (evidence: `README.md`)
- Researcher → Chat service manager: connects agent (evidence: `README.md`)
- Chat service manager → Chat channels: serves channels (evidence: `parlai/chat_service/services/messenger/messenger_manager.py`)
- Human participant → Chat channels: sends messages
- Chat service manager → Agent lifecycle: creates agents (evidence: `parlai/chat_service/core/chat_service_manager.py`)
- Chat service manager → Dialogue worlds: runs worlds (evidence: `parlai/chat_service/core/chat_service_manager.py`)
