KARLA: Knowledge-base Augmented Retrieval for Language Models

François Crespin, Fabian M. Suchanek, Nils Holzenberger
Télécom Paris
Institut Polytechnique de Paris, France
{francois.crespin, fabian.suchanek, nils.holzenberger}@telecom-paris.fr


Abstract

We propose a new method that allows an LLM to automatically pull in factual knowledge from a knowledge base during token generation. This means that (1) factual knowledge in the LLM output can be updated without retraining the LLM, (2) facts in the LLM output can be traced to the knowledge base for transparency and explainability, and (3) smaller models can achieve the same factual accuracy as larger models. Our core idea is to train the model to produce special tokens that trigger a query to the knowledge base. Our experiments show that our method improves factual grounding in both short and long-form generation, and allows factual revisions to take effect through KB edits rather than parameter updates.1

1 Introduction↩︎

Language models can acquire factual knowledge during pre-training, enabling them to answer factual questions without explicit access to external resources [1]. However, this knowledge is stored implicitly in model parameters, making individual facts difficult to inspect, correct, or selectively update. This creates a fundamental limitation for factual generation: models may hallucinate [2], become temporally misaligned as world knowledge changes [3], [4], or over-rely on memorized facts even when external evidence provides a conflicting update [5]. Furthermore, their factual recall is uneven across relations and entities, and degrades for long-tail entities [6]. Finally, relying on parameters to store factual knowledge does not scale efficiently: factual knowledge capacity increases with model size, and conversely, memorizing large-scale knowledge bases may require extremely large models and training budgets [7].

Figure 1: KARLA in action.

Retrieval-augmented generation (RAG) methods [8][10] and tool-use approaches [11], [12] allow pulling in factual information from external textual resources or tools. These methods improve factual grounding and make some knowledge updates possible through changes to the retrieval corpus or tool backend. However, retrieval alone does not eliminate parametric factual reliance. The model may ignore retrieved evidence, blend it with memorized knowledge, or generate claims that are not attributable to the retrieved source [13][15].

In this paper, we propose KARLA, a method that entices a language model to query factual knowledge from a knowledge base (KB, also called knowledge graph), i.e., a structured repository of subject-relation-object triples.

This endeavor is challenging for several reasons: First, the model must issue correct queries, i.e., it must identify the subject and relation of a query that has a chance to deliver a result. Second, the model must learn to issue correct queries also for entities that were not seen during training, and about which it has no parametric knowledge. (While it appears easy to determine that population size is a reasonable query for “Paris”, what is a reasonable query for “9-hydroxyrisperidone”?) Finally, our method has to work without any manual supervision or intervention.

Our key idea is to generate a synthetic corpus directly from the KB, interleaved with relation-specific query tokens. The model is then fine-tuned on this corpus to issue these tokens whenever it is about to generate factual information (Figure 1). During inference, we replace these tokens with the results of a query to the KB. Our goal is to separate linguistic competence from factual knowledge: the language model handles interpretation and generation, while the KB provides the atomic factual values. This brings several advantages:

  1. Factual knowledge can be updated in the KB at virtually no cost, without retraining the model. Any change is effective immediately.

  2. Knowledge that was pulled in from the KB can be marked as such, thus leaving a provenance that serves transparency and explainability. Every KB-sourced span is verifiable against a specific fact in the KB, a guarantee that neither vanilla generation nor RAG can deliver.

  3. The model can be much smaller, as all factual knowledge resides in the KB and not in the parameters. KARLA models scale not with the number of facts (as parametric knowledge does), but with the number of relations (which is typically small), meaning that our approach allows even small models to achieve high factual accuracy with KBs of near-arbitrary size.

Indeed, our experiments on factual question answering, long-form generation, and counterfactual KB-update settings show that (1) the model will generate updated information from the KB even when this contradicts its own parametric outdated knowledge, (2) a substantial part of generated long-form text can be sourced to the KB, and (3) small models such as Qwen0.6B comfortably beat larger models in factual accuracy when enhanced with our method.

2 Related Work↩︎

2.0.0.1 Language models as KBs.

Pretrained models store facts implicitly [1], but their capacity is limited to \(\approx\)​2 bits/parameter [16], [17] and uneven for long-tail entities [6]. Theoretical work suggests that external lookup outperforms memorization under these constraints [18], which motivates our shift of factual storage outside the model.

2.0.0.2 Retrieval-augmented generation

\(\!\!\!\!\)(RAG) places passages retrieved from external documents in the context window of the model [8][10]. However, the model can choose to ignore this information, or hallucinate information that was not given [13][15], as we also show in our experiments.

2.0.0.3 Tool-use approaches

\(\!\!\!\!\)let the model issue calls to external systems [11], [12], [19], sometimes via learned special tokens per tool [20], but rely on annotated demonstrations of tool use that do not scale to the relation inventory of a typical KB. KARLA instead generates training data synthetically from the KB itself. KBLaM [21] integrates a knowledge base into a language model through continuous key-value representations that support dynamic updates without retraining. However, this method holds the entire KB via an attention mechanism and attends over all knowledge tokens at query time. Hence, it is applicable only to small KBs. KARLA, in contrast, is designed for large KBs such as YAGO [22] with millions of triples.

2.0.0.4 Large Memory Language Models

\(\!\!\!\!\)(LMLMs) [23] are pre-trained from scratch with retrieved factual values masked from the loss, so that the model learns lookup behavior rather than memorization. The method takes as input a corpus of text, and builds up the KB from there. Our method, in contrast, is designed for the scenario where the user already possesses a KB, and wants the language model to answer with factual information from this source.

3 Methodology: KARLA↩︎

3.1 Problem Setup↩︎

3.1.0.1 Approach.

We are given a pre-trained language model and a knowledge base (KB). Formally, a KB is a set of triples of the form \(\langle{}s, r, o\rangle{}\), where \(s\) is a subject entity, \(r\) is a relation (or predicate) from a closed set \(\mathcal{R}\), and \(o\) is the corresponding object, as in \(\langle\)Paris, populationTotal, 2,047,602\(\rangle\). Our objective is to fine-tune the model so that it interleaves natural-language generation with inline queries of the form \(\langle{}s, r, ?\rangle{}\). These inline queries are then replaced by an object \(o\) for which \(\langle{}s, r, o\rangle{}\) is in the KB (see Figure 1).

3.1.0.2 Inline queries.

In practice, the inline query \(\langle{}s, r, ?\rangle{}\) with result \(o\) is expressed as \[\langle{}r\rangle \, \langle\texttt{subj}\rangle{}s\langle/\texttt{subj}\rangle \, \langle\texttt{KB}\rangle{}o : o_{\text{desc}} \langle/\texttt{KB}\rangle\] In this sequence, \(\langle{}r\rangle\) is a relation-specific trigger token. The tag \(\langle\texttt{subj}\rangle\) marks the subject, which is used to query the KB. The model will be trained to identify the subject here from the preceding part of the sentence. The tag \(\langle\texttt{KB}\rangle\) marks the answer to the query that was retrieved from the KB. It is included in the output sequence of tokens as soon as the inline query is generated, so as to allow the model to condition the following tokens on \(o\). The text \(o_{\text{desc}}\) is a short description of the object as retrieved from the KB (e.g., by help of the relation schema:description). It provides information about \(o\) that the model may not have in its parameters, in particular for long-tail or unseen entities. If the query has several answers in the KB, one of them is picked at random. This is motivated by the use case of long-form generation, where a single object will fulfill the expected role (as in “Elvis Presley won the \(\langle\)award\(\rangle\langle\texttt{subj}\rangle\)Elvis Presley\(\langle/\texttt{subj}\rangle\langle\texttt{KB}\rangle\)Grammy Award\(\langle/\texttt{KB}\rangle\)”, where the Grammy Award is one of the awards of Elvis).

3.1.0.3 Predicate Representation and Initialization.

We represent each relation as an atomic special token \(\langle{}r\rangle\) rather than as a plain-text label. This has the advantage that the model cannot generate relations that do not exist in the KB. It also reduces per-call inference cost, because each retrieval action emits one token rather than the several sub-tokens of a plain-text predicate label. To speed up convergence, we initialize the new embeddings from the base tokenizer. Let \(E \in \mathbb{R}^{|\mathcal{V}| \times d}\) denote the embedding matrix of the original tokenizer where \(\mathcal{V}\) is the vocabulary set and \(d\) is the embedding dimension. For a relation \(r\), we define the embedding of the corresponding predicate token \(E_{\langle r \rangle}\) as the mean of its constituent sub-token embeddings [19]. The added vocabulary introduces \(|\mathcal{R}| \cdot d\) embedding parameters, a negligible fraction of the base model size. We provide an ablation against a plain-text predicate representation in Appendix 11.

3.2 Generating the training corpus↩︎

To train the model to interact with the KB, we require a corpus in which natural language is interleaved with KB queries. One could, of course, take an existing corpus of text, and weave in the KB queries. However, this would require jointly solving several information extraction tasks, including named entity recognition [24], entity linking and entity disambiguation [25], [26], and relation extraction [27]. In addition, naturally occurring text provides highly imbalanced coverage of KB relations, with long-tail predicates appearing too rarely to support robust learning [28]. We thus generate the training corpus synthetically from the KB.

