PageIndex RAG: Stop Paying Twice for Overlapping Evidence
说明与用途
文章讨论了 PageIndex RAG 中重复证据导致双重计费的问题。提供了一个 Python 脚本,用于去重页面、限制证据大小并生成稳定的提示前缀,从而防止双重计费并实现高效的提示缓存。
问题
Retrieving overlapping document sections causes duplicate evidence to be sent to the answer model, leading to double billing for identical content.
结果
The provided Python assembler deduplicates overlapping pages, enforces a 24,000-byte evidence budget, and outputs a deterministic prompt prefix. This prevents double billing for identical evidence and enables efficient prompt caching.
工作流
- 1. Ingest documents: fingerprint source, preserve page text, build the tree, and version artifacts.
- 2. Retrieve: authorize access, navigate the tree, and resolve selected nodes into source-page references.
- 3. Assemble evidence: deduplicate pages by (document_sha256, page) key, enforce an evidence budget, and construct a stable prompt prefix.
- 4. Cache the stable prefix: store the policy-and-evidence prefix separately from the changing question to enable prompt caching.
- 5. Generate answer: send the assembled prompt to the model, ensuring token limits are respected.
证据
You retrieve three relevant document sections. Two of them cite the same page. Your RAG pipeline concatenates all three and sends 18,000 tokens to the answer model.
If a parent section and one of its children both reference the same page, you need deduplication before inference—not after the bill arrives.
The assembler passed local checks for deterministic ordering, duplicate removal, conflicting page text, and budget rejection.
The 24,000-byte limit is an illustrative transport guard, not a token estimate.
- 记录日期: 2026-10-16T14:56:14.731Z