SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2024.findings-emnlp.927 · EMNLP Findings · 2024

Less is More: Making Smaller Language Models Competent Subgraph Retrievers for Multi-hop KGQA

Mirella Lapata, Hongru Wang, Pavlos Vougiouklis, Jeff Pan, Wenyu Huang, Guancheng Zhou, Jaxon Bieber, Jeremy Bieber

Code that ran

10 of 14 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, 1 violated it and 8 have no contract verdict; 1 failure of our instrument; 4 no recorded run), measured 2026-11-24; 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/2024.findings-emnlp.927.json · badge: /api/ran/2024.findings-emnlp.927.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
hwy9855/GSR canonical (classifier label)
classifier basis: census
10 ran · 4 no recorded run
FunctionStatusWhere it lives
decode_predictions Ran
ran on a synthesized input
hwy9855/GSR/src/preprocess/prepare_reader_data.py
code served (permissive licence) · get_code("61116289851f7e1b")
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 torch

torch.manual_seed(0)

# Analyze the function: decode_predictions takes a single parameter 'pred'
# which is a string that gets split by '<SEP>' into relations
# Each relation is further split by '>' and tokens are processed
# The function expects a string with specific formatting

pred_input = "<token_0><token_1><token_2>><SEP><token_3><token_4>><SEP><token_5>"

ARGS = {
    "pred": pred_input
}
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 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
decode_predictions_wo_sep Ran
ran on a synthesized input
hwy9855/GSR/src/preprocess/prepare_reader_data.py
code served (permissive licence) · get_code("f82ca8b81e2f5964")
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 torch
import numpy as np

def decode_predictions_wo_sep(pred):
    rels = pred.split('<rel_0')[1:]
    pred_path = []
    for rel in rels:
        decoded_rel = []
        rel_tokens = ('<rel_0' + rel).split('>')[:-1]
        for token in rel_tokens:
            decoded_rel.append(token[7:])
        pred_path.append('.'.join(decoded_rel))
    return pred_path

# Setup: pred is a string that contains relation markers
# The function splits by '<rel_0', then processes each relation
# It extracts tokens between '<rel_0' and '>', and takes characters from position 7 onwards
# Example: '<rel_0subject>object' would give 'subject' and 'object' joined by '.'

pred_string = '<rel_0entity_1>entity_2<rel_0concept_a>concept_b'

ARGS = {
    'pred': pred_string
}
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 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
decode_template Ran
ran on a synthesized input
hwy9855/GSR/src/preprocess/pseudo_question_generation.py
code served (permissive licence) · get_code("5890bc8c654a1b03")
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.

# Analyzing the function: decode_template expects a string parameter 'sample'
# The function splits by newlines, checks if lines start with digits,
# extracts substrings, and expects exactly 10 templates to be extracted

# Create a sample string that will produce exactly 10 templates
# Lines starting with 1 digit followed by non-digit: extract from index 3 onwards
# Lines starting with 2 digits: extract from index 4 onwards

sample = """1a template1
2b template2
3c template3
10 template4
11 template5
1d template6
2e template7
3f template8
10 template9
11 template10"""

ARGS = {
    "sample": sample
}
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 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
get_query Ran
ran on a synthesized input
hwy9855/GSR/src/preprocess/get_freebase_examples.py
code served (permissive licence) · get_code("aa6b3768fa0972c3")
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

# Set random seed for reproducibility
torch.manual_seed(0)

# Define arguments for get_query function
# The function takes two string parameters: rel and prefix
# rel: a relation name
# prefix: a prefix label

ARGS = {
    "rel": "film.director.film",
    "prefix": "ns"
}
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
get_sft_data Ran
ran on a synthesized input
hwy9855/GSR/src/preprocess/prepare_reader_data.py
code served (permissive licence) · get_code("b3a68ef38e2f3e20")
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

class MockTokenizer:
    def __call__(self, text):
        # Simple mock: count words and return input_ids based on word count
        word_count = len(text.split())
        return {'input_ids': list(range(word_count))}