For this purpose, we first have to sample facts from the KB. A naive uniform sampling would generate a corpus of disconnected facts, in which each sentence expresses a single fact and the phrasings in which the facts appear are severely limited. Therefore, we generate texts that talk about several facts of a single entity before moving on to the next entity. If we sample entities instead of facts, though, we cannot ensure that all relations appear equally often. We therefore formulate the sampling as an iterative greedy process designed to satisfy a target distribution across the relational schema. Let \(\mathcal{R}\) be the set of KB predicates and \(T\) the target frequency for each relation. At each iteration \(i\), we identify the least used relation \(r^* \in \mathcal{R}\). We then sample an entity \(e\) uniformly at random from the set \(\{e \mid \exists (e, r^*, o) \in \text{KB}\}\). For the selected entity \(e\), we retrieve its fact neighborhood \(\mathcal{F}(e)=\{\langle{}e, r, o\rangle \mid \langle{}e, r, o\rangle \in \text{KB}\}\), i.e., the set of all KB triples with \(e\) as subject. When a relation \(r\) admits several objects, we sample one uniformly at random. We remove from the neighborhood all facts with relations \(r\) that have already appeared \(2\times{}T\) times in previous samples. We then sample \(k\) facts from this reduced neighborhood. The complete sampling algorithm is provided in Appendix 8. We also prove in Proposition 1 in the same appendix that our method yields per-relation counts bounded between \(T\) and \(2\times{}T\) regardless of the KB’s natural relation distribution (as we sample with replacement).

Once the facts are sampled, we prompt a teacher LLM (GPT-5 mini [29] in our experiments) to produce the training corpus. For this purpose, we iteratively feed it with each sampled entity subgraph, together with natural-language descriptions of the relations, and prompt it to generate an encyclopedia-style paragraph (approximately 250 tokens) with inline queries. Prompts are provided in Tables 8 and 9 (Appendix 14). We validate each generated example using two checks: (i) for every annotated object mention, the text span must match exactly the referenced object \(o\); and (ii) every sampled relation in \(\mathcal{F}(e)\) must appear in the output. If either check fails, the teacher receives structured feedback describing missing relations and parsing errors, and generation is retried up to two times, after which the subgraph is discarded. This affects less than \(0.5\%\) of subgraphs in our experiments.

3.3 Training↩︎

We then train our input model on the generated corpus. Let \(\tilde{x} = (\tilde{x}_1, \ldots, \tilde{x}_M)\) denote a sequence of tokens with inline queries and their KB-returned objects. Since training covers only a small subset of the KB, the model must learn to handle cases where the KB contains no matching fact. In 10% of inline queries (sampled independently), we replace the successful lookup result with the failure token \(\langle\texttt{KB\_FAIL}\rangle\). This teaches the model to recover from empty or unresolved KB queries by falling back to its parametric knowledge.

To enforce the separation of natural language and KB knowledge, we employ a masked next-token prediction loss. The loss is defined as: \[\mathcal{L}(\theta) = -\sum_{t=1}^{N} m_t \cdot \log p_\theta\left(\tilde{x}_t \mid \tilde{x}_{<t}\right)\] The binary mask \(m_t \in \{0, 1\}\) is constructed to gate the gradient flow: \[m_t = \begin{cases} 0 & \text{if } \tilde{x}_t \in \text{span}(\langle\texttt{KB}\rangle, \dots, \langle/\texttt{KB}\rangle) \\ 1 & \text{otherwise} \end{cases}\] By setting \(m_t = 0\) for tokens within the retrieval-result span, the model is not penalized for failing to predict the returned object \(o\) from the context alone. Instead, supervision is concentrated on the surrounding natural language and on the retrieval query that obtains the relevant KB evidence. This reduces direct supervision pressure to store KB facts in the model parameters and encourages the model to condition factual generation on the retrieved KB object.

3.4 Inference↩︎

Before generation begins, we pre-process the prompt to bring any entities into the form that KARLA-models can digest. More precisely, any entity mention \(e\) in the prompt is replaced by ⟨KB⟩\(e^*\)\(e^*_{desc}\)⟨/KB⟩, where \(e^*\) is the canonical KB entity of \(e\). To determine \(e^*\), we use a two-stage pipeline inspired by [26]:

  1. Candidate Retrieval: A bi-encoder (all-MiniLM-L6-v2 [30]) retrieves the top 10 candidate entities from a FAISS [31] index built over entity embeddings.

  2. Contextual Re-ranking: A small language model (Qwen3 1.7B) then re-ranks these candidates using the surrounding generation context to resolve ambiguities and determine \(e^*\).

This allows the model to condition any following tokens on \(e^*\).

The generation then proceeds auto-regressively. A KB query is triggered when the generation terminates in a sequence of the form: \[\langle{}r\rangle\, \langle\texttt{subj}\rangle \, s \, \langle/\texttt{subj}\rangle\] where \(r\) is a relation-specific token. When detected, the model generation is paused to resolve \(s\) to a canonical entity \(s^*\) of the KB, in the same way as before. The system then attempts to fetch an object \(o\) such that \(\langle{}s^*, r, o\rangle \in \text{KB}\). The generation continues by appending either the retrieved object or a failure signal to the sequence: \[\text{Output} = \begin{cases} \langle\texttt{KB}\rangle \, o : o_{\text{desc}} \, \langle/\texttt{KB}\rangle & \text{if } \langle{}s^*, r, o\rangle \in \text{KB} \\ \langle\texttt{KB\_FAIL}\rangle & \text{otherwise} \end{cases}\] In the event of a \(\langle\texttt{KB\_FAIL}\rangle\), the model falls back to its internal parametric weights to complete the sequence. This makes it possible to distinguish content that comes from the KB from content that comes from parametric memory.

4 Experiments↩︎

4.1 Experimental setup↩︎

4.1.0.1 Knowledge bases.

We instantiate KARLA on two knowledge bases with complementary domains: YAGO [32], a general-domain encyclopedic KB, and PrimeKG [33], a biomedical KB. Using both resources allows us to evaluate whether the method generalizes across open-domain and specialized scientific knowledge. Detailed statistics for the KBs are in Appendix 7.

4.1.0.2 Training data.

For both KBs, we construct the training corpus as explained in Section 3.2. We sample \(T = 1000\) triples per relation with \(k = 7\) relations per subject, over \(|\mathcal{R}| = 99\) relations for YAGO (after filtering non-semantic predicates such as yago:url) and \(|\mathcal{R}| = 18\) for PrimeKG. As shown in Figure 2, this yields a near-balanced distribution of relations in the corpus. The resulting training corpus contains \(36{,}929\) paragraphs for YAGO and \(10{,}470\) paragraphs for PrimeKG (example outputs are given in Tables 8 and 9 in Appendix 14). We also generate a test corpus with the same procedure, with subjects different from the ones in the training corpus. This yields \(1{,}389\) YAGO and \(382\) PrimeKG paragraphs.

Figure 2: Per-relation sample counts, sorted in ascending order. For each percentile of relations on the x-axis, the y-axis (log scale) shows the number of available samples.

4.1.0.3 KARLA configurations.

All KARLA-models are based on Qwen 3-Base [34] and fine-tuned with LoRA [35] applied to all attention and MLP projection matrices, following [36]. We keep the optimization setup fixed across model sizes: learning rate \(10^{-5}\), LoRA rank \(64\), and scaling factor \(\alpha{=}128\) (higher rank and \(\alpha\) improve convergence, see Fig. 5 Appendix 10). We train on YAGO for 3 epochs and on PrimeKG for 5 epochs, holding out 10% of each corpus for validation; full training details are in Appendix 9. We evaluate under several configurations that share the same KB, and the same training corpus, differing only at inference:

standard configuration (Section 3).

same as KARLA, removing the entity description \(e^*_{desc}\) from the prompt.

same as KARLA, but every query returns \(\langle \text{KB\_FAIL} \rangle\).

same model, evaluated on raw passages without inline queries.

4.1.0.4 Competitors.

We compare against four families of competitors:

Qwen-3 with no fine-tuning, probing parametric recall.

LoRA fine-tuning on the same synthetic corpus but without tool markup, forcing facts into parameters.

the model is given the 1-hop neighborhood of the target entity in the KB, retrieved by entity linking, in its context window (details in Appendix 12.0.0.1).

prompted (not fine-tuned) tool use, where the relation schema is provided in the system prompt (details in Appendix 12.0.0.2).

the closest published baseline, which trains an externalized-memory LM from scratch [23].

4.1.0.5 Experiments.

First, we study the impact of KARLA on the perplexity of the generated tokens (Section 4.2). Second, we study the impact of KARLA on the factuality of the generated text (Section 4.3). Finally, we study how KARLA fares when the KB contradicts the LLM’s parametric knowledge (Section 4.4).

4.2 KARLA reduces perplexity↩︎

