SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2108.13934 · EMNLP · 2021

Robust Retrieval Augmented Generation for Zero-shot Slot Filling

Gaetano Rossiello, Michael Glass, Alfio Gliozzo, Md Faisal, Mahbub Chowdhury

arXiv · PDF · Open in the Atlas

Code that ran

7 of 8 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 6 have no contract verdict; 1 failure 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/2108.13934.json · badge: /api/ran/2108.13934.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/retrieve-write-slot-filling community (classifier label)
classifier basis not recorded on the link
7 ran · 1 no recorded run
FunctionStatusWhere it lives
clean_text Ran
ran on a synthesized input
IBM/retrieve-write-slot-filling/slot_filling/kilt_passage_corpus.py
code served (permissive licence) · get_code("d890771bd3e4b3f7")
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 re

_WHITESPACE = re.compile('\\s+')

def clean_text(paragraph: str):
    return _WHITESPACE.sub(' ', paragraph.replace('::::', ': ')).strip()

ARGS = {
    'paragraph': 'This is a test::::with    multiple   spaces and::::'
}
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 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_relation_from_inst Ran
ran on a synthesized input
IBM/retrieve-write-slot-filling/slot_filling/dataset_stats.py
code served (permissive licence) · get_code("e57ce1467b8c1988")
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

def get_relation_from_inst(json_inst):
    return json_inst['input'].split(' [SEP] ')[1]

ARGS = {
    'json_inst': {
        'input': 'subject entity [SEP] relation_type [SEP] object entity'
    }
}
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
matching_passage_ids Ran
ran on a synthesized input
IBM/retrieve-write-slot-filling/dpr/dpr_kilt_slot_filling_dataset.py
code served (permissive licence) · get_code("0fa853d294de8b23")
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 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 torch
import numpy as np

# Analyze the function: it takes pids (iterable of tuples with pid, start, end),
# start_para and end_para (numbers representing paragraph boundaries)
# The function iterates over pids and unpacks each as (pid, start, end)
# It calculates overlap between passage ranges and the para range

# Create sample passage ids with (pid, start, end) tuples
pids = [
    (1, 0, 50),
    (2, 30, 80),
    (3, 100, 150),
    (4, 60, 120),
]

# Define paragraph boundaries
start_para = 40
end_para = 100

ARGS = {
    "pids": pids,
    "start_para": start_para,
    "end_para": end_para,
}
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 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
normalize_answer Ran
ran; our contract draft was wrong, not the code
IBM/retrieve-write-slot-filling/slot_filling/rag_util.py
pointer only (licence: Apache-2.0); the stored copy get_code serves, from borealisai/radar-decoding, is pointer only (licence: LGPL-3.0) · get_code("e7e75981cb464788")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (Apache-2.0), but get_code serves the stored copy, first harvested from borealisai/radar-decoding, and LGPL-3.0, as GitHub detects it on that repository, is not in the permissive set Syntology serves inline. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

postprocess_docs Ran
ran on a synthesized input
IBM/retrieve-write-slot-filling/slot_filling/rag_util.py
code served (permissive licence) · get_code("89afe8d9e930bb10")
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
import torch.nn as nn
from transformers import RagTokenizer, RagConfig

torch.manual_seed(0)

# Create a minimal stand-in for the generator tokenizer
class MockTokenizer:
    def batch_encode_plus(self, strings, max_length=None, return_tensors=None, padding=None, truncation=None):
        batch_size = len(strings)
        seq_length = 8
        return {
            'input_ids': torch.randint(0, 1000, (batch_size, seq_length)),
            'attention_mask': torch.ones((batch_size, seq_length), dtype=torch.long)
        }

# Create a minimal stand-in for RagTokenizer
class MockRagTokenizer:
    def __init__(self):
        self.generator = MockTokenizer()

# Create a minimal stand-in for RagConfig
class MockRagConfig:
    def __init__(self):
        self.title_sep = " | "
        self.doc_sep = " // "
        self.max_combined_length = 128

