wikillm

Paper · 2022-05-30 · cs.AI, cs.LG

Multi-Game Decision Transformers

One GPT-2-style transformer, trained offline on Atari trajectories from 41 games, predicts return, action and reward tokens from 84x84 frames cut into 14x14 patches. At play time it samples a high target return, then an action. Author-reported: 126% of human-normalised IQM across the 41 games, gains with model size, and fast fine-tuning to 5 held-out games.

Return-conditioned sequence modelingImitation learningMulti-task learningTransfer learningoffline-rldecision-transformeratarisequence-modelingscaling

arXivPDFCodeMarkdown15 min read

AI-compiled by claude-haiku-5-5 on 2026-10-18, not yet reviewed by a human. Every claim cites its source; check it when a detail matters.

In plain words

Most game-playing AI systems learn one game at a time. This paper asks whether one neural network can learn many old Atari video games at once, using only recordings of other players and without playing live while it learns.

The trick is to treat each game as a long sequence of tokens, the same way a language model treats text. Each step holds the picture cut into small squares, a target score to aim for, the action taken and the reward received. A transformer, the kind of model behind chat assistants, learns to predict the next token. When it plays, it first asks for a high but plausible target score, then picks an action that fits that target.

The authors report that bigger models do better, and that a model trained on many games can pick up a new game quickly from a small amount of data. They release the pre-trained models and code. All results are their own.

TL;DR

  • Offline, single-set-of-weights agent for 41 training Atari games (46 in total, 5 held out), trained on DQN replay trajectories §3.3.
  • Decision-transformer sequence model over image patches, return, action and reward tokens §3.1 §3.2.
  • Expert-level behaviour comes from sampling a high target return before each action, a classifier-guided idea borrowed from language generation §3.4.
  • Author-reported: 126% human-normalised IQM across 41 games, scaling with size, best fine-tuning among the methods tested §1 §4.5.
  • Released code is inference-only and differs from the main text in several places. Read the Paper vs code section before reimplementing.

Problem

Offline RL normally needs one policy per task, and multi-environment training on Atari has been studied less than single-game or single-environment RL §1. Training data mixes expert and non-expert play §3.3. Plain behaviour cloning imitates that mix and rarely produces the best episodes §4.7. Temporal- difference (TD) methods such as C51 and CQL become unstable as the model grows in the multi-game setting §4.4. The authors want a single model that is trained on all data but can still act at expert level, and that scales §1.

Method

Sequence formulation §3.1. The agent sees observation o^t, emits action a^t and gets reward r^t. The model is a decoder-only transformer trained with next-token prediction over the sequence \langle ..., o^t_1, ..., o^t_M, \hat{R}^t, a^t, r^t, ... \rangle, where \hat{R}^t is the target return for the remainder of the episode §3.1. The order puts the return before the action, so the model can sample a return first and then an action. Observation patches are not predicted, because the authors judge them non-discrete and expensive to generate §3.1.

Tokenization §3.2 app. B.1.

  1. Each 84x84 grayscale frame app. B.1 is cut into a 6x6 grid of 14x14 pixel patches, giving M = 36 patches §3.2 app. B.1.
  2. Each patch is linearly projected and gets a trainable position encoding §3.2.
  3. Returns are uniformly quantised into integer bins from -20 to 100 §3.2.
  4. Actions are already discrete §3.2.
  5. Rewards are mapped to a ternary class {-1, 0, +1} §3.2. See Paper vs code for the four-class version in the release.
  6. One timestep is therefore 36 patch tokens, one return, one action and one reward token, 39 in all. Four frames make a 156-token sequence §4.1.

Attention mask app. B.1. Ordinary causal masking would block the patches of one frame from attending to each other. The authors allow full attention within the observation tokens of a timestep and keep causal masking across timesteps.

Training data §3.3. The data come from an existing set of Atari trajectories collected while DQN agents trained §3.3. Per training game there are 2 runs of 50 checkpoints, each with 1M environment steps §3.3. Across 41 games that totals 4.1 billion steps and about 160 billion tokens §3.3. There is no filtering or balancing §3.3. Five games are held out for transfer tests §3.3 app. B.2.

