> For the complete documentation index, see [llms.txt](https://doc.duaer.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://doc.duaer.com/advanced-ai/rag-in-n8n.md).

# Retrieve relevant context with RAG in Duaer

Write documents into a vector store, then retrieve pieces for the model when someone asks. Duaer RAG usually has a load branch and a retrieve branch.
## What RAG is

RAG combines a language model with external material. On a question, relevant pieces are retrieved and handed to the model, instead of relying only on what the model saw in training. A vector store searches by semantic closeness, not simple keyword match.

## Insert into the vector store

1. Fetch the source files or text with nodes.
2. Add a vector-store node and choose insert documents.
3. Connect an embedding model that turns text into vectors.
4. Split into chunks with a data loader. Add metadata to chunks when you need it.

## Retrieve

Attach the same vector store as a tool on an Agent, using the same embedding model you used on insert, or query with the vector-store node directly. Set how many chunks to return, and include metadata when you need it.

Do not stuff a whole long document into every prompt. If you change the embedding model and do not rebuild the store, retrieval answers the wrong thing. Template notes link here.
## Questions

### What does RAG mean in Duaer?

Write documents into a vector store, retrieve matching pieces when someone asks, and give those pieces to the model as context. It is not stuffing the whole file into every prompt.

### In Duaer, do you rebuild the vector store when you change the embedding model?

Yes. Insert and retrieve must use the same embedding model. If you change the model and do not rebuild the store, retrieval answers the wrong thing.

