# A Generalist Agent

Scott Reed, Konrad Zolna, Emilio Parisotto, Sergio Gomez Colmenarejo, Alexander Novikov, Gabriel Barth-Maron and 14 more · arXiv · 2022-5-12

- **Problem** Most control policies are built for one domain, so each new task, sensor set or robot needs its own model. This study asks whether one transformer with one set of weights can act across many tasks, observation types and embodiments.
- **Method** Gato serializes text, image patches, discrete values and continuous values into one token stream, embeds each token, and trains a decoder-only transformer with a masked next-token loss, prompting each task with a demonstration.
- **Results** A single pretrained Gato scores above 50% of expert return on over 450 of 604 simulated tasks, and reaches 50.2% average success on real-robot RGB Stacking Skill Generalization against 49% for BC-IMP.

![Figure 2: Training phase of Gato. Data from diﬀerent tasks and modalities is serialized into a ﬂat sequence of tokens, batched, and processed by a transformer…](https://refivu.com/papers/890475cb-e797-43df-8de3-0d0eb9ed882e/figures/figure-fb66d5fbf9e2d771f8aa8b5c8b651123.png?thumb=512)

**Figure 2** :Training phase of Gato. Data from diﬀerent tasks and modalities is serialized into a ﬂat sequence of tokens, batched, and processed by a transformer neural network akin to a large language model. Masking is used such that the loss function is applied only to target outputs, i.e. text and various actions.

[Original paper](https://arxiv.org/abs/2205.06175v3) · [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) · Scott Reed, Konrad Zolna, Emilio Parisotto, Sergio Gomez Colmenarejo, Alexander Novikov, Gabriel Barth-Maron, Mai Gimenez, Yury Sulsky, Jackie Kay, Jost Tobias Springenberg, Tom Eccles, Jake Bruce, Ali Razavi, Ashley Edwards, Nicolas Heess, Yutian Chen, Raia Hadsell, Oriol Vinyals, Mahyar Bordbar, Nando de Freitas · A Generalist Agent · Original paper figure · Extracted the figure area from page 2 of the original PDF.

## The question behind a generalist agent

The study asks whether one network can serve as a policy across tasks whose inputs, outputs and bodies differ widely, instead of hand-building a policy with suitable inductive biases for each domain. The authors treat natural language as a shared grounding across embodiments that otherwise have little in common, and they expect that grounding to support combinations of behaviours the model was never trained on.

The model size is set by a practical limit: 1.2B parameters is the scale at which real-time control of a real robot remains possible, and the authors expect better hardware to move that limit upward. A second question follows from the first. Once a generalist exists, can it learn a new task from a small number of demonstrations, and how much does the choice of pretraining data change the result?

## Turning every modality into one token stream

Every kind of data is converted into a flat sequence of integer tokens, so that training and sampling look much like those of a large language model. Text is split with SentencePiece into 32000 subwords and mapped to integers in the range \[0, 32000). Images are cut into non-overlapping 16x16 patches in raster order, following ViT. Each pixel is scaled into \[-1, 1\] and then divided by 4, the square root of the patch size of 16.

Discrete values, such as Atari button presses, are flattened in row-major order and become integers in \[0, 1024). Continuous values, such as proprioception or joint torques, are flattened and mu-law encoded into \[-1, 1\] when they are not already in that range. They are then discretized into 1024 uniform bins and shifted into the range \[32000, 33024), so that they do not overlap the text tokens.

The embedding function treats the token types differently. Text, discrete and continuous tokens go through a learned lookup table, and every token receives a learnable position encoding based on its place inside its timestep. Image patch tokens pass through one ResNet block to give one vector per patch, and they receive an additional learnable within-image position encoding.

## Training objective and prompt conditioning

The sequence is factorized with the chain rule, so each token is predicted from all the tokens before it. Only some positions are scored: a mask is one for text tokens and for logged agent actions, and zero for image tokens and other non-predicted observations. The training loss is the negative log-likelihood summed over the batch and over the sequence positions, with the mask selecting which positions count.

\\\[ L(\\theta,B) = -\\sum\_{b=1}^{\|B\|}\\sum\_{l=1}^{L} m(b,l)\\,\\log p\_\\theta\\big(s\_l^{(b)} \\mid s\_1^{(b)},\\ldots,s\_{l-1}^{(b)}\\big) \\\] Figure 2 shows this stage: tokens from different tasks are batched, and the loss is applied only to target outputs such as text and actions.

Several tasks can share one embodiment and one observation and action format, so the model needs context to know which task it is in. Instead of one-hot task identifiers, the authors use prompt conditioning, in which a prompt from an episode of the same source agent on the same task is prepended. Prompts are prepended to 25% of the sequences in each batch.

Half of these prompts come from the end of an episode, which works as goal conditioning in many domains, and the other half are sampled uniformly from the episode.

Episodes and documents are usually longer than the context, so the training code samples random subsequences of L tokens. Each batch mixes domains roughly uniformly, with some manual upweighting of the larger and higher-quality datasets.

## Running Gato as a control policy

At deployment the prompt, such as a demonstration, is tokenized to start the sequence. By default the first 1024 tokens of the demonstration are used, and the first observation is tokenized and appended. Gato then samples the action one token at a time until the number of tokens fixed by the action specification has been produced. The tokens are decoded back into an action, sent to the environment, and the new observation is appended before the loop repeats.

Figure 3 illustrates this loop with a game console as the environment, where interleaved observations, separator tokens and earlier actions feed the next action.

The model attends to all earlier observations and actions within its window of 1024 tokens. The authors found transformer XL memory helpful during deployment, although they did not use it during training.

## Data mixture and filtering

Table 1 lists 596 control tasks across 16 control environments, totalling 63M episodes and about 1.5T tokens, and these control datasets make up 85.3% of the sampling weight. Figure 1 and the control results count 604 tasks. The control data come from specialist reinforcement learning agents in environments including Meta-World, Sokoban, BabyAI, DM Control Suite, DM Lab, the Arcade Learning Environment, Procgen, Modular RL and a simulated Kinova Jaco arm.

The vision and language data, which make up 14.7% of the sampling weight, include MassiveText, M3W, ALIGN, MS-COCO Captions, Conceptual Captions, LTIP, OKVQA and VQAv2.

Only episodes whose return is at least 80% of the expert return for the task are kept. The expert return is the maximum, over sliding windows of W consecutive episodes, of the average return inside the window. W is set to the smaller of 1000 and 0.1 times the total number N of episodes.

The language data is MassiveText, and the vision-language sets include ALIGN with 1.8B image and alt-text pairs and LTIP with 312 million images with captions. Visual question answering uses OKVQA with 9K and VQAv2 with 443K image, question and answer triplets. Each training episode from these sets joins five image and text pairs, which are padded or randomly cropped to the training sequence length.

## Simulated control results

Figure 5 shows how many tasks clear each score threshold, grouped by domain.

On ALE Atari, Gato reaches average human score or better on 23 games and more than twice human score on 11 of them. The online single-task agents that produced the Atari data still score higher than Gato. The authors suggest that more capacity or offline RL training could close this gap, and a specialist Atari agent reaches better than human on 44 games.

On BabyAI, Gato is above 80% of expert score on nearly all levels, and reaches 75% on BossLevel, the hardest one. The BabyAI 1.0 and 1.1 baselines reached 77% and 90% on that same task, but they were trained on it alone with a million demonstrations, so they are not a like-for-like comparison. On Meta-World, Gato exceeds 50% of expert score on 44 of 45 tasks, exceeds 80% on 35 tasks and exceeds 90% on 3 tasks.

On the DM Control Suite from state, Gato is above 50% of expert score on 21 of 30 tasks and above 80% on 18 tasks.

## RGB Stacking results on a real robot

The RGB Stacking task uses a Sawyer arm and three coloured blocks, with the goal of stacking red on blue while ignoring green. The shapes vary across several shape axes, and five triplets are held out as test sets. Observations are two 128x128 camera images, the arm and gripper joint angles and the end-effector pose, and the object state is not observed.

Episodes last 400 timesteps at 20 Hz. Skill Generalization trains on data that excludes the test shapes, while Skill Mastery trains on data that includes them.

On Skill Generalization, each test triplet was evaluated over 200 episodes on the real robot. Gato averaged 50.2% success and BC-IMP averaged 49%. Per group, Gato scored 24.5%, 33%, 50.5%, 76.5% and 66.5%, while BC-IMP scored 23%, 39.3%, 39.3%, 77.5% and 66%. Gato is higher on groups 1, 3 and 5 and lower on groups 2 and 4.

Skill Mastery uses the test shapes in training, and it was evaluated with an earlier version of the architecture and without fine-tuning. Gato averaged 75.6% success against 74.6% for BC-IMP. The authors state that Gato exceeds or closely matches BC-IMP on all but one training triplet.

## Adapting to new tasks and goals

Four tasks were held out of pretraining: cartpole.swingup, assembly-v2, order\_of\_apples\_forage\_simple and boxing.

On cartpole.swingup and assembly-v2, pretraining on all data gives the best fine-tuning results, and same-domain pretraining comes next. Removing control data gives no benefit on cartpole.swingup and negative transfer on assembly-v2. Figure 9 compares the full Gato, the ablations and the from-scratch model on these few-shot tasks.

On order\_of\_apples\_forage\_simple, same-domain pretraining alone is enough to approach the maximum reward of 19, so adding other data gives no visible gain there. Unlike the no-vision tasks, pretraining without control data helps on this task. The authors suggest this is because DM Lab images are simulated yet look natural, so transfer from image captioning and visual question answering is plausible.

On boxing, no pretraining variant helped, and the randomly initialized model worked better than every pretrained variant. The authors hypothesise that the game's visually distinct inputs make transfer difficult.

For RGB Stacking, Gato was fine-tuned separately on five subsets of the test demonstrations, and it was compared with the expert and with CRR trained on 35k episodes.

To test a perceptual change, the authors collected 500 demonstrations of stacking blue on green with a 3D mouse, totalling 2 hours and 45 minutes, and fine-tuned Gato on them. Figure 11 contrasts the standard stack-red-on-blue task with this new goal.

## Scale and specialist agents

Performance for each task is taken as a percentage of expert score. It is averaged within each domain and then averaged across domains, so that each domain carries equal weight. At an equal token count, the larger models perform better, and the authors read this as a clear improvement with scale.

## Limitations

The context is limited to 1024 tokens. Image observations can each take more than one hundred tokens, so for some environments only a short piece of a demonstration fits in the transformer. The authors attribute this limit mainly to the quadratic scaling of self-attention. Early tests of prompt-based in-context learning on new environments showed no significant gain over prompt-less evaluation.

Gato is derived from imitation learning, and it was trained offline with supervised learning. No web-scale control dataset exists, so the approach depends on the available control datasets. Observation-only video data and online RL data are suggested as sources, but the authors do not test them in this work.

Image tokens and non-textual observations are not predicted, so the model does not learn to generate them. Transfer to a new task from very different visual inputs, as seen on boxing, did not work, and the cause remains a hypothesis.

## Paper info

- **Authors**: Scott Reed, Konrad Zolna, Emilio Parisotto, Sergio Gomez Colmenarejo, Alexander Novikov, Gabriel Barth-Maron, Mai Gimenez, Yury Sulsky, Jackie Kay, Jost Tobias Springenberg, Tom Eccles, Jake Bruce, Ali Razavi, Ashley Edwards, Nicolas Heess, Yutian Chen, Raia Hadsell, Oriol Vinyals, Mahyar Bordbar, Nando de Freitas
- **Venue**: arXiv · Preprint
- **First published**: 2022-5-12
- **Added**: 2026-10-20
- **Updated**: 2022-11-11
- **Version**: v3
- **arXiv**: 2205.06175
- **Category**: cs.AI · cs.CL · cs.LG · cs.RO
- **Original paper terms**: [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/)
- **What we show**: Paper info, commentary and permitted figures from the original paper

[Original paper ↗](https://arxiv.org/abs/2205.06175v3) · [PDF ↗](https://arxiv.org/pdf/2205.06175v3)

AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.

## Abstract

Inspired by progress in large-scale language modeling, we apply a similar approach towards building a single generalist agent beyond the realm of text outputs. The agent, which we refer to as Gato, works as a multi-modal, multi-task, multi-embodiment generalist policy. The same network with the same weights can play Atari, caption images, chat, stack blocks with a real robot arm and much more, deciding based on its context whether to output text, joint torques, button presses, or other tokens. In this report we describe the model and the data, and document the current capabilities of Gato.

## Quote from the paper

Scott Reed, Konrad Zolna, Emilio Parisotto, Sergio Gomez Colmenarejo, Alexander Novikov, Gabriel Barth-Maron, Mai Gimenez, Yury Sulsky, Jackie Kay, Jost Tobias Springenberg, Tom Eccles, Jake Bruce, Ali Razavi, Ashley Edwards, Nicolas Heess, Yutian Chen, Raia Hadsell, Oriol Vinyals, Mahyar Bordbar, Nando de Freitas (2022). A Generalist Agent. arXiv:2205.06175v3. https://arxiv.org/abs/2205.06175v3

**BibTeX**

```
@misc{reed2022generalist,
  title = {{A Generalist Agent}},
  author = {Scott Reed and Konrad Zolna and Emilio Parisotto and Sergio Gomez Colmenarejo and Alexander Novikov and Gabriel Barth-Maron and Mai Gimenez and Yury Sulsky and Jackie Kay and Jost Tobias Springenberg and Tom Eccles and Jake Bruce and Ali Razavi and Ashley Edwards and Nicolas Heess and Yutian Chen and Raia Hadsell and Oriol Vinyals and Mahyar Bordbar and Nando de Freitas},
  year = {2022},
  eprint = {2205.06175},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2205.06175v3}
}
```

## Other paper commentary

- [Escaping Whack-a-Mole: Optimizing Documentation as Repo-Specific Playbooks for Coding Agents](https://refivu.com/en/papers/52e2d558-711f-4753-af6e-c88268527a9b-escaping-whack-a-mole-optimizing-documentation-as-repo.md)
- [VeriLadder: A Multi-Agent Specification Refinement System for Tool-Verified Verilog Datasets](https://refivu.com/en/papers/f3a3ce4f-fd41-462e-8bb7-f3e5263ba827-veriladder-a-multi-agent-specification-refinement-system-for.md)
- [AutoPILOT: A Visual Agent Harness for Real-Time Gameplay](https://refivu.com/en/papers/610b7c6f-2c3b-4308-bb50-b139b48fceb7-autopilot-a-visual-agent-harness-for-real-time.md)
- [LesionAgent: Training-Free Agentic Tumor Tracking and Response Assessment in Longitudinal CT](https://refivu.com/en/papers/aad1fd25-45a9-4d0f-bd6b-86f8fce045bc-lesionagent-training-free-agentic-tumor-tracking-and.md)
- [Same Executions, Different Gaps: Judgment Rules in Web-Agent Evaluation](https://refivu.com/en/papers/cb9c224a-78cc-40d2-ad37-8bf5d1ed1cf4-same-executions-different-gaps-judgment-rules-in-web.md)
- [Social Interaction Breaks Replicate Independence in Controlled-Clone LLM Agents](https://refivu.com/en/papers/b0f57efe-64e2-489e-934b-c47f708f4f19-social-interaction-breaks-replicate-independence-in.md)
- [Generating Long Sequences with Sparse Transformers](https://refivu.com/en/papers/25192f20-3966-40d3-94ed-65ebcaba60f7-generating-long-sequences-with-sparse-transformers.md)
- [Denoising Diffusion Implicit Models](https://refivu.com/en/papers/211aa1a1-08e2-40a7-b187-72384021f47a-denoising-diffusion-implicit-models.md)
- [Phi-3 Technical Report: A Highly Capable Language Model Locally on Your Phone](https://refivu.com/en/papers/1ae6b2e4-9099-4676-8fc3-523fa63b6919-phi-3-technical-report-a-highly-capable-language.md)
- [BLIP-2: Bootstrapping Language-Image Pre-training with Frozen Image Encoders and Large Language Models](https://refivu.com/en/papers/3bd907be-414a-4e3b-b195-d25379e2be77-blip-2-bootstrapping-language-image-pre-training-with.md)
- [Visual Instruction Tuning](https://refivu.com/en/papers/760eaf17-9dbc-40d5-afee-d36c375c59e3-visual-instruction-tuning.md)
- [Segment Anything](https://refivu.com/en/papers/da97e79e-c51b-4305-9514-76a2433c46a4-segment-anything.md)

## Terms in this paper

- [ResNet](https://refivu.com/en/terms/ca7e0121c7a8-resnet)
- [training loss](https://refivu.com/en/terms/684fcdc4da77-training-loss)
- [SentencePiece](https://refivu.com/en/terms/acec043085a4-sentencepiece)
- [Tokenization](https://refivu.com/en/terms/a90afb6902b4-tokenization)
- [Gato](https://refivu.com/en/terms/6e59800ad79a-gato)

---

AI-written text can contain mistakes. [Refivu](https://refivu.com/en/papers/890475cb-e797-43df-8de3-0d0eb9ed882e-a-generalist-agent)