# Setup the arguments
config = MockRagConfig()
tokenizer = MockRagTokenizer()

docs = [
    {
        'title': ['"Document Title 1"', '"Document Title 2"'],
        'text': ['This is the first document text.', 'This is the second document text.']
    },
    {
        'title': ['"Another Title 1"', '"Another Title 2"'],
        'text': ['Another document content here.', 'More content in this document.']
    }
]

input_strings = [
    'What is the meaning of life?',
    'How does machine learning work?'
]

prefix = 'rag'
n_docs = 2
return_tensors = 'pt'

ARGS = {
    'config': config,
    'tokenizer': tokenizer,
    'docs': docs,
    'input_strings': input_strings,
    'prefix': prefix,
    'n_docs': n_docs,
    'return_tensors': return_tensors
}
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
prefix_allowed_tokens_fn Ran
ran on a synthesized input
IBM/retrieve-write-slot-filling/slot_filling/rag_client_server_apply.py
code served (permissive licence) · get_code("1d4a7d4d6e3eb7e0")
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
import numpy as np
from transformers import BartTokenizerFast
from tokenizers import Tokenizer
from tokenizers.models import BPE
from tokenizers.trainers import BpeTrainer
from tokenizers.pre_tokenizers import Whitespace

torch.manual_seed(0)

# Create a minimal BartTokenizerFast instance
# We need to build a tokenizer with the required token IDs
tokenizer_obj = Tokenizer(BPE())
tokenizer_obj.pre_tokenizer = Whitespace()
tokenizer_obj.train_from_iterator(["hello world test"], trainer=BpeTrainer())

# Create BartTokenizerFast wrapper
gtokenizer = BartTokenizerFast(tokenizer_object=tokenizer_obj)

# Set token IDs to known values for testing
gtokenizer.eos_token_id = 2
gtokenizer.bos_token_id = 0
gtokenizer.pad_token_id = 1

# Create candidates_text (not used in function but required parameter)
candidates_text = ["hello world", "test example"]

# Create batch_candidates: List[List[np.ndarray]]
# Each element is a list of numpy arrays representing token sequences for one batch item
candidate_1 = np.array([5, 6, 7, 2], dtype=np.int64)  # sequence with eos at end
candidate_2 = np.array([5, 6, 8], dtype=np.int64)      # different sequence
candidate_3 = np.array([5, 9, 10, 11, 2], dtype=np.int64)  # longer sequence

batch_item_0 = [candidate_1, candidate_2]
batch_item_1 = [candidate_3]

batch_candidates = [batch_item_0, batch_item_1]

# Create batch_id
batch_id = 0

# Create input_ids: torch.Tensor with shape (1,) as per assertion
# Testing with a prefix that has length > 1
input_ids = torch.tensor([0, 5, 6], dtype=torch.long)

