CALIBER
Quickstart

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.

  1. Agent resources › Object Store › Bucket browser creates · bucket: policy-corpus (11 docs)
    Create the bucket policy-corpus (new-bucket field, +), open it, New folder policies, open the folder and Upload the eleven policy documents (not the READMEs).
    Fill in
    new-bucket-namepolicy-corpus
    Folderpolicies
    Uploadthe 11 *.md files in assets/dataset/sources/
    Click Create bucket, then Upload
    You'll see: Eleven rows policies/<name>.md; the preview of data-retention-policy.md shows the retention table with Security audit logs.
    Screen snapshot
    caliber · Agent resources › Object Store › Bucket browser
    Object StoreBucket browser
    Create bucket, then Upload
  2. Agent resources › Knowledge Bases › New knowledge base creates · KB version v1
    Create new, bucket policy-corpus, tick the policies folder, name it, and under Advanced configuration choose Markdown Aware, MiniLM L6 v2, chunk size 1400, overlap 120. Create knowledge base.
    Fill in
    Namepolicy-qa-kb
    Sourcesfolder policies (1 selected)
    Chunking strategy / size / overlapMarkdown Aware / 1400 / 120
    Embedding modelMiniLM L6 v2
    Click Create knowledge base
    You'll see: A KBR-… run goes queued, then completed; the header switcher reads v1 (active).
    Screen snapshot
    caliber · Agent resources › Knowledge Bases › New knowledge base
    Knowledge BasesNew knowledge base
    Create knowledge base
  3. Knowledge Bases › policy-qa-kb › Explore › Chunks creates · chunk + lineage check
    Open Explore › Chunks; search 365 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 27 in the Version Summary.
    Screen snapshot
    caliber · Knowledge Bases › policy-qa-kb › Explore › Chunks
    Knowledge BasesChunks
    Read / inspect this surface — no form to fill.
  4. Knowledge Bases › policy-qa-kb › Explore › Query creates · retrieval mode comparison
    Ask the same question in Dense, Hybrid and GraphRAG.
    Fill in
    QuestionHow long are security audit logs retained?
    Retrieval modeDense, then Hybrid, then GraphRAG
    Click Ask
    You'll see: Citations reading [1] <file>.md and, under Retrieved chunks, a chunk containing 365 days, in every mode.
    Screen snapshot
    caliber · Knowledge Bases › policy-qa-kb › Explore › Query
    Knowledge BasesQuery
    Ask
  5. Prompt lifecycle › Prompts › New prompt › Calibration creates · test set: policy-qa-calibration
    Create the prompt kb-answer (paste the body of kb-answer.md), open its Calibration stage and upload calibration-questions.jsonl under Upload calibration dataset as policy-qa-calibration.
    Fill in
    Prompt namekb-answer
    Upload calibration datasetcalibration-questions.jsonl
    Dataset namepolicy-qa-calibration
    Click Upload Dataset
    You'll see: Uploaded 41 examples to policy-qa-calibration. and the set appears under Test Sets.
    Screen snapshot
    caliber · Prompt lifecycle › Prompts › New prompt › Calibration
    PromptsCalibration
    Upload Dataset
  6. Knowledge Bases › policy-qa-kb › Calibrate creates · calibration runs + baseline
    Run Dense, top-k 1, Set baseline, then run Hybrid, top-k 1.
    Fill in
    Test setpolicy-qa-calibration
    Retrieval mode / Top-kDense / 1, then Hybrid / 1
    Click Run calibration
    You'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 snapshot
    caliber · Knowledge Bases › policy-qa-kb › Calibrate
    Knowledge BasesCalibrate
    Run calibration
  7. Knowledge Bases › policy-qa-kb › Build › New version creates · KB version v2
    New version, tick the policies folder, Advanced configuration: Markdown Aware, MiniLM, chunk size 500, overlap 60.
    Fill in
    Chunk size / Overlap500 / 60
    Click Create version of policy-qa-kb
    You'll see: A second run completes and the switcher shows v2 (active): a finished build activates itself.
    Screen snapshot
    caliber · Knowledge Bases › policy-qa-kb › Build › New version
    Knowledge BasesNew version
    Create version of policy-qa-kb
  8. Knowledge Bases › policy-qa-kb (version switcher) creates · activate / rollback
    Choose v1 and click Set active; then v2 and Set active again.
    Click Set active
    You'll see: v1 (active), then v2 (active). The rollback route has no button; Set active on the earlier version is the UI's rollback.
    Screen snapshot
    caliber · Knowledge Bases › policy-qa-kb (version switcher)
    Knowledge Basespolicy-qa-kb (version switcher)
    Set active
  9. Get started › Cookbooks creates · workflow: installed draft
    Install Grounded Knowledge Assistant: Install, name it, acknowledge the prerequisite, confirm.
    Fill in
    Namecookbook-06-kb-assistant
    Click Install
    You'll see: The Workflow Studio opens on a paused draft with a Knowledge Query node, a Confidence node and an Output.
    Screen snapshot
    caliber · Get started › Cookbooks
    Cookbooks
    Install
  10. Agent resources › Workflows › Studio creates · workflow run
    Select the knowledge node, set Knowledge base to policy-qa-kb and Top-K 3, Save, Validate; from the workflow page click Resume, then Open editor › Run Monitor, enter the question and Run.
    Fill in
    Knowledge basepolicy-qa-kb
    Top-K3
    Run inputHow long are security audit logs retained?
    Click Run
    You'll see: Valid.; run completed; the Output holds [1] data-retention-policy.md and 365 days.
    Screen snapshot
    caliber · Agent resources › Workflows › Studio
    WorkflowsStudio
    Run
  11. Operate › Observability, then Operate › Review Queues creates · review queue: policy-qa-review
    Copy the newest trace's id from the address bar (?trace=tr-…). + New Queue policy-qa-review with the question decision_justified; open it, paste the trace id into Trace ids, Enqueue, answer Pass, Submit review.
    Fill in
    Namepolicy-qa-review
    Question keydecision_justified
    Trace idsthe run's trace id
    Click Submit review
    You'll see: The item is completed and reads Reviewed by admin · wrote 1 assessment(s) back to the trace.
    Screen snapshot
    caliber · Operate › Observability, then Operate › Review Queues
    Review QueuesReview Queues
    Submit 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/.

