Give an AI your own documents

Find the right page, then let the model answer

A language model only knows what it read in training, so it guesses about anything new. RAG (retrieval-augmented generation) fixes this in two steps: search your documents for the passages that answer the question, then paste them into the prompt. Below are eight ways to do the search. Each one tries to fix a mistake plain search can make, and none of them always wins.

Try this first
  1. Open “Read the documents” below. They describe a made-up island, Fernport, so no AI model already knows the answers.
  2. In Plain RAG, press “How much does the ferry cost?”. Read which passages were found, their scores, and the prompt the model receives.
  3. In Query RAG, press “How much is a boat ticket?” and compare what plain search would have found.
  4. In Graph RAG, press the Mira question and see the search hop from one name to the next.
  5. In Document RAG, press the winter ferry question and see why the whole timetable helps.
  6. In Multi-query and HyDE, press the Mira question and compare the place of the tour passage with plain meaning search. Then press “What else does Tomas do?”.
  7. In Parent-document and Chunk size, press the winter ferry question and see which pieces keep the answer together.
  8. Optional: press “Ask the model” to download a small AI model once and let it answer from the passages.
Read the 10 documents

Fernport is a made-up island. Its 10 documents are cut into 32 passages of 2 sentences each.

Fernport Bakery
Fernport Bakery stands on Harbour Street. It is run by Mira Okafor. Mira is famous for her dark rye bread, baked only on Tuesdays. She learned to bake from Tomas Reyes when she was sixteen. The shop opens at 7 in the morning and closes when the bread is gone.
Fernport Lighthouse
The Fernport Lighthouse was built in 1891 on the north cliff. Its lamp can be seen 30 kilometres out at sea. Guided tours run on Saturdays and Sundays at 10:00 and 14:00. The guide is Tomas Reyes, who has climbed the lighthouse’s 120 stairs every week for 20 years. The lighthouse is closed in January for repairs.
Ferry timetable
The ferry crosses from Millbay on the mainland to Fernport in 40 minutes. A ferry fare costs 6 coins, and children ride free. Bikes travel for 1 coin more. December to February is the quiet season. Then there is only one crossing a day, at 10:00 from Millbay. The rest of the year, the ferry leaves Millbay at 8:00, 12:00 and 17:00.
Lantern Festival
The Lantern Festival lights up Fernport every October. People hang paper lanterns along Harbour Street for a week. On the last night of the festival, everyone walks to the north cliff to watch the lighthouse lamp switch on.
Visitor rules
Visitors may camp only at the campsite behind the school. Fires are allowed on the beach, but never in the woods. Dogs must stay on a lead near the harbour.
Harbour guide
The Fernport harbour is the busiest place in town. The harbour has a long stone wall, and the harbour wall keeps the water calm inside. Fishers bring their catch to the harbour at dawn, and the harbour market sells it fresh by seven. Every morning the harbour fills with gulls, nets and carts. The ferry from the mainland ties up at the harbour, at the far end of the east pier. A small harbour office hands out maps and answers questions. The harbour café serves hot soup to anyone who is cold. Walk along the harbour edge at sunset to see the water turn orange. At night the harbour is lit by a row of yellow lamps, and the harbour is quiet. The harbour crane lifts crates of apples, wool and salt from the quay onto carts. Young children feed the gulls near the harbour steps, while old fishers mend their nets and trade stories about the weather. Two painted sheds beside the harbour store ropes, buoys and lamps. A harbour bell rings at noon, and again when the tide turns. Anyone who loves the sea should spend a slow afternoon at the harbour.
Fernport School
Fernport School teaches about forty children, from age five to twelve. Classes start at 9 in the morning and end at 3. Every child learns to swim in the sea pool, and older children learn to sail. The school library is open to the whole town on Wednesdays. The school choir sings at the end of every term.
Saturday market
The Saturday market fills the square beside the town hall. Farmers sell apples, honey and goat cheese. Weavers sell wool scarves and hats. A woman named Ida Lund sells smoked fish from a blue stall. The market opens at 8 in the morning and packs up at noon.
Weather and seasons
Fernport is mild and damp. Summer days reach about 22 degrees, and the sea is warm enough to swim in July and August. Autumn brings strong winds from the west. Fog often covers the cliffs in the early morning. It snows only once or twice a year, and the snow melts by noon.
History of Fernport
Fernport began as a fishing village about 400 years ago. The first stone houses were built in 1650, from rock taken from the cliffs. A great storm in 1702 washed away the old pier, and the town built a new one. In 1950 a bridge was planned, but the islanders voted against it. Today about 900 people live in Fernport.

