Cookbook 06 · Build
Grounded Knowledge Assistant
A policy assistant you can measure: cited chunks, retrieval modes compared, calibration that lifts Recall@1, and low-confidence runs sent to review.
BuildCore120–180 min
What you build. A retrieval assistant over 11 company policies (5,100 words): a
policy-corpus bucket, a knowledge base policy-qa-kb built as two versions (1,400- and 500-character chunks), retrieval calibrated on 41 questions, and an installed knowledge_rag workflow bound to it. A top-1 similarity gate marks outside-the-corpus questions needs_review and a review queue receives them. Storage, chunking, embeddings and ranking are real; answer text and model-judged scores are simulated by default.
Surfaces: Object Store Knowledge Bases Prompts Workflows Cookbooks Observability Review Queues Evaluations
What you learn
- Upload 11 policies to the object store and build knowledge base version 1 (a queued job a worker runs): 11 sources, 27 chunks, 384-dimension vectors
- Ask in Dense, Hybrid and GraphRAG and check that the cited chunk holds the clause (
365 days) - Import 41 calibration questions and run Calibrate (Recall@k, nDCG@k), set a baseline and compare modes
- Build the tuned version 2 (69 chunks), Set active to switch versions and roll back
- Meet real build failures: no object store, no embedding libraries, an unreadable file (build completes with
failed_sources: 1), nothing readable (build fails) - Install the cookbook workflow, run it, and enqueue the low-confidence run in a Review Queue
Implementation flow
flowchart LR
C[("Bucket policy-corpus: 11 policies")] --> B1["Build KB v1: 27 chunks"]
B1 --> EX["Explore: dense, hybrid, GraphRAG"]
B1 --> CAL["Calibrate: 41 questions"]
CAL --> B2["Build v2: 69 chunks, auto-active"]
B2 --> ACT["Set active and rollback"]
B1 --> WF["Workflow: knowledge_query to Confidence"]
WF --> G{"Top-1 score gate 0.42"}
G -->|confident| OUT["Output with citations"]
G -->|needs_review| RQ[("Review Queue")]
RQ --> TR["Reviewer answer written back to trace"]Step-by-step UI only
Each step shows the exact navigation path, the fields to fill, the button to click, and a snapshot of the CALIBER screen you'll be on.
Agent resources › Object Store › Bucket browsercreates · bucket: policy-corpus (11 docs)Create the bucketpolicy-corpus(new-bucket field, +), open it, New folderpolicies, open the folder and Upload the eleven policy documents (not the READMEs).Fill innew-bucket-name policy-corpusFolder policiesUpload the 11 *.mdfiles inassets/dataset/sources/Click Create bucket, then UploadYou'll see: Eleven rowspolicies/<name>.md; the preview ofdata-retention-policy.mdshows the retention table withSecurity audit logs.Screen snapshotcaliber · Agent resources › Object Store › Bucket browserCreate bucket, then UploadAgent resources › Knowledge Bases › New knowledge basecreates · KB version v1Create new, bucketpolicy-corpus, tick thepoliciesfolder, name it, and under Advanced configuration choose Markdown Aware, MiniLM L6 v2, chunk size 1400, overlap 120. Create knowledge base.Fill inName policy-qa-kbSources folder policies(1 selected)Chunking strategy / size / overlap Markdown Aware / 1400 / 120 Embedding model MiniLM L6 v2 Click Create knowledge baseYou'll see: AKBR-…run goes queued, then completed; the header switcher readsv1 (active).Screen snapshotcaliber · Agent resources › Knowledge Bases › New knowledge baseCreate knowledge baseKnowledge Bases › policy-qa-kb › Explore › Chunkscreates · chunk + lineage checkOpen Explore › Chunks; search365 days; open the source filter.You'll see:data-retention-policy.md · chunk …in the results, all 11 documents in the source filter,Chunk count 27in the Version Summary.Screen snapshotcaliber · Knowledge Bases › policy-qa-kb › Explore › ChunksRead / inspect this surface — no form to fill.Knowledge Bases › policy-qa-kb › Explore › Querycreates · retrieval mode comparisonAsk the same question in Dense, Hybrid and GraphRAG.Fill inQuestion How long are security audit logs retained?Retrieval mode Dense, then Hybrid, then GraphRAG Click AskYou'll see: Citations reading[1] <file>.mdand, under Retrieved chunks, a chunk containing365 days, in every mode.Screen snapshotcaliber · Knowledge Bases › policy-qa-kb › Explore › QueryAskPrompt lifecycle › Prompts › New prompt › Calibrationcreates · test set: policy-qa-calibrationCreate the promptkb-answer(paste the body ofkb-answer.md), open its Calibration stage and uploadcalibration-questions.jsonlunder Upload calibration dataset aspolicy-qa-calibration.Fill inPrompt name kb-answerUpload calibration dataset calibration-questions.jsonl Dataset name policy-qa-calibrationClick Upload DatasetYou'll see:Uploaded 41 examples to policy-qa-calibration.and the set appears under Test Sets.Screen snapshotcaliber · Prompt lifecycle › Prompts › New prompt › CalibrationUpload DatasetKnowledge Bases › policy-qa-kb › Calibratecreates · calibration runs + baselineRun Dense, top-k 1, Set baseline, then run Hybrid, top-k 1.Fill inTest set policy-qa-calibrationRetrieval mode / Top-k Dense / 1, then Hybrid / 1 Click Run calibrationYou'll see: Recall@k 88% and nDCG@k 90% (Faithfulness and Answer correctness—on the simulated stack, the judges need a model; with a real provider they are percentages, e.g. 96% and 71%); after Hybrid, Recall@k 93% and Vs. baseline +5% on Recall@k and nDCG@k.Screen snapshotcaliber · Knowledge Bases › policy-qa-kb › CalibrateRun calibrationKnowledge Bases › policy-qa-kb › Build › New versioncreates · KB version v2New version, tick thepoliciesfolder, Advanced configuration: Markdown Aware, MiniLM, chunk size 500, overlap 60.Fill inChunk size / Overlap 500 / 60 Click Create version of policy-qa-kbYou'll see: A second run completes and the switcher showsv2 (active): a finished build activates itself.Screen snapshotcaliber · Knowledge Bases › policy-qa-kb › Build › New versionCreate version of policy-qa-kbKnowledge Bases › policy-qa-kb (version switcher)creates · activate / rollbackChoosev1and click Set active; thenv2and Set active again.Click Set activeYou'll see:v1 (active), thenv2 (active). The rollback route has no button; Set active on the earlier version is the UI's rollback.Screen snapshotcaliber · Knowledge Bases › policy-qa-kb (version switcher)Set activeGet started › Cookbookscreates · workflow: installed draftInstall Grounded Knowledge Assistant: Install, name it, acknowledge the prerequisite, confirm.Fill inName cookbook-06-kb-assistantClick InstallYou'll see: The Workflow Studio opens on a paused draft with a Knowledge Query node, a Confidence node and an Output.Screen snapshotcaliber · Get started › CookbooksInstallAgent resources › Workflows › Studiocreates · workflow runSelect the knowledge node, set Knowledge base topolicy-qa-kband Top-K 3, Save, Validate; from the workflow page click Resume, then Open editor › Run Monitor, enter the question and Run.Fill inKnowledge base policy-qa-kbTop-K 3 Run input How long are security audit logs retained?Click RunYou'll see:Valid.; runcompleted; the Output holds[1] data-retention-policy.mdand365 days.Screen snapshotcaliber · Agent resources › Workflows › StudioRunOperate › Observability, then Operate › Review Queuescreates · review queue: policy-qa-reviewCopy the newest trace's id from the address bar (?trace=tr-…). + New Queuepolicy-qa-reviewwith the questiondecision_justified; open it, paste the trace id into Trace ids, Enqueue, answer Pass, Submit review.Fill inName policy-qa-reviewQuestion key decision_justifiedTrace ids the run's trace id Click Submit reviewYou'll see: The item iscompletedand readsReviewed by admin · wrote 1 assessment(s) back to the trace.Screen snapshotcaliber · Operate › Observability, then Operate › Review QueuesSubmit review
Assets (copy-paste)
The exact files this cookbook uses — copy each into the matching field. Source: docs-site/cookbooks/06-knowledge-retrieval-policy-qa-lab/assets/.
{"id": "C01", "tags": ["answer", "effective-date"], "input": {"question": "A customer was charged on 12 February 2026. How many days do they have to request a refund?"}, "expected": {"sources": ["refund-policy.md"], "answer": "A charge made before 1 March 2026 stays under the 14-day window of version 3.1.", "evidence": "remains subject to the 14-day window of version 3.1"}}
{"id": "C02", "tags": ["answer"], "input": {"question": "Where in the Billing portal do I find the Request refund button?"}, "expected": {"sources": ["refund-policy.md"], "answer": "Open Account > Billing > Charges, select the charge and choose Request refund.", "evidence": "Open Account > Billing > Charges"}}
{"id": "C03", "tags": ["answer"], "input": {"question": "Are one-time setup fees refundable?"}, "expected": {"sources": ["refund-policy.md"], "answer": "No. One-time setup fees are non-refundable in every case.", "evidence": "One-time setup fee | No | None | Non-refundable in every case"}}
{"id": "C04", "tags": ["answer"], "input": {"question": "How long does an approved refund take to reach the original payment method?"}, "expected": {"sources": ["refund-policy.md"], "answer": "Approved refunds are returned to the original payment method within 5 to 10 business days.", "evidence": "within 5 to 10 business days"}}
{"id": "C05", "tags": ["answer"], "input": {"question": "Who has to approve a refund of more than $5,000?"}, "expected": {"sources": ["refund-policy.md"], "answer": "A Finance Operations manager must approve it, which adds up to 3 business days.", "evidence": "A refund above $5,000 needs approval from a Finance Operations manager"}}
{"id": "C06", "tags": ["answer"], "input": {"question": "A customer was charged twice for the same invoice. How long do they have to report the error?"}, "expected": {"sources": ["refund-policy.md"], "answer": "They must report the error within 90 days of the charge.", "evidence": "report the error within 90 days of the charge"}}
{"id": "C07", "tags": ["answer"], "input": {"question": "How are refunds for add-on seats paid out?"}, "expected": {"sources": ["refund-policy.md"], "answer": "As a pro-rated account credit for the unused days, not to the card.", "evidence": "Pro-rated credit for unused days"}}
{"id": "C08", "tags": ["answer"], "input": {"question": "Is multi-factor authentication required for a customer account that can change billing details?"}, "expected": {"sources": ["information-security-policy.md"], "answer": "Yes. MFA is required for any customer account that can change billing details or access customer data.", "evidence": "MFA is also required for every customer account that holds an administrator role"}}
{"id": "C09", "tags": ["answer"], "input": {"question": "What is the minimum password length?"}, "expected": {"sources": ["information-security-policy.md"], "answer": "Passwords must be at least 14 characters long.", "evidence": "Passwords must be at least 14 characters long"}}
{"id": "C10", "tags": ["answer", "trap"], "input": {"question": "Within how many hours must someone report a suspected security incident?"}, "expected": {"sources": ["information-security-policy.md"], "answer": "Within 24 hours of becoming aware, without waiting to confirm the suspicion.", "evidence": "report it to security@caliber.example within 24 hours"}}
{"id": "C11", "tags": ["answer"], "input": {"question": "How quickly must a critical vulnerability be fixed?"}, "expected": {"sources": ["information-security-policy.md"], "answer": "Critical findings must be fixed within 7 days of confirmation.", "evidence": "| Critical | 7 days |"}}
{"id": "C12", "tags": ["answer"], "input": {"question": "How long can production access be granted for?"}, "expected": {"sources": ["information-security-policy.md"], "answer": "At most 8 hours, granted just in time and logged.", "evidence": "Production access is granted just in time, for at most 8 hours"}}
{"id": "C13", "tags": ["answer"], "input": {"question": "What encryption protects customer data at rest?"}, "expected": {"sources": ["information-security-policy.md"], "answer": "Customer data at rest is encrypted with AES-256.", "evidence": "Customer data at rest is encrypted with AES-256"}}
{"id": "C14", "tags": ["answer", "trap"], "input": {"question": "How soon are customers told about a confirmed incident that affects their data?"}, "expected": {"sources": ["information-security-policy.md"], "answer": "Affected customers are notified within 72 hours of confirmation.", "evidence": "notifies affected customers within 72 hours of confirmation"}}
{"id": "C15", "tags": ["answer", "table"], "input": {"question": "How long are security audit logs retained?"}, "expected": {"sources": ["data-retention-policy.md"], "answer": "Security audit logs are kept for 365 days and then automatically purged.", "evidence": "| Security audit logs | 365 days |"}}
{"id": "C16", "tags": ["answer", "table", "trap"], "input": {"question": "How long are application logs kept?"}, "expected": {"sources": ["data-retention-policy.md"], "answer": "Application logs are kept for 90 days.", "evidence": "| Application logs | 90 days |"}}
{"id": "C17", "tags": ["answer", "table"], "input": {"question": "How long are authentication logs retained?"}, "expected": {"sources": ["data-retention-policy.md"], "answer": "Authentication (access) logs are kept for 180 days.", "evidence": "| Authentication (access) logs | 180 days |"}}
{"id": "C18", "tags": ["answer", "table"], "input": {"question": "How long are encrypted backups kept?"}, "expected": {"sources": ["data-retention-policy.md"], "answer": "Encrypted backups are kept on a rolling 35-day basis and then overwritten.", "evidence": "| Encrypted backups | 35 days, rolling |"}}
{"id": "C19", "tags": ["answer", "trap"], "input": {"question": "After a customer closes their account, within how many days is their content deleted?"}, "expected": {"sources": ["data-retention-policy.md"], "answer": "Within 30 days of the account being closed.", "evidence": "the customer's content is deleted within 30 days"}}
{"id": "C20", "tags": ["answer", "table"], "input": {"question": "How long are billing and invoice records kept?"}, "expected": {"sources": ["data-retention-policy.md"], "answer": "Billing and invoice records are kept for 7 years from the invoice date.", "evidence": "| Billing and invoice records | 7 years |"}}
{"id": "C21", "tags": ["answer"], "input": {"question": "What suspends the automatic purges for data that is relevant to litigation?"}, "expected": {"sources": ["data-retention-policy.md"], "answer": "A legal hold placed by Legal suspends every deletion until Legal lifts it in writing.", "evidence": "A legal hold suspends every deletion in this policy"}}
{"id": "C22", "tags": ["answer", "trap"], "input": {"question": "How many days does the Privacy Office have to respond to a verified access request?"}, "expected": {"sources": ["privacy-requests-policy.md"], "answer": "Within 30 calendar days of receiving the request.", "evidence": "responds to a verified request within 30 calendar days"}}
{"id": "C23", "tags": ["answer"], "input": {"question": "By how much can the response deadline be extended for a complex privacy request?"}, "expected": {"sources": ["privacy-requests-policy.md"], "answer": "By up to 60 further days, and the requester must be told within the first 30 days.", "evidence": "extended by up to 60 further days"}}
{"id": "C24", "tags": ["answer"], "input": {"question": "How many PTO days a year does an employee with 6 years of service accrue?"}, "expected": {"sources": ["leave-and-time-off-policy.md"], "answer": "25 days a year.", "evidence": "employees with 5 or more years of service receive 25 days a year"}}
{"id": "C25", "tags": ["answer"], "input": {"question": "How many PTO days can be carried over to the next year, and by when must they be used?"}, "expected": {"sources": ["leave-and-time-off-policy.md"], "answer": "At most 5 days, which must be used by 31 March or they expire.", "evidence": "carry over at most 5 days"}}
{"id": "C26", "tags": ["answer", "effective-date"], "input": {"question": "How many weeks of paid leave does a primary caregiver get for a child born in March 2026?"}, "expected": {"sources": ["leave-and-time-off-policy.md"], "answer": "16 weeks at full pay; the earlier 12 weeks applies only to children born or placed before 1 January 2026.", "evidence": "| Primary caregiver | 16 weeks at full pay |"}}
{"id": "C27", "tags": ["answer"], "input": {"question": "After how many consecutive sick days is a medical certificate required?"}, "expected": {"sources": ["leave-and-time-off-policy.md"], "answer": "After 3 consecutive days of sickness.", "evidence": "A medical certificate is required after 3 consecutive days of sickness"}}
{"id": "C28", "tags": ["answer"], "input": {"question": "How many days a week must a hybrid employee who lives near an office work from it?"}, "expected": {"sources": ["remote-work-policy.md"], "answer": "At least 2 days a week.", "evidence": "at least 2 days a week"}}
{"id": "C29", "tags": ["answer"], "input": {"question": "How much is the one-time home-office stipend, and when can I claim it?"}, "expected": {"sources": ["remote-work-policy.md"], "answer": "$600, paid once, after 90 days of employment.", "evidence": "| Home-office stipend | $600, paid once | After 90 days of employment |"}}
{"id": "C30", "tags": ["answer"], "input": {"question": "How many working days a year may I work from another country?"}, "expected": {"sources": ["remote-work-policy.md"], "answer": "Up to 20 working days per calendar year, with manager approval at least 30 days ahead.", "evidence": "up to 20 working days per calendar year"}}
{"id": "C31", "tags": ["answer", "effective-date"], "input": {"question": "What is the hotel limit per night for a trip that starts in August 2026?"}, "expected": {"sources": ["travel-and-expense-policy.md"], "answer": "$220 per night ($300 in tier 1 cities); the earlier $180 limit applied only to travel before 1 July 2026.", "evidence": "| Hotel | $220 per night |"}}
{"id": "C32", "tags": ["answer"], "input": {"question": "Above what amount does a single expense need a receipt?"}, "expected": {"sources": ["travel-and-expense-policy.md"], "answer": "Any single expense over $25, except meal per diems.", "evidence": "A receipt is required for any single expense over $25"}}
{"id": "C33", "tags": ["answer"], "input": {"question": "Who must approve a business class flight before it is booked?"}, "expected": {"sources": ["travel-and-expense-policy.md"], "answer": "A Vice President.", "evidence": "Business class needs approval from a Vice President"}}
{"id": "C34", "tags": ["answer", "table"], "input": {"question": "Who may sign a contract with an annual value of $150,000?"}, "expected": {"sources": ["vendor-procurement-policy.md"], "answer": "The Chief Financial Officer.", "evidence": "| Above $100,000, up to $500,000 | Chief Financial Officer |"}}
{"id": "C35", "tags": ["answer"], "input": {"question": "How many competing quotes does a $40,000 purchase need?"}, "expected": {"sources": ["vendor-procurement-policy.md"], "answer": "At least three competing quotes, unless the Director of Finance Operations approves a single-source purchase in writing.", "evidence": "needs at least three competing quotes"}}
{"id": "C36", "tags": ["answer", "trap"], "input": {"question": "How quickly must I report a lost or stolen laptop?"}, "expected": {"sources": ["acceptable-use-and-device-policy.md"], "answer": "Within 4 hours of discovering the loss, to the IT Service Desk; no second security report is needed.", "evidence": "within 4 hours of discovering the loss"}}
{"id": "C37", "tags": ["answer"], "input": {"question": "How often are company laptops replaced?"}, "expected": {"sources": ["acceptable-use-and-device-policy.md"], "answer": "On a 36-month refresh cycle, or earlier if faulty.", "evidence": "36-month refresh cycle"}}
{"id": "C38", "tags": ["answer", "table"… truncated — open the file in the repo for the full content.
Evaluation & quality gates
| Quality gate | Target |
|---|---|
| Version 1 build | completed, 11 sources, 27 chunks, active |
| Clause's chunk in the top 3 (hybrid) | 41/41 (dense 40/41, graph_hybrid 35/41) |
| Score gate 0.42 | refuses all 5 questions outside the corpus; cannot refuse the 2 trap questions |
| Calibration at top_k = 1, dense to hybrid | Recall@1 0.878 to 0.9268, nDCG@1 0.9024 to 0.9512 |
| Version 2 and workflow review | 69 chunks, rollback works; only the 0.25-confidence run is enqueued for review |
Developer notes & gotchas
- Flag.
CALIBER_FEATURE_COOKBOOKS=trueand nothing else (no Aria, no integrations). Knowledge needs more than the base install: an S3-compatible store, theknowledge-localextra (from a checkout:caliber/.venv/bin/pip install -e "caliber[knowledge,knowledge-local]") and theall-MiniLM-L6-v2model (about 90 MB). Start withHF_HUB_OFFLINE=1 scripts/cookbook-env.sh up lab06 --flags cookbooks --s3. - Real: object store, queue and worker, chunking, embeddings, ranking, Recall@k, nDCG@k, the score gate, activation and rollback. Simulated (default
fakeLLM/eval providers): answer text is an extractive digest, Faithfulness and Answer-correctness are blank (—), and Evaluations refuses scoring with400 evaluation requires a real LLM provider. - No decision is produced on a simulated stack. The
kb-answerprompt and theCitationFaithfulnessjudge are stored for real, but answer, abstain or clarify and the 0.90 faithfulness target need a real model. The lab verifies the evidence (both conflicting refund documents are retrieved together) and what retrieval alone can refuse. - The gate has a limit. 0.42 is tuned on this question set. It cannot refuse the 2 trap questions (Enterprise terms), whose policy exists but whose clause does not (scores 0.56 and 0.66); that needs a model and the review queue. Re-derive the gate from your own scores.
- Retrieval always returns chunks. The dress-code question still returns nearest chunks; refusing is a decision on top.
graph_hybridis worse here (35/41), and hybrid helps the 1,400-character chunks but hurts the 500-character ones, which is why you calibrate. - Build behavior. A finished build activates itself, even with an unreadable file, so read
failed_sources. AGE retrieval is not used (pgvector and Apache AGE are off). The first build can sitqueuedfor minutes withoutHF_HUB_OFFLINE=1. - Runnable.
sdk/caliber-sdk/examples/cookbooks/cookbook_06_grounded_knowledge_assistant.py(about a minute, 51 ok lines) andcaliber/caliber-ui/e2e/cookbooks/labs/06-knowledge-retrieval.spec.ts; environment:scripts/cookbook-env.sh up lab06.