At the end of the last lesson, a player at table 5 asked whether card 17 changes how many shells the Tidepool Traders market wants. The search returned page 4, Trading, then the components list, then Scoring. The chunk that describes card 17 came sixth, at 0.580, below five chunks that never mention it.
The rules desk can only answer from what the search returns, so a question that names a card has to find that card. In this lesson, you’ll find out why a search by meaning misses an exact number, and you’ll add a keyword step to search() that catches card numbers and game names. Then you’ll check that the fix leaves the café’s other questions alone. Start with the fix most people try first: take the extra words out of the question.
See Why Card 17 Sinks
The fix depends on the cause, so first find out why the search ranks card 17 so low. Table 5’s question has many words about shells and the market and only two that point at card 17. A reasonable guess is that the other words drown out the number. If that’s right, then a question with nothing but the exact names should find the card.
Create try-card.js in the project folder. It searches for the game and the card alone and prints the top four results with their chunk IDs:
try-card.js
import { search } from "./search.js";
const question = "Tidepool Traders card 17";
const results = await search(question, 4);
for (const result of results) {
const { score, id, page, heading } = result;
console.log(score.toFixed(3), id, `page ${page}, ${heading}`);
}
The chunk that holds card 17 is tidepool-traders-6, the first of the two chunks under Tide Cards on page 3. Its text contains Card 17, the very words the question names, apart from the capital C. Before you run node try-card.js, predict where tidepool-traders-6 ranks now.
0.725 tidepool-traders-2 page 1, Components
0.696 tidepool-traders-7 page 3, Tide Cards
0.692 tidepool-traders-5 page 2, Turn
0.684 tidepool-traders-6 page 3, Tide Cards
The card 17 chunk is fourth, at 0.684. The components list is first, and second is the other Tide Cards chunk, which lists card 22 but not card 17. Taking out the words about shells and the market moved card 17 from sixth to fourth, but didn’t put it first. The top scores are higher than before, because the question is now mostly the game’s name, but card 17 still doesn’t stand out.
Why doesn’t an exact match count for more? Remember how embed() builds a vector: the model makes one vector for each token, and mean pooling averages them. The number 17 is a small part of that average.
The model was trained to place texts with similar wording and topics close together, not to keep identical strings apart, so “card 17” ends up near any other numbered card, such as “card 4”. The components list, which says the game has 24 tide cards, numbered 1 to 24, is about numbered cards as well.
You can confirm this by changing only the number. Create compare-numbers.js, which embeds table 5’s question twice, once with card 17 and once with card 4, and compares the two vectors:
compare-numbers.js
import { embed } from "./embed.js";
import { similarity } from "./similarity.js";
const asked = await embed(
"Tidepool Traders: does card 17 change how many shells the market wants?"
);
const other = await embed(
"Tidepool Traders: does card 4 change how many shells the market wants?"
);
console.log(similarity(asked, other).toFixed(3));
Run it with node compare-numbers.js:
0.928
The two questions ask about different cards, yet their vectors score 0.928, close to the 1.000 of identical text. Changing the card moves the vector only a little. A small move can reorder chunks whose scores are close, but nothing makes the chunk with the exact number come out on top. Exact names, codes, and numbers are the blind spot of a search by meaning, because the one token that matters is outweighed by everything around it.
You could ask for more results. Card 17’s chunk came sixth, so search(question, 6) would return it, though still below five chunks that don’t mention it. It would also add two more chunks to every paid answer request, and you pay for those as input tokens. A better label can help too, but it can’t promise an exact match. To be sure the named card counts, you need a step that compares the exact text and rewards a match.
If you’d like to see that from another angle, such as what happens with error codes or order numbers in other kinds of documents, the button above opens the mentor with the question.