SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2210.03078 · EMNLP · 2022

RAINIER: Reinforced Knowledge Introspector for Commonsense Question Answering

Yejin Choi, Hannaneh Hajishirzi, Sean Welleck, Ximing Lu, Jiacheng Liu, Pengfei He, Skyler Hallinan

arXiv · PDF · Open in the Atlas

Code that ran

7 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; 4 honoured the contract we drafted, 0 violated it and 0 have no contract verdict; 3 failures of our instrument; 6 no recorded run), measured 2026-11-22; 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/2210.03078.json · badge: /api/ran/2210.03078.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
liujch1998/rainier marked official in Papers with Code
Papers with Code archive
7 ran · 6 no recorded run
FunctionStatusWhere it lives
clamp Ran
ran, honoured the contract we drafted
liujch1998/rainier/rainier/ppo.py
code served (permissive licence) · get_code("37a3441d06cf812e")
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 float, 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)

# Construct valid arguments for the clamp function
value = torch.randn(2, 4)
min_value = torch.tensor(-1.0)
max_value = torch.tensor(1.0)

ARGS = {
    "value": value,
    "min_value": min_value,
    "max_value": max_value,
}
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 float, 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
logits_to_entropy Ran
ran, honoured the contract we drafted
liujch1998/rainier/rainier/ppo.py
code served (permissive licence) · get_code("601afc113e2c5295")
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 1, dtype family float, shape (2,) 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)

# The function logits_to_entropy takes logits and computes entropy
# by creating a Categorical distribution and calling entropy() on it.
# logits should be a tensor suitable for torch.distributions.Categorical

# Create logits: shape (batch_size, num_classes)
# batch_size=2, num_classes=4
logits = torch.randn(2, 4)

ARGS = {
    "logits": logits
}
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 1, dtype family float, shape (2,) — shape (2,) 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
mask_pad Ran
ran, honoured the contract we drafted
liujch1998/rainier/rainier/ppo.py
code served (permissive licence) · get_code("a9c6a287d240022c")
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 float, 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
import numpy as np

torch.manual_seed(0)

# The function mask_pad takes:
# - value: a tensor that gets multiplied by mask
# - mask: a binary mask tensor (0s and 1s)
# - pad_value: optional padding value (defaults to NEGATIVE_INF)

# Create a small value tensor (batch=2, features=4)
value = torch.randn(2, 4)

# Create a mask tensor with same shape (0s and 1s)
mask = torch.tensor([[1.0, 1.0, 0.0, 1.0],
                      [1.0, 0.0, 1.0, 0.0]])

# Optional pad_value parameter
pad_value = -100.0

