Name-Swap Probes for Detecting Fabricated Entity Facts

When a language model writes a biography of someone it barely knows, it rarely says "I don't know." It writes what a typical person of that kind would plausibly have: a birth year in the right decade, a degree from a well-known university, a career in the field the prompt implies. These fabrications are often fluent and confident, which is why detectors that flag low-probability tokens miss them. We propose a simple test that catches them. Take the finished text, replace the subject's name with several random names of the same type (other people, other companies), and re-score each factual span. If the model assigns the span nearly the same probability no matter whose name is attached, the span came from the model's generic prior for that kind of entity, not from anything it knows about this entity. That makes it a likely fabrication, however confident the model was.

This reuses an old idea, entity masking: hiding or replacing entity names so a model cannot fall back on memorized associations. Masking was built to force classifiers to read context instead of recalling facts. We turn it into a measuring tool. Prior work used masking to suppress memory. We use the gap between the masked and unmasked model to tell when memory is actually present. The resulting score needs a handful of extra forward passes over the completed text, needs no training, and has a black-box variant for closed APIs.

Core Claim

Our hypothesis is that a large share of the confident entity-level hallucinations that uncertainty measures miss are cases where the model's output is name-invariant: the probability it gives a span hardly changes when the subject's name is swapped for a random name of the same type. A score built on this difference should beat likelihood- and entropy-based detectors on long-form entity hallucination, especially on rare entities and on high-confidence errors.

Formally, let $e$ be the subject entity, $y$ the generated text, and $s$ a factual span (a proper noun, number, or date) starting at position $t$. Let $e'$ range over $K$ random same-type substitute names, inserted wherever $e$ appears in both the prompt and $y_{<t}$. We define the name-specificity of the span as

$$\Delta(s) = \log p(s \mid e, y_{<t}) - \log \frac{1}{K}\sum_{k=1}^{K} p(s \mid e'_k, y'_{<t}),$$

where $y'_{<t}$ is the prefix with the name substituted. A large $\Delta$ means the name carried information that raised the span's probability, so the model plausibly recalls a fact. A $\Delta$ near zero means the span is what the model would say about anyone of that type. Because $y$ is fixed and teacher-forced, meaning we score text that already exists rather than generate token by token, the cost is $K$ forward passes per document. This is far less than doubling the cost of every decoding step.

Why This Is Not Already Done

The motivating evidence is strong. Sources of Hallucination by Large Language Models on Inference Tasks showed that models use entity names as lookup keys for memorized facts, and that their apparent reasoning collapses when names are replaced by "Person X" or random names. That study only diagnoses the problem, and only for classification. Factual or Contextual? Disentangling Error Types in Entity Description Generation found that for obscure entities models fall into a "context trap," producing descriptions that fit the surrounding text but are false. Name-invariance is the signature we would expect of that behavior. FActScore found factual precision near 80% for very frequent entities that drops sharply for rare ones. HalluEntity found that proper nouns (30.9%) and numbers (36.2%) are the most error-prone entity types. These are exactly the slots a type prior fills easily.

The closest method is the black-box placeholder pipeline in A Causal View of Entity Bias in (Large) Language Models. It replaces entities with typed placeholders so that relation extraction and reading comprehension rely on context rather than memory. That paper uses masking to remove parametric knowledge from the answer. We keep the original answer and use masking as a counterfactual to measure whether parametric knowledge was there. The method also constrains our design: it found that bare [ENTITY] tokens strip away the entity's type and hurt performance. For that reason our main substitutes are random same-type names, borrowing the zero-coverage mention randomization idea surveyed in Entity Masking for Robust Contextual Learning, and we treat bare placeholders as an ablation.

Trusting Your Evidence: Hallucinate Less with Context-aware Decoding also contrasts two conditionings. However, it removes a retrieved document in order to suppress memory, and it applies the contrast at every token. Our method removes only the name, applies only at entity spans, and aims to detect missing memory in closed-book generation.

Research Program

The work has three parts.

First, we build the probe. For each biography, we tag entity spans with an off-the-shelf named-entity tagger and number detector. We sample $K$ substitute names of matching type and rough frequency from a name list. We then score $\Delta$ with an open model (Llama3-8B as the primary scorer, plus a smaller and a larger model). Two details need care. Pronouns and other mentions of the subject in $y_{<t}$ must be substituted consistently. Spans that literally contain the subject's name are excluded.

Second, we study when name-invariance fails as a signal. The predicted failure mode is the type-typical truth, such as "American" for an American politician, which is correct but name-invariant. We will measure this directly. We will also test a combined score that pairs $\Delta$ with a cheap typicality estimate, namely how often the span appears across the substitutes' own generations.

