SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2010.03790 · 2020

Text-based RL Agents with Commonsense Knowledge: New Challenges, Environments and Baselines

arXiv · PDF · Open in the Atlas

Code that ran

11 of 13 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 11 have no contract verdict; 0 failures of our instrument; 2 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/2010.03790.json · badge: /api/ran/2010.03790.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
IBM/commonsense-rl canonical (classifier label)
classifier basis: census
11 ran · 2 no recorded run
FunctionStatusWhere it lives
add_triplets_to_graph Ran
ran on a synthesized input
IBM/commonsense-rl/utils/kg.py
code served (permissive licence) · get_code("58c721ed14e522fa")
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 tuple. 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 networkx as nx

# Create a small graph
graph = nx.DiGraph()

# Add some initial nodes with data
graph.add_node("entity_a", data="entity_a")
graph.add_node("entity_b", data="entity_b")

# Create triplets (entity1, entity2, relation)
triplets = [
    ["Entity_A", "Entity_B", "knows"],
    ["Entity_C", "Entity_D", "located_in"],
    ["entity_a", "entity_e", "works_with"],
]

ARGS = {
    "graph": graph,
    "triplets": triplets,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
networkx — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple — a tuple output has no array shape of its own; none is 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
build_padding Ran
ran on a synthesized input
IBM/commonsense-rl/utils/generic.py
code served (permissive licence) · get_code("07103f48313c8a22")
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 ndarray, ndim 1, dtype family float, shape (5,) 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 numpy as np

# Test case 1: padding='random', size=5
ARGS = {
    'padding': 'random',
    'size': 5
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ndarray, ndim 1, dtype family float, shape (5,) — shape (5,) 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
construct_graph Ran
ran on a synthesized input
IBM/commonsense-rl/utils/kg.py
code served (permissive licence) · get_code("a8fb47a8145651ed")
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 tuple. 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 networkx as nx

ARGS = {
    'triplets': [
        ['Entity1', 'Entity2', 'RelationType1'],
        ['Entity2', 'Entity3', 'RelationType2'],
        ['Entity1', 'Entity3', 'RelationType1'],
        ['ENTITY4', '  Entity5  ', '  RELATION3  ']
    ]
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
networkx — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple — a tuple output has no array shape of its own; none is 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
emb_layer Ran
ran on a synthesized input
IBM/commonsense-rl/models.py
code served (permissive licence) · get_code("88d7a924e63c4345")
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 Embedding. 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

torch.manual_seed(0)

# Create a mock gensim KeyedVectors-like object
class MockKeyedVectors:
    def __init__(self, vectors):
        self.vectors = vectors

# Create small embedding vectors: 5 vocabulary items, 4 dimensions each
embedding_vectors = torch.randn(5, 4).numpy()

# Construct the keyed_vectors argument
keyed_vectors = MockKeyedVectors(embedding_vectors)

# Define ARGS dict with all parameters
ARGS = {
    "keyed_vectors": keyed_vectors,
    "trainable": 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 Embedding — a Embedding output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Embedding 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
getUniqueFileHandler Ran
ran on a synthesized input
IBM/commonsense-rl/utils/generic.py
code served (permissive licence) · get_code("fd2df73b8fd45096")
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 BufferedWriter. 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 io
import os
import tempfile

# Create a temporary directory for testing
temp_dir = tempfile.mkdtemp()
results_filename = os.path.join(temp_dir, 'test_results')

ARGS = {
    'results_filename': results_filename,
    'ext': '.pkl',
    'mode': 'wb'
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type BufferedWriter — a BufferedWriter output has no array shape of its own; none is 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
get_extractor Ran
ran on a synthesized input
IBM/commonsense-rl/utils/extractor.py
code served (permissive licence) · get_code("b95c5d577a7e53d2")
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 function. 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 string
from nltk import ngrams, word_tokenize

translator = str.maketrans('', '', string.punctuation)

def tokenize(text: str):
    return word_tokenize(text.lower().translate(translator).strip())

def is_substring(text: str, elements: set) -> bool:
    for element in elements:
        if text in element:
            return True
    return False

def max_substring_extraction(text: str, entities: set, ngram: int=3, stopwords: set=None) -> set:
    candidates = set()
    for N in range(ngram, 0, -1):
        for tokens in ngrams(tokenize(text), N):
            entity = '_'.join(tokens)
            if entity in entities:
                if stopwords and entity in stopwords.words() or is_substring(entity, candidates):
                    continue
                candidates.add(entity)
    return candidates

def any_substring_extraction(text: str, entities: set, ngram: int=3, stopwords: set=None) -> set:
    candidates = set()
    for N in range(ngram, 0, -1):
        for tokens in ngrams(tokenize(text), N):
            entity = '_'.join(tokens)
            if entity in entities:
                if stopwords and entity in stopwords:
                    continue
                candidates.add(entity)
    return candidates

def get_extractor(token_extractor_type: str):
    if token_extractor_type == 'any':
        return any_substring_extraction
    return max_substring_extraction

ARGS = {
    'token_extractor_type': 'any'
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
nltk — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type function — a function output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a function 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
illegal_locations Ran
ran on a synthesized input
IBM/commonsense-rl/game_generation/twc_make_game.py
code served (permissive licence) · get_code("27cc7170e9ece2ec")
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 set. 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.

# Setup code for illegal_locations function

ARGS = {
    'obj': {
        'locations': ['wardrobe', 'bed'],
        'category': 'clothing',
        'name': 'clean shirt'
    }
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type set — a set output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a set 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
is_substring Ran
ran on a synthesized input
IBM/commonsense-rl/utils/extractor.py
code served (permissive licence) · get_code("f9e37121fb751fdb")
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 bool, 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)

ARGS = {
    "text": "hello",
    "elements": {"hello world", "goodbye", "hello there"}
}
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 bool, 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
load_json Ran
ran on a synthesized input
IBM/commonsense-rl/game_generation/twc_data.py
code served (permissive licence) · get_code("066e4dbaa7dc5bcd")
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 json
import tempfile
import os

# Create a temporary JSON file with valid content
temp_dir = tempfile.mkdtemp()
temp_file = os.path.join(temp_dir, "test.json")

test_data = {
    "key1": "value1",
    "key2": [1, 2, 3],
    "key3": {"nested": "object"}
}

with open(temp_file, 'w') as f:
    json.dump(test_data, f)

ARGS = {
    "path": temp_file
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — 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
prettify_config Ran
ran on a synthesized input
IBM/commonsense-rl/game_generation/twc_make_game.py
code served (permissive licence) · get_code("42013e4fee0d53d4")
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 str. 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 MockConfig:
    def __init__(self):
        self.objects = True
        self.take = True
        self.rooms = False
        self.open = "value1"
        self.distractors = False
        self.drop = True
        self.isolated_rooms = "value2"
        self.train = False
        self.test = True

config = MockConfig()

ARGS = {
    'config': config
}
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 str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str 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
shortest_path_subgraph Ran
ran on a synthesized input
IBM/commonsense-rl/utils/kg.py
code served (permissive licence) · get_code("844e853beb7ba89f")
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 DiGraph. 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 networkx as nx

# Build a knowledge graph (kg_graph)
kg_graph = nx.DiGraph()
kg_graph.add_nodes_from(['apple', 'kitchen', 'table', 'fruit', 'red', 'food'])
kg_graph.add_edges_from([
    ('apple', 'fruit', {'relation': 'isA'}),
    ('apple', 'food', {'relation': 'isA'}),
    ('apple', 'red', {'relation': 'hasColor'}),
    ('fruit', 'food', {'relation': 'isA'}),
    ('kitchen', 'table', {'relation': 'contains'}),
    ('apple', 'kitchen', {'relation': 'locatedIn'}),
])

# Build a previous graph (prev_graph)
prev_graph = nx.DiGraph()
prev_graph.add_nodes_from(['apple', 'kitchen'])
prev_graph.add_edge('apple', 'kitchen', relation='at')

# Define nodes to include in subgraph
nodes = ['fruit', 'food']

# Define inventory_entities (items the agent has)
inventory_entities = ['apple']

# Define command_entities (items mentioned in the command)
command_entities = ['food', 'kitchen']

# Define path_len
path_len = 2

# Define add_all_path
add_all_path = False

ARGS = {
    'kg_graph': kg_graph,
    'prev_graph': prev_graph,
    'nodes': nodes,
    'inventory_entities': inventory_entities,
    'command_entities': command_entities,
    'path_len': path_len,
    'add_all_path': add_all_path,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
networkx — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type DiGraph — a DiGraph output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a DiGraph output the recorded ndim 1 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
make_batch Not yet run
unverified (harvested, no recorded run)
IBM/commonsense-rl/games/dataset.py
code served (permissive licence) · get_code("d6f593cf555a535b")
How it ran

no invocation recorded.

tokenize Not yet run
unverified (harvested, no recorded run)
IBM/commonsense-rl/utils/extractor.py
code served (permissive licence) · get_code("250f091f8f3d5d75")
How it ran

no invocation recorded.

Also present in other papers' code

Of 13 samples lifted from this paper's linked repositories, 13 carry a function identity and 0 do not. Of the 13 distinct functions with an identity, 1 are also present in other papers whose code we hold (1 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.

FunctionAlso present inEarliest-datedOthers named
load_json 1 other paper
1 dated earlier
1805.07594 (2018-05)
Generalizing Point Embeddings using the Wasserstein Space of Elliptical Distributions

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

Text-based games have emerged as an important test-bed for Reinforcement Learning (RL) research, requiring RL agents to combine grounded language understanding with sequential decision making. In this paper, we examine the problem of infusing RL agents with commonsense knowledge. Such knowledge would allow agents to efficiently act in the world by pruning out implausible actions, and to perform look-ahead planning to determine how current actions might affect future world states. We design a new text-based gaming environment called TextWorld Commonsense (TWC) for training and evaluating RL agents with a specific kind of commonsense knowledge about objects, their attributes, and affordances. We also introduce several baseline RL agents which track the sequential context and dynamically retrieve the relevant commonsense knowledge from ConceptNet. We show that agents which incorporate commonsense knowledge in TWC perform better, while acting more efficiently. We conduct user-studies to estimate human performance on TWC and show that there is ample room for future improvement.

For agents

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

get_harvested_code_for_paper("2010.03790")
get_code_for_paper("2010.03790")
have("2010.03790")

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

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

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

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

Connect an agent — have() is free.