

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Still calibrating
click for more info
Not enough gems
Cost: 6 gems
1: Large Language Models
incomplete
2: OpenRouter API Setup
incomplete
3: Spell Correction
incomplete
4: Query Rewriting
incomplete
5: Query Expansion
incomplete
This lesson's interactive features are locked, please to keep using them
Typos can kill search results. "Padington" ranks extremely low in keyword search, even though the user clearly wanted "Paddington."
Let's fix the user's spelling for them with AI before we run the search.
"Old-school" spell-checkers are often based on dictionaries and simple if/then rules. They can catch common typos, but they have a big limitation: they lack context awareness. For example, the word "read" is a typo in this sentence:
That's a bright read carpet.
But it's correct in this one:
I love to read books.
Luckily, a decent LLM will catch these kinds of errors.
While "prompt engineering" is a bit of a meme, there really are some useful tips for writing better prompts. Read through Anthropic's prompting guide to understand what kinds of detail can be helpful in a prompt.
Add spelling correction to improve queries before running hybrid search.
rrf_parser.add_argument(
"--enhance",
type=str,
choices=["spell"],
help="Query enhancement method",
)
f"""Fix any spelling errors in the user-provided movie search query below.
Correct only clear, high-confidence typos. Do not rewrite, add, remove, or reorder words.
Preserve punctuation and capitalization unless a change is required for a typo fix.
If there are no spelling errors, or if you're unsure, output the original query unchanged.
Output only the final query text, nothing else.
User query: "{query}"
"""
f"Enhanced query ({METHOD}): '{QUERY}' -> '{ENHANCED_QUERY}'\n"
Where:
METHOD is the enhancement method (e.g. "spell")QUERY is the original queryENHANCED_QUERY is the enhanced query returned by the LLMRun and submit the CLI tests.