

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: Manual Evaluation
incomplete
2: Golden Dataset
incomplete
3: Precision Metrics
incomplete
4: Recall Metrics
incomplete
5: F1 Score
incomplete
6: Error Analysis
incomplete
7: LLM Evaluation
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
Okay, so your search system can return 100 movies about "bears," but how many are actually relevant?
That's what precision measures. It's a simple formula:
precision = relevant_retrieved / total_retrieved
If you return 10 movies but only 7 are relevant, your precision is:
7/10 = 0.7 = 70%
Higher precision = less junk in the results.
"Precision@K" or "P@K" is a common metric that measures precision for the top K results returned by a search system. Users only look at the top K results, so we just focus on those.
import argparse
def main() -> None:
parser = argparse.ArgumentParser(description="Search Evaluation CLI")
parser.add_argument(
"--limit",
type=int,
default=5,
help="Number of results to evaluate (k for precision@k, recall@k)",
)
args = parser.parse_args()
limit = args.limit
# run evaluation logic here
if __name__ == "__main__":
main()
k=6
- Query: dangerous bear wilderness survival
- Precision@6: 1.0000
- Retrieved: The Edge, Man in the Wilderness, Claws, Unnatural, Into the Grizzly Maze, Alaska
- Relevant: Unnatural, Alaska, The Edge, Into the Grizzly Maze, Claws, Man in the Wilderness, The Revenant
- Query: cute british bear marmalade
- Precision@6: 0.1667
- Retrieved: Paddington, The Indian in the Cupboard, The Duchess, The Great Bear, The Bear, Goldilocks and the Three Bears
- Relevant: Paddington
Run and submit the CLI tests.