SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2205.00274 · NAACL · 2022

Clues Before Answers: Generation-Enhanced Multiple-Choice QA

Yue Zhao, Yu Gu, Zixian Huang, Ao Wu, Gong Cheng, Jiaying Zhou

arXiv · PDF · Open in the Atlas

Code that ran

5 of 11 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; 1 honoured the contract we drafted, 0 violated it and 4 have no contract verdict; 0 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/2205.00274.json · badge: /api/ran/2205.00274.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
nju-websoft/GenMC community
Papers with Code archive
5 ran · 6 no recorded run
FunctionStatusWhere it lives
BertIntermediate Ran
ran on a synthesized input
nju-websoft/GenMC/model/modeling_genmc.py
code served (permissive licence) · get_code("9d9d13aefaa0121e")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned Tensor, ndim 2, dtype family float, shape (2, 3) 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 import nn
import math

def gelu(x):
    """Implementation of the gelu activation function.
        For information: OpenAI GPT's gelu is slightly diffretrievernt (and gives slightly diffretrievernt results):
        0.5 * x * (1 + torch.tanh(math.sqrt(2 / math.pi) * (x + 0.044715 * torch.pow(x, 3))))
    """
    return x * 0.5 * (1.0 + torch.erf(x / math.sqrt(2.0)))

def swish(x):
    return x * torch.sigmoid(x)

ACT2FN = {'gelu': gelu, 'relu': torch.nn.functional.relu, 'swish': swish}

class BertIntermediate(nn.Module):

    def __init__(self, config):
        super(BertIntermediate, self).__init__()
        self.dense = nn.Linear(config.hidden_size, config.intermediate_size)
        self.intermediate_act_fn = ACT2FN[config.hidden_act] if isinstance(config.hidden_act, str) else config.hidden_act

    def forward(self, hidden_states):
        hidden_states = self.dense(hidden_states)
        hidden_states = self.intermediate_act_fn(hidden_states)
        return hidden_states


class Config:
    def __init__(self, hidden_size, intermediate_size, hidden_act):
        self.hidden_size = hidden_size
        self.intermediate_size = intermediate_size
        self.hidden_act = hidden_act


INIT_ARGS = {
    'config': Config(hidden_size=4, intermediate_size=3, hidden_act='gelu')
}

ARGS = {
    'hidden_states': torch.randn(2, 4)
}
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
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, 3) — shape (2, 3) 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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
BertSelfAttention Ran
ran on a synthesized input
nju-websoft/GenMC/model/modeling_genmc.py
code served (permissive licence) · get_code("6a50fa25bd29286f")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) 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 torch
from torch import nn
import math

class BertSelfAttention(nn.Module):

    def __init__(self, config):
        super(BertSelfAttention, self).__init__()
        if config.hidden_size % config.num_attention_heads != 0:
            raise ValueError('The hidden size (%d) is not a multiple of the number of attention heads (%d)' % (config.hidden_size, config.num_attention_heads))
        self.num_attention_heads = config.num_attention_heads
        self.attention_head_size = int(config.hidden_size / config.num_attention_heads)
        self.all_head_size = self.num_attention_heads * self.attention_head_size
        self.query = nn.Linear(config.hidden_size, self.all_head_size)
        self.key = nn.Linear(config.hidden_size, self.all_head_size)
        self.value = nn.Linear(config.hidden_size, self.all_head_size)
        self.dropout = nn.Dropout(config.attention_probs_dropout_prob)

    def transpose_for_scores(self, x):
        new_x_shape = x.size()[:-1] + (self.num_attention_heads, self.attention_head_size)
        x = x.view(*new_x_shape)
        return x.permute(0, 2, 1, 3)

    def forward(self, hidden_states, attention_mask):
        mixed_query_layer = self.query(hidden_states)
        mixed_key_layer = self.key(hidden_states)
        mixed_value_layer = self.value(hidden_states)
        query_layer = self.transpose_for_scores(mixed_query_layer)
        key_layer = self.transpose_for_scores(mixed_key_layer)
        value_layer = self.transpose_for_scores(mixed_value_layer)
        attention_scores = torch.matmul(query_layer, key_layer.transpose(-1, -2))
        attention_scores = attention_scores / math.sqrt(self.attention_head_size)
        attention_scores = attention_scores + attention_mask
        attention_probs = nn.Softmax(dim=-1)(attention_scores)
        attention_softmax = attention_probs
        attention_probs = self.dropout(attention_probs)
        context_layer = torch.matmul(attention_probs, value_layer)
        context_layer = context_layer.permute(0, 2, 1, 3).contiguous()
        new_context_layer_shape = context_layer.size()[:-2] + (self.all_head_size,)
        context_layer = context_layer.view(*new_context_layer_shape)
        return (context_layer, attention_softmax)