To analyze how KARLA benefits from executing queries over the KB, we measure the perplexity of KARLA on our test corpus. We ask whether the reduction in uncertainty from conditioning on KB evidence is large enough to compensate for the cost of generating the query. For the competitors, we report standard perplexity: \[\mathrm{PPL}(x) = \exp\left( -\frac{1}{N} \sum_{i=1}^{N} \log p_\theta(x_i \mid x_{<i}) \right)\] For KARLA models, we report target-normalized masked perplexity. Let \(m_j \in \{0,1\}\) denote a scoring mask over the augmented sequence. The mask is set to zero for KB-returned objects, since these tokens are supplied by the external executor rather than predicted by the model. It is set to one for all tokens generated by the model, including test tokens and query tokens. We define: \[\mathrm{PPL}_{\mathrm{aug}}(\tilde{x}) = \exp\left( -\frac{1}{N} \sum_{j=1}^{M} m_j \log p_\theta(\tilde{x}_j \mid \tilde{x}_{<j}) \right)\] This is not the ordinary perplexity of the augmented sequence: the denominator is the number of tokens \(N\) in the non-augmented sequence, not the number of scored tokens nor the full augmented length \(M\). The metric thus measures the description length of the original passage while charging the model for the additional inline query tokens. A lower score means that the evidence obtained through KB execution reduces uncertainty enough to outweigh the overhead of producing the KB query.

Table 1: Perplexity on the synthetic held-out set. KARLA and KARLA-empty-KB report normalized perplexity. Other rows report standard perplexity.
Model Setup YAGO PrimeKG
Qwen 0.6B KARLA 7.09 3.96
KARLA-empty-KB 9.27 5.61
KARLA-raw 11.17 6.38
Raw-text SFT 8.79 5.08
Qwen 1.7B KARLA 6.05 3.36
KARLA-empty-KB 7.65 4.59
KARLA-raw 9.16 5.11
Raw-text SFT 7.28 4.28
Qwen 4B KARLA 5.32 2.96
KARLA-empty-KB 6.54 3.89
KARLA-raw 7.61 4.47
Raw-text SFT 6.27 3.75
Qwen 8B KARLA 5.08 2.84
KARLA-empty-KB 6.13 3.75
KARLA-raw 7.06 4.20
Raw-text SFT 5.77 3.51

5pt

Table 1 shows that KARLA improves this target-normalized score across both KBs and all model sizes. Compared with the Parametric SFT baseline, KARLA models lower perplexity for every evaluated Qwen 3 model. The mean score over the four model sizes decreases from \(7.03\) to \(5.89\) on YAGO and from \(4.15\) to \(3.28\) on PrimeKG, corresponding to relative reductions of \(16.2\%\) and \(21.0\%\). These gains hold despite the fact that KARLA models are penalized for generating queries, indicating that learned KB access provides useful evidence beyond what is captured by parametric-only fine-tuning. In the evaluation corpus, \(22\%\) of YAGO tokens and \(13\%\) of PrimeKG tokens are supplied directly by KB retrieval. A comparable share of the generated text is grounded in an explicit triple.

KARLA-empty-KB degrades performance from \(5.89\) to \(7.40\) on YAGO and from \(3.28\) to \(4.46\) on PrimeKG on average, showing that the improvement is not explained merely by tool syntax, sequence formatting, or tokenization artifacts, but by the actual values returned by the KB queries. KARLA-raw falls below Parametric SFT, indicating that KARLA trades standard text performance for inline-query specialization.

Table 2: Inline-query exact-match accuracy (\(\%\)) on the test corpus, broken down by predicted subject (Subj.), predicted relation (Rel.), and joint prediction (Both requiring the subject and relation to be correct).
YAGO PrimeKG
3-5 (lr)6-8 Setup Model Subj. Rel. Both Subj. Rel. Both
KARLA Qwen 0.6B 99.4 87.2 86.7 96.9 94.7 91.8
KARLA Qwen 1.7B 99.6 89.9 89.5 98.1 96.6 94.9
KARLA Qwen 4B 99.7 91.2 91.0 99.2 97.8 97.0
KARLA Qwen 8B 99.7 88.1 87.9 99.4 95.3 94.8

4pt

We next assess inline-query accuracy on the test corpus, measured separately for the relation token, the subject span, and their joint prediction. Table 2 shows that KARLA can indeed predict the subject and the relation with high accuracy. The accuracy is slightly lower for the relations on YAGO, likely because its relations are more heterogeneous and because multiple predicates can be plausible from similar textual contexts. The relation accuracy on PrimeKG reaches \(97.8\%\), indicating that its biomedical schema provides a more learnable relation-selection problem.

Together with the empty-KB ablation, this diagnostic supports the interpretation that KARLA’s gains come from learned use of external evidence rather than from sequence-format artifacts. The model reliably learns to ground subjects and to issue executable queries.

4.3 KARLA improves factuality↩︎

We next evaluate whether learned KB execution improves factuality, using YAGO as the KB. We consider both short-form question answering on the long-tail subset of PopQA [6] and long-form generation on the first 100 entities from FActScore [37]. Following [38], we replace ambiguous PopQA subject mentions with their canonical Wikipedia titles to isolate factual recall from entity disambiguation. Remaining setup details are reported in Appendix 13.

We compare KARLA against base models, 1-hop graph RAG, prompted tool use, and LMLM [23] where applicable. Table 3 reports the results.

The base LM performs poorly on both datasets regardless of size, confirming that parametric knowledge alone is insufficient, especially for the long-tail questions of PopQA. Tool-schema prompting improves over the baseline only modestly: the model sees the relation schema at inference time but is not trained to decide when to call the KB, which relation to select, or how to format an executable retrieval path. A single well-placed query suffices for PopQA, which the prompted model can partially manage zero-shot; long-form generation, however, requires chaining several calls, and the model typically issues one before reverting to parametric memory.

LMLM outperforms the prompted baselines but still falls behind KARLA. Several factors plausibly contribute: (1) LMLM is pre-trained from scratch on Wikipedia, whereas KARLA inherits the general linguistic competence from Qwen3; (2) KARLA queries a curated KB with a closed schema, whereas LMLM’s database is built from GPT-4o annotations of Wikipedia, so annotation errors propagate into retrieval; and (3) LMLM stores entities and relations as free-form surface strings resolved by fuzzy matching, whereas YAGO returns canonical typed values directly.

1-hop graph RAG performs strongly, as expected: the target entity’s one-hop neighborhood already contains the evidence needed to answer the query, though the model becomes noticeably more conservative (fewer extracted claims on FActScore Table 7 in Appendix 13). KARLA-no-desc surpasses graph RAG on PopQA and falls only slightly behind on FActScore, suggesting that lightweight entity-level context is especially useful in the multi-relation long-form setting. The full KARLA outperforms graph RAG on both datasets. KARLA also generates more atomic claims, which means that the gains do not come from being more conservative. Rather, the difference is structural: in graph RAG the model selects from the retrieved neighborhood and can still fall back on parametric memory, whereas in KARLA the answer is supplied directly by the KB.

Table 3: Short-form and long-form factuality results.PopQA reports accuracy on long-tail factual questions.FActScore evaluates long-form factual generation.
Model Setup PopQA FActScore
Qwen 0.6B KARLA 78.56 53.0
KARLA-no-desc 55.97 24.54
KARLA-empty-KB 17.73 23.2
Base LM 16.37 22.78
1-hop graph RAG 54.45 53.1
Tool-schema prompt 15.37 24.4
Qwen 1.7B KARLA 78.98 53.7
KARLA-no-desc 65.76 33.75
KARLA-empty-KB 21.09 29.1
Base LM 22.30 23.71
1-hop graph RAG 55.02 55.5
Tool-schema prompt 20.73 29.0
Qwen 4B KARLA 80.91 58.9
KARLA-no-desc 66.98 39.07
KARLA-empty-KB 24.66 33.8
Base LM 23.41 24.16
1-hop graph RAG 56.17 56.8
Tool-schema prompt 41.74 30.0
Qwen 8B KARLA 80.63 57.3
KARLA-no-desc 66.38 38.72
KARLA-empty-KB 27.23 35.9
Base LM 27.31 26.4
1-hop graph RAG 58.68 58.2
Tool-schema prompt 35.67 32.2
LLAMA2-382M LMLM 52.00 23.9
GPT2-774M LMLM 50.80 31.9

5pt

4.4 KARLA can deal with updated facts↩︎

Finally, we evaluate how KARLA and the competitors fare when the KB is updated. In our previous evaluations, the factual information expected from the model was largely in line with what was seen at pretraining time. Here we move to a setting where this alignment no longer holds, as is the case in practice. To this end, we introduce Counterfactual YAGO, a controlled update benchmark derived from YAGO. Unlike unlearning benchmarks such as TOFU [39] or RESTOR [40], our goal is not to remove knowledge from the model or recover from training contamination. Rather, we evaluate factual overriding, where the system has to reply with updated information even if the old information is strongly represented in the pretrained model’s parametric memory. We construct the benchmark by sampling 400 entities across four Wikipedia popularity quartiles. For each target entity, we keep the subject fixed but replace all of its facts by all of the facts of another entity of the same type (top-level class in YAGO). For example, the city of Paris could receive its population, location, area, and other properties from London. In this way, internal consistency is preserved (e.g., population size and area correlate).

