NSFW (including funny example, don't worry)
RAG is "Retrieval-Augmented Generation". It's a prompt-engineering technique where we run the prompt through a database query before giving it to the model as context. The results of the query are also included in the context.
In a certain simple and obvious sense, RAG has been part of search for a very long time, and the current innovation is merely using it alongside a hard prompt to a model.
My favorite example of RAG is Generative Agents. The idea is that the RAG query is sent to a database containing personalities, appointments, tasks, hopes, desires, etc. Concretely, here's a synthetic trace of a RAG chat with Batman, who I like using as a test character because he is relatively two-dimensional. We ask a question, our RAG harness adds three relevant lines from a personality database, and the model generates a response.
> Batman, what's your favorite time of day?
Batman thinks to themself: I am vengeance. I am the night.
Batman thinks to themself: I strike from the shadows.
Batman thinks to themself: I don't play favorites. I don't have preferences.
Batman says: I like the night. The twilight. The shadows getting longer.