DEV Community

Cover image for Source spans taught me that converted text without provenance is a quote you can't verify
InApp
InApp

Posted on Originally published at imapp.blogspot.com

Source spans taught me that converted text without provenance is a quote you can't verify

I've been shipping document-to-Markdown conversion for agents — PDF, DOCX, PPTX, XLSX, EPUB, HTML — and the lesson that keeps repeating is about source spans. When you flatten a 40-page contract into plain Markdown, every sentence becomes equally trustworthy-looking. There's no "this clause was on page 12, section 4.2" left. For RAG pipelines that's fine until an agent cites it, and then you're debugging a hallucination that started as a parsing decision.

What I learned building the converters: preserve what you can. Heading hierarchy maps cleanly to Markdown structure, tables survive as tables, but page numbers, cell coordinates, and slide numbers are exactly the spans that die first. I started keeping an optional provenance sidecar — original location metadata keyed to output chunks — so a retrieval hit can point back to "page 12" instead of just "somewhere in the doc." The agents consuming it stopped inventing citations because the citation slot was already filled with something true.

The second lesson: spans matter more the longer the document. A one-page memo can lose its provenance and nobody notices. A 300-page annual report cannot. The breakage mode isn't loud — it's an agent confidently answering from the wrong section, and every downstream answer inherits the error silently.

If you're shipping anything in this space, my advice is to treat location data as part of the output contract, not as decoration. Ask what an agent would need to verify a claim against the original, and keep that thread intact. The Markdown is the summary; the spans are the evidence.

Top comments (0)