Technique 1: Plain RAG: search, then answer

The documents are cut into short passages of 2 sentences (chunking). Your question is turned into search words, and every passage gets a score: each search word it contains adds that word’s weight, and rare words weigh more than common ones. The best 3 passages are pasted into the prompt above your question.

Try “How much does the ferry cost?”: the passage with the fare comes first, because it shares the most rare words with the question.

What this technique did

  1. Search words in your question: much, ferry, cost.
  2. Scored all 32 passages: each search word a passage contains adds that word’s weight (rarer words weigh more).
  3. Kept the best 3 with a score above 0.

3 passages found for “How much does the ferry cost?”.

What the model is given

  1. Ferry timetable score 5.95
    The ferry crosses from Millbay on the mainland to Fernport in 40 minutes. A ferry fare costs 6 coins, and children ride free.
  2. Ferry timetable score 2.46
    Then there is only one crossing a day, at 10:00 from Millbay. The rest of the year, the ferry leaves Millbay at 8:00, 12:00 and 17:00.
  3. Harbour guide score 2.46
    The ferry from the mainland ties up at the harbour, at the far end of the east pier. A small harbour office hands out maps and answers questions.
The full prompt the model receives
Answer the question using only the passages below. If they do not contain the answer, say you do not know.

[1] Ferry timetable: The ferry crosses from Millbay on the mainland to Fernport in 40 minutes. A ferry fare costs 6 coins, and children ride free.
[2] Ferry timetable: Then there is only one crossing a day, at 10:00 from Millbay. The rest of the year, the ferry leaves Millbay at 8:00, 12:00 and 17:00.
[3] Harbour guide: The ferry from the mainland ties up at the harbour, at the far end of the east pier. A small harbour office hands out maps and answers questions.

Question: How much does the ferry cost?

Downloads Qwen3 0.6B (about 580 MB) the first time, then answers on your device.

Technique 2: Query RAG: rewrite the question

People and documents often use different words for the same thing. Before searching, the question is rewritten: related words from a small word list are added (boat → ferry, ticket → fare). Big systems ask an AI model to do this rewrite, or to write a made-up answer and search with that.

Try “How much is a boat ticket?”: plain search finds nothing, because no document says “boat” or “ticket”. The rewritten question finds the fare.

What this technique did

  1. Search words in your question: much, boat, ticket.
  2. Rewrote the question by adding related words: much → cost, boat → ferry, ticket → fare.
  3. Scored all 32 passages: each search word a passage contains adds that word’s weight (rarer words weigh more).
  4. Kept the best 3 with a score above 0.

3 passages found for “How much is a boat ticket?”.

What the model is given

  1. Ferry timetable score 9.45
    The ferry crosses from Millbay on the mainland to Fernport in 40 minutes. A ferry fare costs 6 coins, and children ride free.
  2. Ferry timetable score 2.46
    Then there is only one crossing a day, at 10:00 from Millbay. The rest of the year, the ferry leaves Millbay at 8:00, 12:00 and 17:00.
  3. Harbour guide score 2.46
    The ferry from the mainland ties up at the harbour, at the far end of the east pier. A small harbour office hands out maps and answers questions.
Compare: what plain search would give

No passage found, so the model gets no help from the documents.

The full prompt the model receives
Answer the question using only the passages below. If they do not contain the answer, say you do not know.

