

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
Users often describe what they want in messy, informal ways. Let's transform their intent into better search queries. For example, users might type:
But what search engines need to perform well are specific, concise queries. For example:
LLMs have approximate knowledge of many things... so the better models are pretty good at transforming vague user input into more specific, searchable terms.
Build a query rewriter that handles vague user input.
f"""Rewrite the user-provided movie search query below to be more specific and searchable.
Consider:
- Common movie knowledge (famous actors, popular films)
- Genre conventions (horror = scary, animation = cartoon)
- Keep the rewritten query concise (under 10 words)
- It should be a Google-style search query, specific enough to yield relevant results
- Don't use boolean logic
Examples:
- "that bear movie where leo gets attacked" -> "The Revenant Leonardo DiCaprio bear attack"
- "movie about bear in london with marmalade" -> "Paddington London marmalade"
- "scary movie with bear from few years ago" -> "bear horror movie 2015-2020"
If you cannot improve the query, output the original unchanged.
Output only the rewritten query text, nothing else.
User query: "{query}"
"""
f"Enhanced query ({METHOD}): '{QUERY}' -> '{ENHANCED_QUERY}'\n"
Run and submit the CLI tests.