Mental model
An interactive citation is a typed relationship between a response claim and one or more source records, not a decorative footnote appended to an entire answer. Preserve the claim identity, response revision, source identifier, and source version together. The interface can then show which evidence was attached, let users inspect it, and avoid presenting an unresolved or unrelated link as verification.
Build the claim-to-source map
The source of truth should be a structured response model. A claim has a stable identifier within a response revision, the text range it covers, and a list of source identifiers. Each source identifier resolves through a registry containing a human-readable title, canonical URL, publisher, and version or retrieval date. The registry is the place to repair a moved URL; the response record should keep the source identity that was used when the answer was produced.
Streaming complicates text ranges. A token delta can end halfway through a sentence, a Markdown link, or a citation payload. Do not attach a citation by searching each incoming fragment for a marker string. Consume typed protocol events, accumulate the answer for the active response ID, and finalize claim boundaries against the normalized text for that revision. If a provider emits citation parts, retain their offsets and source metadata as typed fields. If the application extracts claims itself, give those claims IDs and validate that every range refers to the same response revision.
JavaScript string offsets use UTF-16 code units. A server that stores Unicode scalar offsets or byte offsets must convert explicitly before the browser highlights a range. Better still, store claim IDs and a stable text hash next to the range, so an edit or regenerated answer cannot silently reuse stale offsets. When the hash differs, hide the old inline marker and ask the renderer to recompute or mark the reference as needing review.
Render evidence without overstating it
An inline marker should open a short source card with the source title, publisher, publication or retrieval date, and a direct link. A separate bibliography or side panel works better when one claim has several sources or when the answer is long. Use normal links or buttons with accessible names; a hover-only tooltip leaves keyboard and touch users without the evidence. Keep keyboard focus on the marker while its detail panel is open, and return focus to that marker when the panel closes.
The displayed relation must remain narrow. A source attached to one sentence does not automatically support the next paragraph, and the presence of a primary-source link does not mean anyone checked whether the document entails the claim. Use wording such as “Source for this claim” rather than “Verified.” If the source cannot be resolved, preserve its recorded title and show an unavailable status instead of silently deleting the reference. That lets the reader distinguish a broken destination from missing provenance.
If the interface lets a user report a mismatch, store that report against the claim ID and response revision. Do not turn a click or an open event into a factuality label. A reviewer can inspect the claim and the cited passage later; telemetry should record the evidence identity needed for that review, without logging more answer text than the product needs.
Theory
Coverage can help an editorial review find claims that have no attached source. Assign each reviewable claim a risk weight in review points and set only when at least one source is attached to that claim and resolves to a registry record. The score is dimensionless because the same review-point unit appears in numerator and denominator:
For five claims weighted 2, 2, 1, 3, and 2 review points, suppose four claims have a resolvable source. If the unsupported claim carries 2 points, then , or 80%. This says that 80% of the assigned review weight has a linkable source. It says nothing about whether the linked documents actually support the claims. Entailment review and source quality remain separate checks.
Failure modes and misconceptions
| Design choice | Failure to watch for | Production response |
|---|---|---|
| Citation offsets in streamed text | A later delta or Unicode conversion shifts the highlighted span | Bind ranges to a response revision and text hash; invalidate on mismatch |
| One citation for a full answer | A source supports one claim but appears to support unrelated claims | Store claim-level relations and render each marker beside its own claim |
| Hover-only source details | Keyboard, screen-reader, and touch users cannot inspect the evidence | Use a focusable link or button with a stable accessible label |
| Link opens a copied URL | Redirects, unsafe schemes, or a moved document obscure provenance | Resolve canonical HTTPS URLs from the source registry and retain publisher metadata |
Inline markers add visual density, while a side panel costs a navigation step. Choose based on answer length and the number of citations per claim. Keep the citation list available in a predictable place and avoid adding an announcement for every streamed token; announce the finalized answer or a concise citation status instead.
Trade-offs
Inline footnotes make evidence easy to discover beside a claim, but multiple markers can fragment a short response and compete with reading flow. A source drawer keeps long bibliographies together, at the cost of an extra interaction and more state to manage on mobile. Pick one default based on citation density, then keep the same source order and keyboard behavior across answers. If a product uses a “verified” label, it needs a separate review record that captures who checked entailment and when; an accessible link alone cannot earn that label.
Decision scenario
A response revision finishes with three factual claims. Its typed source event identifies two sources, but text normalization moved the second claim's range and its stored hash no longer matches. Keep the valid source relation on the first claim. For the second, preserve the source identifier but mark the range as needing review; do not display a badge that implies the source supports the shifted text. Recompute the range against the final revision or leave the claim unlinked until a reviewer confirms the relationship.
Learning outcomes
- Model citations as claim-level relations tied to one response revision.
- Compute weighted attachment coverage and explain why it does not measure factual correctness.
- Design an accessible source card that preserves publisher and unresolved-source status.
Implementation
The renderer should create DOM nodes from trusted metadata and use textContent for labels. It should not concatenate model text into HTML or infer a trusted destination from a visible label.
typescripttype SourceRecord = {id: string;title: string;publisher: string;url: string;revision: string;};type ClaimCitation = {claimId: string;responseRevision: number;sourceIds: string[];};export function appendClaimSources(list: HTMLUListElement,relation: ClaimCitation,sources: Map<string, SourceRecord>,currentRevision: number,): void {list.replaceChildren();if (relation.responseRevision !== currentRevision) {list.setAttribute("aria-label", "Sources need review for this response revision");return;}for (const sourceId of relation.sourceIds) {const source = sources.get(sourceId);const item = document.createElement("li");if (!source) {item.textContent = "Recorded source is unavailable";list.append(item);continue;}const linkUrl = new URL(source.url);if (linkUrl.protocol !== "https:") continue;const link = document.createElement("a");link.href = linkUrl.href;link.textContent = source.title;link.setAttribute("aria-label", "Source: " + source.title + ", published by " + source.publisher);link.rel = "noopener noreferrer";link.target = "_blank";item.append(link);list.append(item);}}