All articles

AI development

Build a RAG Knowledge Base for Your Business

Build a business knowledge assistant with permission-aware retrieval, source citations, document updates and an answer-quality test.

A digital data visualization
Illustrative photograph from the original article, sourced from Unsplash.

What RAG is and why your business needs it

A retrieval-augmented generation (RAG) knowledge base is an AI system that answers questions by searching your actual documents first, then generating a response based on what it finds. Instead of the AI guessing or drawing on generic training data, it pulls the specific paragraph from your HR handbook, sales playbook, or technical manual and uses that as the basis for its answer.

Think of it as giving an AI assistant a filing cabinet. When someone asks a question, the assistant opens the cabinet, pulls the right folder, reads the relevant pages, and gives an answer with a citation pointing back to the source. No guessing, no hallucination.

This matters because off-the-shelf tools like ChatGPT and Claude are trained on public internet data. They do not know your internal pricing, your company's return policy, your onboarding checklist, or the specifics of your client contracts. You can paste documents into the chat window, but that approach breaks down once you have more than a few dozen pages. Context windows have hard limits, and even the largest models cannot hold your entire document library in a single conversation.

RAG solves this. It separates the "knowing where to look" step from the "generating an answer" step, which means you can connect thousands of documents without hitting context limits or paying to send your entire knowledge base with every query.

At Luminous Digital Visions, we build custom AI systems that include RAG pipelines tailored to each client's document structure and team workflows. This guide walks through how RAG works, what the components cost, and how to decide between building your own system and buying a managed platform.

Last updated: 30 March 2026.

Decide whether a managed assistant already meets the need

Chat products can support uploaded files, connectors and knowledge features. A custom RAG system is not automatically necessary merely because the information is internal. First assess whether an approved existing product provides the retrieval, permissions and operating controls you need.

A custom system becomes useful when you need specific integrations, document-level access rules, retrieval evaluation or an interface embedded in your workflow. Compare the maintenance burden as well as the demonstration quality.

The RAG pipeline from documents to answers

A RAG system has seven steps. Each step is a separate component, and understanding them helps you evaluate vendors, brief a developer, or scope a build.

Step 1: Document ingestion

Your documents enter the system. This means PDFs, Word files, plain text, CSVs, Notion exports, Confluence pages, Google Docs, or whatever format your team uses. The ingestion layer converts everything into plain text. Some formats are cleaner than others. PDFs with scanned images need OCR (optical character recognition) first. Well-structured Markdown or HTML files are the easiest to process.

Step 2: Chunking

The plain text gets split into smaller pieces called chunks. A chunk might be a single paragraph, a section under a heading, or a fixed number of tokens (typically 200-500 tokens per chunk). Chunking matters because the retrieval step works at the chunk level. If your chunks are too large, you retrieve irrelevant text along with the relevant text. If they are too small, you lose context and the answer quality drops.

The best chunking strategy depends on your documents. For structured documents with clear headings (like an employee handbook), splitting by section works well. For unstructured documents (like meeting transcripts), a sliding window with overlap gives better results.

Step 3: Embedding

Each chunk gets converted into a numerical vector (a list of numbers) that represents its meaning. This is done by an embedding model. Two chunks about the same topic will have similar vectors, even if they use different words. This is what makes semantic search possible. Someone asking "how many vacation days do I get?" will match a chunk that says "employees receive 15 days of paid time off annually" because the meaning is similar even though the exact words differ.

Step 4: Vector storage

The vectors go into a vector database, which is a database optimized for finding similar vectors quickly. When a query comes in, the database can search millions of vectors and return the closest matches in milliseconds.

Step 5: Query processing

A user asks a question. That question gets embedded using the same model that embedded the documents, producing a query vector.

Step 6: Retrieval

The system searches the vector database for document chunks whose vectors are closest to the query vector. It typically retrieves 5-15 chunks, ranked by similarity. Some systems add a re-ranking step here to improve precision.

Step 7: Generation

The retrieved chunks get passed to a large language model along with the user's question and an instruction like "Answer the question based only on the provided context. Cite which document each fact comes from." The model generates a natural-language answer with citations pointing back to specific documents.

