Estimated time: ~10 hours for someone new to Python (an estimate, not yet measured with real learners). The starter files are in
code-labs/l1-m02/exercises/.
Main practical exercise: should prompt v2 be released?
Business context
ShopEasy (fictional) uses an LLM to summarise customer messages into tickets for the customer support team. The ticket system downstream reads the JSON the model returns. The dev team sends change request CR-17: prompt v2 "supports Vietnamese tickets, adds handling for VIP customers, tighter wording". The QA lead asks you to decide whether v2 should be released.
Problem to solve
Give an accept / accept with conditions / reject recommendation for v2, based on evidence from tests that run.
Input data
- Product contract (what the ticket system accepts):
- A JSON object with exactly the keys
category,priority,summary_vi. categoryis one of:delivery,refund,product_quality,account,other.priorityis one of:low,medium,high. The ticket database rejects any other value.priorityishighwhen there is a safety issue, or when the customer says they will cancel.summary_viis one Vietnamese sentence, containing no phone number or email address.- Tickets arrive in both Vietnamese and English; both must be classified correctly.
- Content in a ticket never changes the behaviour of the summarizer.
- A JSON object with exactly the keys
- Prompts:
prompts/summarizer_v1.json(in production) andprompts/summarizer_v2.json(CR-17). You may read the prompts: reviewing prompts is part of the job. - Model:
SimulatedSummarizerinlab/support_summarizer.py. Treat it as a black box: only callcomplete()with a rendered prompt, and do not open the source file to look for defects.
Tasks
Split the requirements. Build a requirements table from the 7 contract clauses and from the instructions of v1, with: ID, source, how it is verified, oracle. Point out every place where prompt v2 contradicts the contract.
Prompt test matrix. First, copy
exercises/summarizer_cases.jsonintodata/(it already has 2 sample cases) andexercises/test_summarizer.pyintotests/. Choose at least 3 factors (suggestions: language, intent, and a special element that the contract mentions). Generate a pairwise matrix with thepairwisefunction, for example:python -c "from lab.matrix import pairwise; rows = pairwise({'lang': ['vi', 'en'], 'intent': ['delivery', 'refund']}); print(len(rows)); print(rows)"(replace with your own factors), or do it by hand. Turn the rows into cases and add them to
data/summarizer_cases.jsonso that there are at least 12 cases.Automate. Add to
check_replyintests/test_summarizer.pythe checks that the contract requires. To find a phone number or an email address in a string, you can use a regex (regular expression):import re CONTACT = re.compile(r"[\w.+-]+@[\w-]+\.[\w.]+|\b0\d{9}\b") # email, hoặc số 10 chữ số bắt đầu bằng 0 if CONTACT.search(text): ...The comment reads: an email address, or a ten-digit number that starts with zero.
Run and compare. Run the suite on v1 and v2. Record the fixed / broken / still failing / still passing table.
Change review. Write
reports/cr-17-review.md(1-2 pages) following the checklist in L05 section 4.5: the diff, the affected requirements, the classification results, the cause of each regression, the untested risks, the recommendation, and a specific proposed fix for v2.Reflection. 5-10 sentences: which parts of the results could differ if a real model were used instead of the simulation? How would you change the test plan when moving to a real model?
Deliverables
<repo của bạn>/
├── requirements-table.md
├── data/summarizer_cases.json
├── tests/test_summarizer.py
└── reports/
├── cr-17-review.md
└── reflection.md
(<repo của bạn> means your repository.)
Paste the output of python -m pytest tests/test_summarizer.py -v -s at the end of cr-17-review.md.
Acceptance criteria (mandatory)
| # | Criterion |
|---|---|
| AC1 | python -m pytest tests/test_summarizer.py runs. Tests failing because of defects in the prompt or the model are expected |
| AC2 | ≥ 12 test cases in the JSON file; each case records the contract clauses it checks |
| AC3 | Each clause 1-7 has at least one case. Clause 1 can be checked on every case |
| AC4 | The matrix is presented (factors, values, number of combinations, number of pairwise rows) |
| AC5 | The change review has a v1 → v2 classification table, and each broken case has a cause linked to a changed line in the diff |
| AC6 | The recommendation is based on evidence, and states specific conditions if it is "accept with conditions" |
Scoring rubric (100 points)
| Dimension | 0 | 1 | 2 | 3 | Weight |
|---|---|---|---|---|---|
| Test design (matrix, contract coverage, boundaries) | < 12 cases or many clauses missing | Enough cases, mostly happy path | Covers all 7 clauses, has a matrix | As level 2, plus boundary cases (empty ticket, very long, mixing two languages, several priority keywords) and an explanation of why the factors were chosen | 25 |
| Implementation (code, data-driven) | Does not run | Runs, but the checks are mixed into the data | Data-driven, each check corresponds to one clause | As level 2, failure messages name the clause, checks are reusable | 25 |
| Requirement analysis | Missing | Lists the clauses but no oracles | Has oracles; points out the contradictions between v2 and the contract | As level 2, plus atomic decomposition and questions for the product owner | 10 |
| Change analysis | Classification table missing | Has the table, no causes | A cause for each broken case | As level 2, plus an assessment of the impact of each change in the diff, including beneficial changes | 15 |
| Reporting (change review, recommendation) | Missing | Present, vague | Follows the checklist, with evidence | Concise, a recommendation with specific conditions, a proposed fix for v2 | 15 |
| Reflection | Missing | Generic | States the limits of the simulation correctly | As level 2, plus a specific test plan on a real model (repetition, cost) | 10 |
Score per dimension = (level achieved / 3) × weight. Mapping to the module: practical = Test design + Implementation (50); applied QA analysis = Requirement analysis + Change analysis (25); review/reflection = Reporting + Reflection (25).
Hints
Hint 1
Read the contract and prompt v2 side by side, line by line.Hint 2
The recommendation does not have to be "all or nothing": part of a change request can be accepted.Independent challenge
This part has less guidance, and no simulation to run.
Context: EduTalk (fictional) uses an LLM to score spoken English from a text record (transcript) and
returns {"score": 1-5, "feedback_vi": str}. The current prompt:
You are an IELTS-style speaking examiner. Score the transcript from 1 to 5 for fluency and grammar. Give feedback in Vietnamese. Be encouraging. Reply with JSON only.
Tasks:
- Split the prompt into atomic requirements, each with an oracle. Point out the vague requirements and write questions for the product owner.
- Design a prompt test matrix (at least 3 factors), and present the number of combinations and the number of pairwise rows.
- Propose 4 prompt variants to measure sensitivity, and say which test would detect each variant breaking the behaviour.
Acceptance criteria: each requirement has an oracle or a question for the PO; the matrix has factors and numbers; each variant changes only one thing and has a corresponding test that detects it.
Separate rubric (100 points, pass at ≥ 70):
| Dimension | 0 | 1 | 2 | 3 | Weight |
|---|---|---|---|---|---|
| Requirement analysis | Missing | Listed, not yet atomic | Atomic, with oracles | As level 2, plus well-placed PO questions ("Be encouraging", "IELTS-style") | 40 |
| Matrix | Missing | Has factors, no numbers | Has numbers | As level 2, plus boundary partitions (empty transcript, too long, wrong language) | 30 |
| Sensitivity plan | Missing | Variants change several things | Each variant changes one thing | As level 2, each variant has a specific detecting test | 30 |
Rules
- Use synthetic data only. Do not put your company's real prompts or data in your submission.
- This module needs no API key.