class Config:
    def __init__(self, hidden_size, num_attention_heads, attention_probs_dropout_prob):
        self.hidden_size = hidden_size
        self.num_attention_heads = num_attention_heads
        self.attention_probs_dropout_prob = attention_probs_dropout_prob


INIT_ARGS = {
    'config': Config(hidden_size=8, num_attention_heads=2, attention_probs_dropout_prob=0.1)
}

ARGS = {
    'hidden_states': torch.randn(2, 3, 8),
    'attention_mask': torch.zeros(2, 2, 3, 3)
}

if __name__ == '__main__':
    model = BertSelfAttention(**INIT_ARGS)
    output = model(**ARGS)
    print("Output shapes:", output[0].shape, output[1].shape)
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
Imports
torch — 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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
DPDALayear Ran
ran on a synthesized input
nju-websoft/GenMC/model/modeling_genmc.py
code served (permissive licence) · get_code("c6411bfe6a205d2c")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) 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 torch
from torch import nn

class DPDALayear(nn.Module):

    def __init__(self, dim):
        super(DPDALayear, self).__init__()
        self.W_p = nn.Linear(2 * dim, dim)
        self.W_q = nn.Linear(2 * dim, dim)
        self.W_map = nn.Linear(dim, dim)

    def forward(self, P, Q, p_mask=None, q_mask=None):
        P_ori = P
        Q_ori = Q
        A = torch.matmul(P, Q.transpose(dim0=1, dim1=2))
        if p_mask is not None:
            p_mask = p_mask.float()
            p_mask = 1 - p_mask
            p_mask = p_mask * -10000.0
            p_mask = p_mask.unsqueeze(dim=2)
            p_mask = p_mask.expand_as(A)
            A = A + p_mask
            A = A.to(P.dtype)
        if q_mask is not None:
            q_mask = q_mask.float()
            q_mask = 1 - q_mask
            q_mask = q_mask * -10000.0
            q_mask = q_mask.unsqueeze(dim=1)
            q_mask = q_mask.expand_as(A)
            A = A + q_mask
            A = A.to(Q.dtype)
        p_weight, _ = torch.max(A, dim=2)
        q_weight, _ = torch.max(A, dim=1)
        A_q = torch.softmax(A, dim=2)
        A_p = torch.softmax(A.transpose(dim0=1, dim1=2), dim=2)
        P_q = torch.matmul(A_q, Q)
        Q_p = torch.matmul(A_p, P)
        P_t = torch.cat([P_q, P], dim=2)
        Q_t = torch.cat([Q_p, Q], dim=2)
        Q = torch.matmul(A_p, P_t)
        P = torch.matmul(A_q, Q_t)
        P = P_ori + self.W_p(P)
        layer_norm = nn.LayerNorm(normalized_shape=[P.size(-2), P.size(-1)], elementwise_affine=False)
        P = layer_norm(P)
        Q = Q_ori + self.W_q(Q)
        layer_norm = nn.LayerNorm(normalized_shape=[Q.size(-2), Q.size(-1)], elementwise_affine=False)
        Q = layer_norm(Q)
        return (P, Q, p_weight, q_weight)


INIT_ARGS = {
    'dim': 4
}

ARGS = {
    'P': torch.randn(2, 3, 4),
    'Q': torch.randn(2, 5, 4),
    'p_mask': None,
    'q_mask': None
}

