Towards Data Science
Read post

Loop Engineering for Cross-References: When RAG Answers ‘see Section 7.2’ Instead of the Actual Answer

Enterprise RAG pipelines often return incomplete answers when retrieved passages contain cross-references like 'see Section 7.2' instead of the actual data. This post presents a loop engineering pattern that resolves such references systematically: the generation schema is extended with `pending_references` and `answer_completeness` fields; when the LLM flags an unresolved reference, an orchestrator triggers a second pass that resolves the reference deterministically against relational tables (toc_df, object_registry) or via a small LLM call for ambiguous phrasings, then re-retrieves the target region and re-generates a complete answer. The approach deliberately keeps parsing and retrieval cheap by default (lazy reference extraction, top-1 retrieval) and expands only on typed signals from structured output, avoiding confidence-score heuristics. Four reference types are covered: section, table/figure, conditional clause, definitional, and external references.

    #rag#pydantic
Today•24m read time•From towardsdatascience.com
Post cover image
Table of contents
1. Where cross-references live in each brick2. The running example: “see Table 3 row (E)”3. First pass: the pipeline runs once4. The orchestrator reads the feedback and loops back5. Second pass: resolving references on demand6. Cheap defaults, signal-driven expansion7. Variations: the four kinds of cross-reference8. Conclusion9. Sources and further reading
8 Impressions
Towards Data Science's image
Towards Data Science

Towards Data Science is a community-powered publication that showcases work in data science, machine...

1.2K Followers

•

7.3K Upvotes

Would you recommend this post?

Copy link
WhatsApp
Facebook
X
New Squad
  • © 2026 Daily Dev Ltd.
  • Guidelines
  • Explore
  • Tags
  • Sources
  • Squads
  • Leaderboard