SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 1911.03705 · 2019

CommonGen: A Constrained Text Generation Challenge for Generative Commonsense Reasoning

arXiv · PDF · Open in the Atlas

Code that ran

5 of 6 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 5 have no contract verdict; 0 failures of our instrument; 1 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/1911.03705.json · badge: /api/ran/1911.03705.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
allenai/CommonGen-Eval canonical (classifier label)
classifier basis: census
5 ran · 1 no recorded run
FunctionStatusWhere it lives
clear_output Ran
ran on a synthesized input
allenai/CommonGen-Eval/data_utils.py
code served (permissive licence) · get_code("e00658a45cf979c4")
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

torch.manual_seed(0)

# Analyze the function:
# - output: a string that the function processes
# - model_name: a string that the function checks with .lower() and 'in' operator

# Test case 1: with llama-2-7b in model name and newlines in output
output_1 = "some initial text\n\nThis is the main content after double newline"
model_name_1 = "llama-2-7b"

# Test case 2: with llama-2-7b but no double newlines
output_2 = "some text without double newlines"
model_name_2 = "Llama-2-7B-chat"

# Test case 3: without llama in model name
output_3 = "any output text\n\nwith newlines"
model_name_3 = "gpt-3.5-turbo"

# Use first test case for ARGS
ARGS = {
    "output": output_1,
    "model_name": model_name_1
}
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
openai_chat_request Ran
ran on a synthesized input
allenai/CommonGen-Eval/eval_utils.py
code served (permissive licence) · get_code("a9d15e4437a4a672")
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 list, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim 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 openai
from unittest.mock import MagicMock, patch

# Mock the OpenAI API response
def mock_chat_completion_create(**kwargs):
    return {
        'choices': [
            {
                'finish_reason': 'stop',
                'message': {'content': 'This is a mock response from OpenAI.'}
            },
            {
                'finish_reason': 'length',
                'message': {'content': 'This is another mock response.'}
            }
        ]
    }

# Patch the openai.ChatCompletion.create method
openai.ChatCompletion.create = MagicMock(side_effect=mock_chat_completion_create)

