How AI looks things up
Find the right part first, then answer
Imagine a friend asks you a question about a storybook. You don't know the answer by heart. So you flip through the book, find the right paragraph, and read it out.
AI tools do the same when they answer from your documents. First they find the paragraphs that best match your question. Then they answer using what they found. This is called RAG, short for "Retrieval-Augmented Generation". It simply means "look it up, then answer".
This page shows the looking-up part. It searches 4 short stories, split into paragraphs:
- The Ant and the Grasshopper
- The Boy Who Cried Wolf
- The Three Little Pigs
- The Tortoise and the Hare
It gives each paragraph a score for how many words it shares with your question, and picks the best one. Rare words count more than common ones.
6 examples: which paragraph did it find?
Each example shows a question, and the paragraph the search picked as the best match.
-
You ask:
Why was the grasshopper hungry in winter?Found in: The Ant and the Grasshopper
When winter finally arrived, the ground froze and snow covered the fields. The grasshopper had no food stored away and grew hungry and cold, with no music left to play.
✅ Right paragraph. "Grasshopper", "hungry" and "winter" all appear in it.
-
You ask:
Why did the villagers stop believing the boy?Found in: The Boy Who Cried Wolf
No one came to help, and the wolf scattered the flock. The shepherd boy learned a hard lesson that evening: once you have lied, people stop believing you even when you are telling the truth.
✅ Right paragraph. "Stop believing" is in the story, word for word.
-
You ask:
Why did the wolf blow down the straw house?Found in: The Three Little Pigs
The wolf huffed and puffed with all his might, but the brick house did not budge. No matter how hard he tried, the wolf could not blow the sturdy brick house down, and the three pigs stayed safe inside.
❌ Right story, wrong part. You asked about the straw house, but it picked the brick house. That paragraph has "wolf", "blow" and "house" even more times. It matches words, not meaning.
-
You ask:
What is the moral about lying?Found in: The Tortoise and the Hare
The moral of the story is simple: slow and steady wins the race.
❌ Wrong story. The word "moral" matched the tortoise story. The story about lying says "lied", and to this search, "lying" and "lied" are different words.
-
You ask:
What happens when you are dishonest?🤷 Nothing found — no story shares a word with this question.
❌ Missed. The Boy Who Cried Wolf is all about being dishonest. But the story never uses the words in this question, so the search finds nothing.
-
You ask:
tax rules for crypto🤷 Nothing found — no story shares a word with this question.
✅ Honest. None of the stories are about taxes, so it says so instead of making up an answer.
The lesson: this search matches words, not meaning. Use the story's own words, and it finds the right paragraph. Say the same thing in other words, and it misses or picks the wrong one. Many AI tools today search by meaning instead. But the idea is the same: look it up first, then answer.
Try your own question
Ask anything about the 4 stories. See which paragraphs match best, and how well.
Tip: the search only matches whole words, the same words the story uses. Capital letters don't matter. "grasshopper" finds the story, but "grass" finds nothing. To this search, they are different words.
This part needs a one-time download of up to 35 MB: Python, plus the search tool the demo uses. On mobile data, you may want to wait for Wi-Fi. After that, your browser keeps it, and it is quick.
Everything on this page runs on your own device. Nothing you type is sent anywhere, and nothing is saved. This page never talks to an AI. It only does the looking-up part.
Curious how it works? The Python code behind this page is on GitHub. In a terminal, it can also give the paragraphs it found to a real AI, which writes an answer.
See the code on GitHub Run it in a terminal instead