Français
Applied AI · Intermediate level · Session 4

RAG: give memory to the model

RAG = Retrieval-Augmented Generation: retrieve relevant evidence before generating an answer — each question becomes an open-book exam.

RAG pipeline simulator

Ask a question about a company's fictitious documentary base (internal regulations, teleworking agreement, expense policy, release notes). The simulator runs the 4 steps of the query pipeline, one by one.

💡 Indexed base (ingestion already done, offline): 8 chunks from 4 internal documents. Ingestion — cutting, vectorizing, indexing — has already happened. You only see the query pipeline here.
1 Vectorization of the question (embedding)
2 Retrieval: the k closest chunks (here k = 3)
3 Assembling the prompt: instruction + context + question
4 Generating the response
Educational simulation: the displayed vectors are simplified (8 dimensions instead of hundreds or thousands ⚠) and the “generation” is simulated. In a real system, each step is supported by a real embedding model and LLM — but the pipeline logic is exactly this.

Chunking Visualizer

Paste some text (or use the example) and compare three cutting strategies. Look at what each strategy breaks — or preserves.

💡 To observe: in fixed size, the scale table is cut right in the middle — a line “€130 / night” without a header no longer means anything. The structural cut respects the sections and keeps the picture whole. The overlap (highlighted in copper) prevents a boundary phrase from disappearing from both chunks.

Vector Similarity Explorer

Reminder of Session 1: meaning becomes geometry . Each word is a point (here in 2 dimensions for readability; in reality hundreds ⚠). Click on two words to measure their similarity cosine — the cosine of the angle between their vectors.

Work & HR Finance Technical Exact codes (⚠ traps)
Click on two points to compare. Suggestions: leave vs. vacation (close), then ERR-4471 vs. ERR-4472 (the code trap).

From vanilla RAG to robust RAG

Run a teaching cascade: multi-query and HyDE improve the search probe, broad retrieval preserves candidates, a cross-encoder performs reranking, and an evidence gate decides whether to answer or refuse.

1 · Reformulate — multi-query + HyDE

2 · Retrieve broadly — recall first

3 · Reranking — cross-encoder

4 · Evidence gate — answer or refuse

Limits: deterministic simulation, not a benchmark. Multi-query, HyDE, and reranking add latency and cost. Model self-evaluation is not external evidence. Never send confidential data to web search without an explicit policy and authorization.
Evaluation: retain a stage only if it improves recall/precision, citation support, or correct refusal on an annotated evaluation set while meeting latency, cost, and privacy budgets.