# Context Injection

- **Canonical URL:** https://getaimath.com/dictionary/context-injection/
- **Topics:** [Retrieval-Augmented Generation (RAG)](https://getaimath.com/dictionary/category/retrieval-augmented-generation-rag/)
- **Last updated:** 2026-11-25

## What is Context Injection?

**In one sentence:** Context injection is placing retrieved information into the model's prompt so it can use it to answer.

The retrieved chunks are inserted with instructions like "Answer using only the information below." The model then reads them as part of its context. This also means untrusted content can sneak in instructions, so it must be handled carefully.

![RAG (Retrieval-Augmented Generation): The Open-Book Exam — Simple cartoon comparing an AI guessing from memory and making things up versus RAG: 1. Search your real documents, 2. Hand the exact page to the AI, 3. Get a factual answer with a page citation.](https://getaimath.com/diagrams/retrieval-augmented-generation-rag.png)
*Napkin Diagram (Retrieval-Augmented Generation (RAG)): Without RAG, AI answers from blurry memory; with RAG, it opens your real documents to the right page before answering.*

## What is an example of Context Injection?

Adding three handbook paragraphs above the user's question before sending it to the model.

## Why does Context Injection matter?

It is the step where retrieval actually helps the model answer.

## Related Concepts

- [Reranking](https://getaimath.com/dictionary/reranking/): Reranking reorders search results with a more careful model so the most relevant ones end up on top.
- [Grounding](https://getaimath.com/dictionary/grounding/): Grounding means making an AI's answer based on real, verifiable sources instead of the model's guesses.
- [Hybrid Search](https://getaimath.com/dictionary/hybrid-search/): Hybrid search combines keyword search and semantic vector search to get better results than either alone.
- [Citation Generation](https://getaimath.com/dictionary/citation-generation/): Citation generation is when an AI shows which sources support each part of its answer.
- [Query Expansion](https://getaimath.com/dictionary/query-expansion/): Query expansion adds related words or alternative phrasings to a search query to find more relevant results.
- [Knowledge Base](https://getaimath.com/dictionary/knowledge-base/): A knowledge base is an organized collection of information, like documents, FAQs and guides, that a system can search.

---
Source: The AI Math Dictionary (https://getaimath.com/dictionary/context-injection/)
