Citations, Data Audit Trails, and Hallucinations
Ask the LLM to cite sources when it generates an output. Seems simple.
What happens when that LLM output is carried across to another LLM which is synthesising between multiple LLM outputs. This becomes difficult. There is a reason why referencing is such a pain in the ass in academic research.
Problem Statement: How to make the Synthesiser reliably:
- Identify the source(s) for each piece of information it includes in the summary.
- Transfer the correct citation marker(s) from the source probe(s) to the summary.
- Consolidate the source lists from multiple probes into one correct list for the summary, re-mapping markers if necessary to avoid clashes.
Challenges:
- Information Merging: When the synthesiser combines info from multiple probes (e.g. Probe A says revenue is $5m, Probe B says revenue is $5.1m) how does it cite the synthesised statement - revenue was around $5m-$5.1m? It needs to include both markers
- Paraphrasing: If the Synthesiser paraphrases significantly, it might lose the direct 1:1 mapping to the original cited sentence/number, making it harder for the LLM to know which marker to transfer
- Market collision and renumbering: Obvious but needs to be considered. If Probe A uses 1 for Source X but Probe B also uses 1 for Source Y, the Synthesiser must recognise this collision when using info from both. But it needs to consolidate the source list and potentially re-number or use global unique markers in its output. Or use the full source detail inside of < > and then we beautify afterwards. Hence unique IDs are better but require the LLMs to manage them well without hallucinating.
- Hallucinations/Omissions: LLMs might still invent markers, omit them, or assign them to the wrong source
Okay, so let's compare two approaches.
Proposal 1: "Ground-up Redesign, by o3" (Placeholder-Based)
- Core Philosophy: Treat citation management as a deterministic data handling problem, completely separate from the LLM's creative text generation task. The LLM never invents or manages citation IDs; it only copies opaque placeholders provided by the system.
- Mechanism:
- Python generates unique placeholders (
{{c0a9}}). - Placeholders are linked to source metadata in a structured JSON (
citationslist) accompanying the text. - The LLM is given text containing these placeholders and is expected to return text with the exact sameplaceholders.
- Crucially: A strict validation function runs after every LLM interaction, ensuring perfect synchrony between placeholders in the text and keys in the JSON list. Mismatches cause immediate failure/retry.
- Synthesis involves merging JSON lists, creating global placeholders (
{{g1}}), updating text, and re-validating. - Placeholders are converted to user-facing superscripts only as the very last rendering step.
- Python generates unique placeholders (
Proposal 2: "LLM-Powered Synthesis, by Gemini 2.5 pro" (Unique Textual Markers)
- Core Philosophy: Trust the LLM to handle citation generation and propagation as part of its narrative task, using unique textual markers (like
[DocA_p5]) to make it easier for the LLM than sequential superscripts. Add validation/correction layers to mitigate LLM errors. - Mechanism:
- Researcher LLM generates text and inline citation markers (
[ID]) and a## Sourcessection mapping markers to details. - Synthesiser LLM is prompted to combine texts, propagate the correct
[ID]markers, and generate a consolidated## Sourcessection. - A post-processing step parses the LLM's output (text and sources section), validates consistency between markers used and markers defined, and potentially attempts error correction.
- Optional final renumbering converts
[ID]markers to superscripts.
- Researcher LLM generates text and inline citation markers (
Why Proposal 1 was chosen:
- Reliable: Deterministic Python code for ID generation and mapping removes reliance on inconsistent LLM citation handling.
- Validation: Strict fail-fast checks after each LLM step immediately catches placeholder/JSON mis-matches and prevents downstream errors
- Separation of concerns: LLM focuses on generating text, citation management is handled by code
- LLM pitfalls: LLMs behave weirdly and have known difficulties with performing structured tasks like citation management
ABORT THE FUCKING MISSION - FUCKING HELL
Well that did not go as intended, a few hours and refactors later I realised never to do this fucking shit again. Simple is smooth, smooth is fast.