An internal chatbot that answers employee questions from company documents, such as SOPs, HR policies, product guides, or regulations, is now one of the fastest AI applications to deliver value. The technology behind it is usually RAG (Retrieval-Augmented Generation): the AI first searches for relevant document passages, then writes its answer based on them.
This article continues our RAG discussion from a practical angle: what the architecture looks like, and which costs to budget for each month.
RAG chatbot architecture, layer by layer
1. Document sources
Files on shared drives, the intranet, document systems, or knowledge bases. Decide which documents are official and who owns them. This preparation is covered in getting your data ready for AI.
2. Ingest pipeline
Documents are read, their text extracted, then split into small chunks of a few paragraphs. Each chunk gets metadata: document title, section, date, and access rights. The pipeline reruns on a schedule as documents change.
3. Embeddings and a vector database
Each chunk is converted into an embedding, a list of numbers representing its meaning, and stored in a vector database. Options include dedicated services, extensions to an existing database (such as pgvector for PostgreSQL), or vector search features in search engines.
4. Retrieval
When a user asks a question, it is also converted into an embedding, and the system finds the most similar chunks. The best results usually come from combining vector search with keyword search, plus filtering by the user’s access rights.
5. LLM and prompt
The selected chunks go into the prompt together with the question, and the LLM writes an answer that cites its source documents. A key instruction: if the answer is not in the documents, say so.
6. Interface and integration
The chatbot can live in an internal portal, an office chat app, or WhatsApp. The user’s login determines which documents may be searched.
7. Monitoring and evaluation
Log questions, answers, sources used, and user feedback. Keep a set of test questions to measure accuracy regularly.
Operating cost components
- LLM cost. Usually charged per token (word piece) for input and output. This is typically the largest component and depends most on question volume.
- Embedding cost. Paid when documents are first ingested and when they are updated, plus a little for each question. Usually far smaller than LLM cost.
- Vector database and storage. Depends on the number of chunks and the service chosen.
- Application servers and pipelines. Backend hosting, the ingest scheduler, and logs.
- Maintenance. Team time to update documents, monitor answer quality, and refine prompts.
How to estimate LLM cost
Use this simple formula, then plug in your provider’s price per token:
Tokens per month = questions per day × tokens per question × working days
Example: 500 questions per day, each about 3,000 tokens (question, document passages, and answer), over 22 working days, gives about 33 million tokens per month. Multiply by the price per million tokens for the model you use.
Ways to reduce cost:
- Limit the number of chunks sent to the LLM, for example the 3–5 most relevant.
- Use a smaller model for simple questions.
- Cache answers to frequently repeated questions.
- Consider an open-source model on your own servers if volume is very high or data must not leave the internal network.
Cloud API or self-hosted model?
A cloud API is quick to start and usually gives high-quality answers, but cost grows with usage and data is sent to the provider. A self-hosted model gives full control over data, but needs investment in GPU servers and a team to maintain them. Many organizations start with a cloud API for the prototype, then reassess once usage patterns are clear.
Conclusion
A RAG chatbot is more than connecting documents to ChatGPT. A good architecture handles document chunking, retrieval, access rights, and evaluation. Its operating cost can be estimated from the start by calculating question volume and tokens.
Plan your internal chatbot
The DNASTUDIO team helps design the RAG architecture, prepare documents, and estimate realistic operating costs for your organization.