[1] Ferry timetable: The ferry crosses from Millbay on the mainland to Fernport in 40 minutes. A ferry fare costs 6 coins, and children ride free.
[2] Ferry timetable: Then there is only one crossing a day, at 10:00 from Millbay. The rest of the year, the ferry leaves Millbay at 8:00, 12:00 and 17:00.
[3] Harbour guide: The ferry from the mainland ties up at the harbour, at the far end of the east pier. A small harbour office hands out maps and answers questions.

Question: How much is a boat ticket?

Downloads Qwen3 0.6B (about 580 MB) the first time, then answers on your device.

Technique 3: Graph RAG: follow the links between names

First, every passage is read once to find names (entities). Two names are linked when a passage mentions both, which builds a graph: a map of who and what is connected. For a question, the search finds the names in it, follows each link one hop, and also keeps passages that mention a linked name.

Try “When can I meet the man who taught Mira to bake?”: the answer is the lighthouse tour times, which never mention Mira. Plain search cannot find them; the graph hops from Mira to Tomas Reyes, and Tomas leads the tours.

What this technique did

  1. Names in your question: Mira Okafor.
  2. In the graph, Mira Okafor is linked to: Fernport Bakery, Tomas Reyes.
  3. Each passage gets its word score, plus 1 for every name from your question and 0.5 for every linked name it mentions.
  4. Kept the best 3.
The graph: 4 links between names
  • Fernport Bakery — Mira Okafor
  • Mira Okafor — Tomas Reyes
  • Fernport Lighthouse — Tomas Reyes
  • Fernport Lighthouse — Lantern Festival

3 passages found for “When can I meet the man who taught Mira to bake?”.

What the model is given

  1. Fernport Bakery score 7.83
    Mira is famous for her dark rye bread, baked only on Tuesdays. She learned to bake from Tomas Reyes when she was sixteen.
  2. Fernport Bakery score 4.33
    Fernport Bakery stands on Harbour Street. It is run by Mira Okafor.
  3. Fernport Lighthouse score 0.50
    Guided tours run on Saturdays and Sundays at 10:00 and 14:00. The guide is Tomas Reyes, who has climbed the lighthouse’s 120 stairs every week for 20 years.
Compare: what plain search would give
  1. Fernport Bakery score 6.33
    Mira is famous for her dark rye bread, baked only on Tuesdays. She learned to bake from Tomas Reyes when she was sixteen.
  2. Fernport Bakery score 2.83
    Fernport Bakery stands on Harbour Street. It is run by Mira Okafor.
The full prompt the model receives
Answer the question using only the passages below. If they do not contain the answer, say you do not know.

[1] Fernport Bakery: Mira is famous for her dark rye bread, baked only on Tuesdays. She learned to bake from Tomas Reyes when she was sixteen.
[2] Fernport Bakery: Fernport Bakery stands on Harbour Street. It is run by Mira Okafor.
[3] Fernport Lighthouse: Guided tours run on Saturdays and Sundays at 10:00 and 14:00. The guide is Tomas Reyes, who has climbed the lighthouse’s 120 stairs every week for 20 years.

Question: When can I meet the man who taught Mira to bake?

Downloads Qwen3 0.6B (about 580 MB) the first time, then answers on your device.

Technique 4: Document RAG: pass whole documents

Cutting text into passages can split a sentence from the one that explains it. Here each whole document is scored instead, and the best one is passed in full, in its original order. This costs a longer prompt, so it suits short documents or models that can read a lot at once.

Try “What time does the ferry leave in winter?”: plain search hands over “Then there is only one crossing a day, at 10:00” but leaves out the passage that says “then” means December to February. The whole timetable keeps them together.

What this technique did

  1. Search words in your question: time, ferry, leave, winter.
  2. Scored each of the 10 whole documents instead of 2-sentence passages.
  3. Picked “Ferry timetable” and passed the whole document, in its original order.

1 passage found for “What time does the ferry leave in winter?”.

What the model is given

  1. Ferry timetable score 5.95
    The ferry crosses from Millbay on the mainland to Fernport in 40 minutes. A ferry fare costs 6 coins, and children ride free. Bikes travel for 1 coin more. December to February is the quiet season. Then there is only one crossing a day, at 10:00 from Millbay. The rest of the year, the ferry leaves Millbay at 8:00, 12:00 and 17:00.