assets/dataset/calibration-questions.jsonl
{"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 gateTarget
Version 1 buildcompleted, 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.42refuses all 5 questions outside the corpus; cannot refuse the 2 trap questions
Calibration at top_k = 1, dense to hybridRecall@1 0.878 to 0.9268, nDCG@1 0.9024 to 0.9512
Version 2 and workflow review69 chunks, rollback works; only the 0.25-confidence run is enqueued for review
Developer notes & gotchas
  • Flag. CALIBER_FEATURE_COOKBOOKS=true and nothing else (no Aria, no integrations). Knowledge needs more than the base install: an S3-compatible store, the knowledge-local extra (from a checkout: caliber/.venv/bin/pip install -e "caliber[knowledge,knowledge-local]") and the all-MiniLM-L6-v2 model (about 90 MB). Start with HF_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 fake LLM/eval providers): answer text is an extractive digest, Faithfulness and Answer-correctness are blank (—), and Evaluations refuses scoring with 400 evaluation requires a real LLM provider.
  • No decision is produced on a simulated stack. The kb-answer prompt and the CitationFaithfulness judge 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_hybrid is 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 sit queued for minutes without HF_HUB_OFFLINE=1.
  • Runnable. sdk/caliber-sdk/examples/cookbooks/cookbook_06_grounded_knowledge_assistant.py (about a minute, 51 ok lines) and caliber/caliber-ui/e2e/cookbooks/labs/06-knowledge-retrieval.spec.ts; environment: scripts/cookbook-env.sh up lab06.

CALIBER : Contextual Adaptive Lifecycle for Intelligent Build, Evaluation, and Refinement — Cookbooks — every recipe is UI-implementable on the shipped platform. Source + assets under docs-site/cookbooks/<nn>-…/. Regenerate with python3 docs-site/cookbooks/training/build.py.