ARGS = {
    "value": value,
    "mask": mask,
    "pad_value": pad_value
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, 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 float, 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
reduce_mean Ran
ran; our contract draft was wrong, not the code
liujch1998/rainier/rainier/ppo.py
code served (permissive licence) · get_code("e5bacba887a721ef")
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 test tensors
value = torch.randn(2, 4)  # batch_size=2, dim=4
mask = torch.ones(2, 4)    # same shape as value

# Test with axis=None
ARGS = {
    "value": value,
    "mask": mask,
    "axis": 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 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
reduce_std Ran
ran, honoured the contract we drafted
liujch1998/rainier/rainier/ppo.py
code served (permissive licence) · get_code("24a6def7a7175be1")
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 reduce_std function
# value: tensor of values to compute statistics on
# mask: binary mask to select which values to include

value = torch.randn(2, 4)  # shape (2, 4)
mask = torch.ones(2, 4)    # shape (2, 4), all ones to include all values

ARGS = {
    "value": value,
    "mask": mask,
}
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
reduce_sum Ran
ran; our contract draft was wrong, not the code
liujch1998/rainier/rainier/ppo.py
code served (permissive licence) · get_code("5874b0a8910897fd")
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 testing
value = torch.randn(2, 4)  # Shape (2, 4)
mask = torch.randint(0, 2, (2, 4)).float()  # Shape (2, 4), binary mask as floats

ARGS = {
    "value": value,
    "mask": mask,
    "axis": 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 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
whiten Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
liujch1998/rainier/rainier/ppo.py
code served (permissive licence) · get_code("f22da26515d11255")
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 float, 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 small tensors for testing
# values: the main tensor to whiten
# masks: binary mask tensor with same shape as values
values = torch.randn(2, 4)
masks = torch.ones(2, 4)

# Create ARGS dict with all parameters of whiten function
ARGS = {
    "values": values,
    "masks": masks,
    "shift_mean": True
}
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 float, 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
PPOTrainer Not yet run
unverified (harvested, no recorded run)
liujch1998/rainier/rainier/ppo.py
code served (permissive licence) · get_code("702f0dd46130de79")
How it ran

no invocation recorded.

Policy Not yet run
unverified (harvested, no recorded run)
liujch1998/rainier/rainier/ppo.py
code served (permissive licence) · get_code("af8e5334f66e1240")
How it ran

no invocation recorded.

Reward Not yet run
unverified (harvested, no recorded run)
liujch1998/rainier/rainier/ppo.py
code served (permissive licence) · get_code("8e4768065a6e2e46")
How it ran

no invocation recorded.

T5ForConditionalGenerationAndTokenRegression Not yet run
unverified (harvested, no recorded run)
liujch1998/rainier/rainier/ppo.py
code served (permissive licence) · get_code("793d7e2a816c5031")
How it ran

no invocation recorded.

T5ForTokenRegression Not yet run
unverified (harvested, no recorded run)
liujch1998/rainier/rainier/ppo.py
code served (permissive licence) · get_code("1fa7b1b16bcc201e")
How it ran

no invocation recorded.

Value Not yet run
unverified (harvested, no recorded run)
liujch1998/rainier/rainier/ppo.py
code served (permissive licence) · get_code("d77834c9fb30a1e7")
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, 6 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 6 later) and 7 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
reduce_mean
brick of this paper's assembly: helper
7 other papers
7 later · 3 only as an assembly brick
2212.10409 (2022-12)
ClarifyDelphi: Reinforced Clarification Questions with Defeasibility Rewards for Social and Moral Situations
2305.13829 (2023-05)
Learning from Mistakes via Cooperative Study Assistant for Large Language Models
2305.18290 (2023-05)
Direct Preference Optimization: Your Language Model is Secretly a Reward Model
and 4 more not named here
reduce_sum
brick of this paper's assembly: helper
7 other papers
7 later · 3 only as an assembly brick
2212.10409 (2022-12)
ClarifyDelphi: Reinforced Clarification Questions with Defeasibility Rewards for Social and Moral Situations
2305.13829 (2023-05)
Learning from Mistakes via Cooperative Study Assistant for Large Language Models
2305.18290 (2023-05)
Direct Preference Optimization: Your Language Model is Secretly a Reward Model
and 4 more not named here
reduce_std
brick of this paper's assembly: helper
5 other papers
5 later · 1 only as an assembly brick
2212.10409 (2022-12)
ClarifyDelphi: Reinforced Clarification Questions with Defeasibility Rewards for Social and Moral Situations
2305.13829 (2023-05)
Learning from Mistakes via Cooperative Study Assistant for Large Language Models
2306.01693 (2023-06)
Fine-Grained Human Feedback Gives Better Rewards for Language Model Training
and 2 more not named here
logits_to_entropy
brick of this paper's assembly: helper
3 other papers
3 later · 3 only as an assembly brick
2305.15065 (2023-05)
Inference-Time Policy Adapters (IPA): Tailoring Extreme-Scale LMs without Fine-tuning
2305.18290 (2023-05)
Direct Preference Optimization: Your Language Model is Secretly a Reward Model
2407.16970 (2024-07)
Towards Aligning Language Models with Textual Feedback
mask_pad
brick of this paper's assembly: helper
2 other papers
2 later · 2 only as an assembly brick
2305.18290 (2023-05)
Direct Preference Optimization: Your Language Model is Secretly a Reward Model
2407.16970 (2024-07)
Towards Aligning Language Models with Textual Feedback
clamp
brick of this paper's assembly: helper
1 other paper
1 later · 1 only as an assembly brick
2306.01693 (2023-06)
Fine-Grained Human Feedback Gives Better Rewards for Language Model Training

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-22.

Repositories linked to this paper

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

Abstract

Knowledge underpins reasoning. Recent research demonstrates that when relevant knowledge is provided as additional context to commonsense question answering (QA), it can substantially enhance the performance even on top of state-of-the-art. The fundamental challenge is where and how to find such knowledge that is high quality and on point with respect to the question; knowledge retrieved from knowledge bases are incomplete and knowledge generated from language models are inconsistent. We present RAINIER 1 , or Reinforced Knowledge Introspector, that learns to generate contextually relevant knowledge in response to given questions. Our approach starts by imitating knowledge generated by GPT-3, then learns to generate its own knowledge via reinforcement learning where rewards are shaped based on the increased performance on the resulting question answering. RAINIER demonstrates substantial and consistent performance gains when tested over 9 different commonsense benchmarks: including 5 datasets that are seen during model training, as well as 4 datasets that are kept unseen. Our work is the first to report that knowledge generated by models that are orders of magnitude smaller than GPT-3, even without direct supervision on the knowledge itself, can exceed the quality of commonsense knowledge elicited from GPT-3.

For agents

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

get_harvested_code_for_paper("2210.03078")
get_code_for_paper("2210.03078")
have("2210.03078")

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

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

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

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

Connect an agent — have() is free.