A retriever searches a corpus for passages related to the query, and the application inserts selected passages into the model context. The generator then produces an answer conditioned on both the request and retrieved material, often with citations or other grounding checks.