We compare three update mechanisms on a shared test set of QA prompts (1072 in total covering 52 relations) whose correct answers are also determined by the counterfactual KB. We report Exact Match accuracy against the counterfactual object. First, for the parametric baseline, we continue LoRA fine-tuning on a separate training set of QA pairs whose answers are determined by the counterfactual KB. Training and test sets cover the same entities and facts but use disjoint templates, so improvements reflect learned facts rather than memorized surface forms (Table 13 Appendix 14). This baseline therefore measures how many gradient steps are needed to absorb the revised facts into the model weights, even when the parametric updater is trained directly on the update task. Second, for KARLA, we keep the model parameters fixed and replace only the inference-time KB; evaluation is zero-shot. Third, we evaluate a 1-hop graph RAG baseline, where the local counterfactual KB neighborhood of the linked entity is placed in the context window; evaluation is also zero-shot.

Figure 3: Parametric fine-tuning update curve. Baseline LMs require continued LoRA fine-tuning. KARLA and 1-hop graph RAG both use Qwen3 4B.
Table 4: KB-update accuracy by Wikipedia popularity quantile (Q1 = least popular, Q4 = most popular). KARLA and 1-hop graph RAG both use Qwen3 4B.
Setup Q1 Q2 Q3 Q4
KARLA 97.3 95.9 95.6 95.6
1-hop graph RAG 89.1 93.2 92.3 77.8

6pt

Figure 3 shows that LoRA baselines require continued optimization to approach acceptable performance. Larger models adapt faster, but all parametric variants still require hundreds of update steps. KARLA, in contrast, updates factual behavior immediately by replacing the KB, reaching \(96.1\%\) accuracy without any additional gradient steps.

The 1-hop graph RAG baseline reaches only \(87.3\%\) overall accuracy despite being given the local KB neighborhood in context (prompt in Table 10 Appendix 14). While this number is sensitive to prompt phrasing, the popularity-stratified results in Table 4 isolate a failure mode that prompt engineering is unlikely to close: accuracy drops from \(89.1\%\) on Q1 to \(77.8\%\) on Q4, precisely where the model is likely most certain about its own knowledge, and is unlikely to accept conflicting information from its prompt. The model may ignore the retrieved field and revert to its memorized answer for the original entity (Example 14 Appendix 14), or fall back to parametric knowledge that is itself wrong, producing a value matching neither the KB nor the real world (Example 15 Appendix 14). These results support the central claim of factual externalization: once the model has learned query formulations, factual values can be changed outside the model. The remaining errors are primarily incorrect relation selection or entity-resolution mistakes, rather than failures to store the revised facts in the parameters.

4.5 Ablations↩︎

4.5.0.1 Special-token vs.free-form predicates.

KARLA matches its free-form counterpart on inline-query accuracy (Fig. 7 Appendix 11) and slightly outperforms it on PopQA, while eliminating the up to 11% out-of-schema predicate emissions (Table 6 Appendix 13).

4.5.0.2 Empty KB.

KARLA-empty-KB degrades both perplexity (Table 1) and factuality on PopQA and FActScore (Table 3), confirming that KARLA’s gains come from the interaction with the KB.

4.5.0.3 Entity descriptions.

KARLA-no-desc loses 13–23 points on PopQA relative to KARLA and a comparable margin on FActScore (Table 3), indicating that lightweight semantic context about the queried entity is needed for the model to plan useful lookups even when the atomic values themselves come from the KB.

4.5.0.4 Training corpus size.

Figure 6 Appendix 10 shows that inline-query accuracy is near zero for \(T \leq 100\), jumps sharply at \(T = 500\), and converges across all four Qwen3 sizes at \(T = 1000\).

5 Conclusion↩︎

KARLA shows that pretrained language models can be post-trained to pull factual information from a KB, allowing smaller models to match or surpass larger ones on factual questions, and to be redeployed without retraining when KB facts (or even the entire KB) change as long as the relation schema is unchanged. Retrieval and parametric knowledge are entangled rather than substitutable: issuing a useful query requires the model to identify the right subject from context and select the right relation from a closed inventory, both of which draw on linguistic and world knowledge inherited from pretraining. Future work can investigate how KARLA can be extended to multi-hop queries, which require composing several KB lookups. All our code and data is available in the supplementary material and will be made available publicly.

6 Limitations↩︎

6.0.0.1 Predicate vocabulary is closed by construction.

Each relation is represented as an atomic special token whose embedding is learned during fine-tuning. KARLA models can therefore generalize to new entities, but extending the schema to new predicates requires additional training.

6.0.0.2 Entity disambiguation is required.

KARLA requires the disambiguation of named entities. This is an open domain of research, with no perfect approaches. Yet, the problem is orthogonal to KARLA, which can work with any approach in a drop-in fashion. KARLA-no-disambig, which replaces the two-stage entity resolver with top-1 bi-encoder retrieval, changes PopQA accuracy by around one point at every model size (Table 6 in Appendix 13). This modest effect reflects the pre-disambiguated nature of PopQA, whose ambiguous mentions have been substituted with canonical Wikipedia titles; we expect disambiguation to matter substantially more in a real-world deployment.

6.0.0.3 Coverage inherited from the KB.

Since factual values come from the KB, queries to relations or entities that are not in the KB fall back to parametric memory, where our grounding guarantees no longer hold. This dependence is the price of treating the KB as the source of truth.

7 KB Details↩︎

Table 5 summarizes the two knowledge bases used in our experiments. YAGO provides broad encyclopedic coverage over general-domain entities, while PrimeKG provides a biomedical graph organized around diseases, drugs, genes, proteins, biological processes, phenotypes, and related clinical concepts. For each KB, we report the published graph scale together with the relation inventory used by KARLA after preprocessing.

Table 5: Overview of the knowledge bases used in KARLA.For YAGO, entities and facts are reported from YAGO 4.5.For PrimeKG, nodes, relationships, node types, and edge types are reported from the original PrimeKG release.
YAGO PrimeKG
Domain General encyclopedic Biomedical / precision medicine
Entities / nodes \(49.0\)M \(129{,}375\)
Relations / edge types \(110\) \(18\)
Facts / edges \(109.0\)M \(4{,}050{,}249\)
Entity / node types \(110\) \(10\)
Main source Wikidata, Schema.org 20 biomedical resources

5pt

8 Predicate-Balanced Sampling↩︎

We sample entities using a greedy procedure that prioritizes under-represented predicates. Let \(\mathrm{KB}\) be the knowledge base, \(\mathcal{E}\) its entities, and \(\mathcal{R}\) its predicates after filtering non-semantic metadata predicates. \(T\) denotes the target number of occurrences, and \(C = \alpha T\) is a saturation cap with \(\alpha > 1\). The parameter \(k\) is the maximum number of predicates sampled per entity.

We define: \[\mathcal{E}(r) = \{e \in \mathcal{E} \mid \exists o,\;(e,r,o) \in \mathrm{KB}\},\] the entities having predicate \(r\), and \[\mathcal{R}(e) = \{r \in \mathcal{R} \mid \exists o,\;(e,r,o) \in \mathrm{KB}\},\] the predicates attached to entity \(e\).

Figure 4: Predicate-balanced entity sampling

Here, \(r^*\) is the under-represented anchor predicate, \(\mathcal{A}\) is the set of eligible additional predicates attached to the sampled entity, \(\mathcal{S}_{\mathrm{add}}\) is the set of additional predicates sampled from \(\mathcal{A}\), \(\mathcal{S}_e\) is the final predicate set used for entity \(e\), and \(\mathcal{F}_e\) is the set of retrieved facts added to the dataset. Entities are sampled with replacement, while additional predicates are sampled without replacement for each entity.

8.0.0.1 Balance guarantee.

We show that Algorithm 4 produces a corpus whose relation frequencies are bounded, independently of the natural distribution of the KB.

Proposition 1 (Relation balance). Upon termination of Algorithm 4, the per-relation counts satisfy:

  1. Lower bound (coverage): for every \(r \in \mathcal{R}\), \[\mathrm{count}(r) \geq T.\]

  2. Upper bound (saturation): for every \(r \in \mathcal{R}\), \[\mathrm{count}(r) \leq C = \alpha T.\]

8.0.0.2 Proof.

Since \(\mathcal{R}\) is constructed from the KB, every relation has at least one supporting triple, so \(\mathcal{E}(r) \neq \emptyset\) for all \(r \in \mathcal{R}\).

Lower bound. The selection step (line 5) picks \(r^* \in \arg\min_{r \in \mathcal{U}} \mathrm{count}(r)\), where \({\mathcal{U} = \{r \in \mathcal{R} : \mathrm{count}(r) < T\}}\). The uniform sample in line 6 is always well-defined since \(\mathcal{E}(r^*) \neq \emptyset\). Each iteration increments \(\mathrm{count}(r^*)\) by exactly one (line 12). The loop terminates only when \(\mathcal{U} = \emptyset\), i.e., when \(\mathrm{count}(r) \geq T\) for every \(r \in \mathcal{R}\). Sampling entities with replacement means relations with \(|\mathcal{E}(r)| < T\) are still pushed to \(\mathrm{count}(r) \geq T\) by repeatedly resampling from the same small entity set.

