Final assignment
- After the case studies
- about 5 hr
What you will be able to do
Use every module of the course on one change that real knowledge bases meet every month: new documents, a new version, a notice that expires and a document that only staff may see. You prove with measurements that the assistant still finds the right evidence, cites it, says “the documents do not say” when they do not, and forgets what it must forget.
Before you startWhat to know and to have ready
- You completed Modules 1 to 6. Each part below names the lessons that it uses.
- You do not need the case studies for this assignment. The certificate asks for at least one of them.
- Start from your own
policy-assistantat the end of Module 6, or copy the course’s snapshotend-of-m06with the steps of Use a snapshot. Runpython -m pytestfirst: it must show90 passed, 1 deselectedbefore you change anything. - Some tests pin the course’s own collection and question set, for example 36 documents and 67 questions. They fail after Parts 1 and 2, as expected. Update their numbers, and list in your report each test that you changed and why.
- Part 5 needs live model calls, because recorded answers cannot answer new questions. Use a free local model with Ollama, or your own key, as the project README describes. No payment is required.
- Tested with Python 3.12 and the versions in
requirements.txt, on macOS.
The change: three new documents
Section titled “The change: three new documents”Mei brings three documents from Grace’s team. You write them yourself, from the facts below, in the same Markdown format and front matter as the other documents in corpus/documents/:
- Holiday returns notice (public, version 1, effective from 2026-11-20 to 2027-01-31, the last day for returns, as in the earlier holiday notice). Items bought between 20 November 2026 and 15 January 2027 can be returned until 31 January 2027, even when the normal return window has ended. It does not apply to gift cards or to custom-cut products.
- Returns policy, version 5 (public, effective from 2027-02-01). The same as version 4, except one new rule: opened large appliances (pressure washers, lawn mowers, generators) have a restocking fee of 10% of the price, unless the item is faulty.
- Suspected fraud procedure (staff, version 1, effective from 2026-11-01). What an agent does when a return looks fraudulent: do not accuse the customer, do not refund, open a case for the payment team, and reply with the neutral text in the document.
Grace asks one question that decides whether the update ships: “A customer bought a lawn mower that was delivered on 25 November 2026, and asks on 10 January 2027 whether they can still return it. Version 4’s 45 days ended on 9 January; only the holiday notice allows it. Will the assistant quote the holiday notice, and will it never show the fraud procedure to a customer?”
The documents and questions are synthetic. No real customers.
Part 1: write and ingest the documents
Section titled “Part 1: write and ingest the documents”Uses Preserve metadata and Updates and deletions.
- Write the three documents with complete front matter (
doc_id,title,version,effective_from,effective_towhere it applies,owner,access,languageanddoc_type). Version 5 keeps thedoc_idof the returns policy, in a new file such asreturns-policy.v5.md. - Retire version 4 on the day before version 5 starts, as in the module practice of Operational handoff. Version 4 is the HTML file
returns-policy.v4.html, so add the line<meta name="effective_to" content="2027-01-31">under itseffective_fromline. Without it, both versions are in force from 1 February 2027. Add a row for each new document tocorpus/inventory.csv, and set theeffective_toof version 4 there too. - Run
python -m policy_assistant ingest. Show that only the new and changed documents were processed, and showinfobefore and after. - Show with
chunksthat every new chunk has a stable ID, its document, version, section and access label, and trace three of them back to a line in the source file.
Part 2: extend and freeze the question set
Section titled “Part 2: extend and freeze the question set”Uses Corpus and questions and Retrieval measures.
- Write 12 new questions, Q68 to Q79, as new lines of
questions/questions.jsonl. Give each line every field that the other lines have:id,question,language,kind,as_of,public_ok,abstain,reference_answer,keys,must_not,relevant,relevant_chunks,wrong_version,tagsandnotes. The project refuses a line with a missing field. Copy a similar question as a model, for example Q22 for a date question or Q51 for a staff-only question. Write at least 3 with an “as of” date that the holiday notice or version 5 decides (one on 10 January 2027, one on 15 February 2027), 2 that only the restocking-fee rule answers, 2 that the documents cannot answer, 2 staff-only questions about the fraud procedure, 1 in French, and 2 ordinary questions. Give each its reference answer and relevant passages, and whether a public agent may see the answer. - Freeze the set: commit it (or save a copy with the time) before you run any measurement on it. Write one sentence on why, from Answer measures.
Part 3: retrieval, measured fairly
Section titled “Part 3: retrieval, measured fairly”Uses Lexical, dense and hybrid search, Reranking and query changes and Find where it fails.
- Run
evalon all 79 questions for the course’s default (rerank, top 5) and one other setting that you choose and justify, for example--k 10or--method dense. Change one thing only.eval --k 1gives hit@1. - Report hit@5 (or recall@k), MRR and hit@1, overall and for your 12 new questions, and list every new question that each setting misses, with the rank of its first relevant passage.
evalreports only the whole set and each kind. For your 12 questions, change the question IDs in the Python loop of Find where it fails: it prints the rank of the first relevant passage and recall@5. - For the date questions, show that the date filter returns the version in force on the question’s date, and what happens without the filter.
Part 4: access, before the model sees anything
Section titled “Part 4: access, before the model sees anything”Uses Permissions and isolation.
- For a public audience, show that no fraud-procedure chunk reaches the context of any question, including your staff-only questions, and that those questions are answered with “the documents do not say” or a referral, not with staff text.
- Show the same questions for a staff audience, and that the answers then cite the procedure. The answers in this part need your live model, as in Part 5.
- Explain in two or three sentences why filtering after retrieval would not be enough, with your own numbers.
Part 5: grounded answers and abstention
Section titled “Part 5: grounded answers and abstention”Uses Assemble context, Answer and cite and Handle difficult evidence.
- Run
askon your 12 questions with your live model, for the default setting. - For each answer, report what the citation checks found, and score it by hand for correctness, support and citation accuracy, as in Answer measures.
- Show at least one abstention that is right, and explain at least one answer that is wrong, with the stage where it failed.
Part 6: the notice expires
Section titled “Part 6: the notice expires”Uses Updates and deletions and Operational handoff.
- Remove the holiday notice from the collection, as Mei would after it ends, and ingest again.
- Prove with
search,chunksandaskthat no index entry or new answer still returns or cites its passages, and that your 10 January 2027 question now abstains or answers from the version in force, as your documents say. - Run
audit. It checks only the course’s recorded answers, not your live ones. So keep the output of your Part 5askruns in a file, and list the answers that cite a passage of the notice. In a real assistant, these are the cached answers to drop. - Update the handoff record (
infoand the README): document fingerprint, models with revisions, prompt version, costs and the rebuild command.
What to submit
Section titled “What to submit”Your policy-assistant folder (without .env, the index and the virtual environment) with the new documents and questions and REPORT.md:
# Policy assistant: holiday notice, returns v5, fraud procedure## Documents and ingestion (Part 1: front matter, incremental ingest, traced chunks)## Question set (Part 2: the 12 questions, frozen before measuring, and why)## Retrieval (Part 3: two settings, one change, the measures and the misses)## Access (Part 4: public vs staff, and why filtering first matters)## Answers and abstention (Part 5: citation checks and hand scores, one right abstention, one failure by stage)## Deletion (Part 6: proof that the notice is gone everywhere)## Handoff and limits (versions, costs, rebuild command; synthetic data, one live model, what you did not test)Check your work
Section titled “Check your work”A reviewer marks each item demonstrated, partially demonstrated or not yet demonstrated, with a reason. To complete the course, all four required items must be demonstrated.
- Traceable chunks and citations (required): every new chunk traces to its source line; every citation in the answers is checked, and wrong ones are reported.
- A retrieval evaluation set (required): 12 new questions with relevant passages, frozen before measurement; two settings that differ in one thing, measured on all 79 questions.
- Evidence-based abstention (required): unanswerable and staff-only questions are answered with “the documents do not say” for the public audience, and at least one right abstention is shown.
- Update and deletion behaviour (required): incremental ingestion, the version in force by date, and proof that the expired notice no longer appears anywhere.
There are no key numbers to compare for your new questions: they and your live model are yours. The course’s own results for the 67 original questions are in Retrieval measures and Answer measures.
Recap
You maintained a knowledge base the way a team must: new documents with clear versions and access labels, a frozen question set, one change at a time, access enforced before the model sees anything, answers that cite or abstain, and deletions that really delete. If you have not done one yet, choose a case study for the certificate: Answer questions from public guidance, Search technical documentation or Answer from versioned regulations.