Compare: what plain search would give
  1. Ferry timetable score 5.95
    Then there is only one crossing a day, at 10:00 from Millbay. The rest of the year, the ferry leaves Millbay at 8:00, 12:00 and 17:00.
  2. Ferry timetable score 2.46
    The ferry crosses from Millbay on the mainland to Fernport in 40 minutes. A ferry fare costs 6 coins, and children ride free.
  3. Harbour guide score 2.46
    The ferry from the mainland ties up at the harbour, at the far end of the east pier. A small harbour office hands out maps and answers questions.
The full prompt the model receives
Answer the question using only the passages below. If they do not contain the answer, say you do not know.

[1] Ferry timetable: The ferry crosses from Millbay on the mainland to Fernport in 40 minutes. A ferry fare costs 6 coins, and children ride free. Bikes travel for 1 coin more. December to February is the quiet season. Then there is only one crossing a day, at 10:00 from Millbay. The rest of the year, the ferry leaves Millbay at 8:00, 12:00 and 17:00.

Question: What time does the ferry leave in winter?

Downloads Qwen3 0.6B (about 580 MB) the first time, then answers on your device.

Technique 5: Multi-query: ask several ways, then merge

One question can be worded badly. Here the question is rewritten 3 other ways, and each of the 4 wordings searches by meaning (embeddings). The 4 rankings are merged with rank fusion: a passage earns 1 ÷ (60 + its rank) from every search that found it, and the earnings are added. These rewrites were written by hand for this demo; a real system asks a language model for them.

Try “What else does Tomas do?”: the rewrites agree on the lighthouse passage and it moves to first place. Then try the Mira question: it stays at place 3. More wordings help sometimes, not always.

What this technique did

  1. Wrote 3 rewrites of the question (written by hand for this demo; a real system asks a language model): “What is the job of Tomas Reyes?”, “Who leads the lighthouse tours?”, “What does Tomas Reyes teach?”.
  2. Search 1, your question: top 3 are Fernport Bakery (bakery-2); Fernport Lighthouse (lighthouse-2); Fernport School (school-2).
  3. Search 2, rewrite: top 3 are Fernport Bakery (bakery-2); Fernport Lighthouse (lighthouse-2); History of Fernport (history-3).
  4. Search 3, rewrite: top 3 are Fernport Lighthouse (lighthouse-2); Lantern Festival (festival-2); Fernport Lighthouse (lighthouse-3).
  5. Search 4, rewrite: top 3 are Fernport Bakery (bakery-2); Fernport Lighthouse (lighthouse-2); Fernport School (school-1).
  6. Rank fusion: a passage earns 1 ÷ (60 + its rank) from every search that holds it, and the earnings are added. A passage found by several searches rises.
  7. For this example, the first right passage is at rank 2 for plain meaning search and at rank 1 for multi-query: a better place. This is one question, not a rule.

3 passages found for “What else does Tomas do?”.

What the model is given

  1. Fernport Lighthouse fused 0.0648 = 1/62 (search 1) + 1/62 (search 2) + 1/61 (search 3) + 1/62 (search 4)
    Guided tours run on Saturdays and Sundays at 10:00 and 14:00. The guide is Tomas Reyes, who has climbed the lighthouse’s 120 stairs every week for 20 years.
  2. Fernport Bakery fused 0.0492 = 1/61 (search 1) + 1/61 (search 2) + 1/61 (search 4)
    Mira is famous for her dark rye bread, baked only on Tuesdays. She learned to bake from Tomas Reyes when she was sixteen.
  3. Fernport School fused 0.0460 = 1/69 (search 1) + 1/64 (search 2) + 1/63 (search 4)
    Fernport School teaches about forty children, from age five to twelve. Classes start at 9 in the morning and end at 3.
Compare: what plain meaning search would give (the question alone)
  1. Fernport Bakery rank 1
    Mira is famous for her dark rye bread, baked only on Tuesdays. She learned to bake from Tomas Reyes when she was sixteen.
  2. Fernport Lighthouse rank 2
    Guided tours run on Saturdays and Sundays at 10:00 and 14:00. The guide is Tomas Reyes, who has climbed the lighthouse’s 120 stairs every week for 20 years.
  3. Fernport School rank 3
    Every child learns to swim in the sea pool, and older children learn to sail. The school library is open to the whole town on Wednesdays.