Upper bound. A relation \(r\) can be incremented in two ways: (i) with \(r^*\), which requires \(\mathrm{count}(r) < T\) (via membership in \(\mathcal{U}\)), or (ii) as an expansion relation in \(\mathcal{S}_{\mathrm{add}}\), which requires \(\mathrm{count}(r) < C\) (line 7). Since \(T \leq C\), in both cases \(\mathrm{count}(r) < C\) before the increment, so \(\mathrm{count}(r) \leq C\) after it. A single iteration increments \(\mathrm{count}(r)\) by at most one hence \({\mathrm{count}(r) \leq C}\).

Termination. The total count \(\sum_{r \in \mathcal{R}} \mathrm{count}(r)\) strictly increases by at least one per iteration (via the anchor \(r^*\)) and is bounded above by \(\sum_{r \in \mathcal{R}} C = \alpha T |\mathcal{R}|\), so the algorithm terminates in finitely many iterations.

9 Training details↩︎

We fine-tune Qwen3-Base [34] at four scales (0.6B, 1.7B, 4B, 8B) with LoRA [35] applied to all attention and MLP projection matrices within each transformer block (rank \(r=64\), scaling factor \(\alpha=128\)). The base model weights are kept frozen. In addition to the LoRA adapters, we train the embeddings of the newly introduced predicate tokens and the output projection, since both are randomly initialized for tokens absent from the base vocabulary. We optimize with AdamW (learning rate \(10^{-5}\), no weight decay) using a linear decay schedule without warmup, at a per-device batch size of 16, maximum sequence length of 512 tokens, and bf16 mixed precision. Each model is trained on a single NVIDIA L40S (48GB).

10 Scaling Laws / LoRA search↩︎

Performance improves consistently with both model size and LoRA capacity, as we sweep the rank \(r \in \{16, 32, 64\}\) with \(\alpha = 2r\) (Figure 5).

Figure 5: Inline-query exact-match accuracy (\%) on the test corpus across models sizes and LoRA configurations. Prediction requires both the subject and relation to be correct.
Figure 6: Inline-query Exact-match accuracy on the test set across models sizes and target T values.

11 Special-Token vs. Free-Form Predicate Representation↩︎

We compare the special-token predicate representation used in the main paper against a free-form alternative in which relations are not special tokens.

11.0.0.1 Free-form variant.

The free-form variant preserves every other aspect of KARLA: masked retrieval-query objective, synthetic data pipeline, two-stage entity resolution, modifying only how predicates are encoded. Instead of an atomic predicate token \(\langle r \rangle\), the relation is wrapped between two special tokens \(\langle \texttt{KB\_query} \rangle\) and \(\langle \texttt{/KB\_query} \rangle\).

Predicate decoding is left free-form, and a KB query is triggered upon emission of a well-formed \(\langle\texttt{KB\_query}\rangle \, r \, \langle\texttt{/KB\_query}\rangle \langle\texttt{subj}\rangle \, s \, \langle\texttt{/subj}\rangle\) block. If \(r\) does not match any predicate in \(\mathcal{R}\), the executor returns \(\langle\texttt{KB\_FAIL}\rangle\) and the model falls back to parametric generation.

11.0.0.2 In-distribution inline-query accuracy.

Figure 7 reports exact-match accuracy across four Qwen3 model sizes, with both variants trained under the same LoRA configuration. The two representations reach comparable accuracy at convergence. The free-form variant converges slightly faster, which we attribute to its trigger being shared across predicates rather than tied to a per-predicate token.

Figure 7: Inline-query exact-match accuracy (\%) for the special-token (solid) and free-form (dashed) predicate representations across four Qwen3 model sizes. All runs use LoRA with rank r=64 and \alpha=128.

11.0.0.3 Out-of-distribution behavior on PopQA.

The two representations diverge under distribution shift. Table 6 reports PopQA accuracy alongside the rate of out-of-schema emissions for the free-form variant: predicate strings emitted between \(\langle\texttt{KB\_query}\rangle\) and \(\langle\texttt{/KB\_query}\rangle\) that do not correspond to any \(r \in \mathcal{R}\). Such emissions trigger \(\langle\texttt{KB\_FAIL}\rangle\) and force a parametric fallback, regardless of whether an in-schema predicate could have answered the query. By construction, the special-token variant cannot produce them.

12 Baseline Details↩︎

12.0.0.1 1-hop graph RAG.

The 1-hop graph RAG baseline tests whether placing the full KB neighborhood of the target entity in the context window is sufficient to ground generation. Given an input prompt, we first identify the target entity using KARLA’s two-stage entity linker, then retrieve its complete one-hop neighborhood. Each fact is verbalized through a fixed per-relation template. The full verbalized neighborhood is then prepended to the user query (full template in Table 10 Appendix 14).

12.0.0.2 Tool-schema guided.

The tool-schema guided baseline tests whether a base LM, given the KB schema in context, can issue executable retrieval calls without fine-tuning. The full YAGO relation inventory is enumerated in the system prompt together with a description per relation, followed by two to three in-context examples illustrating the expected output format (Tables 11 and 12 Appendix 14). The model is instructed to emit calls wrapped in [GRAPH_QUERY]...[/GRAPH_QUERY] tags, with the subject and relation separated by <SEP>.

At inference, we scan the generated text for well-formed GRAPH_QUERY blocks. The subject is resolved through the same two-stage entity-linking pipeline used by KARLA (Section 3.4); the relation must match a string in \(\mathcal{R}\) verbatim, including the angle brackets. Each resolved block is replaced by the retrieved KB object, and generation is resumed conditioned on the inserted value. If the relation is not in \(\mathcal{R}\), or no triple \(\langle s^*, r, o\rangle\) exists in the KB, the block is replaced with an empty string and the model continues without correction.

13 Experiments setup↩︎

All KARLA models are evaluated using greedy decoding.

13.0.0.1 PopQA.

We evaluate on the long-tail entity subset of PopQA, following [41], which contains 1,399 entities with fewer than 100 weekly Wikipedia views. We measure performance with Exact Match, checking whether the gold answer appears in the generated output. To be consistent with [23], and because we evaluate base (non-instruction-tuned) models, we avoid probing instruction-following ability by re-formulating each question as a completion prompt. Table 6 contains the detailed results for the KARLA models.

13.0.0.2 FActScore.

FActScore [37] is an open-domain biography generation benchmark. It evaluates factuality by extracting atomic claims from the generation and verifying each one against Wikipedia using an LLM-based RAG pipeline. We follow the official evaluation protocol with ChatGPT, reporting both the factuality score and the number of extracted atomic claims. We prompt the model on the first 100 biography queries with a maximum generation length of 256 tokens, using the same fixed template as [23]: “Tell me a bio of \(\langle\)name\(\rangle\). \(\langle\)name\(\rangle\) is”. Table 7 contains the detailed results for the KARLA models and baselines.

Table 6: PopQA reports accuracy on long-tail factual questions. OOS (%) reports the percentage of retrieval attempts whose emitted predicate is not in \(\mathcal{R}\).
Model Setup PopQA OOS (%)
Qwen 0.6B KARLA 78.56 0.0
KARLA-no-desc 55.97 0.0
KARLA-no-disambig. 77.48 0.0
KARLA-no-special-tokens 76.91 3.7
KARLA-empty-KB 17.73 0.0
Qwen 1.7B KARLA 78.98 0.0
KARLA-no-desc 65.76 0.0
KARLA-no-disambig. 79.41 0.0
KARLA-no-special-tokens 79.20 10.9
KARLA-empty-KB 21.09 0.0
Qwen 4B KARLA 80.91 0.0
KARLA-no-desc 66.98 0.0
KARLA-no-disambig. 80.20 0.0
KARLA-no-special-tokens 78.63 9.8
KARLA-empty-KB 24.66 0.0
Qwen 8B KARLA 80.63 0.0
KARLA-no-desc 66.38 0.0
KARLA-no-disambig. 80.27 0.0
KARLA-no-special-tokens 78.06 4.6
KARLA-empty-KB 27.23 0.0

5pt

Table 7: Detailed FActScore results. Instruct results are reported only for the setups evaluated with instruct-tuned models. # Claims reports the average number of atomic claims extracted per generation.
Model Setup FActScore # Claims
Qwen 0.6B KARLA 53.0 40.51
KARLA-no-desc 24.54 40.45
KARLA-empty-KB 23.2 40.00
Base LM 22.78 40.51
1-hop graph RAG 53.1 31.42
Tool-schema prompt 24.4 27.67
KARLA 53.7 42.83
KARLA-no-desc 33.75 39.19
KARLA-empty-KB 29.1 42.65
Base LM 23.71 38.78
1-hop graph RAG 55.5 30.12
Tool-schema prompt 29.0 14.20
Qwen 4B KARLA 58.9 41.20
KARLA-no-desc 39.07 40.33
KARLA-empty-KB 33.8 39.50
Base LM 24.16 39.10
1-hop graph RAG 56.8 32.90
Tool-schema prompt 30.0 23.20
KARLA 57.3 39.39
KARLA-no-desc 38.72 37.07
KARLA-empty-KB 35.9 38.90
Base LM 26.4 39.21
1-hop graph RAG 58.2 30.30
Tool-schema prompt 32.2 22.20