Training objective §3.1 §3.2. Cross-entropy on the next return, action and reward tokens. Training is ordinary next-token prediction and needs no change to the usual infrastructure. The expert-level inference step below only changes sampling at play time §3.4.

Expert action inference §3.4 alg. 1 app. B.3. The authors model "expert-level" as a binary variable whose probability grows with the return, P(\mathrm{expert}^t | R^t, ...) \propto \exp(\kappa R^t), with inverse temperature \kappa. Applying Bayes' rule to the learned return distribution gives a biased sampling rule. The biased logits add \kappa times a normalised return, (R - R_{\mathrm{low}})/(R_{\mathrm{high}} - R_{\mathrm{low}}) §3.4. The main text sets \kappa = 10 §3.4 app. B.3. The return is resampled at every step app. B.3, which avoids storing past target returns app. B.3.

Pseudocode
# Expert return and action inference  [alg. 1] [§3.4]
# Input:  environment env, trained model; kappa = 10
# Output: one action per environment step

def play_episode(model, env):
    # Start from the observation tokens and the history  [alg. 1]
    context = start_context(env)
    while not env.done:
        # Return logits over the 121 bins from -20 to 100  [alg. 1] [app. B.3]
        return_logits = model.return_logits(context)
        # Add kappa * normalised return to each logit  [§3.4]
        normalised = (return_bins + 20) / 120
        biased = return_logits + kappa * normalised
        # Sample a target return; top 85th percentile  [app. B.3]
        target = sample(biased, temperature=1, top_percentile=85)
        # Sample an action conditioned on that target  [alg. 1]
        action_logits = model.action_logits(context, target)
        action = sample(action_logits, temperature=1, top_percentile=85)
        reward, observation = env.step(action)
        # Slide the window; the history is regenerated, not stored  [app. B.3]
        context = slide(context, observation, action, reward)

The authors also describe a simpler alternative. It draws N = 128 return samples from the model, keeps the largest one, and conditions the action on it app. B.3. This needs no \kappa. The reported settings for it are return temperature 0.75, no return percentile cut-off, and action logits in the top 50th percentile at temperature 1 app. B.3. The authors say the two choices perform similarly app. B.3. The released code implements this alternative, not the \kappa version (see Paper vs code).

Baselines §4.2 app. C. Behaviour cloning is the same transformer with the return token removed app. C. C51 is online multi-game DQN with an Impala CNN §4.2. CQL adds a behaviour-cloning term to C51's categorical loss §4.2. Representation baselines are CPC, BERT and ACL, each with its own pre-training objective and then a behaviour-cloning head §4.2 app. C.

Image augmentation app. B.5. Random crop (4 zero pixels of padding on each side, then crop back to 84x84) and random rotation worked best. The authors also tried channel permutation, pixel permutation and flips. The same random parameters are used for each window, and augmentation is applied in both pre-training and fine-tuning app. B.5.

Evaluation app. B.4. Atari 2600 with the preprocessing of Agarwal et al. 2020, 18 shared discrete actions, no sticky actions, and each game scored over 16 rollouts app. B.4. Observations are JPEG-compressed in the dataset and at evaluation app. B.4.

Hyperparameters

