• Home
  • Blog
  • How to Build an AI Assistant on Your Company Data (RAG, Step by Step)

How to Build an AI Assistant on Your Company Data (RAG, Step by Step)

How to build an AI assistant that answers from your company's documents: how RAG works, cutting hallucinations, preventing leaks, and costs.

Most companies have the same problem: the answers exist, but they are buried in wikis, shared drives, ticket histories, contracts and Slack threads. An AI assistant that can answer questions from your documents — accurately, with sources, and without showing people things they shouldn't see — is one of the most useful AI projects a business can take on.

This guide explains how these assistants are built, step by step, in plain language: the standard approach (RAG), how to keep answers accurate and private, and what it costs.

You don't "train" the model on your data

The most common misunderstanding first. When people say they want to "train a chatbot on company data", they usually picture feeding all their documents into the model so it learns them. That is rarely the right approach.

The usual approach is retrieval-augmented generation (RAG):

  1. When someone asks a question, the system searches your documents for the passages most likely to contain the answer.
  2. It hands those passages to the language model along with the question.
  3. The model writes an answer from those passages — and can cite the passages it drew on.

The model itself doesn't change. Your documents are indexed for search, and only the passages relevant to a question are sent to the model when someone asks. If you use a hosted embeddings service or vector database, check where your data is stored and how each provider handles it.

RAG vs fine-tuning

RAGFine-tuning
What it doesLooks up relevant passages for each questionAdjusts the model's behaviour or style through extra training
When documents changeRe-index the changed documents; answers update right awayNeeds another round of training
Shows its sourcesYes — it can point to the passages it was givenNo
Respects document permissionsYes, if search is filtered per userNo — anyone with access to the model may be able to get out what was trained in
Best forAnswering questions from documents that changeConsistent tone, format or a specialised task

For a knowledge assistant, RAG is almost always the starting point. Fine-tuning can be added later for style or a narrow task, but it is not a way to keep facts current.

How to build it, step by step

1. Choose one use case and one set of documents

Start narrow: "answer support agents' questions from the help center and the last year of resolved tickets", or "answer employees' HR questions from the handbook". A narrow scope makes it far easier to judge whether answers are good.

2. Connect and clean the data

Pull the documents in from where they live — a wiki, Google Drive or SharePoint, a helpdesk, a database. Then clean them: remove duplicates and outdated versions, and keep useful metadata such as title, date, owner and who is allowed to see each document. Many answer-quality problems start here, not in the model.

3. Split documents into chunks

Long documents are split into smaller passages ("chunks") so search can find the precise section that answers a question. Good chunking follows the document's structure — headings, sections, table rows — rather than cutting every few hundred words. Each chunk keeps its source and permission metadata.

Each chunk is turned into an embedding — a numerical representation of its meaning — and stored in a vector database so the system can find passages with similar meaning, not just matching words. Many production systems combine this with traditional keyword search (hybrid search), because exact terms like product codes and names matter.

5. Retrieve the right passages

When a question comes in, the system searches the index, then re-ranks the best candidates so the most relevant few are sent to the model. This step can matter as much to answer quality as the choice of model.

6. Generate the answer — with citations

The model receives the question, the retrieved passages and clear instructions: answer only from these passages, cite which ones you used, and say "I don't know" when the passages don't contain the answer. Showing the sources lets people check the answer in one click, which is what makes them trust it.

7. Enforce permissions before the model sees anything

Filter search results by the person's access rights before passages reach the model. If the model never sees a document, it cannot leak it in an answer. Apply the same filter to anything else you show, such as source links and titles. This is the most important safeguard in a company assistant, and it has to be designed in from the start. (For a related discussion on limiting what AI agents can access in production systems, see this Hacker News thread.)

8. Evaluate before launch — and keep evaluating

Build a test set of real questions with known good answers, and score the assistant on it: did it find the right passages, is the answer correct, did it cite properly, did it refuse when it should have? Rerun the test whenever you change documents, chunking, prompts or models. For one developer's lessons from building a large RAG chatbot for a Fortune 500 company, see this Hacker News discussion.

9. Launch where people already work

Put the assistant where questions already get asked — Slack or Microsoft Teams, your helpdesk, your intranet or your product. Collect feedback (a simple thumbs up or down) and review failed questions every week; they show you which documents are missing or unclear.

How to reduce hallucinations and prevent leaks

  • Ground every answer in retrieved passages, and instruct the model not to answer from general knowledge.
  • Always show sources, so wrong answers are easy to spot and correct.
  • Let it say "I don't know". An honest "I couldn't find that" is far better than a confident wrong answer.
  • Filter by permissions at search time, never by asking the model to keep secrets.
  • Keep documents current. Re-index automatically when documents change, and remove outdated versions.
  • Test continuously against your question set, not just once before launch.
  • Log questions and answers (in line with your privacy policy) so you can audit and improve them.

What it costs

Build

Most of the cost is engineering time. With Pine Technologies:

OptionPrice
Dedicated RAG/LLM engineer (joins your team)$1,500–$3,500 per month, by seniority
Dedicated team (can include a PM, developers, QA and a designer)From $5,000 per month for a 3-person team
Fixed-scope projectFrom $10,000, paid by milestone, with 3 months of post-launch support

As a rough guide — illustrations, not quotes — a proof of concept over one set of documents can take one engineer around a month, while a production assistant with several data sources, permissions and evaluation might need a small team for a few months.

Run

Monthly running costs are mostly model usage, billed per token, plus embeddings and a vector database for search, hosting and monitoring. Model costs vary a lot by model and usage; our AI agent development cost guide works through a monthly example with published model prices.

Next steps

If you want an assistant that answers from your own documents, tell us where your knowledge lives and who needs to use it. You can have us build it through our RAG and LLM development services, or add the skills to your team by hiring a pre-vetted RAG and LLM engineer or prompt engineer — candidates in 48 hours, from $1,500 a month. Whichever you choose, all code and materials belong to you.

For more ways AI can help across your business, see our guide to AI agents for small and mid-sized businesses.

Frequently Asked Questions

Should I use RAG or fine-tuning for my company's data?

For an assistant that answers questions from your documents, start with RAG (retrieval-augmented generation). It looks up the relevant passages at the moment someone asks, so answers stay current when documents change, can cite their sources, and respect who is allowed to see what. Fine-tuning changes how a model writes or behaves; it is not a good way to teach it facts that change, and it cannot enforce document permissions.

How do I keep the assistant from hallucinating or leaking documents?

You can't eliminate hallucinations entirely, but you can greatly reduce them: make it answer only from retrieved passages and show its sources, tell it to say when it doesn't know, and test it against a set of real questions before launch and after every change. To prevent leaks, filter search results by the user's permissions before anything reaches the model, so it never sees documents the person asking isn't allowed to read.

What does it cost to build a RAG chatbot?

Most of the cost is engineering time. With Pine Technologies, a dedicated RAG/LLM engineer costs $1,500 to $3,500 a month depending on seniority, and fixed-scope projects start at $10,000. As a rough illustration, not a quote, a proof of concept over one set of documents might take one engineer around a month, while a production assistant with several data sources, permissions and evaluation might need a small team for a few months. Running costs are mostly model usage, plus search infrastructure and hosting.