This seven-step pipeline is the foundation of every RAG system, whether it is a startup's internal chatbot or an enterprise knowledge platform. If you are evaluating AI agent development partners, ask them to walk you through each step and explain their choices at every stage.

Preparing your documents for RAG

The quality of your RAG system depends more on document preparation than on model selection. Garbage in, garbage out applies here more than anywhere else.

Formats that work well

Plain text (.txt), Markdown (.md), and well-structured HTML convert cleanly. Word documents (.docx) parse reliably with standard libraries. CSVs and spreadsheets work for structured data like pricing tables or product specs. PDFs are the most common format and the most problematic. Digital-native PDFs (created from Word or a web app) parse well. Scanned PDFs need OCR, which introduces errors. PDFs with complex layouts, tables, or multi-column formatting often produce garbled text without custom parsing logic.

Formats that cause problems

PowerPoint files lose their visual context when converted to text. Image-heavy documents need image captioning or OCR. Audio and video files need transcription first. If a large portion of your knowledge lives in these formats, budget extra time for the conversion step.

Cleaning your documents

Before chunking, clean the extracted text. Remove headers, footers, and page numbers that repeat on every page. Strip out table of contents entries. Fix encoding issues (smart quotes, special characters). Remove duplicate documents. If you have five versions of the same policy document, only the current version should go into the index.

Chunk size considerations

The LangChain documentation recommends starting with 500-token chunks and 50-token overlap as a baseline. Smaller chunks (200-300 tokens) improve precision for factual lookups but can lose context. Larger chunks (800-1000 tokens) preserve more context but may retrieve irrelevant content alongside the relevant content.

Run a few test queries after your initial chunking and see whether the retrieved chunks contain the right information. If the answers are vague, try smaller chunks. If the answers lack context, try larger ones. This is an empirical process, not a formula.

Choose an embedding model with a representative test

Choose a model that supports the languages and document types in the collection. Test retrieval on real questions and known source passages. Compare the results with a keyword baseline, especially for product identifiers, names and exact policy terms.

Confirm current dimensions, input limits and pricing in the provider documentation. Keep the embedding configuration with the index. Changing models generally requires rebuilding the vectors so stored documents and incoming queries remain compatible.

See the OpenAI embeddings guide for one implementation route. The best choice depends on retrieval quality for your collection.

Choose storage around access and operations

Compare managed vector services, a database extension such as pgvector and a self-hosted search system against your operational requirements. Look at filtering, deletion, backups, observability, recovery and the team’s existing skills.

Self-hosting gives your team more operational responsibility; it does not by itself prevent data from leaving the environment. External embedding or generation calls, telemetry, logs and backups must also be mapped. Compare current service terms rather than relying on older free-tier capacities.

Making retrieval accurate

The retrieval step determines whether the right document chunks reach the language model. A system that retrieves the wrong chunks will produce wrong answers, regardless of how good the LLM is.

Basic similarity search

The simplest approach: embed the query, find the nearest vectors, return those chunks. This works well for straightforward factual questions where the query and the answer use similar language. "What is our return policy?" matches a chunk containing the words "return policy" through semantic similarity.

Hybrid search (keyword + semantic)

Semantic search sometimes misses exact terms. If someone asks about "Form W-9 requirements" and the document uses that exact term, a keyword match can be more reliable than a semantic match. Hybrid search combines both approaches and usually outperforms either one alone. Weaviate and some Pinecone configurations support this natively.

Re-ranking

After the initial retrieval returns 20-50 candidate chunks, a re-ranking model scores each chunk against the query and reorders them. Cohere's rerank model and cross-encoder models from Hugging Face are the common choices. Re-ranking adds a small amount of latency (50-200ms) but can significantly improve the precision of retrieved results.

Query expansion

Sometimes the user's question does not contain enough information for a good vector match. Query expansion rewrites or augments the query before searching. A simple version: ask the LLM to generate 2-3 alternative phrasings of the question, embed all of them, and merge the results. This helps when users ask vague questions like "how does onboarding work?" that could match many different documents.

Metadata filtering

If your documents have metadata (department, document type, date, product line), you can filter before or during retrieval. A question about "engineering team PTO" should only search engineering-related documents, not the entire knowledge base. Metadata filters reduce noise and improve speed.