NameValueWhereNotes
DT-200M architecture10 layers, d_model 1280, 20 heads, about 200M paramsapp. B.1 tab. 1 Multi_game_decision_transformers_public_colab.ipynbReleased model config matches. Heads = d_model/64 Multi_game_decision_transformers_public_colab.ipynb
DT-40M architecture6 layers, d_model 768, 12 headsapp. B.1 tab. 1Used for the expert-data and seed experiments §4.8 app. B.1
DT-10M architecture4 layers, d_model 512, 8 headsapp. B.1 tab. 1
Training hardware64 TPUv4 per model; DT-10M 1 day, DT-40M 2 days, DT-200M 8 daysapp. B.1 tab. 1Training time as reported
Sequence length4 frames, 156 tokens§4.14 x (36 + 3) = 156 §3.2
Patch size14x14, M = 36 (6x6 grid) on 84x84 grayscale§3.2 [fn. 2] app. B.1 Multi_game_decision_transformers_public_colab.ipynbStride-14 convolution in the released code
Return vocabulary121 integer bins, -20 to 100, bin size 1§3.2 [fn. 1] Multi_game_decision_transformers_public_colab.ipynb Multi_game_decision_transformers_public_colab.ipynbApp. B.1 says 120 buckets; see Paper vs code
Reward tokens3 classes (ternary) per paper§3.2Release uses 4 classes; see Paper vs code
Dropoutnot stated in paperMulti_game_decision_transformers_public_colab.ipynb0.1 in the released model definition
Pre-training optimiserLAMB, betas 0.9 / 0.999§4.1Training code is not in the repository
Pre-training learning rate3e-4, 4000 linear warm-up steps§4.1Decay after warm-up: not stated
Pre-training weight decaynone§4.1
Pre-training gradient clip1.0§4.1
Pre-training batch size2048§4.1
Pre-training length10M steps§4.1
Fine-tuning length100k steps§4.1Same protocol for all methods §4.5
Fine-tuning learning rate1e-4§4.1
Fine-tuning weight decay1e-2§4.1
Fine-tuning batch size256§4.1
Fine-tuning data1% of a held-out game, about 500,000 transitionsapp. B.2 §4.5§4.5 says "1M steps"; see Pitfalls
Pre-training data for transfer41 training games, 100M steps each§4.5
Held-out gamesAlien, MsPacman, Pong, SpaceInvaders, StarGunner§3.3 app. B.2
Training games41, from 46 selected for DQN outperforming random§3.3Selection follows Gulcehre et al. 2020
Action samplingtemperature 1, top 85th percentile of logitsapp. B.3Code default is 50 (see Paper vs code)
Return sampling (main)temperature 1, top 85th percentile, kappa = 10§3.4 app. B.3
Return sampling (alternative)N = 128 samples, temperature 0.75, max, no cut-offapp. B.3 Multi_game_decision_transformers_public_colab.ipynbMatches released code
Action sampling (alternative)top 50th percentile, temperature 1app. B.3 Multi_game_decision_transformers_public_colab.ipynbMatches released code
Expert-data sharetop 10% of trajectories by episodic return, per game§4.8 app. F
Image augmentationrandom crop (pad 4) and random rotationapp. B.5Applied in pre-training and fine-tuning
Evaluation rollouts16 per game, no sticky actionsapp. B.4
Seeds1 for all main results; 5 for DT-40M§4.1 app. B.1
CQL behaviour-cloning weight1 with full data, 4 with 1% fine-tuning§4.2Following CQL recommendations
CQL pre-training1M gradient steps, per-replica batch 32, 32 cores (global 256), lr 0.00025app. CFine-tuning: 100k steps, batch 32, one CPU
C51 (multi-game)multi-step n = 4; Impala 64/128/128 channels; batch 128; update period 256§4.215M gradient steps, about 4B env steps app. C
CQL scaling sizes(5 blocks, 128 ch) 5M; (10, 256) 30M; (5, 512) 60M; (10, 512) 120M§4.2Impala blocks x channels
CPCtwo 512-unit MLP layers with ReLU; Impala CNN 16/32/32 channels; batch 256; lr 0.00025app. C1M representation steps; fine-tune every 50k; best reported
BERT and ACL2 self-attention layers, 4 heads of 256 units, feed-forward 512, k = 16§4.2 app. CACL adds an action-prediction loss

Results

Author-reported. Setup: 41 training Atari games §3.3. Human-normalised score (HNS) and inter-quartile mean (IQM) across games §4.1 app. B.4. Baselines are behaviour cloning, online C51, offline CQL, and representation methods §4.2. Single training seed except for DT-40M app. B.1.

SettingMetricBaselineThis paperSource
Multi-game DT, all 41 training games (model size not named in the sentence)IQM of HNSTraining dataset: 101%126%§1 fig. 1
Multi-game DT vs BC, per gamegames where DT beats BCBCDT better in 31 of 41§4.7 fig. 8
Multi-game C51 (online) vs Impalamedian HNSImpala median 70% (computed by the authors from published Impala results)68%§4.3
DT-40M, 5 seedsmedian HNS, mean and sdnone (single runs elsewhere)0.79, sd 0.06app. B.1
DT-40M, 5 seedsIQM, mean and sdnone0.95, sd 0.05app. B.1
Scaling with model size, training gamesIQMCQLDT keeps improving over more than one order of magnitude; CQL does not improve and drops for larger models§4.4 fig. 5
Transfer to 5 held-out games, 1% dataper-game score after 100k stepsCQL from scratch on 1%Pre-trained DT best on every held-out game; values in figure only§4.5 fig. 6
Expert data vs full data, 40M modelsIQMBC-40M trained on expert dataDT-40M trained on full data beats BC-40M on expert data; ordering only in text, values in figure§4.8 fig. 9
Beat the best demonstration% over best dataset score (top-3 rollouts)0% (best dataset score)Gains in a number of games; values in figure only§4.6 fig. 7

