Keep RAG citations verifiable with stable chunk IDs

In production RAG systems, evidence can become harder to trace as data moves through the pipeline, even when retrieval works well. A broad link to an entire document does not let readers verify which passage supports a specific claim. Each chunk should receive a when the data is first ingested, such as a combination of document hash, page number, and chunk position.

That ID should remain unchanged through every later step. The model should see short labels such as [1] and [2], while the application keeps the label-to-ID map for that request. If the model receives five chunks but cites [7], the application can immediately detect a .

A should serve as a , while the actual chunk text remains in a simple, dependable . This design can work across different stacks, including LangChain and Elasticsearch.

Key points

  • Create each chunk ID once when the source data is ingested.
  • Build IDs from stable values such as the document hash, page, and chunk position.
  • Show the model short labels and keep the real ID mapping inside the application.
  • Reject citations to labels that were not included in the model's request.
  • Use the as an index, not as the only home for the chunk text.
Read original