The full prompt the model receives
Answer the question using only the passages below. If they do not contain the answer, say you do not know.

[1] Fernport Lighthouse: Guided tours run on Saturdays and Sundays at 10:00 and 14:00. The guide is Tomas Reyes, who has climbed the lighthouse’s 120 stairs every week for 20 years.
[2] Fernport Bakery: Mira is famous for her dark rye bread, baked only on Tuesdays. She learned to bake from Tomas Reyes when she was sixteen.
[3] Fernport School: Fernport School teaches about forty children, from age five to twelve. Classes start at 9 in the morning and end at 3.

Question: What else does Tomas do?

Downloads Qwen3 0.6B (about 580 MB) the first time, then answers on your device.

Technique 6: HyDE: search with a made-up answer

A question and its answer often sound different, but two answers sound alike. HyDE (hypothetical document embeddings) first writes a pretend answer, then searches for passages that mean the same as that pretend answer. The answers here were written by hand for this demo. A real system asks a language model to write them, and that model has not read your documents, so it can guess wrong facts. The search only needs the answer to sound like the right page.

Try the Mira question: plain meaning search puts the tour times third, and the pretend answer puts them first. Try “What are the visitor rules?”: the first passage is the same either way, but the pretend answer also brings the second rules passage into the top 3.

What this technique did

  1. A hypothetical answer, written by hand for this demo: “Tomas Reyes guides the lighthouse tours on Saturdays and Sundays, at 10:00 and 14:00.”
  2. A real system asks a language model to write it, and that model has not read your documents, so it may guess wrong facts. It only has to sound like the right page, because the search compares meaning, not truth.
  3. Searched with the meaning of that made-up answer instead of the meaning of the question, and kept the 3 closest passages.
  4. For this example, the first right passage is at rank 3 for plain meaning search and at rank 1 for HyDE: a better place. This is one question, not a rule.
  5. Right passages in the top 3: 1 of 1 for HyDE, 1 for plain meaning search.

3 passages found for “When can I meet the man who taught Mira to bake?”.

What the model is given

  1. Fernport Lighthouse rank 1
    Guided tours run on Saturdays and Sundays at 10:00 and 14:00. The guide is Tomas Reyes, who has climbed the lighthouse’s 120 stairs every week for 20 years.
  2. Lantern Festival rank 2
    On the last night of the festival, everyone walks to the north cliff to watch the lighthouse lamp switch on.
  3. Lantern Festival rank 3
    The Lantern Festival lights up Fernport every October. People hang paper lanterns along Harbour Street for a week.
Compare: what plain meaning search would give (the question alone)
  1. Fernport Bakery rank 1
    Mira is famous for her dark rye bread, baked only on Tuesdays. She learned to bake from Tomas Reyes when she was sixteen.
  2. Fernport Bakery rank 2
    Fernport Bakery stands on Harbour Street. It is run by Mira Okafor.
  3. Fernport Lighthouse rank 3
    Guided tours run on Saturdays and Sundays at 10:00 and 14:00. The guide is Tomas Reyes, who has climbed the lighthouse’s 120 stairs every week for 20 years.
The full prompt the model receives
Answer the question using only the passages below. If they do not contain the answer, say you do not know.

[1] Fernport Lighthouse: Guided tours run on Saturdays and Sundays at 10:00 and 14:00. The guide is Tomas Reyes, who has climbed the lighthouse’s 120 stairs every week for 20 years.
[2] Lantern Festival: On the last night of the festival, everyone walks to the north cliff to watch the lighthouse lamp switch on.
[3] Lantern Festival: The Lantern Festival lights up Fernport every October. People hang paper lanterns along Harbour Street for a week.

Question: When can I meet the man who taught Mira to bake?

Downloads Qwen3 0.6B (about 580 MB) the first time, then answers on your device.

