How RAG Works
RAG has two phases.
Preparing the data (done once, then refreshed):
- Documents are converted to text and split into chunks.
- An embedding model turns each chunk into a vector, a list of numbers that captures its meaning.
- The vectors and their text are stored in a vector database.
Answering a question (every request):
- The user's question is turned into a vector with the same embedding model.
- The vector database returns the chunks whose meaning is closest to the question.
- Those chunks are added to the prompt as context.
- The model writes an answer using that context.
When a document changes, you update its chunks and vectors. The model itself never changes.