# facebookarchive/mixer architecture

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

- Interactive diagram: https://gitdiagram.com/facebookarchive/mixer
- Repository: https://github.com/facebookarchive/mixer

## Overview

MIXER is a Torch/Lua system for training and evaluating recurrent neural networks on machine translation. The documented workflow begins at main.lua, which launches training and testing; Trainer.lua iterates over datasets for training and evaluation. The model_factory.lua builds a single-step network, while Mixer.lua unrolls and trains it through recurrent steps. The repository also documents data preparation, minibatch provision, sequence-level reinforcement components, and BLEU/ROUGE scoring. Source excerpts were unavailable, so links among these subsystems are included only where the README explicitly describes their behavior.

Main entry points: [`Trainer.lua`](https://github.com/facebookarchive/mixer/blob/master/Trainer.lua) (Training loop), [`main.lua`](https://github.com/facebookarchive/mixer/blob/master/main.lua) (Run entry point), [`Mixer.lua`](https://github.com/facebookarchive/mixer/blob/master/Mixer.lua) (Recurrent unrolling), [`model_factory.lua`](https://github.com/facebookarchive/mixer/blob/master/model_factory.lua) (Step model factory)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_run["Training and evaluation"]
  node_main["Run entry point<br/>[main.lua]"]
  node_trainer["Training loop<br/>[Trainer.lua]"]
end

subgraph group_model["Model and sequence learning"]
  node_mixer["Recurrent unrolling<br/>[Mixer.lua]"]
  node_model_factory["Step model factory<br/>[model_factory.lua]"]
  node_sampler["Sequence sampler"]
  node_reinforce_criterion["Sequence reward criterion"]
  node_weighted_criterion["Weighted NLL criterion"]
  node_linear["Input-gradient-free linear"]
end

subgraph group_data["Data and scoring"]
  node_data_source["Mini-batch provider<br/>[DataSource.lua]"]
  node_data_prep["Data preparation<br/>[makedata.lua]"]
  node_tokenizer["Tokenizer<br/>[tokenizer.lua]"]
  node_reward_factory["BLEU and ROUGE<br/>[reward_factory.lua]"]
end

node_user(("Experimenter"))

node_user -->|"runs"| node_main
node_main -->|"launches"| node_trainer
node_trainer -->|"trains"| node_mixer
node_trainer -->|"iterates data"| node_data_source
node_mixer -->|"clones step model"| node_model_factory

click node_main "https://github.com/facebookarchive/mixer/blob/master/main.lua"
click node_trainer "https://github.com/facebookarchive/mixer/blob/master/Trainer.lua"
click node_mixer "https://github.com/facebookarchive/mixer/blob/master/Mixer.lua"
click node_model_factory "https://github.com/facebookarchive/mixer/blob/master/model_factory.lua"
click node_sampler "https://github.com/facebookarchive/mixer/blob/master/ReinforceSampler.lua"
click node_reinforce_criterion "https://github.com/facebookarchive/mixer/blob/master/ReinforceCriterion.lua"
click node_weighted_criterion "https://github.com/facebookarchive/mixer/blob/master/ClassNLLCriterionWeighted.lua"
click node_linear "https://github.com/facebookarchive/mixer/blob/master/LinearNoBackpropInput.lua"
click node_data_source "https://github.com/facebookarchive/mixer/blob/master/DataSource.lua"
click node_data_prep "https://github.com/facebookarchive/mixer/blob/master/makedata.lua"
click node_tokenizer "https://github.com/facebookarchive/mixer/blob/master/tokenizer.lua"
click node_reward_factory "https://github.com/facebookarchive/mixer/blob/master/reward_factory.lua"

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_main,node_trainer toneBlue
class node_mixer,node_model_factory,node_sampler,node_reinforce_criterion,node_weighted_criterion,node_linear toneAmber
class node_data_source,node_data_prep,node_tokenizer,node_reward_factory toneMint
class node_user toneIndigo
```

## Components

### Training and evaluation

- [Run entry point](https://github.com/facebookarchive/mixer/blob/master/main.lua): `main.lua`
- [Training loop](https://github.com/facebookarchive/mixer/blob/master/Trainer.lua): `Trainer.lua`

### Model and sequence learning

- [Recurrent unrolling](https://github.com/facebookarchive/mixer/blob/master/Mixer.lua): `Mixer.lua`
- [Step model factory](https://github.com/facebookarchive/mixer/blob/master/model_factory.lua): `model_factory.lua`
- [Sequence sampler](https://github.com/facebookarchive/mixer/blob/master/ReinforceSampler.lua): `ReinforceSampler.lua`
- [Sequence reward criterion](https://github.com/facebookarchive/mixer/blob/master/ReinforceCriterion.lua): `ReinforceCriterion.lua`
- [Weighted NLL criterion](https://github.com/facebookarchive/mixer/blob/master/ClassNLLCriterionWeighted.lua): `ClassNLLCriterionWeighted.lua`
- [Input-gradient-free linear](https://github.com/facebookarchive/mixer/blob/master/LinearNoBackpropInput.lua): `LinearNoBackpropInput.lua`

### Data and scoring

- [Mini-batch provider](https://github.com/facebookarchive/mixer/blob/master/DataSource.lua): `DataSource.lua`
- [Data preparation](https://github.com/facebookarchive/mixer/blob/master/makedata.lua): `makedata.lua`
- [Tokenizer](https://github.com/facebookarchive/mixer/blob/master/tokenizer.lua): `tokenizer.lua`
- [BLEU and ROUGE](https://github.com/facebookarchive/mixer/blob/master/reward_factory.lua): `reward_factory.lua`

### Other components

- **Experimenter**

## Connections

- Experimenter → Run entry point: runs
- Run entry point → Training loop: launches
- Training loop → Recurrent unrolling: trains
- Training loop → Mini-batch provider: iterates data
- Recurrent unrolling → Step model factory: clones step model