if __name__ == '__main__':
    model = DPDALayear(**INIT_ARGS)
    output = model(**ARGS)
    print("Output shapes:")
    print(f"P shape: {output[0].shape}")
    print(f"Q shape: {output[1].shape}")
    print(f"p_weight shape: {output[2].shape}")
    print(f"q_weight shape: {output[3].shape}")
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
Imports
torch — 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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
SemanticMatch Ran
ran on a synthesized input
nju-websoft/GenMC/model/modeling_genmc.py
code served (permissive licence) · get_code("2b423e9207ab7b7e")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) 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 torch
from torch import nn
import copy

class DPDALayear(nn.Module):

    def __init__(self, dim):
        super(DPDALayear, self).__init__()
        self.W_p = nn.Linear(2 * dim, dim)
        self.W_q = nn.Linear(2 * dim, dim)
        self.W_map = nn.Linear(dim, dim)

    def forward(self, P, Q, p_mask=None, q_mask=None):
        P_ori = P
        Q_ori = Q
        A = torch.matmul(P, Q.transpose(dim0=1, dim1=2))
        if p_mask is not None:
            p_mask = p_mask.float()
            p_mask = 1 - p_mask
            p_mask = p_mask * -10000.0
            p_mask = p_mask.unsqueeze(dim=2)
            p_mask = p_mask.expand_as(A)
            A = A + p_mask
            A = A.to(P.dtype)
        if q_mask is not None:
            q_mask = q_mask.float()
            q_mask = 1 - q_mask
            q_mask = q_mask * -10000.0
            q_mask = q_mask.unsqueeze(dim=1)
            q_mask = q_mask.expand_as(A)
            A = A + q_mask
            A = A.to(Q.dtype)
        p_weight, _ = torch.max(A, dim=2)
        q_weight, _ = torch.max(A, dim=1)
        A_q = torch.softmax(A, dim=2)
        A_p = torch.softmax(A.transpose(dim0=1, dim1=2), dim=2)
        P_q = torch.matmul(A_q, Q)
        Q_p = torch.matmul(A_p, P)
        P_t = torch.cat([P_q, P], dim=2)
        Q_t = torch.cat([Q_p, Q], dim=2)
        Q = torch.matmul(A_p, P_t)
        P = torch.matmul(A_q, Q_t)
        P = P_ori + self.W_p(P)
        layer_norm = nn.LayerNorm(normalized_shape=[P.size(-2), P.size(-1)], elementwise_affine=False)
        P = layer_norm(P)
        Q = Q_ori + self.W_q(Q)
        layer_norm = nn.LayerNorm(normalized_shape=[Q.size(-2), Q.size(-1)], elementwise_affine=False)
        Q = layer_norm(Q)
        return (P, Q, p_weight, q_weight)

class SemanticMatch(nn.Module):

    def __init__(self, dim, layer_num):
        super(SemanticMatch, self).__init__()
        dpda_layer = DPDALayear(dim)
        self.q_o = nn.ModuleList([copy.deepcopy(dpda_layer) for _ in range(layer_num)])
        self.linear = nn.Linear(2 * dim, dim)
        self.relu = nn.ReLU()
        self.tanh = nn.Tanh()

    def forward(self, q, o, mask_q, mask_o):
        for layer_module in self.q_o:
            q, o, q_weight, o_weight = layer_module(q, o, mask_q, mask_o)
        q, _ = torch.max(q, dim=1)
        o, _ = torch.max(o, dim=1)
        q_o = self.get_vector(q, o)
        return (q_o, q_weight, o_weight)

    def get_vector(self, v1, v2):
        p_b = torch.cat([v1, v2], dim=1)
        p_b = self.linear(p_b)
        p_b = self.relu(p_b)
        return p_b


INIT_ARGS = {
    'dim': 4,
    'layer_num': 2,
}

ARGS = {
    'q': torch.randn(2, 3, 4),
    'o': torch.randn(2, 5, 4),
    'mask_q': torch.zeros(2, 3, dtype=torch.long),
    'mask_o': torch.zeros(2, 5, dtype=torch.long),
}

if __name__ == '__main__':
    model = SemanticMatch(**INIT_ARGS)
    output = model(**ARGS)
    print("Output shapes:")
    print(f"  q_o: {output[0].shape}")
    print(f"  q_weight: {output[1].shape}")
    print(f"  o_weight: {output[2].shape}")
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
Imports
torch — 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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
gelu Ran
ran, honoured the contract we drafted
nju-websoft/GenMC/model/modeling_genmc.py
code served (permissive licence) · get_code("a8eafe3c0d1e9892")
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) 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 math

