Free & open · no paywall, ever

IntegrAuth Academy

Identity, security and practical AI — free, from zero. Byte-sized lessons, real diagrams, hands-on labs, zero fluff. Two programs, each with its own exam and certificate.

20 tracks 241 lessons 242 hands-on labs 230+ diagrams 100% free

English is hard? Your browser can translate this page into Tamil, Telugu, Kannada, Malayalam or Hindi. Tech words stay in English so you learn the real names.

How?
  • Chrome on phone: ⋮ menu → Translate
  • Chrome on computer: right-click → Translate to …
  • Edge: the translate icon in the address bar
Practical AI Track 1 · AI Essentials
0/75 lessons read
AI ESSENTIALS · LESSON 10

Search by meaning: embeddings and RAG

Priya wants a bot that answers from the company handbook. The AI has never seen it. Your goal: see how the right pages reach the AI.

🧪 Interactive lab — enable JavaScript to play with this one.

questionBilling FAQ · 0.99Invoice help · 0.97Vacation policy · 0.34Office Wi-Fi · 0.00Cosine similarity to the questionsame direction → 1.0 (same meaning)right angle → 0.0 (unrelated)opposite → −1.0Top-2 retrieved:1 · Billing FAQ (0.99)2 · Invoice help (0.97)Real embeddings have hundreds ofdimensions — same idea, more axes.
Figure — Near in meaning means pointing the same way. Each text becomes an arrow. The best matches point the same way as the question.
Key points
  • Retrieval finds the right parts of your files and adds them to the prompt.
  • Texts with a similar meaning get similar numbers.
  • Meaning search can miss exact words, like codes. Add keyword search.
  • A wrong answer often means the right page never reached the AI.

Why the AI needs help

An AI knows only its training and what is in the chat. Your price list is in neither. Retrieval finds the right parts of your files. The AI answers from them, and cites them, so it makes up far less. It is like an open-book exam. The AI does not memorize your files. It opens the right pages, then answers.

Search by meaning

A special AI model turns a piece of text into a list of numbers. This list is an embedding. Think of it as an arrow. Texts about the same thing point the same way. "Check my balance" points near "View your statement", with no shared words.

A score shows how close two arrows point. It is called cosine similarity. The same direction scores 1. Unrelated, at a right angle, scores 0. Opposite scores −1.

RAG, step by step

First, cut each document into small parts, called chunks. Store an embedding for each chunk. Then, for each question, make an embedding too. Find the few chunks that point most the same way. Paste them into the prompt. Tell the AI to answer only from them. This whole method is RAG.

Now fix a broken bot.

🧪 Interactive lab — enable JavaScript to play with this one.

Go deeper: the math behind the score

An embedding is usually several hundred to a few thousand numbers. A simple example uses just 2. Take the arrows (0.8, 0.6) and (0.6, 0.8). Multiply them number by number, then add: 0.8×0.6 + 0.6×0.8 = 0.96. Then divide by the two arrow lengths. Here both lengths are 1. So the score is 0.96. The two texts are very alike.

Think of a supermarket. Pasta sits near the sauces, far from the shampoo. Embeddings give each text a place on that kind of floor plan.

Go deeper: where RAG breaks
  • Bad chunks. A table is split in half. Or a chunk says "this rises to 20%" but not what rises.
  • Exact words. Embeddings catch the general meaning. An error code, a part number or a name can match the wrong page.
  • One search only. Some questions need 2 searches. The second search needs the answer to the first.
  • Who is asking. Meaning search does not check who asks. See permission-aware RAG.
  • Hidden orders. Found text can carry prompt injection.

Priya's bot said the Pune hotel limit was ₹5,000 a night. It cited a real source. But that was the old travel policy. The new one scored a bit lower. The fix was not a smarter AI. She deleted the old file. She added "valid from" dates the AI could see.

Go deeper: better ways to search

Hybrid search. A keyword search, like the classic BM25, runs next to the meaning search. The two result lists are merged. Then a re-ranker model often puts the merged list in a better order. This helps when both meaning and exact words matter.

Agentic search. The AI gets search tools. It decides what to look up, reads, and looks again. This helps with questions that need several searches. It also helps with exact text, like code, logs and IDs. It costs more calls, tokens and time.

Classic RAG — retrieve once, then answerAgentic search — the model decides what to look up, and whenQuestionSearch oncetop-K by similarityPaste chunksinto the promptModel writes the answerQuestionModel as agent"what do I still need?"Toolssearch · grep · SQL · read fileAnswer, with sourcescall a toolresults1 lookup · fixed before the model thinksrepeat until it has enough(more calls, more tokens, slower)
Figure — One search or a search loop. Classic RAG searches once. Agentic search looks, reads and looks again. It does better on questions that need several searches, but it costs more calls and time.

Other options. A small set of files that rarely changes can go straight into the prompt. A knowledge graph links people, teams and products, so questions can follow the links. Classic RAG still works well for simple look-ups in large sets of text. It needs no retraining (see Prompt, RAG or fine-tune?).

Go deeper: vector databases

A list of numbers is also called a vector. A vector database stores them next to the text. It quickly finds the ones nearest to a question. With millions of chunks, it uses a fast shortcut that can miss a match now and then. As of October 2026, pgvector, Qdrant and Chroma are open source. Weaviate has an open-source core. Pinecone is a closed, hosted service.

Each embedding model makes its own kind of numbers. Numbers from 2 models can't be compared. So if you switch models, you must embed everything again.

Watch out

An old or wrong source gets cited just as confidently. And every search must check who is asking. See Build retrieval that works.

🧪 Try it free

Open the TensorFlow Embedding Projector. Search "coffee" and look at the words nearest to it.