SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2306.00323 · NeurIPS · 2023

Thought Cloning: Learning to Think while Acting by Imitating Human Thinking

Jeff Clune, Shengran Hu

arXiv · PDF · Open in the Atlas

Code that ran

3 of 7 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 3 have no contract verdict; 0 failures of our instrument; 4 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/2306.00323.json · badge: /api/ran/2306.00323.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
ShengranHu/Thought-Cloning canonical (classifier label)
classifier basis: census
3 ran · 4 no recorded run
FunctionStatusWhere it lives
evaluate Ran
ran on a synthesized input
ShengranHu/Thought-Cloning/babyai/evaluate.py
code served (permissive licence) · get_code("5ddbfe9ab59cd4a4")
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 dict. 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


class SimpleAgent:
    def __init__(self):
        self.model = SimpleModel()
        self.last_reward = 0
        self.last_done = False
    
    def on_reset(self):
        pass
    
    def act(self, obs):
        # Returns dict with 'action' key
        return {'action': 0}
    
    def analyze_feedback(self, reward, done):
        self.last_reward = reward
        self.last_done = done


class SimpleModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 2)
    
    def forward(self, x):
        return self.linear(x)


class SimpleEnv:
    def __init__(self):
        self.step_count = 0
        self.max_steps = 3
    
    def reset(self):
        self.step_count = 0
        return torch.randn(4)
    
    def step(self, action):
        self.step_count += 1
        obs = torch.randn(4)
        reward = 1.0
        done = self.step_count >= self.max_steps
        info = {}
        return obs, reward, done, info


torch.manual_seed(0)

agent = SimpleAgent()
env = SimpleEnv()
episodes = 2
model_agent = True
offsets = None

ARGS = {
    'agent': agent,
    'env': env,
    'episodes': episodes,
    'model_agent': model_agent,
    'offsets': offsets
}
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 dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict 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
evaluate_demo_agent Ran
ran on a synthesized input
ShengranHu/Thought-Cloning/babyai/evaluate.py
code served (permissive licence) · get_code("3a317898c18a2a4e")
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 dict. 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

torch.manual_seed(0)

class DemoAgent:
    def __init__(self, demos):
        self.demos = demos

# Create mock demos - each demo is a list of frames
demo_1 = [torch.randn(4) for _ in range(5)]
demo_2 = [torch.randn(4) for _ in range(3)]
demo_3 = [torch.randn(4) for _ in range(7)]

agent = DemoAgent(demos=[demo_1, demo_2, demo_3])

ARGS = {
    'agent': agent,
    'episodes': 2
}
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 dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict 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
maskedNll Ran
ran on a synthesized input
ShengranHu/Thought-Cloning/babyai/submodules.py
code served (permissive licence) · get_code("bb2e81ff7543e52a")
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
from torch.autograd import Variable

torch.manual_seed(0)

# seq: a tensor of shape (batch_size, seq_len, vocab_size) containing log probabilities
# The function uses torch.gather(seq, 2, target.unsqueeze(2)) so seq must be 3D
# with dimension 2 being the vocabulary dimension
batch_size = 2
seq_len = 5
vocab_size = 4

# Create seq as log probabilities - shape (batch_size, seq_len, vocab_size)
seq_data = torch.randn(batch_size, seq_len, vocab_size)
seq = Variable(seq_data, requires_grad=True)

# gtSeq: ground truth sequence with START and END tokens
# Shape should be (batch_size, seq_len) with START token at beginning
# The function does gtSeq.data.new() so it needs to be a tensor/Variable
# gtSeq has START token at position 0, then words, then END token, then padding
# Valid tokens are > 0, padding is 0
gtSeq_data = torch.tensor([
    [1, 2, 3, 1, 0],  # START(1), W1(2), W2(3), END(1), PAD(0)
    [1, 2, 1, 0, 0],  # START(1), W1(2), END(1), PAD(0), PAD(0)
], dtype=torch.long)
gtSeq = Variable(gtSeq_data)

# returnScores: boolean flag
returnScores = False

ARGS = {
    'seq': seq,
    'gtSeq': gtSeq,
    'returnScores': returnScores,
}
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
get_model_dir Not yet run
unverified (harvested, no recorded run)
ShengranHu/Thought-Cloning/babyai/utils/model.py
code served (permissive licence) · get_code("2cbc87bf930aff09")
How it ran

no invocation recorded.

get_model_path Not yet run
unverified (harvested, no recorded run)
ShengranHu/Thought-Cloning/babyai/utils/model.py
code served (permissive licence) · get_code("5e7bbe8728391df2")
How it ran

no invocation recorded.

load_model Not yet run
unverified (harvested, no recorded run)
ShengranHu/Thought-Cloning/babyai/utils/model.py
code served (permissive licence) · get_code("63cced98b78ed47a")
How it ran

no invocation recorded.

manhattan_distance Not yet run
unverified (harvested, no recorded run)
ShengranHu/Thought-Cloning/babyai/bot.py
code served (permissive licence) · get_code("c1ffbae9fb9c6fc2")
How it ran

no invocation recorded.

Also present in other papers' code

Of 7 samples lifted from this paper's linked repositories, 7 carry a function identity and 0 do not. Of the 7 distinct functions with an identity, 5 are also present in other papers whose code we hold (5 with at least one paper dated earlier, 0 the same month, 0 later) and 2 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.

FunctionAlso present inEarliest-datedOthers named
evaluate 2 other papers
2 dated earlier
1810.08272 (2018-10)
BabyAI: A Platform to Study the Sample Efficiency of Grounded Language Learning
evaluate_demo_agent 2 other papers
2 dated earlier
1810.08272 (2018-10)
BabyAI: A Platform to Study the Sample Efficiency of Grounded Language Learning
get_model_path 2 other papers
2 dated earlier
1810.08272 (2018-10)
BabyAI: A Platform to Study the Sample Efficiency of Grounded Language Learning
manhattan_distance 2 other papers
2 dated earlier
1810.08272 (2018-10)
BabyAI: A Platform to Study the Sample Efficiency of Grounded Language Learning
load_model 1 other paper
1 dated earlier
2007.12770 (2020-07)
BabyAI 1.1

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

Language is often considered a key aspect of human thinking, providing us with exceptional abilities to generalize, explore, plan, replan, and adapt to new situations. However, Reinforcement Learning (RL) agents are far from human-level performance in any of these abilities. We hypothesize one reason for such cognitive deficiencies is that they lack the benefits of thinking in language and that we can improve AI agents by training them to think like humans do. We introduce a novel Imitation Learning framework, Thought Cloning, where the idea is to not just clone the behaviors of human demonstrators, but also the thoughts humans have as they perform these behaviors. While we expect Thought Cloning to truly shine at scale on internet-sized datasets of humans thinking out loud while acting (e.g. online videos with transcripts), here we conduct experiments in a domain where the thinking and action data are synthetically generated. Results reveal that Thought Cloning learns much faster than Behavioral Cloning and its performance advantage grows the further out of distribution test tasks are, highlighting its ability to better handle novel situations. Thought Cloning also provides important benefits for AI Safety and Interpretability, and makes it easier to debug and improve AI. Because we can observe the agent's thoughts, we can (1) more easily diagnose why things are going wrong, making it easier to fix the problem, (2) steer the agent by correcting its thinking, or (3) prevent it from doing unsafe things it plans to do. Overall, by training agents how to think as well as behave, Thought Cloning creates safer, more powerful agents. 1

For agents

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

get_harvested_code_for_paper("2306.00323")
get_code_for_paper("2306.00323")
have("2306.00323")

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

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

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

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

Connect an agent — have() is free.