Third, we build a black-box variant for closed APIs. We pose short targeted questions about each extracted claim, both with the real name and with substitute names. A claim is flagged when the real-name answer matches the modal substitute answer as often as substitutes match each other.

We then use the detector for mitigation. Flagged spans trigger either abstention or retrieve-and-regenerate in the style of DRAD from Mitigating Entity-Level Hallucination in Large Language Models. This lets us ask whether a better trigger yields more factual text for the same number of retrieval calls.

Baselines

The naive reference is no detector at all. The base rate is the 15% entity hallucination rate HalluEntity reports, so a random detector's AUPRC is about 0.15.

The first real competitor is token likelihood and entropy at the entity level, the signal behind DRAD's real-time detection. This is the natural rival because it is equally cheap and training-free. We will run it with the same scoring model, the same span segmentation, and thresholds tuned on the same development split.

The strongest existing reference-free detector in the file is Focus. On Llama3-8B, HalluEntity reports an AUROC of 0.78 and AUPRC of 0.40 for Focus. Claim-Conditioned Probability and SAR, the other HalluEntity methods, will be rerun alongside it. To beat Focus, the name-swap score must reach a higher AUPRC than 0.40 on HalluEntity using the same Llama3-8B scorer, either alone or combined with Focus. The combination must also beat Focus on the high-confidence error subset.

DRAD's detector reportedly beat SelfCheckGPT variants on WikiBio GPT-3, but no reported result was found on Lacuna for its numerical scores. We will therefore reimplement it rather than quote a number.

The key ablations separate the ingredient that matters. Removing the name entirely tests whether a type cue is needed. Bare [PERSON] placeholders test whether a typed but nameless slot suffices. Random same-type names are the full method. Varying $K$ shows how many substitutes are needed. A further ablation swaps only the prompt name and leaves the prefix unchanged, to check that consistent substitution matters.

For mitigation, the baseline is DRAD's own entropy trigger at a matched number of retrieval calls. DRAD reports 1.40 calls per question on 2WikiMultihopQA, against 9.61 for multi-round retrieval. The success measure is FActScore on generated biographies at equal call budgets, using ChatGPT's reported 58.3% FActScore as context for the scale of improvement possible.

Why not just…?

Why not just threshold entity entropy, as DRAD does? HalluEntity reports that likelihood and entropy have poor precision, because true rare entities naturally have high entropy. DRAD itself notes that confidently wrong outputs escape detection. Name-swap scoring targets the second failure directly. The decisive test is the subset of hallucinated spans with above-median token probability. If entropy does as well as our score there, our hypothesis is wrong.

Why not just sample several generations and check consistency? This is the most serious threat. Sampling-based checks such as the SelfCheckGPT variants DRAD compares against are already strong. However, a type prior can be consistent: the model may give the same plausible birth decade every time. Sampling with the same name cannot distinguish "consistent because known" from "consistent because generic," and name-swapping can. We will run a sampling-consistency baseline with a matched number of forward passes. If it matches us on rare entities, we will report name-swapping as a cheaper equivalent rather than a better signal.

Why not just use context-aware decoding with the name masked? That would remove entity memory from the output, which is the opposite of what closed-book biography generation needs. CAD's own design targets the case of a retrieved document conflicting with memory. We include it in the mitigation comparison on FActScore biographies, and we expect it to lower factual precision for well-known entities.

Why not just retrieve for every entity? RADIANT (RADIANT) shows that models often fail to use retrieved text faithfully, and DRAD shows that retrieving for everything costs several times more calls. The relevant question is which trigger spends a fixed retrieval budget best. Our matched-budget comparison answers it.

Proposed Experiments

The main detection experiment runs on HalluEntity's 18,785 annotated entities. We report AUROC and AUPRC overall and broken down by entity type and by sentence position, to test HalluEntity's "end-of-sentence trap." Our prediction is that late-sentence numbers and dates, where the type prior dominates, show the largest gains.

A second experiment uses FActScore-style biographies grouped into frequency bins, scored with the automated FActScore pipeline, whose reported error rate against human experts is under 2%. We will also report WikiBio GPT-3 detection for comparison with DRAD.

The decisive checks are three. First, $\Delta$ must beat Focus and entropy on the high-confidence error subset. Second, the gain must grow as entities become rarer, consistent with the context trap. Third, typed random names must beat bare placeholders, which would replicate the Causal View finding in a new setting.

The negative check is the false-flag rate on type-typical true attributes. If most of our flags fall on correct generic facts, the score measures typicality rather than ignorance. In that case the typicality-corrected combined score becomes the actual contribution.

Finally, we report the black-box question-based variant on GPT-3.5 or a similar API against a sampling-consistency baseline, along with the matched-budget mitigation results on biographies and 2WikiMultihopQA.