Contents
What to cover
Sketch your own design first. A complete answer has these parts; the notes say what each should settle.
- Requirementscorpus size and churn; permission models of each source; latency target; acceptable error/abstention; data residency; who maintains connectors; languages
- Estimates
- API
- Data model
- Architectureconnectors with change capture and ACL sync; parsing/chunking with metadata; embeddings + lexical index (per-language handling); permission pre-filter at query time; query rewriting; hybrid retrieval; reranker; grounded generation with per-claim citations; citation verification/abstention; feedback capture; observability with per-request retrieval traces; offline eval set by department and language
- Deep divesa user loses access to a doc — how fast does the assistant stop citing it?; How do you evaluate retrieval with no labels at first?; What breaks if you remove the reranker?
- Trade-offsper-tenant index vs shared index with filters; freshness vs ingestion cost; reranker latency vs precision; long-context stuffing vs top-k; one multilingual embedder vs per-language
- EvaluationACLs enforced before generation and in every cache; retrieval and generation evaluated separately; concrete latency budget; deletion and revocation paths; rollout plan with a pilot group and feedback loop
Reference design
One way to answer it, part by part. Open a part once you have your own version of it.
Requirements
Functional
- Answer free-text questions in English, French and German, including cross-lingual ones (ask in French, cite an English page), with numbered citations that link to the exact passage.
- Multi-turn follow-ups; optional filters by source, space and date.
- Abstain (“I can’t find this in sources you can access”) rather than guess.
Assumptions to confirm
- Corpus and churn: ~2M Confluence pages, ~3M text-bearing Drive files, ~50M Slack threads (channels only, no DMs at launch), ~5M tickets. ~1% of documents change per day; Slack and tickets change by the minute.
- Permission models: Confluence space permissions plus inherited page restrictions; Drive per-file ACLs with groups, domain-wide and “anyone with the link” sharing; Slack channel membership; ticketing project roles. Group membership comes from the IdP via SCIM.
- Latency: first token p95 < 2 s, full answer p95 < 8 s.
- Error tolerance: a confident wrong answer with a citation is worse than abstaining. Target ≥ 95% claim-level faithfulness; accept 10–15% abstention at launch.
- Data residency: index, caches, traces and LLM inference stay in UK/EU regions; no training on company data.
- Connector ownership: a platform team owns connectors and their freshness SLOs; source admins own ACL correctness.
- Zero permission leaks is a hard constraint, not a metric to trade off.
Estimates
- Traffic: 50k users × 30% daily active × 5 questions = 75k questions/day. Spread over a ~10-hour UK/EU working window: 75k / 36,000 s ≈ 2 QPS average, ~8 QPS peak (4×).
- Chunks: Confluence 2M × 8 = 16M; Drive 3M × 12 = 36M; Slack 50M threads ≈ 50M; tickets 5M × 2 = 10M → ~110M chunks of ~400 tokens ≈ 44B tokens.
- Vector index: 110M × 1,024 dims × 1 byte (int8) ≈ 113 GB, plus ~15–30 GB for the HNSW graph (32–64 four-byte neighbour ids per vector at layer 0) → ~130–145 GB in memory, a handful of shards plus replicas. BM25 over 44B tokens ≈ 0.3–0.5 TB.
- Embedding: backfill 44B tokens ÷ an assumed ~50k tokens/s per GPU ≈ 880k GPU-seconds ≈ 245 GPU-hours (days on a few GPUs). Daily churn 1.1M chunks × 400 = 0.44B tokens ≈ 2.5 GPU-hours.
- Generation: 10 chunks × 400 + 1.5k system/history ≈ 5.5k input and 400 output tokens. 75k × 5.5k ≈ 410M input + 30M output tokens/day. At an assumed $3/M input and $15/M output: $1,230 + $450 ≈ $1.7k per working day, ~2 cents per question (~$37k/month).
- Rerank: 50 candidates × 8 QPS = 400 pairs/s at peak — one or two GPUs.
- Latency budget (p95): group expansion 50 ms, query rewrite 300 ms, filtered hybrid retrieval 150 ms, rerank 200 ms, LLM first token 800 ms → TTFT ≈ 1.5 s; 400 tokens at ~80 tokens/s adds ~5 s, streamed.
API
POST /v1/ask (Server-Sent Events)
{ "conversation_id": "c_9f2",
"question": "Quelle est la politique de congé parental ?",
"filters": {"sources": ["confluence", "drive"], "updated_after": "2025-01-01"} }
events:
status {"stage": "retrieving"}
token {"text": "..."}
citation {"n": 1, "doc_id", "title", "url", "snippet", "source", "updated_at", "verified": true}
final {"abstained": false, "trace_id": "t_81c", "latency_ms": 4210}
POST /v1/feedback {"trace_id", "rating": "up|down", "reason": "wrong|outdated|missing|leak", "comment"}
GET /v1/conversations/{id}
Internal contract every connector implements:
PUT /ingest/docs/{source}/{source_id} {blob_ref, mime, title, url, acl, version, updated_at}
PATCH /ingest/docs/{source}/{source_id}/acl {acl: {allow: [...], deny: [...]}, acl_version}
DELETE /ingest/docs/{source}/{source_id}
PUT /ingest/groups/{group_id} {members: [...], version}
Identity comes from SSO (OIDC) at the gateway; the client never sends a user id. ACL changes have their own endpoint so they never queue behind content re-embedding.
Data model
- Document: doc_id, source, source_id, url, title, lang, owner, version, content_hash, updated_at, deleted_at.
- Chunk: chunk_id, doc_id, text, section_path (heading breadcrumb, Slack thread, ticket field), lang, position, embedding (int8),
acl_tokens[], acl_version. ACLs are denormalised onto chunks as principal tokens (user:42,group:eng-fr,space:HR,domain:all) so the index filters natively. - Principal store: user → groups, transitively expanded from the IdP and source-native groups, versioned, cached per user for ≤ 60 s.
- ACL store: doc_id → allow/deny + acl_version; source of truth for the final pre-generation check.
- Conversation / Turn: question, rewritten queries, answer, citations.
- Trace: principal-set hash, retrieved ids and scores per stage, reranked ids, prompt and model versions, per-sentence verification verdicts, stage latencies, cost. Traces quote documents, so they inherit ACLs, stay in-region and expire after 30 days.
- Feedback and EvalItem (question, language, department, expected doc ids, reference answer, answerable flag).
Storage: OpenSearch or Vespa for the hybrid index with per-language analysers; Postgres for documents, ACLs and conversations; Kafka for change events; object storage for raw files.
Architecture
Flow · 4 stepsReference architecture: ingestion and query path
- Ingest Connectors stream change events to Kafka; parsing, chunking and embedding fill the index while the ACL updater patches acl_tokens and the ACL store.
- Expand and rewrite The orchestrator expands principals (user to groups, cached <= 60 s) and rewrites the question into a standalone query with EN/FR/DE variants and filters.
- Retrieve ACL-filtered hybrid retrieval (k = 100) feeds the cross-encoder rerank (top 8-10 + neighbours); the reranked set is re-checked against the ACL store.
- Generate and verify Grounded generation cites every sentence, the citation verifier keeps, drops or abstains, and the answer streams to the client with a trace.
Data
| Step | Title | What happens |
|---|---|---|
| 1 | Ingest | Connectors stream change events to Kafka; parsing, chunking and embedding fill the index while the ACL updater patches acl_tokens and the ACL store. |
| 2 | Expand and rewrite | The orchestrator expands principals (user to groups, cached <= 60 s) and rewrites the question into a standalone query with EN/FR/DE variants and filters. |
| 3 | Retrieve | ACL-filtered hybrid retrieval (k = 100) feeds the cross-encoder rerank (top 8-10 + neighbours); the reranked set is re-checked against the ACL store. |
| 4 | Generate and verify | Grounded generation cites every sentence, the citation verifier keeps, drops or abstains, and the answer streams to the client with a trace. |
Source: This page's text
| Box | Group | Detail |
|---|---|---|
| Sources | Ingestion | Confluence · Drive · Slack · Ticketing |
| Connectors | Ingestion | change capture + ACL sync |
| Kafka | Ingestion | doc-events | acl-events | group-events |
| Parse + chunk + embed | Ingestion | layout-aware · language detection |
| ACL updater | Ingestion | patch acl_tokens in place |
| Hybrid index | Memory | BM25 per language + HNSW + acl_tokens |
| ACL store | Memory | doc_id → allow/deny + acl_version |
| Orchestrator | Query | expand · rewrite · retrieve · rerank |
| Cross-encoder rerank | Query | top 8-10 + neighbour chunks |
| Grounded generation | Query | every sentence cites [n] |
| Citation verifier | Query | entailment per sentence |
| Client | Query | SSE · trace · feedback |
Source: This page's text
Sequence · 8 stepsLife of one question
- Ask The user asks; identity comes from SSO at the gateway.
- Expand and rewrite The orchestrator expands the user's principals and rewrites the query.
- Retrieve Hybrid retrieval runs with the ACL filter at k = 100.
- Rerank The cross-encoder reranker returns the top 8-10.
- Re-check The final set is re-checked against the ACL store.
- Generate The LLM produces a grounded answer citing every sentence.
- Verify The orchestrator verifies the citations itself.
- Stream The answer streams to the user over SSE.
Data
| Step | From | To | Message |
|---|---|---|---|
| 1 | User | Orchestrator | ask question |
| 2 | Orchestrator | Orchestrator | expand principals + rewrite |
| 3 | Orchestrator | Hybrid index | hybrid retrieval k=100 |
| 3 | Hybrid index | Orchestrator | candidates (reply) |
| 4 | Orchestrator | Reranker | candidates |
| 4 | Reranker | Orchestrator | top 8-10 (reply) |
| 5 | Orchestrator | ACL store | re-check final set |
| 5 | ACL store | Orchestrator | final set (reply) |
| 6 | Orchestrator | LLM | grounded answer |
| 6 | LLM | Orchestrator | answer (reply) |
| 7 | Orchestrator | Orchestrator | verify citations |
| 8 | Orchestrator | User | SSE answer |
Source: This page's text
Confluence Drive Slack Ticketing
| webhooks / change feeds + nightly full ACL crawl
v
Connectors ──► Kafka: doc-events | acl-events (priority) | group-events
v v
Parse + chunk (layout-aware, headings, ACL updater: patch acl_tokens
tables, language detection) in place + ACL store (no re-embed)
v
Multilingual embedder ──► Hybrid index: BM25 per language + HNSW + acl_tokens
User ─SSO─► Gateway ─► Orchestrator
1. expand principals (user → groups, cached ≤ 60 s)
2. rewrite query (small LLM): standalone question, EN/FR/DE variants, filters
3. hybrid retrieval WITH the ACL filter (k = 100) → reciprocal-rank fusion
4. cross-encoder rerank → top 8–10, expand to neighbouring chunks
5. re-check the final set against the ACL store
6. grounded generation: every sentence cites [n]
7. citation verifier (entailment per sentence) → keep / drop / abstain
─► SSE to client · trace → observability · feedback → eval store
Retrieval and answer caches key on (normalised query, principal-set hash, index version) and are purged on ACL version bumps. Per-request traces make every answer reproducible.
Deep dives
A user loses access — how fast do we stop citing it? Group removals flow from the IdP via SCIM into the principal store; expansion happens at query time with a ≤ 60 s cache, so revocation applies within a minute without touching the index. Per-document changes (unsharing a Drive file, restricting a page) arrive by webhook on the priority ACL topic and patch acl_tokens in place, target p99 < 5 minutes. Backstops: step 5 re-checks the cited set; caches are keyed by principal set; a nightly ACL crawl repairs missed webhooks. Canary documents are shared and unshared every 10 minutes while a probe user asks about them; any leak pages on-call.
Evaluating retrieval with no labels. Generate synthetic questions from sampled chunks per department and language (filtered for low word overlap with the source) to get known positives for recall@k. Judge pilot users’ real queries with an LLM relevance grader calibrated on ~300 SME labels, then have SMEs label ~50 hard queries per department. Citation clicks and reformulations are weak online signals.
Removing the reranker. Top-10 precision drops, so more distractors reach the LLM: more irrelevant citations, more abstention on answerable questions, and pressure to pass 30+ chunks, which raises cost and latency. Cross-lingual queries suffer most. Show it with an ablation on nDCG@10 and faithfulness.
Trade-offs
- Per-tenant index vs shared index with filters: one shared index with ACL filters gives better utilisation and one ranking stack. Risk: very selective filters degrade HNSW recall — use filter-aware HNSW and fall back to exact search when a user can see few documents. Keep legal and HR spaces in a separate index to limit blast radius.
- Freshness vs ingestion cost: ACLs within minutes, Slack and tickets near-real-time, Confluence and Drive content within 15 minutes; re-embed only chunks whose hash changed; very large files nightly.
- Reranker latency vs precision: ~200 ms for 50 pairs is the biggest single quality gain; skip it for navigational queries where BM25 top-1 is confident.
- Long-context stuffing vs top-k: stuffing 100k tokens costs ~20× per query, adds seconds and weakens per-claim attribution. Use top-k with neighbour expansion; reserve long context for “summarise this document” on one permitted document.
- One multilingual embedder vs per-language: one model enables cross-lingual retrieval in one index; per-language BM25 analysers (German compound splitting, French elision) keep lexical recall. Revisit only if a language trails by more than ~5 points on its slice.
Evaluation
- Security gates (must be zero): a permission-leak suite of synthetic users with known ACLs, run on every release and against every cache layer; revocation canaries in production.
- Retrieval offline: ~1,500 questions stratified by department × language × source; recall@50, nDCG@10, a cross-lingual slice.
- Generation offline, scored separately: claim-level faithfulness (each sentence entailed by its citation), citation precision and recall, correctness against references, abstention quality on an unanswerable slice.
- Latency: per-stage p50/p95 against the budget; TTFT p95 < 2 s.
- Deletion and revocation: deleted sources gone from index, caches and traces within 24 hours; revocation p99 < 5 minutes.
- Rollout: four-week pilot with two departments (~500 users, all three languages); weekly triage of thumbs-down and abstentions into fixes and new eval items; then expand department by department, A/B testing retrieval changes.
- Monitoring: thumbs-up rate, citation click-through, abstention rate per language, connector lag, ACL sync lag, verifier failure rate, cost per answer; alerts on lag SLO breaches.
What a strong design shows
- Treats permissions as correctness: ACL filter inside retrieval, re-check before generation, principal set in every cache key, and a revocation SLO verified by canaries.
- Evaluates retrieval and generation separately and has a credible plan for starting with no labels.
- Handles three languages concretely: one multilingual embedder, per-language lexical analysers, per-language eval slices.
- Gives a per-stage latency budget and a cost per answer, not just boxes.
- Runs connectors as an operational product: change capture, ACL events on a priority path, nightly reconciliation, deletion propagation.
- Rolls out through a pilot group whose failures become eval items.