Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

These exercises practice retrieving what the Module 5 reading explained, after you finish Lab 5. They aren’t graded. Work each one on paper first, then check your answer. The hints and answers are in the collapsed blocks; open the first hint only when you are stuck, and an answer only after you have one of your own.

Worked example: a contrast set around one word

Pick a word that appears in tickets for more than one queue, such as “tire.” Write one input per queue, keep the length and tone alike, and change only what the customer asks for:

InputLabelWhat the customer wants
“Rear tire goes flat after each ride”repairMechanical work
“Does the tire price include tax?”billingA question about a charge
“Can I save my tire size to my profile?”accountA change to their profile

All three mention a tire, so the word can’t decide the label. Only the request can.

Exercise P5.1 (LO-5.1, ★, about 10 minutes)

Supply two labeled examples using the word “chain” that belong in distinct queues.

Hint 1

Keep the word, and change what the customer wants done.

Hint 2

Change the customer’s request.

Answer

“The chain skips” is repair. “I was billed twice for a chain” is billing.

Both inputs name the chain, so a model can’t route them by the part. The first asks for mechanical work and the second asks about a charge, and that difference is the boundary the pair teaches. An account example works as a third member, such as “Can I note my chain size on my profile?”

Common mistakes: two examples in the same queue, such as two chain repairs, which teach nothing about a boundary; and a pair that differs in several ways at once, such as a long, polite billing ticket next to a two-word repair ticket, where the length could become the cue.

Worked example: testing a suspected shortcut

Suppose every account example in a set is a question that starts “How do I.” A model could learn “How do I means account.” Test the feature in both directions:

If either case goes wrong, the set taught the feature. Add matched contrasts to the set, and keep both cases in the evaluation.

Exercise P5.2 (LO-5.2, ★★, about 15 minutes)

Every billing prompt contains a dollar amount. Which validation case is missing?

Hint 1

Test the feature in both directions, as in the worked example.

Hint 2

Try a receipt without a price.

Answer

Add “Could I get a copy of the receipt?” with label billing, and a ticket that mentions a price but asks for mechanical work, such as “My $8 tube went flat again,” with label repair.

The first case is billing without the feature, and it shows whether the model needs a dollar amount to choose billing. The second is the feature without billing, and it shows whether any dollar amount pulls a ticket into billing. Each case alone tests only one direction.

The common mistake is to add more billing tickets with prices, which only strengthens the shortcut. Another is to test only the first direction, so a model that sends every price to billing still passes.

Worked example: a Jaccard score, step by step

Compare {brake, pads} with {brake, pads, price}:

  1. The intersection, the words in both, is {brake, pads}: 2 words.

  2. The union, the words in either, is {brake, pads, price}: 3 words.

  3. Divide: 2/3.

A higher score is a measure of shared words. The price could still make the intent different: a ticket about the price of pads is billing, and one about worn pads is repair.

Exercise P5.3 (LO-5.3, ★★, about 15 minutes)

Rank {wheel} and {wheel, brake, receipt} for {wheel, brake}.

Hint 1

Work out the intersection and the union for each candidate separately.

Hint 2

Divide overlap by union.

Answer

The scores are 1/2 and 2/3, so the second ranks first.

For {wheel}, the intersection with {wheel, brake} is {wheel} and the union is {wheel, brake}, so 1/2. For {wheel, brake, receipt}, the intersection is {wheel, brake} and the union is {wheel, brake, receipt}, so 2/3. The second shares both of the query’s words and adds only one of its own.

The common mistake is to divide by the wrong set. Dividing the overlap by the candidate’s size gives 1/1 = 1 for {wheel} and 2/3 for the other, which reverses the ranking and favors short candidates. Jaccard divides by the union, so words missing from either side lower the score.

Worked example: changing one thing at a time

To learn whether the order of a fixed set of examples matters, change only the order. Keep the same examples, template, instructions, model, and test cases, and run two orders: labels grouped (repair, repair, billing, billing, account, account) and mixed (repair, billing, account, repair, billing, account). Record the order each test case saw. If accuracy differs, the order is the only explanation the design leaves. If you also changed the examples, you couldn’t tell which change mattered.

Exercise P5.4 (LO-5.3, ★★★, about 25 minutes)

Design a comparison of fixed and dynamic examples that isolates selection. What might you measure besides label accuracy?

Hint 1

List everything that could differ between the two runs, then fix all but one.

Hint 2

Keep the template and evaluation cases fixed.

Answer

Track format compliance, label accuracy, and token use. Keep copies of the selected IDs for each case.

To isolate selection, hold everything else fixed: the template, the instructions, the model, the number of examples k, the rule that orders the chosen examples, and the evaluation cases. Keep the evaluation cases out of the pool. A case left in the pool is its own nearest neighbor, with J = 1, so the dynamic policy would show the model the answer.

Besides overall accuracy, measure accuracy for each label, because a dynamic policy can help one queue and hurt another. Measure the label coverage of each prompt’s examples, since the nearest examples can all share one label. The selected IDs let you explain each failure afterward.

Common mistakes: letting the two policies use different values of k, which mixes the number of examples into the comparison; and drawing a conclusion from a handful of cases, which Module 7 shows can’t separate two prompts.