ARGS = {
    'model': 'gpt-3.5-turbo',
    'engine': 'text-davinci-003',
    'temperature': 0.7,
    'max_tokens': 512,
    'top_p': 0.95,
    'frequency_penalty': 0.1,
    'presence_penalty': 0.2,
    'prompt': 'What is the capital of France?',
    'n': 2,
    'messages': None,
    'stop': ['\n', 'END']
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
openai — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 1, dtype family float — a list output has no array shape of its own; none is stated
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
parse_result Ran
ran on a synthesized input
allenai/CommonGen-Eval/evaluate.py
code served (permissive licence) · get_code("f8baf14dbe5cc687")
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

torch.manual_seed(0)

# The function parse_result takes a string and returns a classification
# It checks for specific keywords in the string (case-insensitive for 'neither' and 'tie')
# and returns the appropriate label

ARGS = {
    'result_str': 'The model chose A as the better response.'
}
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
retry_handler Ran
ran on a synthesized input
allenai/CommonGen-Eval/eval_utils.py
code served (permissive licence) · get_code("2a55bf45c6775c40")
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 sys
import time
from functools import wraps

# Minimal stand-in for openai.error classes
class RateLimitError(Exception):
    pass

class APIError(Exception):
    pass

# Create a mock openai module structure
class MockOpenAIError:
    RateLimitError = RateLimitError
    APIError = APIError

sys.modules['openai'] = type(sys)('openai')
sys.modules['openai'].error = MockOpenAIError()

# Now define the function
def retry_handler(retry_limit=10):
    """
        This is an error handler for requests to OpenAI API.
        If will retry for the request for `retry_limit` times if the error is not a rate limit error.
        Otherwise, it will wait for the time specified in the error message and constantly retry.
        You can add specific processing logic for different types of errors here.

        Args:
            retry_limit (int, optional): The number of times to retry. Defaults to 3.
        
        Usage:
            @retry_handler(retry_limit=3)
            def call_openai_api():
                pass
    """

    def decorate(func):

        @wraps(func)
        def wrapper(*args, **kwargs):
            retried = 0
            while True:
                try:
                    sys.stdout.flush()
                    return func(*args, **kwargs)
                except Exception as e:
                    if isinstance(e, RateLimitError):
                        words = str(e).split(' ')
                        try:
                            time_to_wait = int(words[words.index('after') + 1])
                        except ValueError:
                            time_to_wait = 5
                        time.sleep(time_to_wait)
                    elif isinstance(e, APIError):
                        print('API error:', str(e))
                        if 'Invalid' in str(e):
                            print('Invalid request, returning.')
                            raise e
                    else:
                        print(e.__class__.__name__ + ':', str(e))
                        if retried < retry_limit:
                            print(f'Retrying for the {retried + 1} time..')
                        else:
                            print('Retry limit reached. Saving the error message and returning.')
                            print(kwargs['prompt'])
                            raise e
                        retried += 1
        return wrapper
    return decorate

# Define test function that uses the decorator
@retry_handler(retry_limit=3)
def sample_api_call(prompt="test"):
    return "success"

# Construct ARGS dict
ARGS = {
    'retry_limit': 5
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
openai — 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
shorten Ran
ran on a synthesized input
allenai/CommonGen-Eval/evaluate.py
code served (permissive licence) · get_code("d257fb6875c46f6e")
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 numpy as np

torch.manual_seed(0)

# The function shorten(text, K=-1) takes text and an optional K parameter
# Based on the simple signature, we need to provide:
# - text: a string or text input
# - K: an integer parameter (default -1)

text = "This is a sample text that might be shortened"
K = 10

ARGS = {
    "text": text,
    "K": K
}
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 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
get_conv_template Not yet run
unverified (harvested, no recorded run)
allenai/CommonGen-Eval/fastchat_conversation.py
code served (permissive licence) · get_code("eefaa52fc92c8f55")
How it ran

no invocation recorded.

Also present in other papers' code

Of 6 samples lifted from this paper's linked repositories, 6 carry a function identity and 0 do not. Of the 6 distinct functions with an identity, 3 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 3 later) and 3 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
get_conv_template 69 other papers
68 later, 1 undated
2112.05682 (2021-12)
Self-attention Does Not Need $O(n^2)$ Memory
2204.07705 (2022-04)
SUPER-NATURALINSTRUCTIONS: Generalization via Declarative Instructions on 1600+ NLP Tasks
2302.13971 (2023-02)
LLaMA: Open and Efficient Foundation Language Models
and 66 more not named here
openai_chat_request 2 other papers
2 later
2305.17390 (2023-05)
SWIFTSAGE: A Generative Agent with Fast and Slow Thinking for Complex Interactive Tasks
2024.findings-emnlp.504 (2024 (year only))
How Far Can In-Context Alignment Go? Exploring the State of In-Context Alignment
retry_handler 2 other papers
2 later
2305.17390 (2023-05)
SWIFTSAGE: A Generative Agent with Fast and Slow Thinking for Complex Interactive Tasks
2024.findings-emnlp.504 (2024 (year only))
How Far Can In-Context Alignment Go? Exploring the State of In-Context Alignment

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

Recently, large-scale pre-trained language models have demonstrated impressive performance on several commonsense-reasoning benchmark datasets. However, building machines with commonsense to compose realistically plausible sentences remains challenging. In this paper, we present a constrained text generation task, CommonGen associated with a benchmark dataset, to explicitly test machines for the ability of generative commonsense reasoning. Given a set of common concepts (e.g., {dog, frisbee, catch, throw}); the task is to generate a coherent sentence describing an everyday scenario using these concepts (e.g., "a man throws a frisbee and his dog catches it"). The CommonGen task is challenging because it inherently requires 1) relational reasoning with background commonsense knowledge, and 2) compositional generalization ability to work on unseen concept combinations. Our dataset, constructed through a combination of crowdsourced and existing caption corpora, consists of 79k commonsense descriptions over 35k unique concept-sets. Experiments show that there is a large gap between state-of-the-art text generation models (e.g., T5) and human performance. Furthermore, we demonstrate that the learned generative commonsense reasoning capability can be transferred to improve downstream tasks such as CommonsenseQA by generating additional context.

For agents

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

get_harvested_code_for_paper("1911.03705")
get_code_for_paper("1911.03705")
have("1911.03705")

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

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

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

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

Connect an agent — have() is free.