Technique 7: Parent-document: find small, hand over big

Small pieces are easy to match but give the model little to read. Here each document is cut into 1-sentence child chunks and the question is matched against those. Then the whole parent document of each match is passed on, once, in its original order.

Try “What time does the ferry leave in winter?”: the best child is a single sentence, but its parent is the whole timetable, including the sentence that says “then” means December to February. The cost is a longer prompt.

What this technique did

  1. Search words in your question: time, ferry, leave, winter.
  2. Scored 56 one-sentence child chunks; the best 3 sentences are: “The rest of the year, the ferry leaves Millbay at 8:00, 12:00 and 17:00.” (6.75) “The ferry crosses from Millbay on the mainland to Fernport in 40 minutes.” (2.71) “A ferry fare costs 6 coins, and children ride free.” (2.71)
  3. Those belong to 1 parent document, each passed once, whole and in order: Ferry timetable.

1 passage found for “What time does the ferry leave in winter?”.

What the model is given

  1. Ferry timetable best sentence 6.75
    The ferry crosses from Millbay on the mainland to Fernport in 40 minutes. A ferry fare costs 6 coins, and children ride free. Bikes travel for 1 coin more. December to February is the quiet season. Then there is only one crossing a day, at 10:00 from Millbay. The rest of the year, the ferry leaves Millbay at 8:00, 12:00 and 17:00.
Compare: what plain search would give (2-sentence passages)
  1. Ferry timetable score 5.95
    Then there is only one crossing a day, at 10:00 from Millbay. The rest of the year, the ferry leaves Millbay at 8:00, 12:00 and 17:00.
  2. Ferry timetable score 2.46
    The ferry crosses from Millbay on the mainland to Fernport in 40 minutes. A ferry fare costs 6 coins, and children ride free.
  3. Harbour guide score 2.46
    The ferry from the mainland ties up at the harbour, at the far end of the east pier. A small harbour office hands out maps and answers questions.
The full prompt the model receives
Answer the question using only the passages below. If they do not contain the answer, say you do not know.

[1] Ferry timetable: The ferry crosses from Millbay on the mainland to Fernport in 40 minutes. A ferry fare costs 6 coins, and children ride free. Bikes travel for 1 coin more. December to February is the quiet season. Then there is only one crossing a day, at 10:00 from Millbay. The rest of the year, the ferry leaves Millbay at 8:00, 12:00 and 17:00.

Question: What time does the ferry leave in winter?

Downloads Qwen3 0.6B (about 580 MB) the first time, then answers on your device.

Technique 8: Chunk size: how big should a piece be?

The same documents are cut into chunks of 1, 2 and 4 sentences, and each size is searched on its own. Small chunks are precise but can cut an answer in half. Big chunks keep an answer together but carry words that have nothing to do with the question. You choose the size before searching, so it is worth testing.

Try “What are the visitor rules?”: only the 4-sentence chunk holds all three rules. Try “How much does the ferry cost?”: 1 sentence is enough, and the bigger chunks only add text. Try the winter question: even 4 sentences do not hold “December to February” and “only one crossing” together.

What this technique did

  1. Search words in your question: visitor, rule.
  2. Cut every document into chunks of 1, 2, 4 sentences (ids look like ferry-s1-1) and searched each size on its own.
  3. Size 1: best chunk is rules-s1-1, 57 characters, score 4.04.
  4. Size 2: best chunk is rules-s2-1, 113 characters, score 3.50.
  5. Size 4: best chunk is rules-s4-1, 156 characters, score 3.04.
  6. The list below shows the best chunk of each size side by side. A real system would pick one size first.
  7. Small chunks are precise but can lose the sentence next to them; big chunks keep more together but fill the prompt and add words that have nothing to do with the question. No size is best for every question.

3 passages found for “What are the visitor rules?”.

What the model is given

  1. Visitor rules 1 sentence per chunk · score 4.04
    Visitors may camp only at the campsite behind the school.
  2. Visitor rules 2 sentences per chunk · score 3.50
    Visitors may camp only at the campsite behind the school. Fires are allowed on the beach, but never in the woods.
  3. Visitor rules 4 sentences per chunk · score 3.04
    Visitors may camp only at the campsite behind the school. Fires are allowed on the beach, but never in the woods. Dogs must stay on a lead near the harbour.