Raw per-game scores for the best multi-game models (41 games) tab. 2 app. I. DT (200M), BC (200M), online DQN (10M) and CQL (60M), as reported:

GameDT (200M)BC (200M)Online DQN (10M)CQL (60M)
Amidar101.5101.0629.84.0
Assault2,385.91,872.11,338.7820.1
Asterix14,706.35,162.52,949.1950.0
Atlantis3,105,342.34,237.5976,030.416,800.0
BankHeist5.063.11,069.620.0
BattleZone17,687.59,250.026,235.25,000.0
BeamRider8,560.54,948.41,524.83,246.4
Boxing95.190.968.3100.0
Breakout290.6185.632.662.0
Carnival2,213.82,986.92,021.2440.0
Centipede2,463.02,262.84,848.02,904.0
ChopperCommand4,268.81,800.0951.4400.0
CrazyClimber126,018.8123,350.0146,362.5139,300.0
DemonAttack23,768.47,870.6446.81,202.0
DoubleDunk-10.6-1.5-156.2-2.0
Enduro1,092.6793.2896.3729.0
FishingDerby11.85.6-152.318.4
Freeway30.429.830.632.0
Frostbite2,435.6782.52,748.4408.0
Gopher9,935.03,496.33,205.6700.0
Gravitar59.412.5492.50.0
Hero20,408.813,850.026,568.814,040.0
IceHockey-10.1-8.3-10.4-10.5
Jamesbond700.0431.3264.6500.0
Kangaroo12,700.012,143.87,997.16,700.0
Krull8,685.68,058.88,221.47,170.0
KungFuMaster15,562.54,362.529,383.113,700.0
NameThisGame9,056.97,241.96,548.83,700.0
Phoenix5,295.64,326.93,932.51,880.0
Pooyan2,859.11,677.24,000.0330.0
Qbert13,734.411,276.64,226.511,700.0
Riverraid14,755.69,816.37,306.63,810.0
RoadRunner54,568.849,118.825,233.050,900.0
Robotank63.244.69.217.0
Seaquest5,173.81,175.61,415.2643.0
TimePilot2,743.81,312.5-883.12,400.0
UpNDown16,291.310,454.48,167.65,610.0
VideoPinball1,007.71,140.885,351.00.0
WizardOfWor187.5443.8975.9500.0
YarsRevenge28,897.920,738.918,889.519,505.4
Zaxxon275.050.0-0.10.0

Paper vs code

Official code: google-research/google-research/multi_game_dt, linked from the authors' project page. The page is the project site named in the paper §1 [abstract, footnote]. The repository is Apache-2.0 LICENSE. The folder holds a README (marked "work in progress"), an AUTHORS file and one Colab notebook Multi_game_decision_transformers_public_colab.ipynb. The notebook loads a pre-trained checkpoint from a Google Cloud Storage path Multi_game_decision_transformers_public_colab.ipynb, which was not downloaded for this card. code_commit is the head of the whole google-research repository at clone time. The folder itself was not versioned separately.

What is confirmed by the code:

Differences:

No discrepancy was checked for the baseline implementations (C51, CQL, CPC, BERT, ACL, Impala); they are not in the repository.

