12 questions, 20 points (Parts A and B: 1 point/question; Parts C and D: 3 points/question), 30 minutes. Pass mark: 14/20 (70%). The solutions are for instructors only. A calculator and
code-labs/l3-m05(lab.state,lab.context,lab.summariser,lab.conversation,lab.isolation) are allowed. Every student, name, class, conversation and number in the questions is fictional (simulated) data; none describes a real model, vendor or product. The quiz's own names are Pim and Kai, the classes W4X and J8N, and the check keys start withq01toq03andg1tog4. In the code,ST,CX,SM,C,I,AParelab.state,lab.context,lab.summariser,lab.conversation,lab.isolation,lab.app; the service is thecorrectvariant unless a question says otherwise.
Part A - Multiple choice (1 point/question)
Q1. A state inventory with only two items:
inv = [{"id": "chat", "kind": "conversation", "store": "sessions[sid].history", "scope": "session", "key": "session id", "lifetime": "session",
"writers": ["student"], "test": "a new session does not see it"},
{"id": "notes", "kind": "memory", "store": "App.memory", "scope": "student", "key": "", "lifetime": "week",
"writers": ["helper"], "test": "a new session sees it"}]
ST.validate_inventory(inv) returns:
- A.
['BAD_LIFETIME', 'NO_KEY'], because the checker only looks at one item at a time - B.
['BAD_LIFETIME', 'KIND_NOT_COVERED:environment', 'KIND_NOT_COVERED:task', 'NO_KEY'] - C.
['NO_KEY'], becauseweekstill counts as a valid lifetime for a memory - D.
['BAD_SCOPE', 'KIND_NOT_COVERED:environment', 'KIND_NOT_COVERED:task'], as the key is empty
Q2. Student S0518 sends three sentences ["My name is Pim.", "Remember that my class is W4X.", "Borrow B003."]. With two probes class (asks "What is my class?", expects W4X) and pending (sends "yes", expects Done: B003), ST.survival(..., other="S0315") gives two rows (order control, trim, new_session, other_user):
- A.
class= (yes, no, yes, no);pending= (yes, yes, no, no) - B.
class= (yes, yes, yes, no);pending= (no, no, no, no) - C.
class= (yes, no, no, no);pending= (yes, yes, yes, no) - D.
class= (yes, no, yes, no);pending= (no, no, no, no)
Q3. A hand-built history (the token count of each message under the lab's token proxy: 27, 8, 10, 11, 8, 7; total 71):
h = [{"id": "m01", "role": "system", "text": AP.SYSTEM},
{"id": "m02", "role": "user", "text": "My name is Kai."},
{"id": "m03", "role": "user", "text": "Never recommend books by Thu Ha."},
{"id": "m04", "role": "user", "text": "Please skip anything written by Mai Anh."},
{"id": "m05", "role": "user", "text": "Only recommend science books."},
{"id": "m06", "role": "user", "text": "Recommend a book."}]
ctx = CX.build_context(h, {"strategy": "pin_rules", "budget": 50})
The correct result is:
- A.
droppedis['m04'], the context has 60 tokens,over_budgetis True, Mai Anh is lost - B.
droppedis['m02', 'm04'], the context has 52 tokens, just within budget, name and Mai Anh lost - C.
droppedis empty, the context has 71 tokens,over_budgetis True,lost_factsis empty - D.
droppedis['m03', 'm04'], the context has 50 tokens, within budget, both authors lost
Q4. Three older messages are summarised: "Only recommend math books.", "Never recommend books by Thu Ha.", "Actually, only recommend story books.". The summary is Summary of 3 earlier messages. Only recommend math books. Never recommend books by Thu Ha. The mode of SM.summarise and CX.lost_facts(three_messages, [the_summary]) are:
- A.
invents;['invented:only'], because nobody set the math rule here - B.
faithful;[], because every author and category is still mentioned - C.
keeps_stale;['changed:only'], because the correction to story books is lost - D.
drops_rules;['lost:exclude:Thu Ha', 'lost:only'], since the rules are dropped
Q5. Student A is S0107, script ["My name is Kai.", "What is my phone number?", "Borrow B004."]; B is S0315; canaries ["Kai", "0900-222-107", "B004", "S0107"]. B's plan has one step only, {"via": "own", "text": "yes"}. For the global_task_state variant, I.audit returns:
- A.
placesis['reply'], and there is no loan that nobody asked for in the audit - B.
placesis['reply', 'task'], one loan of B004 to S0315 that nobody asked for - C.
placesis['context', 'task'], one loan of B004 to S0107, the owner of the request - D.
placesis empty, because B never asked anything about A's books or data
Part B - True/False (1 point/question)
Q6. C.evaluate({"kind": "not_contains", "value": "Thu Ha"}, "Sorry, I can only help with library books.") returns True, even though the reply mentions no book at all.
Q7. An audit result with no finding, no unrequested loan and no problems, with a three-step plan that uses own, new and a_session: I.gate(result, plan) returns HOLD.
Q8. With the summarise strategy, a recent message dropped in the "still does not fit the budget" step is put into the summary, so the facts in it are not lost.
Part C - Calculation (3 points/question)
Q9. A hand-built history with one memory message (role memory):
h = [{"id": "m01", "role": "system", "text": AP.SYSTEM},
{"id": "m02", "role": "memory", "text": "Memory for this student: class is J8N."},
{"id": "m03", "role": "user", "text": "Only recommend math books."},
{"id": "m04", "role": "assistant", "text": "Noted: only math books."},
{"id": "m05", "role": "user", "text": "Tell me about B009."},
{"id": "m06", "role": "assistant", "text": "B009 Shapes Everywhere by Thu Ha is a math book."},
{"id": "m07", "role": "user", "text": "What is my class?"}]
Give (a) the token count of m02, of m06 and the total of the history (1 point; the system message is 27 tokens); (b) with keep_system at budget 60: the dropped ids, the token count of the context and lost_facts (1 point); (c) with drop_oldest at budget 50: the dropped ids, lost_facts, and the helper's reply to m07 (1 point).
Q10. Two hand-built run_suite results (key and ok):
base = [("q01/t2/0", True), ("q01/t5/0", True), ("q01/t5/1", False), ("q02/t4/0", True), ("q02/t4/1", True), ("q03/t6/0", False)]
cand = [("q01/t2/0", True), ("q01/t5/0", False), ("q01/t5/1", True), ("q02/t4/0", True), ("q03/t6/0", False), ("q03/t6/1", True)]
(each pair becomes {"key": ..., "ok": ...}). Give (a) new_fail, fixed, still_fail and passed of C.compare(base, cand) (1 point); (b) missing, extra and the result of C.gate (1 point); (c) suppose the candidate makes q01/t5/0 pass again, runs q02/t4/1 again (pass) and drops q03/t6/1: what does the gate return, and which list must the reviewer still read (1 point)?
Part D - Analysis (3 points/question)
Q11. The same A, B, script and canaries as in Q5. B's plan:
plan = [{"via": "own", "text": "What is my phone number?"}, {"via": "bogus", "text": "What is my name?"},
{"via": "new", "text": "yes"}, {"via": "a_session", "text": "What have I borrowed?"}]
Give (a) the defective variants that I.matrix(plan, ...) catches (I.caught), of the five (1 point); (b) why session_fallback is not caught, and one small change of the plan that catches it (1 point); (c) why memory_by_name cannot be caught with this pair and script whatever the plan, and what the I.gate result of the correct service says and does not say (1 point).
Q12. A mutant of C.gate that ignores missing and extra:
def mutant(cmp):
need = ("new_fail", "fixed", "still_fail", "missing", "extra", "duplicate", "changed_check", "malformed", "passed")
if not isinstance(cmp, dict) or any(k not in cmp for k in need):
return "HOLD"
return "HOLD" if cmp["new_fail"] or cmp["duplicate"] or cmp["changed_check"] or cmp["malformed"] else "READY_FOR_REVIEW"
A team's fixed cases have only four comparisons (lists not named are empty): g1 new_fail ["g1/t3/0"]; g2 every list empty, passed 5; g3 still_fail ["g3/t2/0"], passed 4; g4 duplicate ["g4/t1/0"]. Give (a) the cases whose result differs between C.gate and mutant (1 point); (b) whether this set of cases kills the mutant (1 point); (c) one added case that kills it, its result under C.gate and under mutant, and a real situation that the case describes (1 point).