torch.manual_seed(0)

# The gelu function takes a single parameter 'x' which should be a tensor
# The function applies element-wise operations: multiplication, addition, torch.erf, division
# So x should be a torch.Tensor

x = torch.randn(2, 4)

ARGS = {
    "x": x
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
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
BertAttention Not yet run
unverified (harvested, no recorded run)
nju-websoft/GenMC/model/modeling_genmc.py
code served (permissive licence) · get_code("7ccd797d6076b7bf")
How it ran

no invocation recorded.

BertEncoder Not yet run
unverified (harvested, no recorded run)
nju-websoft/GenMC/model/modeling_genmc.py
code served (permissive licence) · get_code("f2960095c4691870")
How it ran

no invocation recorded.

BertLayer Not yet run
unverified (harvested, no recorded run)
nju-websoft/GenMC/model/modeling_genmc.py
code served (permissive licence) · get_code("a9386d3eabfcc480")
How it ran

no invocation recorded.

Config Not yet run
unverified (harvested, no recorded run)
nju-websoft/GenMC/model/modeling_genmc.py
code served (permissive licence) · get_code("02ba0bdc7fc80e5a")
How it ran

no invocation recorded.

GenMC Not yet run
unverified (harvested, no recorded run)
nju-websoft/GenMC/model/modeling_genmc.py
code served (permissive licence) · get_code("aff1ad254055ad43")
How it ran

no invocation recorded.

MyTransformer Not yet run
unverified (harvested, no recorded run)
nju-websoft/GenMC/model/modeling_genmc.py
code served (permissive licence) · get_code("01622174ba8738f7")
How it ran

no invocation recorded.

Also present in other papers' code

Of 11 samples lifted from this paper's linked repositories, 11 carry a function identity and 0 do not. Of the 11 distinct functions with an identity, 4 are also present in other papers whose code we hold (4 with at least one paper dated earlier, 1 the same month, 2 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
gelu
brick of this paper's assembly: helper
198 other papers
113 dated earlier, 1 the same month, 80 later, 4 same year, order not determinable · 32 only as an assembly brick
1408.5882 (2014-08)
Convolutional Neural Networks for Sentence Classification
1810.04805 (2018-10)
BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding
1901.10125 (2019-01)
Glyce: Glyph-vectors for Chinese Character Representations
and 195 more not named here
BertIntermediate
brick of this paper's assembly: model
5 other papers
4 dated earlier, 1 later · 2 only as an assembly brick
1810.04805 (2018-10)
BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding
2004.13278 (2020-04)
VD-BERT: A Unified Vision and Dialog Transformer with BERT
2010.08210 (2020-10)
Coarse-to-Fine Pre-training for Named Entity Recognition
and 2 more not named here
BertAttention
brick of this paper's assembly: model
1 other paper
1 dated earlier
1908.02265 (2019-08)
ViLBERT: Pretraining Task-Agnostic Visiolinguistic Representations for Vision-and-Language Tasks
BertLayer
brick of this paper's assembly: model
1 other paper
1 dated earlier
1908.02265 (2019-08)
ViLBERT: Pretraining Task-Agnostic Visiolinguistic Representations for Vision-and-Language Tasks

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

A trending paradigm for multiple-choice question answering (MCQA) is using a text-to-text framework. By unifying data in different tasks into a single text-to-text format, it trains a generative encoder-decoder model which is both powerful and universal. However, a side effect of twisting a generation target to fit the classification nature of MCQA is the underutilization of the decoder and the knowledge that can be decoded. To exploit the generation capability and underlying knowledge of a pre-trained encoder-decoder model, in this paper, we propose a generation-enhanced MCQA model named GenMC. It generates a clue from the question and then leverages the clue to enhance a reader for MCQA. It outperforms textto-text models on multiple MCQA datasets.

For agents

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

get_harvested_code_for_paper("2205.00274")
get_code_for_paper("2205.00274")
have("2205.00274")

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

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

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

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

Connect an agent — have() is free.