Short answer: use hybrid retrieval for a restaurant menu assistant, then write an append-only audit record for every candidate, score, and citation. Pure vector search is fine for a small, stable menu, but exact dish names, allergens, prices, and date windows are too important to leave to semantic similarity alone.
The data flow is simple: normalize each menu item into a versioned document, index both its text and exact fields, retrieve a broad set, rerank it, and let the answer generator cite only the returned versions. The audit log sits beside that path. It records what the guest asked, which menu snapshot was searched, the scores that won, and the citations shown. That makes a wrong answer diagnosable instead of mysterious.
How should a retrieval architecture handle restaurant menu assistant audit logs?
Treat an answer as an event with an evidence bundle, not as a string. A useful event has a request ID, tenant and restaurant IDs, a normalized query, the menu snapshot ID, retriever versions, candidate IDs, rank scores, policy decisions, model ID, latency, and the final citation IDs. Store the raw guest text separately when privacy policy requires redaction; the audit record can retain a hash and a short normalized form.
The snapshot is the anchor. Each menu import gets a monotonically increasing version and a content hash. A result points to menu_version=184, not merely to “Margherita pizza.” If an owner changes an allergen note at 09:42, a reviewer can still reconstruct what the assistant saw at 09:41. That one field also keeps incident response concrete: the support ticket, the retrieval trace, the generated citation, and the exported review packet all refer to the same immutable input. Without it, a re-index job can silently rewrite history while every dashboard still appears green. I keep the version in the cache key, the response metadata, and the audit row, even though that feels repetitive. The repetition is what makes a later comparison possible.
Keep it append-only.
Here is the core boundary in TypeScript. The search service returns evidence; the answer service is not allowed to invent a citation after the fact.
type MenuDoc = {
id: string;
version: number;
text: string;
fields: { name: string; priceCents?: number; allergens: string[] };
};
type Hit = MenuDoc & { lexicalScore: number; vectorScore: number };
type AuditEvent = {
requestId: string;
queryHash: string;
menuVersion: number;
retriever: { lexical: string; vector: string; reranker: string };
candidates: Array<{ id: string; lexicalScore: number; vectorScore: number }>;
citations: string[];
createdAt: string;
};
async function retrieve(query: string, menuVersion: number): Promise<Hit[]> {
const [lexical, vector] = await Promise.all([
lexicalSearch(query, { menuVersion, limit: 20 }),
vectorSearch(query, { menuVersion, limit: 20 }),
]);
const merged = reciprocalRankFuse(lexical, vector).slice(0, 12);
return rerankByGrounding(query, merged);
}
async function answer(query: string, menuVersion: number, requestId: string) {
const hits = await retrieve(query, menuVersion);
const citations = hits.slice(0, 5).map((hit) => `${hit.id}@${hit.version}`);
await appendAudit({
requestId,
queryHash: sha256(query),
menuVersion,
retriever: { lexical: "bm25-v1", vector: "embed-v3", reranker: "cross-v2" },
candidates: hits.map(({ id, lexicalScore, vectorScore }) => ({ id, lexicalScore, vectorScore })),
citations,
createdAt: new Date().toISOString(),
});
return generateGroundedAnswer(query, hits, citations);
}
The names above are interfaces, not a prescription for a particular search engine. Keep them behind your own boundary so an index migration does not change the audit schema. A failed retrieval should still produce an event with an empty candidate list and a reason such as no_evidence; that is an honest answer state, not a prompt for the model to guess.
Where does pure vector retrieval lose the plot?
Menus contain brittle tokens. “GF,” “no peanuts,” a $14.50 price, and “available Tuesday–Thursday” each have exact semantics. Embeddings help with “something spicy without dairy,” yet they can rank a descriptively similar dish above the item whose allergen field actually matches. Hybrid retrieval lets lexical constraints and structured filters do the safety-critical narrowing before semantic reranking.
There is a cost. Two indexes mean two freshness paths, two sets of metrics, and more tuning. Small restaurants with fewer than a few hundred stable items may reasonably start vector-only, provided they add exact post-filters for allergens, location, and service date. Stick with that simpler design when your query language is narrow and a human reviews every menu update.
I once assumed a citation ID was enough. It was not. A nightly import reused item IDs, so an audit screen linked to today’s text while the logged answer had come from yesterday’s menu. The support engineer could reproduce the question, but not the evidence: the item still existed, the ID still resolved, and the visible price looked plausible. We diffed the import payload, found that a replacement row had inherited the old identifier, and then replayed the request against the previous index build. The fix was boring: immutable versions plus a content hash, carried through cache keys and exports. Boring is good here. I’m not sure every team needs a full event-sourcing system, but every team needs enough immutable context to explain one citation.
A durable audit trail needs more than request logs
HTTP access logs answer “who called when?” They do not answer “why did this dish outrank that one?” Keep an append-only decision record with a retention policy, access controls, and a redaction job. OpenTelemetry trace IDs can connect the request, retrieval spans, and generation span, while the durable event remains queryable after trace sampling drops the span.
Record deterministic inputs: normalized query, filter set, menu version, index build IDs, and reranker configuration. Record outputs separately: candidate order, threshold decisions, selected evidence, and rendered citations. Never store a secret or an unredacted payment detail in the event. If the restaurant needs a regulatory export, generate it from these records rather than from model chat history.
A compact schema might look like this:
const audit = {
event: "retrieval.answer",
requestId: "req_01J...",
traceId: "4bf92f3577b34da6a3ce929d0e0e4736",
menuVersion: 184,
evidence: [{ id: "item_42", version: 184, rank: 1, score: 0.87 }],
decision: "answered_with_citations",
policy: { allergenFilter: "peanut-free", serviceDate: "2026-09-02" },
};
What should you test before shipping grounded citations?
Build a small, adversarial set from real menu edits: renamed dishes, duplicate names, changed prices, deleted items, allergen synonyms, and date-limited specials. For each query, assert that every cited ID exists in the selected snapshot, every hard filter is respected, and an empty evidence set produces a refusal or clarification. Measure recall for required items, citation precision, stale-version rate, and p95 latency separately; a single blended score hides the failure you need to fix.
Replay the audit events in CI. Given the same snapshot and configuration, candidate order should be stable within a documented tolerance. When an embedding model changes, compare old and new evidence bundles before promoting the index. Your mileage may vary across languages and highly seasonal menus; keep that uncertainty visible in the dashboard instead of turning it into a confidence number nobody can explain.
The operational checklist is short enough to remember: pin a menu version at request start, propagate one trace ID, write the audit event before returning the answer, sample payloads only after redaction, alert on stale-version and no-evidence rates, and rehearse an export-and-delete request. The architecture is doing its job when a manager can challenge one sentence and you can show the exact source, ranking inputs, and policy state that produced it.
Top comments (0)