SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2305.16338 · ICML · 2024

Think Before You Act: Decision Transformers with Working Memory

Jie Fu, Xingdi Yuan, Adam Trischler, Romain Laroche, Xue Liu, Jikun Kang

arXiv · PDF · Open in the Atlas

Code that ran

7 of 12 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (3 of them constructed an object rather than computing a result; 2 honoured the contract we drafted, 0 violated it and 3 have no contract verdict; 2 failures of our instrument; 5 no recorded run), measured 2026-11-23; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2305.16338.json · badge: /api/ran/2305.16338.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
luciferkonn/dt_mem canonical (classifier label)
classifier basis: classifier_2025
7 ran · 5 no recorded run
FunctionStatusWhere it lives
GroupLinearLayer Ran
ran on a synthesized input · constructed an object; no result was computed
luciferkonn/dt_mem/src/model.py
code served (permissive licence) · get_code("161899026ce0eb8d")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned an instance of its own class, GroupLinearLayer: the run constructed the object and did not call it, so no result was computed. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn
import math

torch.manual_seed(0)

# Construct arguments for GroupLinearLayer
ARGS = {
    "in_dim": 4,
    "out_dim": 3,
    "num_blocks": 2,
    "bias": True,
    "a": None
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type GroupLinearLayer — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a GroupLinearLayer output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
RelationalMemory Ran
ran on a synthesized input · constructed an object; no result was computed
luciferkonn/dt_mem/src/model.py
code served (permissive licence) · get_code("83fc917b52b947b3")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned an instance of its own class, RelationalMemory: the run constructed the object and did not call it, so no result was computed. The image it ran in was not recorded. The code mentions cuda, and the harness aliases cuda to the CPU for every sample; whether this run needed that is not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import math
import torch
import torch.nn as nn

torch.manual_seed(0)

ARGS = {
    'mem_slots': 4,
    'head_size': 8,
    'attn_drop': 0.1,
    'num_heads': 2,
    'num_blocks': 1,
    'forget_bias': 1.0,
    'input_bias': 0.0,
    'gate_style': 'unit',
    'attention_mlp_layers': 2,
    'return_all_outputs': False,
    'use_topk': False,
    'topk': 3,
    'num_steps': 5,
    'null_attention': False,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type RelationalMemory — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a RelationalMemory output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
RepeatLinear Ran
ran on a synthesized input · constructed an object; no result was computed
luciferkonn/dt_mem/src/model.py
code served (permissive licence) · get_code("a0c499b6fb911e20")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned an instance of its own class, RepeatLinear: the run constructed the object and did not call it, so no result was computed. The image it ran in was not recorded. The code mentions cuda, and the harness aliases cuda to the CPU for every sample; whether this run needed that is not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn

torch.manual_seed(0)

# Analyze the forward method to understand what's needed:
# - x is used with .size(0) to get batch size
# - x is multiplied by w (broadcasting)
# - torch.relu, torch.mean, and self.linear are applied
# - w has shape (num_steps, in_dim) initially, then (batch_size, num_steps, in_dim)
# - x should have shape (batch_size, num_steps, in_dim) for broadcasting to work
# - After mean over dim=1, shape becomes (batch_size, in_dim)
# - self.linear takes (batch_size, in_dim) and outputs (batch_size, out_dim)

in_dim = 4
out_dim = 3
num_steps = 5
batch_size = 2

ARGS = {
    "in_dim": in_dim,
    "out_dim": out_dim,
    "num_steps": num_steps,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type RepeatLinear — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a RepeatLinear output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
accuracy Ran
ran, honoured the contract we drafted
luciferkonn/dt_mem/src/model.py
code served (permissive licence) · get_code("85999f9cb6163ec0")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Tensor, ndim 0, dtype family float, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

# Create small tensors for the accuracy function
# logits: shape (batch_size, num_classes) - raw model outputs
# labels: shape (batch_size, 1) or (batch_size,) - ground truth labels

batch_size = 2
num_classes = 4

# logits: (2, 4) - 2 samples, 4 classes
logits = torch.randn(batch_size, num_classes)

# labels: (2, 1) - 2 samples with class indices
labels = torch.tensor([[0], [2]], dtype=torch.long)

ARGS = {
    "logits": logits,
    "labels": labels,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 0, dtype family float, shape () — shape () as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
cross_entropy Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
luciferkonn/dt_mem/src/model.py
code served (permissive licence) · get_code("7a16e89219207505")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Tensor, ndim 0, dtype family float, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn.functional as F

torch.manual_seed(0)

# Create logits tensor: shape (N*T, num_classes)
# N=2 (batch size), T=3 (sequence length), num_classes=4
N, T = 2, 3
num_classes = 4
logits = torch.randn(N, T, num_classes)

# Create labels tensor: shape (N, T) with class indices
# Labels should be in range [0, num_classes)
labels = torch.randint(0, num_classes, (N, T))

ARGS = {
    "logits": logits,
    "labels": labels,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 0, dtype family float, shape () — shape () as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
encode_return Ran
ran; our contract draft was wrong, not the code
luciferkonn/dt_mem/src/model.py
code served (permissive licence) · get_code("c77c68839b869e29")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Tensor, ndim 2, dtype family int, shape (2, 4) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

# Create a small return tensor with shape (2, 4) - batch size 2, 4 return values
ret = torch.tensor([[100, 150, 200, 250],
                     [50, 75, 125, 175]], dtype=torch.float32)

# Define return range as (min, max) tuple
ret_range = (0, 300)

ARGS = {
    "ret": ret,
    "ret_range": ret_range,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 2, dtype family int, shape (2, 4) — shape (2, 4) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
encode_reward Ran
ran, honoured the contract we drafted
luciferkonn/dt_mem/src/model.py
code served (permissive licence) · get_code("dd64b6c6ba18470c")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Tensor, ndim 2, dtype family int, shape (2, 4) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

# Create a small reward tensor with mixed positive, negative, and zero values
# Shape: (2, 4) - batch of 2, with 4 reward values each
rew = torch.tensor([
    [1.5, -0.5, 0.0, 2.0],
    [0.0, -1.0, 0.5, 0.0]
], dtype=torch.float32)

ARGS = {
    "rew": rew
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 2, dtype family int, shape (2, 4) — shape (2, 4) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
CausalSelfAttention Not yet run
unverified (harvested, no recorded run)
luciferkonn/dt_mem/src/model.py
code served (permissive licence) · get_code("c59ed427653b94b7")
How it ran

no invocation recorded.

DecisionTransformer Not yet run
unverified (harvested, no recorded run)
luciferkonn/dt_mem/src/model.py
code served (permissive licence) · get_code("23804b0d6173123a")
How it ran

no invocation recorded.

DenseBlock Not yet run
unverified (harvested, no recorded run)
luciferkonn/dt_mem/src/model.py
code served (permissive licence) · get_code("88fdc33643df68a8")
How it ran

no invocation recorded.

GPT2 Not yet run
unverified (harvested, no recorded run)
luciferkonn/dt_mem/src/model.py
code served (permissive licence) · get_code("331bf757c4894bec")
How it ran

no invocation recorded.

count_parameters Not yet run
unverified (harvested, no recorded run)
luciferkonn/dt_mem/src/model.py
code served (permissive licence) · get_code("75bf37896d765771")
How it ran

no invocation recorded.

Also present in other papers' code

Of 12 samples lifted from this paper's linked repositories, 12 carry a function identity and 0 do not. Of the 12 distinct functions with an identity, 0 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 0 later) and 12 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-23.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

Decision Transformer-based decision-making agents have shown the ability to generalize across multiple tasks. However, their performance relies on massive data and computation. We argue that this inefficiency stems from the forgetting phenomenon, in which a model memorizes its behaviors in parameters throughout training. As a result, training on a new task may deteriorate the model's performance on previous tasks. In contrast to LLMs' implicit memory mechanism, the human brain utilizes distributed memory storage, which helps manage and organize multiple skills efficiently, mitigating the forgetting phenomenon. Inspired by this, we propose a working memory module to store, blend, and retrieve information for different downstream tasks. Evaluation results show that the proposed method improves training efficiency and generalization in Atari games and Meta-World object manipulation tasks. Moreover, we demonstrate that memory fine-tuning further enhances the adaptability of the proposed architecture. 1 Recently, with the tremendous success of decoder-only Transformer models (Brown et al., 2020; OpenAI, 2023;Dosovitskiy et al., 2021;Touvron et al., 2023), an increasing number of researchers have focused on decoder-only Transformer-based decision-making agents. As shown with GPT-3 (Brown et al., 2020) and follow-up work (Kaplan et al., 2020;Clark et al., 2022), the generalization of these LLMs depends significantly on the model size, i.e. the num-*Equal advising

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2305.16338")
get_code_for_paper("2305.16338")
have("2305.16338")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2305.16338.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2305.16338.svg)](https://syntology.ai/paper/2305.16338)

Connect an agent — have() is free.