Short answer: build citation tracing into ingestion, not into the final prompt. Every chunk in the vector index should carry an immutable link to a specific listing revision, field, and character range; every generated claim should return those identifiers; and the serving layer should verify that the cited revision is still eligible to display.
The first architecture question is cost, because citation quality depends on what the system can afford to retain. The bill is made of parsing and embedding work, vector-index storage, retrieval queries, source snapshots, and observability data. For a listing corpus with frequent edits, the dominant variable is often the number of retained chunk versions, not the size of the polished answer. A useful planning expression is:
monthly_bytes = listings * revisions_per_listing * chunks_per_revision * bytes_per_chunk
Suppose a capacity model uses 2 million listings, 3 retained revisions, 8 chunks per revision, and 4,096 bytes per chunk including text and metadata. That scenario produces about 196.6 GB before index overhead or replicas. These are illustrative inputs, not a benchmark. Replace all four with measurements from the actual feed before making a storage decision.
My default change is to keep vectors only for the active revision while storing compact source snapshots and lineage records for the citation window required by the product. That attacks the multiplying term without severing the evidence chain. The cost is real: once an old vector is gone, an engineer can reproduce the old source and chunk boundaries, but cannot replay the exact historical nearest-neighbor set unless the old index state was also retained.
Keep that loss explicit.
How should retrieval architecture trace citations in real-estate listing discovery?
Treat a citation as a data relationship, not a URL pasted onto prose. A listing page changes: price drops, status moves from active to pending, descriptions are corrected, and duplicate records are merged. A bare listing_id answers which logical property record was involved, but it does not answer which version supported a claim at retrieval time.
The smallest useful lineage tuple is listing_id, revision_id, field_name, start_offset, end_offset, and a content digest. Add ingested_at and the source's own update timestamp for investigation, but do not use timestamps as identity. Two workers can see the same update at different times. The digest catches content drift, while the revision identifier lets the application enforce display policy.
Chunk metadata should therefore survive the whole path:
| Layer | Required evidence | Failure it prevents |
|---|---|---|
| Ingestion | source revision, field, offsets, digest | losing the origin during chunking |
| Vector index | chunk ID plus lineage tuple | returning text with no stable provenance |
| Retrieval | score, query ID, retrieved-at time | hiding which evidence entered generation |
| Generation | claim-to-chunk mapping | attaching one source to an unsupported paragraph |
| Response | current eligibility and citation label | exposing stale or withdrawn inventory |
This architecture follows the basic retrieval-augmented generation split: retrieve external evidence, then condition generation on it. The original RAG paper establishes that broad pattern, but a production listing system still has to define its own provenance and freshness contract. Retrieval relevance alone cannot provide either one.
There is a subtle compliance lesson here from message delivery systems. Recording that an OTP was sent is not proof that a particular recipient received it, just as recording that a listing was retrieved is not proof that every sentence in an answer follows from it. The system needs a claim-level association. Otherwise one highly ranked chunk becomes a decorative citation for nearby claims about bedrooms, school districts, or availability that came from somewhere else.
Model the evidence before choosing chunk size
Start with fields, not token counts. A property description is narrative text and can tolerate paragraph chunks. Price, status, bedroom count, brokerage attribution, and availability are atomic claims. Combining those fields into one synthetic paragraph may improve textual recall, but it also makes the citation ambiguous: a character range in synthesized text no longer points cleanly to the source record.
A practical ingestion model creates two kinds of chunks. Field chunks hold one structured fact and its label. Narrative chunks preserve paragraph boundaries and offsets within the original description. Both receive deterministic identifiers derived from the source identity, revision, field, and range. Determinism matters during retries; a repeated delivery should update the same logical chunk rather than quietly doubling it.
Here is a minimal, storage-agnostic chunker. It deliberately avoids a tokenizer because citation offsets belong to the source string, while model-specific tokenization belongs later in the embedding adapter.
from dataclasses import dataclass
from hashlib import sha256
@dataclass(frozen=True)
class Chunk:
chunk_id: str
listing_id: str
revision_id: str
field_name: str
start_offset: int
end_offset: int
text: str
digest: str
def paragraph_chunks(listing_id: str, revision_id: str, description: str) -> list[Chunk]:
chunks: list[Chunk] = []
cursor = 0
for paragraph in description.split("\n\n"):
start = description.find(paragraph, cursor)
end = start + len(paragraph)
cursor = end
text = paragraph.strip()
if not text:
continue
digest = sha256(text.encode("utf-8")).hexdigest()
identity = f"{listing_id}:{revision_id}:description:{start}:{end}"
chunk_id = sha256(identity.encode("utf-8")).hexdigest()
chunks.append(
Chunk(
chunk_id=chunk_id,
listing_id=listing_id,
revision_id=revision_id,
field_name="description",
start_offset=start,
end_offset=end,
text=text,
digest=digest,
)
)
return chunks
There is an edge case in that example: strip() changes the visible text but the offsets still span the untrimmed paragraph. Pick one contract and test it. I prefer offsets that slice the stored source exactly, then a separate normalized string for embedding, because an investigator should be able to reproduce evidence with source[start:end]. Your mileage may vary if the upstream feed already canonicalizes whitespace, but the stored digest and displayed range must use the same stated convention.
Do not let chunk size become a global magic number. Evaluate it with listing-shaped queries: exact attributes, combinations such as “two bedrooms with parking,” and fuzzy lifestyle language. The winning size is the smallest unit that answers the query while leaving a citation a human can inspect. Larger chunks can carry more context, yet they also broaden the unsupported surface around a matched sentence.
Separate retrieval, claim support, and display eligibility
One score cannot do three jobs. Similarity ranking estimates relevance to a query. Claim support asks whether a retrieved span entails a proposed statement. Display eligibility asks whether the listing and its fields may still be shown under current business rules. Run those decisions as separate stages and record each result.
The request path can stay simple: normalize the query, retrieve candidate chunks, group them by listing revision, assemble an evidence packet, generate claims with chunk IDs, validate each claim-to-chunk link, and finally recheck listing eligibility. If a claim lacks support, omit it or render it as an explicit uncertainty without a citation. Don't “borrow” the nearest citation. A citation that looks plausible but does not support the sentence is worse than no citation because it gives the reader false confidence.
Freshness deserves the same discipline as deliverability. A queue can accept a message after the underlying consent state has changed; likewise, a vector search can return a revision after a listing has been withdrawn. Rechecking the authoritative status near response time closes that race. The index is a discovery structure, not the final authority for whether inventory can be displayed.
The catch is latency. Claim validation and a current-status lookup add work to the critical path. For browsing experiences that require extremely low response times, use deterministic result cards with direct field rendering and reserve generated summaries for a slower secondary view. For archival research, by contrast, current eligibility may be the wrong gate; retain dated snapshots and label them as historical instead of pretending they describe current availability.
Test the trace, not just the answer
An answer-quality test that ignores citations is incomplete. Build a fixture corpus where revisions differ by one material fact, duplicate descriptions refer to different properties, and a listing changes status between retrieval and rendering. Then assert the lineage chain mechanically.
At minimum, verify these invariants:
- every returned citation names a retrieved chunk;
- every chunk digest matches the exact stored evidence span;
- every cited revision belongs to the rendered listing;
- atomic claims such as price and bedroom count cite the corresponding field;
- withdrawn or otherwise ineligible listings do not pass the response-time policy;
- retrying the same revision produces the same chunk IDs.
The nasty case is cross-listing contamination. Similar developments reuse marketing copy, and near-duplicate text can rank above the correct property. A claim may be linguistically supported while belonging to the wrong listing. Tests must therefore check both semantic support and entity identity. I would also log query ID, candidate chunk IDs, chosen claim mappings, policy decision, and index version, with retention limits set deliberately. Full prompts and raw listing descriptions can carry more data than an incident review needs, so broad debug logging is not a free observability win.
Identity still wins.
Operational alerts should target broken invariants rather than subjective prose quality. Track the share of claims without valid chunk mappings, digest mismatches, stale-revision rejections, and citation links that cannot be resolved. I am not sure a universal threshold would be meaningful; traffic mix and feed cadence change the baseline. A short shadow run against your own update stream will establish a defensible threshold better than a borrowed percentage.
Choose retention by the question you must answer later
Retention is an incident-response decision disguised as a storage setting. If the team only needs to explain what evidence supports a current answer, keep active vectors, current source text, lineage metadata, and recent retrieval traces. If it must reconstruct what a user saw weeks earlier, retain immutable source revisions, policy versions, generation inputs, and output-to-claim mappings for that review window. Keeping the source without the policy version can still make the old decision impossible to explain.
Do not retain everything by reflex. Old raw descriptions, prompts, and traces expand access scope and make deletion obligations harder to execute. Define separate lifetimes for active index entries, source snapshots, and request traces; delete expired vectors and payloads; keep only the compact identifiers and audit facts that have a continuing purpose. The trade-off is that a sparse audit record can prove which revision was used but may not reproduce ranking behavior after the index or embedding configuration changes.
The decision rule is plain: optimize chunking for inspectable evidence, gate display against current state, and retain only enough history to answer the organization's stated audit question. Citation tracing works when a reader can move from claim to chunk to exact source revision without trusting the generator's memory.
Top comments (0)