How facebookresearch/coconut works
Coconut is a research training and evaluation application for language models that reason using continuous latent representations. Users prepare question/answer/steps data, select a YAML run configuration, and launch distributed training or evaluation; training can progress through latent-reasoning stages, and evaluation measures generated answers. The graph also shows the documented dataset-preparation branches and the latent-model layer. The README and excerpts support the main workflow; unsampled runner sections limit detail about checkpointing and dataset setup, so those connections are not expanded.
Main entry points: run.py Experiment runner · coconut.py Latent reasoning model · data Prepared datasets · gsm_icot.py GSM conversion
Components 18
Data preparation
- Raw datasets
- GSM conversion
preprocessing/gsm_icot.py - ProntoQA conversion
preprocessing/prontoqa.py - Prepared datasets
data - Dataset processing
dataset.py
Training runtime
- Run configurations
args - Experiment runner
run.py - Run utilities
utils.py - Distributed training
run.py - Generation evaluation
run.py - Model checkpoints
- Experiment logging
- Accuracy and loss
Model and evaluation
- Tokenizer
- Causal language model
- Latent reasoning model
coconut.py
Other components
- Research user
- Weights & Biases
Connections 24
- Research user → Run configurations: selects
README.md - Research user → Raw datasets: provides
README.md - Raw datasets → GSM conversion: converts
README.md - Raw datasets → ProntoQA conversion: converts
README.md - GSM conversion → Prepared datasets: writes JSON
preprocessing/gsm_icot.py - ProntoQA conversion → Prepared datasets: writes splits
preprocessing/prontoqa.py - Research user → Experiment runner: launches
README.md - Run configurations → Experiment runner: configures
README.md - Prepared datasets → Dataset processing: loads data
- Experiment runner → Dataset processing: uses
run.py - Experiment runner → Run utilities: uses
run.py - Experiment runner → Tokenizer: loads
run.py - Experiment runner → Causal language model: loads
run.py - Experiment runner → Latent reasoning model: wraps model
run.py - Latent reasoning model → Causal language model: forwards to
coconut.py - Experiment runner → Distributed training: runs stages
README.md - Distributed training → Latent reasoning model: trains
run.py - Experiment runner → Generation evaluation: runs evaluation
README.md - Generation evaluation → Latent reasoning model: generates with
run.py - Distributed training → Model checkpoints: saves
- Generation evaluation → Model checkpoints: loads
- Distributed training → Experiment logging: logs metrics
run.py - Generation evaluation → Accuracy and loss: computes
run.py - Experiment logging → Weights & Biases: reports to