Locked learning resources

Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Locked learning resources

This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Answer That the Rulebooks Don't Say

In this video, you asked the rules desk a question that no rulebook answers, saw what came back, and added a covered field so that “the rulebooks don’t say” is an answer your code can read and reply to.

Key Points

  • A question the rulebooks don’t cover. Table 1 has a new question: whether a seventh player can join Lantern Harbor by sharing a boat. The rulebook never counts the players or mentions sharing a boat. Its components list gives a boat in each player color, without saying how many colors.
  • What the last lesson’s version did. With only { answer, citations } and “answer only from those chunks”, the model gave a firm “No” and cited lantern-harbor-3, the setup rules on page 2: “Each player chooses a color, takes that color’s boat”. It did in five of five runs, though your wording will differ.
  • A ruling from silence. The model turned the rulebook’s silence into a ruling. Its last sentence noticed the gap, but it still led with no, and the citation made the ruling look backed. So table 1 turns a player away on a rule the publisher never wrote.
  • Same shape, no way to tell. Table 6’s covered question and table 1’s uncovered one came back with the same shape: an answer and at least one citation. The instructions never asked the model to say when the chunks don’t answer, and the record had no field for it.
  • A covered field. ANSWER_SCHEMA gets covered: z.boolean(), and the instructions get one sentence telling the model: if the chunks don’t state the rule the question asks about, set covered to false, leave citations empty, and say that the rulebooks don’t say. The model’s wording is only for the record. Your code chooses what the player sees.
  • Your code chooses the reply. reply() returns an apology when there’s no record. When covered is false or the answer cites no chunk to back it, it returns a fixed reply, DONT_SAY. Otherwise, it returns the model’s answer. The model’s wording changes every run, but DONT_SAY tells each player the same thing: the pages the desk found don’t say, so ask a staff member. Table 1 came back with covered false and no citations in five of five runs, and the desk gave its fixed reply.
  • covered is the model’s judgment. It’s model output, like the answer. On another question, it could come back true, and cite a chunk, for a rule the pages never state, so the instruction makes a decline possible, not certain. And the search can miss a page, so the fixed reply only speaks for the pages the desk found.
  • The cost. In this run, the new sentence and field added 41 input tokens per call. Table 1’s went from 552 to 593.

The rule:

  • covered: z.boolean() in the schema.
  • Instructions: when the chunks don’t state the rule, set covered to false (a request, not a guarantee).
  • Your code picks the reply: DONT_SAY when not covered or nothing cited.

Locked learning resources

Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Already a member? Sign-In

Locked learning resources

The full lesson is for members only. Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Already a member? Sign-In

00:00 The rules desk now answers from the café’s rulebooks and cites the chunks it used. Every question so far had an answer in them. In this video, you’ll ask one that doesn’t, and make the desk say so.

00:13 Create ask-covered.js. It reads the players’ questions, calls answerQuestion(), and prints the record and the cost. It loops over two questions about Lantern Harbor.

00:24 Table 6 asks if they can trade with someone who isn’t next to them. And table 1 has a new question: can a seventh player join by sharing a boat?

00:34 Run it. Table 6 gets a yes, as long as both boats are at the same pier. It cites two chunks from page 4, Trading.

00:44 Table 1 gets a firm no. It cites one chunk, the setup rules on page 2. Your wording will differ, but in five runs, table 1 got a no every time.

00:57 Open that chunk. Each player chooses a color and takes that color’s boat. Nothing in it counts the players or mentions sharing a boat. No page of the Lantern Harbor rulebook does.

01:09 The components list gives a boat in each player color, without saying how many colors.

01:16 So the model took one setup sentence and turned the rulebook’s silence into a ruling. Its last sentence notices the gap, but it still leads with no, and a citation that makes the ruling look backed.

01:27 Now table 1 turns a player away on a rule the publisher never wrote.

01:34 Compare the two records. They have the same shape: an answer and at least one citation. Your code can’t tell which one the rulebooks answer. The instructions say to answer only from the chunks, but they never ask the model to say when the chunks don’t answer, and the record has no field for it.

01:52 Give it one your code can read. Open answer.js, where the schema lives. In ANSWER_SCHEMA, add covered, a boolean. Then add one sentence to the instructions.

02:04 It tells the model: if the chunks don’t state the rule the question asks about, set covered to false, leave citations empty, and say that the rulebooks don’t say.

02:14 That wording is only for the record. Your code chooses what the player sees.

02:21 Back in ask-covered.js, add a constant, DONT_SAY, that holds the desk’s fixed reply. The model’s wording changes every run, but this tells each player the same thing: the pages the desk found don’t say, so ask a staff member.

02:37 Then write a function, reply(), that picks what the desk tells the player. If there’s no record, the desk says it can’t answer right now. If covered is false, or the answer cites no chunk to back it, it’s the fixed reply.

02:51 Otherwise, it’s the model’s answer. Print the desk’s reply after the cost.

02:57 Run it again. Table 6’s record now starts with covered true. With the same pier rule and citations, the desk passes it on. Table 1’s record says covered false, with no citations.

03:11 The desk gives its fixed reply. It did in all five runs.

03:16 But covered is the model’s judgment, like the answer. On another question, it could say true, and cite a chunk, for a rule the pages never state, so a decline is possible, not certain.

03:28 And the search can miss a page, so the desk only speaks for the pages it found.

03:34 In this run, the new sentence and field added 41 input tokens per call. Table 1’s went from 552 to 593.

03:45 When the rulebooks don’t cover a question, make that an answer your code can read. Add a covered field to the schema, tell the model when to set it to false, and let your code choose the reply.

03:57 The desk still trusts the model’s covered value, and every citation it sends back. The next lesson, Check Every Citation, checks each citation against the chunks your code sent.

Become a Member to join the conversation.