For a team building their first RAG system, start with basic similarity search and add hybrid search or re-ranking if test queries show retrieval problems. Over-engineering the retrieval layer before you have real usage data is a common mistake.

Getting the LLM to cite its sources

A RAG system without citations is just a chatbot that happens to search documents internally. Citations are what make the system trustworthy. Your team needs to see where each answer came from so they can verify it and trust it.

How citation generation works

When you pass retrieved chunks to the LLM, you label each chunk with its source document name, page number, or section heading. The system prompt instructs the model to reference these labels in its answer. A typical system prompt looks like:

"Answer the user's question using only the context provided below. For each claim in your answer, cite the source document in square brackets. If the context does not contain enough information to answer the question, say so."

The model then produces answers like: "Employees receive 15 days of PTO per year [Employee Handbook, Section 4.2]. Unused days carry over up to a maximum of 5 days [PTO Policy 2026, page 3]."

Making citations clickable

In a web interface, you can link citations back to the original document or even the specific page. This requires storing document URLs or file paths in your vector database metadata alongside the embeddings. When the system returns a citation, the front end renders it as a link.

Handling low-confidence answers

Good RAG systems include a confidence threshold. If the retrieved chunks have low similarity scores (meaning the system is not confident it found relevant content), the response should say "I could not find a clear answer in the available documents" rather than generating a speculative response. This is a configuration choice, not a model capability. You set the threshold during system design.

This citation-first approach is the same pattern we use when building conversational AI assistants for client-facing applications where accuracy and trust are non-negotiable.

Building the chat interface

The RAG pipeline is the backend. Your team interacts with it through a chat interface. The right interface depends on where your team already spends their time.

Web application

A custom web UI gives you the most control over the experience. You can add document upload, conversation history, user permissions, and admin analytics. Frameworks like Next.js or React make this straightforward. If your team already has an internal web tool, embedding the chat there keeps everything in one place.

Slack bot

For teams that live in Slack, a bot that responds to questions in a dedicated channel or via direct message has the lowest adoption friction. No new app to open. Someone asks a question, the bot answers with citations, and the whole team can see the answer. Slack's API makes bot development relatively simple.

Telegram bot

Smaller teams or businesses that use Telegram for operations can deploy a Telegram bot connected to the same RAG backend. The Telegram Bot API is well-documented and free to use. We have seen this work especially well for field teams who need answers on mobile.

Built into existing tools

If your team uses GoHighLevel for CRM and client communication, you can connect a RAG-powered assistant directly into your GHL workflows. A sales rep can ask the bot about a client's contract terms or service history without leaving their CRM. The same applies to tools with API access like HubSpot, Salesforce, or custom dashboards.

Voice interface

For hands-free use cases (warehouse staff, field technicians, drivers), a voice AI interface lets people ask questions by speaking and get answers read back to them. This adds a speech-to-text layer before the RAG pipeline and a text-to-speech layer after it.

The interface choice is a UX decision, not a technical one. The RAG backend is the same regardless of how people access it.

Four workflows to evaluate with your own documents

These are proposed applications, not measured client deployments. Each requires current documents, permission-aware retrieval and an owner for unanswered questions.

HR policy questions

Retrieve the policy effective for the employee’s location and role, cite the relevant passage and route personal employment decisions to HR. Measure repeat questions and incorrect policy references.

Sales playbooks

Help representatives locate approved positioning and current product details. Keep pricing approval in the sales system. Connect the result to an AI revenue system only where the workflow needs it.

Technical support

Filter by product and version before retrieving troubleshooting steps. Link to the original documentation and capture unanswered questions for its owner.

Client onboarding

Answer from documents that belong to the authenticated client. Do not mix contracts or deliverables across accounts. Escalate ambiguous terms instead of presenting a generated interpretation as a commitment.

Keeping your knowledge base current

A RAG system is only as good as its documents. Stale documents produce stale answers. You need a process for keeping the index current.

Re-indexing on document change

The simplest approach: when a document is updated, re-embed it and replace the old vectors in the database. For Google Drive or SharePoint-based workflows, you can set up a webhook or scheduled sync that detects file modifications and triggers re-indexing. Most businesses need to re-index weekly at minimum. High-velocity environments (where policies or procedures change frequently) should re-index daily or on every save.

