SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2106.01561 · ACL · 2021

Can Generative Pre-trained Language Models Serve as Knowledge Bases for Closed-book QA?

Yue Zhang, Cunxiang Wang, Pai Liu

arXiv · PDF · Open in the Atlas

Code that ran

5 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 5 have no contract verdict; 0 failures of our instrument; 2 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/2106.01561.json · badge: /api/ran/2106.01561.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
wangcunxiang/Can-PLM-Serve-as-KB-for-CBQA canonical (classifier label)
classifier basis: census
5 ran · 2 no recorded run
FunctionStatusWhere it lives
encode Ran
ran on a synthesized input
wangcunxiang/Can-PLM-Serve-as-KB-for-CBQA/simpletransformers/language_modeling/language_modeling_utils.py
code served (permissive licence) · get_code("d34c8ab039bdf946")
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 int; 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 torch

class SimpleTokenizer:
    def encode(self, text):
        return [1, 2, 3]

tokenizer = SimpleTokenizer()
line = "hello world"

ARGS = {
    "data": (tokenizer, line)
}
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 list, ndim 1, dtype family int — 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
encode_sliding_window Ran
ran on a synthesized input
wangcunxiang/Can-PLM-Serve-as-KB-for-CBQA/simpletransformers/language_modeling/language_modeling_utils.py
code served (permissive licence) · get_code("1369dca3f5bbc52a")
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 2, dtype family int; 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 torch
import numpy as np

class MockTokenizer:
    def __init__(self):
        self.sep_token_id = 102
        self.cls_token_id = 101
        self.pad_token_id = 0
    
    def tokenize(self, text):
        # Simple tokenization: split by spaces and add some dummy tokens
        tokens = text.split()
        return tokens
    
    def convert_tokens_to_ids(self, tokens):
        # Simple conversion: map each token to a dummy ID
        return [hash(token) % 1000 for token in tokens]

tokenizer = MockTokenizer()
line = "hello world this is a test sentence for sliding window"
max_seq_length = 16
special_tokens_count = 2
stride = 0.5
no_padding = False

ARGS = {
    "data": (tokenizer, line, max_seq_length, special_tokens_count, stride, no_padding)
}
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 list, ndim 2, dtype family int — 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
load_s2t_t2s Ran
ran on a synthesized input
wangcunxiang/Can-PLM-Serve-as-KB-for-CBQA/evals/rank_cor-ques_in_train.py
code served (permissive licence) · get_code("bdda4461007294e1")
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 tempfile
import os

# Create temporary files with sample data
temp_dir = tempfile.mkdtemp()
f0_path = os.path.join(temp_dir, 'source.txt')
f1_path = os.path.join(temp_dir, 'target.txt')

# Write sample source data
with open(f0_path, 'w', encoding='utf8') as f:
    f.write('hello world\n')
    f.write('good morning\n')
    f.write('goodbye\n')

# Write sample target data (tab-separated translations)
with open(f1_path, 'w', encoding='utf8') as f:
    f.write('bonjour monde\thola mundo\n')
    f.write('buenos días\tbon matin\n')
    f.write('adiós\tao revoir\n')

ARGS = {
    'f0': f0_path,
    'f1': f1_path,
}
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 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
mask_tokens Ran
ran on a synthesized input
wangcunxiang/Can-PLM-Serve-as-KB-for-CBQA/simpletransformers/language_modeling/language_modeling_utils.py
code served (permissive licence) · get_code("e4a3df6f2b78aa86")
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, ndim 3, dtype family int; 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 torch
from transformers import PreTrainedTokenizer

torch.manual_seed(0)

class MockTokenizer(PreTrainedTokenizer):
    def __init__(self):
        self.vocab_size = 1000
        self.mask_token = "[MASK]"
        self.pad_token = "[PAD]"
        self.pad_token_id = 0
        self._pad_token = self.pad_token
        self.cls_token = "[CLS]"
        self.sep_token = "[SEP]"
        self.unk_token = "[UNK]"
        
    def get_special_tokens_mask(self, token_ids, already_has_special_tokens=False):
        # Return a mask indicating which tokens are special tokens
        # For simplicity, mark first and last as special
        mask = [0] * len(token_ids)
        if len(token_ids) > 0:
            mask[0] = 1
            if len(token_ids) > 1:
                mask[-1] = 1
        return mask
    
    def convert_tokens_to_ids(self, tokens):
        if isinstance(tokens, str):
            if tokens == self.mask_token:
                return 103
        return 1
    
    @property
    def vocab_size(self):
        return self._vocab_size
    
    @vocab_size.setter
    def vocab_size(self, value):
        self._vocab_size = value
    
    def __len__(self):
        return self._vocab_size

class MockArgs:
    def __init__(self):
        self.mlm_probability = 0.15
        self.model_type = 'bert'

tokenizer = MockTokenizer()
args = MockArgs()
inputs = torch.randint(100, 500, (2, 4), dtype=torch.long)

ARGS = {
    "inputs": inputs,
    "tokenizer": tokenizer,
    "args": args
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch, transformers — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 3, dtype family int — a tuple 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
tokenize Ran
ran on a synthesized input
wangcunxiang/Can-PLM-Serve-as-KB-for-CBQA/evals/rank_cor-ques_in_train.py
code served (permissive licence) · get_code("352a0a2908125997")
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)

# The function simply returns input, so we need to provide:
# 1. input: can be any value (string, tensor, list, etc.)
# 2. Tokenizer: a tokenizer object (not actually used in the function body)

# Create a minimal stand-in Tokenizer class
class SimpleTokenizer:
    def __init__(self):
        self.vocab_size = 100
    
    def encode(self, text):
        return [1, 2, 3]
    
    def decode(self, tokens):
        return "text"

# Create sample input
input_data = "hello world"
tokenizer = SimpleTokenizer()

ARGS = {
    "input": input_data,
    "Tokenizer": tokenizer
}
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
load_triplets Not yet run
unverified (harvested, no recorded run)
wangcunxiang/Can-PLM-Serve-as-KB-for-CBQA/evals/rank_cor-ques_in_train.py
code served (permissive licence) · get_code("48b450241c34c25e")
How it ran

no invocation recorded.

read_data_source_target Not yet run
unverified (harvested, no recorded run)
wangcunxiang/Can-PLM-Serve-as-KB-for-CBQA/data_reader/data_reader.py
code served (permissive licence) · get_code("1905d50393a33c6e")
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, 2 are also present in other papers whose code we hold (2 with at least one paper dated earlier, 0 the same month, 0 later) and 5 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
encode 1 other paper
1 dated earlier
2010.05324 (2020-10)
Multilingual Offensive Language Identification with Cross-lingual Embeddings
encode_sliding_window 1 other paper
1 dated earlier
2010.05324 (2020-10)
Multilingual Offensive Language Identification with Cross-lingual Embeddings

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

Recent work has investigated the interesting question using pre-trained language models (PLMs) as knowledge bases for answering open questions. However, existing work is limited in using small benchmarks with high test-train overlaps. We construct a new dataset of closed-book QA using SQuAD, and investigate the performance of BART. Experiments show that it is challenging for BART to remember training facts in high precision, and also challenging to answer closed-book questions even if relevant knowledge is retained. Some promising directions are found, including decoupling the knowledge memorizing process and the QA finetune process, forcing the model to recall relevant knowledge when question answering.

For agents

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

get_harvested_code_for_paper("2106.01561")
get_code_for_paper("2106.01561")
have("2106.01561")

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

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

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

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

Connect an agent — have() is free.