For full-stack developers, much of the RAG process maps to familiar tasks: maintaining data, enforcing access and presenting results people can verify.
Retrieval-augmented generation (RAG) is a pattern in which an application retrieves relevant information and supplies it to a model as context for generating a response. It lets the model answer questions using material such as product documentation or internal records without retraining the model when that information changes.
In How AI-Powered Applications Work, we looked at how a knowledge layer supplies information to a model. In this article, we’ll follow a RAG request from retrieval to generation and look at how to check the answer against its sources.
Where RAG Fits in an Application
A customer asks a project management application’s help feature, “How do I export my project data, and are attachments included?”
If the model receives only that question, it might describe a menu that doesn’t exist or incorrectly say that attachments are included.
With RAG, the backend retrieves relevant passages from the export guide and includes them with the question. The model then has the documented export steps and attachment restrictions available when generating its response.
A basic RAG request has three stages:
- Retrieve information. The backend searches the documentation for passages about project exports and attachments.
- Augment the model context. The backend adds the selected passages to the model request alongside the customer’s question and instructions for answering it.
- Generate a response. The model explains the export process using those passages, with references the customer can follow.
Using source material to support a response is called grounding. Retrieval supplies potential evidence, while the generated answer still needs to use that evidence correctly.
Preparing Content for Retrieval
Before a customer asks a question, we need to make the documentation searchable. This preparation is often called ingestion. For a text-based documentation system, it involves extracting useful content from source pages and organizing it in a search index.
Long documents are commonly divided into smaller passages, or chunks, so retrieval can return the relevant part of a page.
For the export guide, we might keep the steps for creating an export together with the explanation of which data the file contains. Headings help identify what each passage covers. If a search result needs more context, the retrieval process can fetch the surrounding paragraphs before passing it to the model.
Each passage also needs metadata, such as its source URL and section title. A document version or update time can help us identify outdated content. If some material has restricted access, the index needs enough information to apply those restrictions during retrieval.
The ingestion process also needs to keep the search index up to date. Changes to the export guide must reach the index, and deleted content must be removed. Otherwise, the model may receive outdated instructions even when retrieval works as intended.
With the content prepared, the next step is deciding how a customer’s question should match the stored passages.
Finding Relevant Passages
Customers won’t always use the same words as the documentation. Someone might ask how to “download everything in a project” when the guide calls the feature a “project data export.” Semantic search aims to find content by meaning, helping retrieval handle differences in wording.
A common way to support this is through embeddings, which represent content as vectors, or lists of numbers. An embedding model converts each passage into a vector that we store alongside its text and metadata. When a question arrives, we use the same embedding model to represent it as a vector, then use vector search to find nearby passage vectors. The application then retrieves the associated text for the model to read.
Keyword search can be particularly useful when a question contains an exact feature name or error code. Hybrid search combines keyword and vector search results so both kinds of matching can influence the retrieved content.
RAG can also retrieve information through keyword search or database queries without using embeddings.
Selecting Context for the Model
Retrieved passages become part of the model’s context, the information available for a particular request. Models have a limited context window, measured in tokens, which are units used to represent text. We need to leave room for the instructions and question as well as the generated answer.
Selecting context therefore involves more than returning a fixed number of search results. We should remove duplicates and passages that don’t help answer the question. We also need to retain qualifications that change the meaning of an instruction. A larger context window gives us more room, but it doesn’t make irrelevant content useful.
Suppose retrieval finds the following passage in the export guide. A simplified view of the assembled model request would look like this:
The retrieved passage supports both parts of the customer’s question. The model can explain where to start an export and clarify that attachments require a separate download. It doesn’t need the entire product manual to answer, but leaving out the sentence about attachments would leave that part of the question unresolved.
The backend can use the export-guide identifier to resolve a citation to the source URL stored in the passage’s metadata. Retrieved content should be treated as source material, with the application’s instructions kept separate from any directions that happen to appear in a document.
The core request flow could look like this in JavaScript-style pseudocode. The helper functions represent application code, rather than a particular library:
Here, selectContext chooses passages within the space allocated to source material. If none are selected, the function returns a message without calling the model. A retrieval failure needs separate error handling so the application doesn’t mistake a failed search for one that found no relevant documentation.
The frontend can present the answer with links to the referenced documentation. The backend should check that any cited identifiers belong to the supplied sources before resolving those links. This makes the answer easier to inspect, although a valid citation alone doesn’t prove that the explanation is correct.
RAG can reduce hallucinations by supplying relevant evidence, but the model can still misread a passage or add unsupported details. For the export question, we should check whether the retrieved context contains the attachment restriction and whether the answer explains it correctly. If that information is missing, the response should acknowledge the gap.
Progress Agentic RAG
Building the pipeline described above means maintaining document processing and retrieval alongside the application itself. The Progress Agentic RAG solution provides these capabilities as a service.
Documents are organized into Knowledge Boxes, where the platform handles extraction, chunking, embeddings and indexing.
Its search and generation APIs let us choose how much of the request flow the platform handles. The /find endpoint combines semantic and keyword search to return relevant content. The /ask endpoint adds generation, passing the retrieved content to a selected language model to produce an answer.
For the export help feature, we could use /find to retrieve passages for the model request shown earlier, or use /ask to handle retrieval and generation together. The developer quickstart walks through uploading documents, checking their processing status, and querying them through the API.
For more basics-style walk-throughs of RAG and Progress Agentic RAG, check out Hassan’s series that starts with Understanding RAG (Retrieval-Augmented Generation). The rest of the series is linked in that post’s wrap-up.
For more basics-style walk-throughs of RAG and Progress Agentic RAG, check out Hassan’s series that starts with Understanding RAG (Retrieval-Augmented Generation). The rest of the series is linked in that post’s wrap-up.
Wrap-up
RAG connects a model response to information the application retrieves. Building it involves preparing searchable content, choosing relevant passages and supplying enough context for the model to answer accurately. Checking the retrieved evidence alongside the response helps us find where the process needs improvement.
For full-stack developers, much of this work belongs in familiar parts of the application: maintaining data, enforcing access and presenting results people can verify. The model adds a way to explain the retrieved information, while the surrounding application determines what information it receives.
For more on building AI-powered applications with Progress, check out the following resources:
- Progress Agentic RAG
- Progress Nexus AI Observability Platform