5pt

14 Prompts and Outputs↩︎

This contains the prompt templates referenced in the main paper: verbalizer prompts (Tables 89), the 1-hop graph RAG prompt (Table 10), the tool-schema prompts (Tables 1112), example train/test pairs from Counterfactual YAGO (Table 13), and illustrative RAG failure cases on Counterfactual YAGO (Tables 1415).

Table 8: System prompt and example for the YAGO verbalizer.
Field Content
System prompt

You are generating training data for a grounded generation model.

Task. Given a subject entity and a set of KB triples, write ONE natural encyclopedic paragraph about the entity, approximately {target_tokens} tokens long.

Writing style. 0pt – Write fluent, well-structured prose, as in a Wikipedia article.
– Use complete sentences with natural transitions (e.g., “Born in …, he later studied at …”).
– You SHOULD enrich the text with general world knowledge to make it read naturally.
– Avoid listing facts separated by semicolons or in bullet-point style.

KB-markup annotation. Whenever you mention the object(s) of a KB triple, wrap ONLY the object text with a markup tag of the form [REL:relationName|surface text]. Examples: “was born in [REL:schema:birthPlace|Bagheria]”, “on [REL:schema:birthDate|May 27, 1956]”.

Rules. 0pt 1. EVERY provided triple MUST be annotated exactly once.
2. The surface text must be MINIMAL: only the object value, no verbs, prepositions, or articles.
OK:[REL:schema:director|Giuseppe Tornatore]
Avoid:[REL:schema:director|directed by Giuseppe Tornatore]
3. Do NOT nest tags inside other tags.
4. If you normalise a KB value, use the normalised form as the surface text.
5. Only annotate the provided triples; do not annotate bridging world knowledge you added.
6. The tagged text REPLACES the object – do NOT write the object in plain text and then repeat it in a tag.
Avoid:“born in Paris [REL:schema:birthPlace|Paris]”
OK:“born in [REL:schema:birthPlace|Paris]”
7. Date surface forms must match the object as provided (do not reformat).

Output. Return ONLY the marked-up paragraph in the marked_paragraph field.

Example user message Subject entity: Giuseppe Tornatore

Relation definitions (use these to understand the triples):
- schema:birthPlace: the place where the person was born
- schema:birthDate: the date of birth of the person
- schema:occupation: occupation of the person
- schema:award: awards received by the person

Triples:
(Giuseppe Tornatore, schema:birthPlace, Bagheria)
(Giuseppe Tornatore, schema:birthDate, May 27, 1956)
(Giuseppe Tornatore, schema:occupation, film director)
(Giuseppe Tornatore, schema:award, Academy Award for Best Foreign Language Film)
Example output Giuseppe Tornatore is an Italian [REL:schema:occupation|film director] and [REL:schema:occupation|screenwriter] born on [REL:schema:birthDate|May 27, 1956] in [REL:schema:birthPlace|Bagheria], a small town in Sicily. After early work in documentary television, he rose to international prominence with his nostalgic, character-driven storytelling, and went on to win the [REL:schema:award|Academy Award for Best Foreign Language Film] for his celebrated film Cinema Paradiso.

6pt

Table 9: System prompt and example for the PrimeKG verbalizer.
Field Content
System prompt

You are generating training data for a grounded biomedical generation model.

Task. Given a subject entity and a set of biomedical KB triples, write ONE fluent biomedical paragraph about the entity, approximately {target_tokens} tokens long.

Writing style. 0pt – Write in clear, natural biomedical prose, as in a concise knowledge-base summary or review-style description.
– Use complete sentences and natural transitions; keep the tone factual, precise, and restrained.
– Do NOT write in bullet-point style or as a list of disconnected facts.

Grounding policy. 0pt – The paragraph must be grounded primarily in the provided triples; only minimal bridging language is allowed.
– Do NOT introduce unsupported facts, mechanisms, causal claims, prevalence statements, diagnostic claims, or treatment recommendations.
– Do NOT speculate or hedge beyond what is justified by the triples.
– Preserve the meaning of each relation type exactly; do not transform one relation type into another.

KB-markup annotation. Whenever you mention the object(s) of a KB triple, wrap ONLY the object text with [REL:relationName|surface text]. Examples: 0pt – “Acetazolamide is a [REL:rdf:type|drug]”
– “The protein is expressed in [REL:Anatomy – Protein (present)|liver]”
– “The drug is indicated for [REL:Drug – Disease (indication)|type 2 diabetes mellitus]”
– “The disease is associated with [REL:Disease – Phenotype (positive)|muscle weakness]”

Rules. 0pt 1. EVERY provided triple MUST be annotated exactly once.
2. The surface text must be MINIMAL: only the object value, no verbs/prepositions/articles.
3. Do NOT nest tags.
4. If you normalize an object value, the normalized form must be the tagged surface text.
5. Only annotate the provided triples; do not annotate added bridging text.
6. The tagged text REPLACES the object – do NOT write the object in plain text and then repeat it in a tag.
Avoid:“targets X [REL:targets|X]”
OK:“targets [REL:targets|X]”
7. If the same object appears in multiple triples, each triple must still be realized exactly once in a semantically distinguishable way.
8. If a relation is negative (absence, contraindication, negative phenotype association), the surrounding sentence must explicitly preserve that negative meaning.

Entity handling. Use terminology appropriate to the entity type: disease, drug, protein, phenotype, anatomy, pathway, biological process, molecular function, cellular component, or exposure.

Output. Return ONLY the marked-up paragraph in the marked_paragraph field.

Example user message Subject entity: Acetazolamide

Relation definitions (use these to understand the triples):
- type: type of the entity
- Drug – Disease (indication): disease for which the drug is indicated
- Drug – Protein (target): protein targeted by the drug
- Drug – Disease (contraindication): disease in which the drug is contraindicated

Triples:
(Acetazolamide, Drug – Disease (indication), glaucoma)
(Acetazolamide, Drug – Protein (target), carbonic anhydrase 2)
(Acetazolamide, Drug – Disease (contraindication), severe hepatic impairment)
Example output Acetazolamide is a [REL:type|drug] that inhibits [REL:Drug – Protein (target)|carbonic anhydrase 2]. It is clinically indicated for [REL:Drug – Disease (indication)|glaucoma], where reduction of aqueous humor production helps lower intraocular pressure. Its use is contraindicated in patients with [REL:Drug – Disease (contraindication)|severe hepatic impairment].

3pt

Table 10: Prompt format used by the 1-hop graph RAG baseline. The linked entity’s 1-hop KB neighborhood is first verbalized into templated completions (one per predicate, from a fixed per-relation template file), concatenated into a single retrieved-context block, and prepended to the user query.
Field Content
Prompt template Answer the question or complete the prompt based on the given retrieved context for {subject}.
Retrieved context:
{fetched_facts} ;
{prompt}
Per-relation completion templates (excerpt) schema:birthPlace“{entity} was born in”
schema:birthDate“{entity} was born on”
schema:hasOccupation“{entity} works as”
schema:award“{entity} has received the award”
Retrieved context (fetched_facts) Giuseppe Tornatore was born in: Bagheria
Giuseppe Tornatore was born on: May 27, 1956
Giuseppe Tornatore works as: film director
Giuseppe Tornatore has received the award: Academy Award for Best Foreign Language Film
User query Tell me a bio of Giuseppe Tornatore.
Final model input Answer the question or complete the prompt based on the given retrieved context for Giuseppe Tornatore.
Retrieved context:
Giuseppe Tornatore was born in: Bagheria
Giuseppe Tornatore was born on: May 27, 1956
Giuseppe Tornatore works as: film director
Giuseppe Tornatore has received the award: Academy Award for Best Foreign Language Film
;
Tell me a bio of Giuseppe Tornatore.
Model output Giuseppe Tornatore is an Italian film director, born in Bagheria on May 27, 1956. He has received the Academy Award for Best Foreign Language Film for his celebrated work.

6pt

Table 11: Tool-schema prompt for the short-form QA setting (PopQA). The model is given the YAGO relation schema in the system prompt and must emit exactly one GRAPH_QUERY block whose relation is copied verbatim from the schema. Each block is resolved against the KB at inference time. The model is not fine-tuned for this task.
Field Content
System prompt

The following is a reference document for answering factual questions using YAGO knowledge base placeholders.

Each factual attribute in an answer is written as a GRAPH_QUERY block of the form:
[GRAPH_QUERY]subject:ENTITY<SEP>relation:RELATION[/GRAPH_QUERY]

The relation must be copied verbatim from the schema reference below, including angle brackets. Each block is automatically replaced by the retrieved value at inference time. Never fill in factual values from memory – always emit a GRAPH_QUERY block.

Examples. 0pt Q: When did Albert Einstein die?
A: Albert Einstein died on [GRAPH_QUERY]subject:Albert Einstein<SEP>relation:<schema:deathDate>[/GRAPH_QUERY].

Q: Who was the doctoral advisor of Niels Bohr?
A: The doctoral advisor of Niels Bohr was [GRAPH_QUERY]subject:Niels Bohr<SEP>relation:<yago:doctoralAdvisor>[/GRAPH_QUERY].

