RAG: AI over your own documents

How tools answer from your files instead of from memory. About 40 min, advanced level.

You'll be able to

Answering from your documents

A language model on its own answers from patterns learned in training. That knowledge stops at a cutoff date and never included your lecture notes, your lab's protocols or your office's policies.

Retrieval-augmented generation (RAG) fixes this in two steps. First, a search step finds the passages in your documents most relevant to the question. Then those passages are placed in the prompt, with an instruction like “answer using only these sources, and cite them”. It's the difference between a closed-book and an open-book exam.

NotebookLM and most “chat with your PDF” tools work this way, as do many campus and company help bots.

Why not paste every document into the prompt? For a few short files, that can work. But models have a limit on how much text they take at once, long inputs cost more and are slower, and relevant details get diluted in a sea of irrelevant ones. Retrieval sends only what matters.

Chunks and embeddings

Before anything can be retrieved, documents are prepared once:

This enables semantic search: matching by meaning rather than exact words. Many systems combine it with ordinary keyword search, called hybrid search, because exact terms like course codes, names and acronyms are sometimes better matched literally.

Retrieval decides the answer

When you ask a question, it's embedded the same way, and the system fetches the few chunks whose embeddings are closest, often measured by cosine similarity. Some systems then re-rank those results with a second model before passing the best ones to the language model.

The model can only work with what retrieval hands it. Bad retrieval means bad answers, however good the model is. Typical retrieval failures:

When an answer is wrong, look at what was retrieved first. That tells you whether to fix the search or the prompt.

Grounding and citations

Grounding means the answer is built from the retrieved passages rather than the model's general knowledge. A good grounded prompt says three things: answer only from these sources, cite the passage for each claim, and say so if the sources don't contain the answer.

Citations are what make grounded answers checkable. In NotebookLM you can click a citation to jump to the exact passage. Use that every time it matters.

Grounding reduces made-up facts; it doesn't eliminate errors. A grounded answer can still:

So the habit is the same as in research: open the cited passage and confirm it says what the answer claims.

Stress-test before you trust

Whether you're using NotebookLM or building your own assistant, test it with questions you already know the answers to.

For builders, write these down as a small test set with expected answers, and record which retrieved chunks each answer used. Checking retrieval and generation separately shows you what to fix.

And remember the documents themselves: only upload material you're allowed to share with the service.

Stress-testing a notebook of three readings

Setup: a student loads three course readings on urban heat into NotebookLM.

Test 1, unanswerable: “What does the city's 2030 climate plan commit to?” None of the readings mention the plan. A well-grounded answer says the sources don't cover it. If the tool answers anyway, with no citations or with citations that don't mention the plan, it's filling the gap from general knowledge, and you note that.

Test 2, answerable: “Why are some neighborhoods hotter than others?” The answer lists tree cover, paved surfaces and building density, with citations. You click each one. Two passages say exactly that. The third mentions building density only as a possible factor the authors didn't measure, while the answer states it as a finding.

Verdict: retrieval found the right passages; generation overstated one of them. You record it as partly supported.

Test 3, rephrased: you ask about the “urban heat island effect” instead of “hotter neighborhoods”, and check that the same passages come back.

Try it

A short test log for a notebook of three sources: an unanswerable question and how the tool handled it, an answerable question with each citation checked against its passage, and your verdict on how far you'd trust it.