class MockArgs:
    def __init__(self):
        self.set = 'train'

# Create mock args object that the function references
args = MockArgs()

tokenizer = MockTokenizer()

ARGS = {
    'question': 'What is the capital of France',
    'all_paths': [
        'France is a country in Europe',
        'Paris is the capital of France',
        'The Eiffel Tower is located in Paris'
    ],
    'max_input_length': 500,
    'tokenizer': tokenizer,
    'prompt_type': 'llama2_chat',
    'prompt_head': ['reasoning paths', 'Reasoning Paths']
}
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
match Ran
ran, violated the contract we drafted
hwy9855/GSR/src/gsr/inference.py
code served (permissive licence) · get_code("4c0b6fe3f3f87b7c")
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 bool, 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 string
import re

def normalize(s: str) -> str:
    """Lower text and remove punctuation, articles and extra whitespace."""
    s = s.lower()
    exclude = set(string.punctuation)
    s = ''.join((char for char in s if char not in exclude))
    s = re.sub('\\b(a|an|the)\\b', ' ', s)
    s = re.sub('\\b(<pad>)\\b', ' ', s)
    s = ' '.join(s.split())
    return s

def match(s1: str, s2: str) -> bool:
    s1 = normalize(s1)
    s2 = normalize(s2)
    return s2 in s1

ARGS = {
    "s1": "The quick brown fox jumps over a lazy dog.",
    "s2": "quick brown fox"
}
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 bool, 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
norm_pred Ran
ran on a synthesized input
hwy9855/GSR/src/reader/inference.py
code served (permissive licence) · get_code("1b4d09f7d2dd3b6d")
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 string
import re

def normalize(s: str) -> str:
    """Lower text and remove punctuation, articles and extra whitespace."""
    s = s.replace('<|eot_id|>', '')
    s = s.lower()
    exclude = set(string.punctuation)
    s = ''.join((char for char in s if char not in exclude))
    s = re.sub('\\b(a|an|the)\\b', ' ', s)
    s = re.sub('\\b(<pad>)\\b', ' ', s)
    s = ' '.join(s.split())
    return s

def norm_pred(pred):
    normed_pred = []
    for p in pred:
        if normalize(p) not in normed_pred:
            normed_pred.append(normalize(p))
    return normed_pred

# Setup: Create test data for norm_pred
pred_list = [
    "The quick brown fox",
    "the quick brown fox",
    "A lazy dog",
    "the quick brown fox",
    "Hello, world!",
    "Hello world"
]

ARGS = {
    "pred": pred_list
}
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 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
normalize Ran
ran; our contract draft was wrong, not the code
hwy9855/GSR/src/gsr/inference.py
code served (permissive licence) · get_code("5a0c8cfebf6c37cd")
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 string
import re

def normalize(s: str) -> str:
    """Lower text and remove punctuation, articles and extra whitespace."""
    s = s.lower()
    exclude = set(string.punctuation)
    s = ''.join((char for char in s if char not in exclude))
    s = re.sub('\\b(a|an|the)\\b', ' ', s)
    s = re.sub('\\b(<pad>)\\b', ' ', s)
    s = ' '.join(s.split())
    return s

ARGS = {
    "s": "The quick brown fox jumps over a lazy dog. Hello, world!"
}
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
normalize Ran
ran on a synthesized input
hwy9855/GSR/src/reader/inference.py
code served (permissive licence) · get_code("dcd2b72f0c935726")
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 string
import re

def normalize(s: str) -> str:
    """Lower text and remove punctuation, articles and extra whitespace."""
    s = s.replace('<|eot_id|>', '')
    s = s.lower()
    exclude = set(string.punctuation)
    s = ''.join((char for char in s if char not in exclude))
    s = re.sub('\\b(a|an|the)\\b', ' ', s)
    s = re.sub('\\b(<pad>)\\b', ' ', s)
    s = ' '.join(s.split())
    return s