Compare: what plain search would give
  1. Visitor rules score 3.50
    Visitors may camp only at the campsite behind the school. Fires are allowed on the beach, but never in the woods.
The full prompt the model receives
Answer the question using only the passages below. If they do not contain the answer, say you do not know.

[1] Visitor rules: Visitors may camp only at the campsite behind the school.
[2] Visitor rules: Visitors may camp only at the campsite behind the school. Fires are allowed on the beach, but never in the woods.
[3] Visitor rules: Visitors may camp only at the campsite behind the school. Fires are allowed on the beach, but never in the woods. Dogs must stay on a lead near the harbour.

Question: What are the visitor rules?

Downloads Qwen3 0.6B (about 580 MB) the first time, then answers on your device.

Word list
RAG
Retrieval-augmented generation: first find (retrieve) the pages that answer a question, then give them to an AI model so it writes (generates) its answer from them.
Language model
An AI that writes text by guessing the next word. It only knows what it read in training, unless you give it more in the prompt.
Prompt
All the text the model receives: here, an instruction, the passages found, and your question.
Document
One page of text, like the ferry timetable.
Passage (chunk)
A short piece of a document. Here every passage is 2 sentences long.
Chunking
Cutting documents into passages so the search can pick out just the useful parts.
Search words
The words of your question that are kept for searching. Very common words like “the” or “how” (stop words, also called filler words) are dropped, and a plural “s” is cut so “tours” matches “tour”.
Stop words (filler words)
Words so common that they say nothing about the topic, like “the”, “is” and “when”.
Plain search
Finding passages by matching the words of your question to the words in the passages, with nothing added.
Plain RAG
RAG that uses plain search to pick the passages.
Query RAG
RAG that first adds related words to the question (query rewriting), then searches.
Graph RAG
RAG that also follows links between names in the knowledge graph to find more passages.
Document RAG
RAG that passes whole documents to the model instead of short passages.
Weight
How much a search word counts. A word found in few passages is more telling, so it weighs more: ln(1 + passages ÷ passages with the word).
Score
A passage’s total: the weights of the search words it contains added up. Higher means a better match.
Rank
A position in a ranked list. Rank 1 is the best result; a better place means a smaller number.
Top 3
Only the 3 best-scoring passages are passed on, to keep the prompt short.
Embedding
A list of numbers that stands for a text’s meaning. Real RAG systems often compare embeddings instead of words; this lab uses words so you can check every score.
Query rewriting
Changing the question before searching, for example by adding related words, so it uses the same words as the documents.
Synonym
A different word with the same or a close meaning, like “boat” and “ferry”.
Entity
A name of a person, place or thing that the graph keeps track of, like Mira Okafor or the lighthouse.
Knowledge graph
A map of entities and the links between them. Here two entities are linked when one passage mentions both.
Hop
One step along a link in the graph, from one entity to a connected one.
Multi-query
Searching with several wordings of one question and merging the results, so a badly worded question is less likely to miss.
Query rewrite
A new wording of the question with the same meaning, like “Who leads the lighthouse tours?” for “What else does Tomas do?”.
Rank fusion (RRF)
Merging several ranked lists: a passage earns 1 ÷ (60 + its rank) from each list that holds it, rank 1 being the top, and the earnings are added.
HyDE
Hypothetical document embeddings: write a pretend answer first, then search for passages whose meaning is close to it.
Hypothetical answer
A pretend answer written only to search with. It may contain wrong facts; it just has to sound like the real page.
Parent document
The whole document that a small matched chunk came from. Parent-document search matches small, then passes the whole parent.
Child chunk
A small piece (here 1 sentence) that is matched against the question. Its parent document is what the model reads.
Chunk size
How many sentences go into one chunk. Small chunks match precisely; big chunks keep more context together.
Hallucination
When a model states something that sounds right but is made up. Good passages in the prompt make this less likely.