Handling version conflicts

If your knowledge base contains multiple versions of the same document (a 2025 employee handbook and a 2026 update), the system needs to know which one is current. The simplest solution: only index the latest version. If you need to preserve historical versions for compliance, add a "version" or "effective date" metadata field and configure the retrieval layer to prefer the most recent version unless the user specifically asks about an older one.

Document lifecycle management

Set up a review cadence. Every quarter, audit which documents are in the index. Remove outdated files. Flag documents that have not been updated in over a year for review. The RAG system can actually help with this: run a report showing which documents are retrieved most and least often, and use that to prioritize updates.

Monitoring answer quality

Track the questions your team asks and the answers the system gives. Look for patterns: are certain topics producing low-quality answers? Are users asking questions that the system cannot answer? These signals tell you where your documentation has gaps and where your chunking or retrieval strategy needs adjustment.

Compare retrieval quality and operational ownership

Test an existing managed knowledge tool with the same documents and questions you would use for a custom build. Evaluate permission enforcement, citations, freshness, answer quality and export options in the actual plan.

A custom implementation can control ingestion, filtering and integrations, but the team also owns authentication, deletion, backups, monitoring and dependency updates. A framework accelerates some components; it does not supply a finished security or maintenance process.

Use a small evaluation set with known answers, deliberately unanswerable questions and documents the test user must not see. Compare the full cost of operating each option, including review and migration. Our custom software services can address requirements that existing tools do not cover.

Estimate ingestion, answering and maintenance separately

Price document parsing, OCR where needed, embedding, index storage, query processing, generation and review. Count re-indexing and deletion work when documents or permissions change. A large collection with few changes behaves differently from a smaller one updated every day.

Measure cost per acceptable answer on a representative set of questions. Include unanswered questions, failed retrieval, retries and human correction. Keep setup and ongoing ownership separate from provider usage fees.

Use current prices for the chosen components and actual pilot usage. The AI ROI guide explains how to compare those costs with a defensible outcome.

How to get started

If you have read this far and want to move forward, here is a practical starting sequence.

Pick one use case. Do not try to build a company-wide knowledge system on day one. Choose the single highest-impact use case: the team that gets the most repetitive questions or the process where finding information takes the longest. HR policy questions, sales playbook lookups, and technical documentation searches are the most common starting points.

Audit your documents. Gather everything relevant to that use case. Check formats, remove duplicates, identify the authoritative version of each document. If your documents are scattered across Google Drive, Notion, email attachments, and shared folders, consolidate them first.

Build a prototype. Use LangChain or a managed platform to get a working system in front of 3-5 users within two weeks. Do not over-engineer the first version. The goal is to learn what your team actually asks and how well the system answers.

Measure and iterate. Track which questions the system answers well and which ones it struggles with. Adjust chunking, add missing documents, tune the system prompt. Most RAG systems need 2-3 rounds of iteration before they are reliable enough for broad deployment.

Scale gradually. Once the first use case is working, expand to the next one. Each new use case means new documents and potentially different retrieval requirements, but the core infrastructure stays the same.

If you want help evaluating whether a RAG knowledge base fits your business, or you need a team to build one, get in touch with us. You can also review our process to see how we scope and deliver AI projects.

Questions before a knowledge-base launch

Does RAG guarantee an accurate answer?

No. Retrieval can select the wrong passage, miss an update or provide incomplete context. Evaluate answer correctness, source support and appropriate refusal separately.

Can it use sensitive documents?

Only within an approved architecture. Map parsing, embedding, storage, model calls, logs and backups. Enforce permissions before retrieval and verify that citations do not reveal restricted material.

What happens when a document changes?

Update or remove its indexed content and verify that old passages stop appearing. Test permission changes as well as text changes. Keep effective dates and document owners available.

How much does it cost?

Use the selected providers’ current rates and measured ingestion and query volume. Add maintenance, evaluation and review. A general monthly range cannot price an unknown collection.

Can it answer in multiple languages?

Test retrieval and generation in each required language, including questions that differ from the source language. Publish the limits found in that evaluation.