Q: What award did Toni Morrison win?
A: Toni Morrison won [GRAPH_QUERY]subject:Toni Morrison<SEP>relation:<schema:award>[/GRAPH_QUERY].

Allowed RELATIONS 0pt <schema:actor> – actor in a Movie or TV Series
<schema:author> – author of a CreativeWork or FictionalEntity
<schema:award> – award won by a Person, Organization, CreativeWork, or Product
<schema:birthDate> – date of birth of a Person
<schema:birthPlace> – place where a Person was born
[… relations in total]
<yago:notableWork> – notable CreativeWork by a Creator or PerformingGroup
<yago:officialLanguage> – official Language of a Country
<yago:studentOf> – Person who was a student of an Academic

Answer the following question.

User query Q: Where was Giuseppe Tornatore born?
Model output A: Giuseppe Tornatore was born in [GRAPH_QUERY]subject:Giuseppe Tornatore<SEP>relation:<schema:birthPlace>[/GRAPH_QUERY].

6pt

Table 12: Tool-schema prompt for the long-form biography setting (FActScore). The model is instructed to write a multi-sentence biography in which each fact is realized as a GRAPH_QUERY block that is resolved against the KB at inference time. The retrieved value is inserted in place of the block and the generation continues conditioned on it. The model is not fine-tuned.
Field Content
System prompt

Write a long biography. Instead of stating a fact, you must emit a call of the form:
[GRAPH_QUERY]subject:ENTITY<SEP>relation:RELATION[/GRAPH_QUERY]
At inference time, each call is resolved and its value is inserted immediately after. Continue the prose using that value.

Example.
Q: Tell me a bio of Akira Kurosawa.
A: Akira Kurosawa is a [GRAPH_QUERY]subject:Akira Kurosawa<SEP>relation:<schema:nationality>[/GRAPH_QUERY]Japanese filmmaker who directed 30 feature films in a career spanning six decades. He was born on [GRAPH_QUERY]subject:Akira Kurosawa<SEP>relation:<schema:birthDate>[/GRAPH_QUERY]23 March 1910 in [GRAPH_QUERY]subject:Akira Kurosawa<SEP>relation:<schema:birthPlace>[/GRAPH_QUERY]Ōimachi, Tokyo, and came of age during a period of rapid cultural change that would shape the themes of his later work.

Allowed RELATIONS 0pt <schema:author> – author of a CreativeWork or FictionalEntity
<schema:award> – award won by a Person, Organization, CreativeWork, or Product
<schema:birthDate> – date of birth of a Person
<schema:birthPlace> – place where a Person was born
<schema:hasOccupation> – what a Person does for a living
[… relations in total]
<yago:doctoralAdvisor> – doctoral advisor of an Academic
<yago:influencedBy> – entity that influenced a Creator or MusicGroup
<yago:notableWork> – notable CreativeWork by a Creator or PerformingGroup

User query Q: Tell me a bio of Giuseppe Tornatore.
Model output A: Giuseppe Tornatore is an Italian [GRAPH_QUERY]subject:Giuseppe Tornatore<SEP>relation:<schema:hasOccupation>[/GRAPH_QUERY]film director and screenwriter, born on [GRAPH_QUERY]subject:Giuseppe Tornatore<SEP>relation:<schema:birthDate>[/GRAPH_QUERY]May 27, 1956 in [GRAPH_QUERY]subject:Giuseppe Tornatore<SEP>relation:<schema:birthPlace>[/GRAPH_QUERY]Bagheria. He is best known for receiving the [GRAPH_QUERY]subject:Giuseppe Tornatore<SEP>relation:<schema:award>[/GRAPH_QUERY]Academy Award for Best Foreign Language Film for his celebrated work.

6pt

Table 13: Example of train/test pairs from Counterfactual YAGO for the parametric baseline (§4.4). Bulgaria’s facts have been replaced by Slovakia’s in the rewritten KB, so the gold answers reflect Slovakia’s values. Train and test prompts cover the same (subject, predicate) pair but use disjoint surface templates, so improvements at evaluation time reflect learned facts rather than memorized phrasings.
Field Content
Subject Bulgaria
Predicate yago:leader
Quartile Q4 (75%–100%)
Gold answer Eduard Heger
Train prompt Who leads Bulgaria? Bulgaria is led by
Train completion Eduard Heger
Test prompt Who is the leader of Bulgaria? The leader of Bulgaria is
Expected answer Eduard Heger
Subject Bulgaria
Predicate yago:populationNumber
Quartile Q4 (75%–100%)
Gold answer 5,449,270
Train prompt How many people live in Bulgaria? Bulgaria has
Train completion 5449270
Test prompt What is the population number of Bulgaria? The population number of Bulgaria is
Expected answer 5449270

6pt

Table 14: Example of parametric override by the 1-hop graph RAG baseline on COUNTERFACTUAL YAGO. Bulgaria’s facts have been replaced by Slovakia’s in the rewritten KB, so the ground-truth demonym is the value present in the retrieved context (Slūfākiyyūn, “Slovaks”). The model instead emits its memorized answer for the original entity, ignoring the retrieved Demonym field. Qwen3 4B-Base, prompt format from Table [tbl:tab:1hop95rag95prompt].
Field Content
Retrieved context (fetched_facts) Official Language: Slovak language
Type: sovereign state
Date Created: 1 January 1993
Replaces: Czech and Slovak Federal Republic
Neighbors: Poprad
Human Development Index: 0.848
Slogan: “Travel in Slovakia - Good idea”
Leader: Eduard Heger
Lowest Point: Bodrog
Population Number: 5449270
Area: 49035.0
Demonym: “Slūfākiyyūn
Location: First Czechoslovak Republic
Highest Point: Gerlachovský štít
Member Of: Group on Earth Observations
Geo: Point(20 49)
User query What is the demonym of Bulgaria? The demonym of Bulgaria is
Expected answer (from KB) Slūfākiyyūn
Model output Bulgarians.

6pt

Table 15: Example of confident fabrication by the 1-hop graph RAG baseline on COUNTERFACTUAL YAGO. Bulgaria’s Date Created field is explicitly present in the retrieved context as 1 January 1993, yet the model generates 1 January 1946 — a date matching neither the retrieved value nor the real-world creation of modern Bulgaria, indicating that the relevant field is not consulted before generation. Qwen3 4B-Base, prompt format from Table [tbl:tab:1hop95rag95prompt].
Field Content
Retrieved context (fetched_facts) Date Created: 1 January 1993
Population Number: 5449270
Lowest Point: Bodrog
Human Development Index: 0.848
Official Language: Slovak language
Neighbors: Poprad
Slogan: “Travel in Slovakia - Good idea”
Replaces: Czech and Slovak Federal Republic
Member Of: Group on Earth Observations
Demonym: “Slūfākiyyūn
Location: First Czechoslovak Republic
Geo: Point(20 49)
Leader: Eduard Heger
Type: sovereign state
Highest Point: Gerlachovský štít
Area: 49035.0
User query When was Bulgaria created? Bulgaria was created on
Expected answer (from KB) 1 January 1993
Model output 1 January 1946.

6pt

References↩︎