ARGS = {
    "s": "The quick brown fox jumps over a lazy dog. <|eot_id|> Hello <pad> world!"
}
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
process_triples Ran
ran on a synthesized input
hwy9855/GSR/src/reader/inference.py
code served (permissive licence) · get_code("d11791179f364d76")
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 torch

torch.manual_seed(0)

# The function takes triples (a list of tuples/lists with 3 elements each)
# and an optional connector string parameter.
# It processes each triple by joining the 3 elements with the connector.

triples = [
    ('subject1', 'predicate1', 'object1'),
    ('subject2', 'predicate2', 'object2'),
    ('subject3', 'predicate3', 'object3'),
]

connector = ', '

ARGS = {
    'triples': triples,
    'connector': connector,
}
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 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
create_training_data_pseudo_question Not yet run
unverified (harvested, no recorded run)
hwy9855/GSR/src/preprocess/prepare_gsr_data.py
code served (permissive licence) · get_code("73f2f7b5bf0e06f9")
How it ran

no invocation recorded.

create_training_data_retrieval Not yet run
unverified (harvested, no recorded run)
hwy9855/GSR/src/preprocess/prepare_gsr_data.py
code served (permissive licence) · get_code("a9b1ea0b5dd2e08a")
How it ran

no invocation recorded.

gen_response Not yet run
unverified (harvested, no recorded run)
hwy9855/GSR/src/preprocess/pseudo_question_generation.py
code served (permissive licence) · get_code("bd7d4f2c01f4f38a")
How it ran

no invocation recorded.

run_inference Not yet run
unverified (harvested, no recorded run)
hwy9855/GSR/src/gsr/inference.py
code served (permissive licence) · get_code("97f82fa05b312950")
How it ran

no invocation recorded.

Also present in other papers' code

Of 14 samples lifted from this paper's linked repositories, 14 carry a function identity and 0 do not. Of the 14 distinct functions with an identity, 2 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 0 later) and 12 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
match 2 other papers
2 same year, order not determinable
2402.11199 (2024-02)
Direct Evaluation of Chain-of-Thought in Multi-hop Reasoning with Knowledge Graphs
2410.20724 (2024-10)
Simple is Effective: The Roles of Graphs and Large Language Models in Knowledge-Graph-Based Retrieval-Augmented Generation
normalize 1 other paper
1 same year, order not determinable
2410.20724 (2024-10)
Simple is Effective: The Roles of Graphs and Large Language Models in Knowledge-Graph-Based Retrieval-Augmented Generation

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

Repositories linked to this paper

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

Abstract

Retrieval-Augmented Generation (RAG) is widely used to inject external non-parametric knowledge into large language models (LLMs). Recent works suggest that Knowledge Graphs (KGs) contain valuable external knowledge for LLMs. Retrieving information from KGs differs from extracting it from document sets. Most existing approaches seek to directly retrieve relevant subgraphs, thereby eliminating the need for extensive SPARQL annotations, traditionally required by semantic parsing methods. In this paper, we model the subgraph retrieval task as a conditional generation task handled by small language models. Specifically, we define a subgraph identifier as a sequence of relations, each represented as a special token stored in the language models. Our base generative subgraph retrieval model, consisting of only 220M parameters, achieves competitive retrieval performance compared to state-of-the-art models relying on 7B parameters, demonstrating that small language models are capable of performing the subgraph retrieval task. Furthermore, our largest 3B model, when plugged with an LLM reader, sets new SOTA end-to-end performance on both the WebQSP and CWQ benchmarks. Our model and data will be made available online: https://github.com/hwy9855/GSR.

For agents

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

get_harvested_code_for_paper("2024.findings-emnlp.927")
get_code_for_paper("2024.findings-emnlp.927")
have("2024.findings-emnlp.927")

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

curl https://syntology.ai/api/ran/2024.findings-emnlp.927.json

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

[![Syntology run record](https://syntology.ai/api/ran/2024.findings-emnlp.927.svg)](https://syntology.ai/paper/2024.findings-emnlp.927)

Connect an agent — have() is free.