Pitfalls

  • Two inference recipes. Main text: kappa = 10, top-85 cut-off §3.4 app. B.3. Release: no kappa, max of 128 return samples at temperature 0.75, top-50 cut-off Multi_game_decision_transformers_public_colab.ipynb. The paper does not say which recipe produced the 126% headline or the per-game raw scores. Pick one and report it.
  • Percentile semantics. Code keeps logits above the p-th percentile Multi_game_decision_transformers_public_colab.ipynb. Top 85th percentile therefore keeps about the top 15% of logits. A reader reading "top 85th percentile" as "keep the top 85%" would get a different policy.
  • Return is written to position 0 only. The release writes one sampled return into position 0 Multi_game_decision_transformers_public_colab.ipynb. Algorithm 1 resamples the return at every step alg. 1. How the released wrapper carries the return between steps is not verified; it uses a window of return values Multi_game_decision_transformers_public_colab.ipynb Multi_game_decision_transformers_public_colab.ipynb.
  • Return bins: 120 or 121. The paper says 120 buckets app. B.1 and 121 logits alg. 1. The code uses 121 Multi_game_decision_transformers_public_colab.ipynb. Use 121 for the closed interval -20..100.
  • Fine-tuning data size. §4.5 says 1% is "1M steps" from a 50M-step dataset §4.5. App. B.2 says roughly 500,000 transitions app. B.2. 1% of 50M is 500,000, so B.2 is consistent with the dataset size and §4.5 is probably a typo.
  • Single seed. Only DT-40M was rerun, over 5 seeds: IQM 0.95 with sd 0.05 app. B.1. All other results are single runs §4.1. The authors call the variance small compared with the gaps they report app. B.1; no significance tests are given.
  • Expert data is a filtered subset. The expert set keeps the top 10% of trajectories by episodic return §4.8 app. F. It is used only for the expert-data comparison; the main method trains on all data §4.8.
  • Reward tokens and the terminal convention. The reward embedding has four classes, and the return target can be -1 after a terminal reward (see Paper vs code). Copy the convention you train with; the paper does not define it.
  • Dropout. A rate of 0.1 appears only in the released model Multi_game_decision_transformers_public_colab.ipynb. The paper says nothing about it.
  • Context is short. Four frames per sequence in all experiments §4.1. No longer memory is evaluated.
  • Compression. Observations are JPEG-compressed in the dataset and at evaluation app. B.4. Reproduced scores depend on this step.
  • Compute. 64 TPUv4 per model, 8 days for DT-200M app. B.1 tab. 1. Reimplementation needs a large accelerator budget; the paper gives no single-GPU setting.
  • Figure and equation numbers. The numbers here follow LaTeX source order, not the compiled PDF: figure 1 is the IQM figure, figure 2 the teaser, and appendix tables are 1 (model sizes) and 2 (raw scores). Check against the compiled PDF before quoting a number.
  • Atari dataset. The training trajectories come from Agarwal et al. 2020 §3.3 app. B.4. The repository does not include them; they must be obtained separately.
  • Expert action inference is independent of training. Only the sampling changes; a model trained with the usual cross-entropy can be used with either recipe §3.4. Keep the training objective and the inference recipe separate when you debug.

Lineage

  • Builds on: decision transformer, treating offline RL as sequence modelling §3.1 (Chen et al. 2021, cited in the paper as chen2021decision; arXiv id not given in the source text). Upside-Down RL §2. GPT-2 architecture §4.1.
  • Uses ideas from: discriminator-guided generation in language models (cited as krause2020gedi) for the expert classifier §3.4; nucleus sampling (cited as holtzman2019curious) for the action cut-off app. B.3.
  • Compared against: C51 (Bellemare et al. 2017), CQL (Kumar et al. 2020), Impala (Espeholt et al. 2018), CPC, BERT, ACL, behaviour cloning §4.2.
  • Concurrent work: Gato (cited as gato2022deepmind) trains a transformer generalist on near-optimal data and needs expert prompts at inference §2.
  • Superseded by: not stated in content on this wiki.

Source and license

Adapted from “Multi-Game Decision Transformers” by Kuang-Huei Lee, Ofir Nachum, Mengjiao Yang, Lisa Lee, Daniel Freeman, Winnie Xu, Sergio Guadarrama, Ian Fischer, Eric Jang, Henryk Michalewski, Igor Mordatch (arXiv:2205.15241), used under CC BY 4.0. Changes: condensed and restructured for implementation, with tables, equations and algorithms taken from the paper and its code, each cited to its source. Not affiliated with or endorsed by the authors. Code citations refer to https://github.com/google-research/google-research/tree/master/multi_game_dt at commit 3ef52111c1fa (Apache-2.0). Any quoted code is shown under that license.