[1]
Fabio Petroni, Tim Rocktäschel, Sebastian Riedel, Patrick Lewis, Anton Bakhtin, Yuxiang Wu, and Alexander Miller. 2019. Language models as knowledge bases? In Proceedings of the 2019 conference on empirical methods in natural language processing and the 9th international joint conference on natural language processing (EMNLP-IJCNLP), pages 2463–2473.
[2]
Joshua Maynez, Shashi Narayan, Bernd Bohnet, and Ryan McDonald. 2020. On faithfulness and factuality in abstractive summarization. In Proceedings of the 58th annual meeting of the association for computational linguistics, pages 1906–1919.
[3]
Angeliki Lazaridou, Adhiguna Kuncoro, Elena Gribovskaya, Devang Agrawal, Adam Liska, Tayfun Terzi, Mai Gimenez, Cyprien de Masson d’Autume, Tomas Kocisky, Sebastian Ruder, Dani Yogatama, Kris Cao, Susannah Young, and Phil Blunsom. 2021. https://arxiv.org/abs/2102.01951. Preprint, arXiv:2102.01951.
[4]
Kelvin Luu, Daniel Khashabi, Suchin Gururangan, Karishma Mandyam, and Noah A Smith. 2022. Time waits for no one! analysis and challenges of temporal misalignment. In Proceedings of the 2022 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, pages 5944–5958.
[5]
Shayne Longpre, Kartik Perisetla, Anthony Chen, Nikhil Ramesh, Chris DuBois, and Sameer Singh. 2021. Entity-based knowledge conflicts in question answering. In Proceedings of the 2021 conference on empirical methods in natural language processing, pages 7052–7063.
[6]
Alex Mallen, Akari Asai, Victor Zhong, Rajarshi Das, Daniel Khashabi, and Hannaneh Hajishirzi. 2023. When not to trust language models: Investigating effectiveness of parametric and non-parametric memories. In Proceedings of the 61st annual meeting of the association for computational linguistics (volume 1: Long papers), pages 9802–9822.
[7]
Xingyu Lu, Xiaonan Li, Qinyuan Cheng, Kai Ding, Xuan-Jing Huang, and Xipeng Qiu. 2024. Scaling laws for fact memorization of large language models. In Findings of the Association for Computational Linguistics: EMNLP 2024, pages 11263–11282.
[8]
Patrick Lewis, Ethan Perez, Aleksandra Piktus, Fabio Petroni, Vladimir Karpukhin, Naman Goyal, Heinrich Küttler, Mike Lewis, Wen-tau Yih, Tim Rocktäschel, and 1 others. 2020. Retrieval-augmented generation for knowledge-intensive nlp tasks. Advances in neural information processing systems, 33:9459–9474.
[9]
Kelvin Guu, Kenton Lee, Zora Tung, Panupong Pasupat, and Mingwei Chang. 2020. Retrieval augmented language model pre-training. In International conference on machine learning, pages 3929–3938. PMLR.
[10]
Sebastian Borgeaud, Arthur Mensch, Jordan Hoffmann, Trevor Cai, Eliza Rutherford, Katie Millican, George Bm Van Den Driessche, Jean-Baptiste Lespiau, Bogdan Damoc, Aidan Clark, and 1 others. 2022. Improving language models by retrieving from trillions of tokens. In International conference on machine learning, pages 2206–2240. PMLR.
[11]
Shunyu Yao, Jeffrey Zhao, Dian Yu, Nan Du, Izhak Shafran, Karthik Narasimhan, and Yuan Cao. 2022. React: Synergizing reasoning and acting in language models. arXiv preprint arXiv:2210.03629.
[12]
Timo Schick, Jane Dwivedi-Yu, Roberto Dessı̀, Roberta Raileanu, Maria Lomeli, Eric Hambro, Luke Zettlemoyer, Nicola Cancedda, and Thomas Scialom. 2023. Toolformer: Language models can teach themselves to use tools. Advances in neural information processing systems, 36:68539–68551.
[13]
Selvan Sunitha Ravi, Bartosz Mielczarek, Anand Kannappan, Douwe Kiela, and Rebecca Qian. 2024. Lynx: An open source hallucination evaluation model. arXiv preprint arXiv:2407.08488.
[14]
The New York Times Company. 2023. https://nytco-assets.nytimes.com/2023/12/NYTComplaint_Dec2023.pdf Complaint.
[15]
Zacchary Sadeddine, Winston Maxwell, Gaël Varoquaux, and Fabian M. Suchanek. 2025. . In SIGIR Forum invited paper.
[16]
Zeyuan Allen-Zhu and Yuanzhi Li. 2023. Physics of language models: Part 3.1, knowledge storage and extraction. arXiv preprint arXiv:2309.14316.
[17]
Zeyuan Allen-Zhu and Yuanzhi Li. 2025. Physics of language models: Part 3.2, knowledge manipulation. In International Conference on Learning Representations, volume 2025, pages 85824–85832.
[18]
Sam Houliston, Ambroise Odonnat, Charles Arnal, and Vivien Cabannes. 2025. Provable benefits of in-tool learning for large language models. arXiv preprint arXiv:2508.20755.
[19]
Renxi Wang, Xudong Han, Lei Ji, Shu Wang, Timothy Baldwin, and Haonan Li. 2025. https://openreview.net/forum?id=XLMAMmowdY. In The Thirteenth International Conference on Learning Representations, ICLR 2025, Singapore, April 24-28, 2025. OpenReview.net.
[20]
Shibo Hao, Tianyang Liu, Zhen Wang, and Zhiting Hu. 2023. Toolkengpt: Augmenting frozen language models with massive tools via tool embeddings. Advances in neural information processing systems, 36:45870–45894.
[21]
Xi Wang, Taketomo Isazawa, Liana Mikaelyan, and James Hensman. 2024. Kblam: Knowledge base augmented language model. arXiv preprint arXiv:2410.10450.
[22]
Fabian M Suchanek, Gjergji Kasneci, and Gerhard Weikum. 2007. Yago: a core of semantic knowledge. In Proceedings of the 16th international conference on World Wide Web, pages 697–706.
[23]
Linxi Zhao, Sofian Zalouk, Christian K Belardi, Justin Lovelace, Jin Peng Zhou, Ryan Thomas Noonan, Dongyoung Go, Kilian Q Weinberger, Yoav Artzi, and Jennifer J Sun. 2025. Pre-training limited memory language models with internal and external knowledge. arXiv preprint arXiv:2505.15962.
[24]
Urchade Zaratiana, Nadi Tomeh, Pierre Holat, and Thierry Charnois. 2024. Gliner: Generalist model for named entity recognition using bidirectional transformer. In Proceedings of the 2024 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies (Volume 1: Long Papers), pages 5364–5376.
[25]
Ledell Wu, Fabio Petroni, Martin Josifoski, Sebastian Riedel, and Luke Zettlemoyer. 2020. Scalable zero-shot entity linking with dense entity retrieval. In Proceedings of the 2020 conference on empirical methods in natural language processing (EMNLP), pages 6397–6407.
[26]
Samy Haffoudhi, Fabian M Suchanek, and Nils Holzenberger. 2026. Lela: an llm-based entity linking approach with zero-shot domain adaptation. arXiv preprint arXiv:2601.05192.
[27]
Pere-Lluı́s Huguet Cabot and Roberto Navigli. 2021. Rebel: Relation extraction by end-to-end language generation. In Findings of the association for computational linguistics: EMNLP 2021, pages 2370–2381.
[28]
Martin Josifoski, Marija Sakota, Maxime Peyrard, and Robert West. 2023. Exploiting asymmetry for synthetic training data generation: Synthie and the case of information extraction. In Proceedings of the 2023 Conference on Empirical Methods in Natural Language Processing, pages 1555–1574.
[29]
OpenAI. 2025. Introducing gpt-5 for developers. https://openai.com/index/introducing-gpt-5-for-developers/. Accessed: 2026-05-16.
[30]
Sentence Transformers. 2021. sentence-transformers/all-minilm-l6-v2. https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2.
[31]
Matthijs Douze, Alexandr Guzhva, Chengqi Deng, Jeff Johnson, Gergely Szilvasy, Pierre-Emmanuel Mazaré, Maria Lomeli, Lucas Hosseini, and Hervé Jégou. 2025. The faiss library. IEEE Transactions on Big Data.
[32]
Fabian M Suchanek, Mehwish Alam, Thomas Bonald, Lihu Chen, Pierre-Henri Paris, and Jules Soria. 2024. Yago 4.5: A large and clean knowledge base with a rich taxonomy. In Proceedings of the 47th international ACM SIGIR conference on research and development in information retrieval, pages 131–140.
[33]
Payal Chandak, Kexin Huang, and Marinka Zitnik. 2023. Building a knowledge graph to enable precision medicine. Scientific data, 10(1):67.
[34]
An Yang, Anfeng Li, Baosong Yang, Beichen Zhang, Binyuan Hui, Bo Zheng, Bowen Yu, Chang Gao, Chengen Huang, Chenxu Lv, and 1 others. 2025. Qwen3 technical report. arXiv preprint arXiv:2505.09388.
[35]
Edward J Hu, Yelong Shen, Phillip Wallis, Zeyuan Allen-Zhu, Yuanzhi Li, Shean Wang, Liang Wang, Weizhu Chen, and 1 others. 2022. Lora: Low-rank adaptation of large language models. Iclr, 1(2):3.
[36]
John Schulman and Thinking Machines Lab. 2025. https://doi.org/10.64434/tml.20250929. Thinking Machines Lab: Connectionism. Https://thinkingmachines.ai/blog/lora/.
[37]
Sewon Min, Kalpesh Krishna, Xinxi Lyu, Mike Lewis, Wen-tau Yih, Pang Koh, Mohit Iyyer, Luke Zettlemoyer, and Hannaneh Hajishirzi. 2023. Factscore: Fine-grained atomic evaluation of factual precision in long form text generation. In Proceedings of the 2023 Conference on Empirical Methods in Natural Language Processing, pages 12076–12100.
[38]
Yujian Liu, Shiyu Chang, Tommi Jaakkola, and Yang Zhang. 2025. Fictitious synthetic data can improve llm factuality via prerequisite learning. In International Conference on Learning Representations, volume 2025, pages 60984–61007.
[39]
Pratyush Maini, Zhili Feng, Avi Schwarzschild, Zachary C Lipton, and J Zico Kolter. 2024. Tofu: A task of fictitious unlearning for llms. arXiv preprint arXiv:2401.06121.
[40]
Keivan Rezaei, Khyathi Chandu, Soheil Feizi, Yejin Choi, Faeze Brahman, and Abhilasha Ravichander. 2024. Restor: knowledge recovery in machine unlearning. arXiv preprint arXiv:2411.00204.
[41]
Akari Asai, Zeqiu Wu, Yizhong Wang, Avi Sil, and Hannaneh Hajishirzi. 2024. Self-rag: Learning to retrieve, generate, and critique through self-reflection. In International conference on learning representations, volume 2024, pages 9112–9141.

  1. Code and data are included in the supplementary material and will be made available publicly.↩︎