ClouisleClouisle

Tutorial: Build a RAG Agent

From product documentation import to retrieval tuning, publish a traceable knowledge Q&A Agent

This tutorial builds a RAG Agent from a set of product documents, focusing on verifying chunking, hybrid retrieval, reranking, citations, and failure diagnostics.

Prerequisites

The current team has embedding and chat models, and optionally a rerank model. Prepare a product document in PDF, Markdown, or DOCX format; a single file must not exceed the site's current upload limit (default 50MB).

Final Result

The Agent answers questions from the documents and returns sources; the retrieval lab explains each result's scores across the vector, full-text, hybrid, and rerank stages.

RAG Agent final result
RAG Agent final result

Step 1: Create a Knowledge Base & Select Models

The embedding model determines the index dimensions, so confirm it before processing documents.
  1. Create a knowledge base and select the current team.
  2. Select the embedding model and optionally a rerank model.
  3. Use a chunk size of 1000 and an overlap of 100.
  4. Save.

Step 2: Import & Process Documents

Preview the chunks first to make sure headings, paragraphs, and tables are not cut too finely.
  1. Select Upload documents and upload the product document.
  2. After the document enters Pending, select Preview chunks.
  3. Check the chunk count, overlap length, and text cleaning results.
  4. Select Start processing and wait until the status becomes Completed.
Document processing completed
Document processing completed

Step 3: Run the Retrieval Lab

Compare configurations with fixed questions instead of adjusting production parameters by feel.
  1. Open Hit testing and enter a question with a clear answer in the documents.
  2. Run vector, full-text, and hybrid retrieval separately.
  3. Compare result overlap counts, per-stage latency, final scores, and diagnostics.
  4. Save the best-performing local preset.
  5. Before selecting Apply to production, confirm at least one hybrid weight is greater than 0.
  1. Create an Agent and select the chat model.
  2. Link the knowledge base you just created and use hybrid.
  3. Select Agentic RAG or Naive RAG as the RAG mode.
  4. Prompt: “answer based only on sources; state uncertainty when no answer can be found”.
  5. Preview and publish.

Acceptance & Troubleshooting

  • Document questions cite the correct documents.
  • Unanswerable questions do not produce unsupported claims.
  • Retrieval lab diagnostics are empty or explainable.
  • Rebuild the index after switching embedding models.
  • If recall fails, check Qdrant, PostgreSQL/pg_search, model credentials, and document status.

How is this guide?

On this page