ARGS = {
    "gtokenizer": gtokenizer,
    "candidates_text": candidates_text,
    "batch_candidates": batch_candidates,
    "batch_id": batch_id,
    "input_ids": input_ids,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, tokenizers, torch, transformers — 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
prepare_seq2seq_batch Ran
ran on a synthesized input
IBM/retrieve-write-slot-filling/slot_filling/rag_util.py
code served (permissive licence) · get_code("f92394bf8b4685cc")
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 torch
import torch.nn as nn

torch.manual_seed(0)

class MockEncoder(nn.Module):
    def __init__(self):
        super().__init__()
        self.model_max_length = 128
    
    def __call__(self, texts, add_special_tokens=True, return_tensors=None, max_length=None, padding='longest', truncation=True, **kwargs):
        batch_size = len(texts)
        seq_length = 4
        output = {
            'input_ids': torch.randint(0, 1000, (batch_size, seq_length)),
            'attention_mask': torch.ones(batch_size, seq_length)
        }
        return output

class MockGenerator(nn.Module):
    def __init__(self):
        super().__init__()
        self.model_max_length = 64
    
    def __call__(self, texts, add_special_tokens=True, return_tensors=None, padding='longest', max_length=None, truncation=True, **kwargs):
        batch_size = len(texts)
        seq_length = 3
        output = {
            'input_ids': torch.randint(0, 1000, (batch_size, seq_length)),
            'attention_mask': torch.ones(batch_size, seq_length)
        }
        return output

class MockTokenizer:
    def __init__(self):
        self.question_encoder = MockEncoder()
        self.generator = MockGenerator()

tokenizer = MockTokenizer()
src_texts = ["What is machine learning?", "How does AI work?"]
tgt_texts = ["Machine learning is...", "AI works by..."]

ARGS = {
    'tokenizer': tokenizer,
    'src_texts': src_texts,
    'tgt_texts': tgt_texts,
    'max_length': None,
    'max_target_length': None,
    'padding': 'longest',
    'return_tensors': None,
    'truncation': True,
    'kwargs': {}
}
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 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
find_para_range Not yet run
unverified (harvested, no recorded run)
IBM/retrieve-write-slot-filling/slot_filling/kilt_passage_corpus.py
code served (permissive licence) · get_code("50ec835b3753c6ec")
How it ran

no invocation recorded.

Also present in other papers' code

Of 8 samples lifted from this paper's linked repositories, 8 carry a function identity and 0 do not. Of the 8 distinct functions with an identity, 8 are also present in other papers whose code we hold (1 with at least one paper dated earlier, 0 the same month, 8 later) and 0 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
normalize_answer 133 other papers
29 dated earlier, 102 later, 1 same year, order not determinable, 1 undated · 1 only as an assembly brick
1508.06615 (2015-08)
Character-Aware Neural Language Models
1606.05250 (2016-06)
SQuAD: 100,000+ Questions for Machine Comprehension of Text
1608.07905 (2016-08)
Machine Comprehension Using Match-LSTM and Answer Pointer
and 130 more not named here
clean_text 1 other paper
1 later
2207.06300 (2022-07)
Re 2 G: Retrieve, Rerank, Generate
find_para_range 1 other paper
1 later
2207.06300 (2022-07)
Re 2 G: Retrieve, Rerank, Generate
get_relation_from_inst 1 other paper
1 later
2207.06300 (2022-07)
Re 2 G: Retrieve, Rerank, Generate
matching_passage_ids 1 other paper
1 later
2207.06300 (2022-07)
Re 2 G: Retrieve, Rerank, Generate
postprocess_docs 1 other paper
1 later
2207.06300 (2022-07)
Re 2 G: Retrieve, Rerank, Generate
prefix_allowed_tokens_fn 1 other paper
1 later
2207.06300 (2022-07)
Re 2 G: Retrieve, Rerank, Generate
prepare_seq2seq_batch 1 other paper
1 later
2207.06300 (2022-07)
Re 2 G: Retrieve, Rerank, Generate

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

Automatically inducing high quality knowledge graphs from a given collection of documents still remains a challenging problem in AI. One way to make headway for this problem is through advancements in a related task known as slot filling. In this task, given an entity query in form of [ENTITY, SLOT, ?], a system is asked to 'fill' the slot by generating or extracting the missing value exploiting evidence extracted from relevant passage(s) in the given document collection. The recent works in the field try to solve this task in an end-to-end fashion using retrieval-based language models. In this paper, we present a novel approach to zero-shot slot filling that extends dense passage retrieval with hard negatives and robust training procedures for retrieval augmented generation models. Our model reports large improvements on both T-REx and zsRE slot filling datasets, improving both passage retrieval and slot value generation, and ranking at the top-1 position in the KILT leaderboard. Moreover, we demonstrate the robustness of our system showing its domain adaptation capability on a new variant of the TACRED dataset for slot filling, through a combination of zero/few-shot learning. We release the source code and pre-trained models 1 .

For agents

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

get_harvested_code_for_paper("2108.13934")
get_code_for_paper("2108.13934")
have("2108.13934")

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

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

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

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

Connect an agent — have() is free.