Give the model knowledge it wasn't trained on.
Ask a question below. Only the chunks that actually match get retrieved and handed to the model.
- RAG (retrieval-augmented generation)
- A way to give a model knowledge it wasn't trained on: split your documents into small chunks, find the chunks most relevant to a question, and hand only those to the model alongside the question.
- Chunk
- A small piece of a larger document. Documents are split into chunks because a whole document is usually too long to search efficiently or fit in a model's context. This lab's sliders below control exactly how that split happens.
- Retrieval
- The step that scores every chunk against a question and keeps only the most relevant ones. Real systems usually score by embedding similarity. This lab uses simple keyword overlap instead (explained further down), but the pipeline shape is identical.
40 words
8 words
This demo scores chunks by how many of your question's words appear in them. A real retrieval-augmented system usually compares embedding vectors instead (see the Embeddings lab), which catches related meaning even without exact word matches. The steps are the same either way: score every chunk, keep the best ones, build context.
Context sent to the model
Context: - Attention is the mechanism that lets a transformer decide, for every token it's processing, how much weight to give every other token in the sequence. Concretely, each token is turned into three vectors: a query, a key, and a value. - at an entire sequence of tokens at once and uses an attention mechanism to decide which other tokens in that sequence are relevant to each one. This lets it capture long-range relationships in text far more efficiently than earlier architectures - in text far more efficiently than earlier architectures could. Transformers were introduced in a 2017 paper called 'Attention Is All You Need', and the core idea has since become the foundation for GPT, Claude, and nearly every other large language Question: How does attention work?