AstraAI

Retrieval Β· RAG

Answer using real notes, not guesses

πŸŽ“ School maths Β· Years 10–11Probability β€” evidence & confidence β€” Ground an answer in retrieved evidence instead of unsupported guessing.Maths by year β†’

The Case. Remember how AI can confidently make things up? This is the fix real chatbots use, called RAG (Retrieval-Augmented Generation): look up real notes first, and only answer from what you actually found.

Your tools. Plain Python retrieves the best-matching note (like before), then builds the answer from it β€” and says ‘I don't know’ when nothing matches, instead of guessing.

Investigate. Press Run. Compare the guess (no retrieval) to the RAG answer (with retrieval) for two questions β€” one the notes cover, one they don't.

  • Without retrieval, the AI can only guess β€” and guesses sound just as confident whether they're right or wrong.
  • With retrieval, the AI grounds its answer in real notes, and admits when it has none. That's why RAG cuts down on hallucination.
your_code.py
Starting Python…
The Reveal

Starting Python… (first time only β€” a few seconds)

πŸ—’οΈ Detective's notes

Bundles your findings, chart and code into one PDF you can keep, print or hand in.

🧩 How this code works

The tools it uses

  • random β€” makes lucky, unpredictable choices β€” like rolling a dice.

What this one does

  • β€’ It uses chance and randomness.

How to read it, top to bottom

  1. 1. Import β€” bring in the tools (listed above).
  2. 2. The data β€” the lists and numbers near the top. These are the bits you change.
  3. 3. The work β€” a little maths, or a loop that repeats a step.
  4. 4. Show it β€” print(...) writes words; plt.show() draws the picture.

Use it for your own problems

  • Change the numbers at the top and press Run β€” nothing breaks, so experiment!
  • Ask your own version of the question β€” swap in your family, your scores, your week.
  • The same tools work on any numbers β€” that's the superpower you're learning.
Need a hint?

retrieve() only returns a note when the score is above 0 β€” no match means an honest 'I don't know' instead of a guess.