November 17th, 2026 at 11:17 am
By Ronak Shah, Nordstone
Last updated: November 2026
A RAG chatbot answers questions by first retrieving relevant passages from your own documents, then asking a language model to write a reply using only that material. In a mobile app, retrieval and model calls run on a server behind your API, not on the phone. This guide covers the architecture, the common failures and the UK data protection duties.
TL;DR
- RAG answers from your own content: the technique was set out in a 2020 research paper on retrieval-augmented generation and is now a standard way to ground a chatbot in company documents.
- Keep the whole pipeline on the server: the NCSC secure AI development guidelines cover securing the systems and supply chain around a model, and the app should only call your own API.
- Prompt injection is a named risk: the OWASP Top 10 for LLM applications also lists vector and embedding weaknesses and unbounded consumption, so treat retrieved text as untrusted, enforce access rules before retrieval and cap usage.
- UK GDPR still applies: the ICO guidance on AI and data protection expects lawful basis, transparency and risk assessment where a chatbot touches personal data, although the ICO says the guidance is under review following the Data (Use and Access) Act.
- Wrong answers often come from retrieval, not only from the model: stale documents, poor chunking and weak search matter as much as which model you pick.
- Cost grows with use: our AI cost guide gives UK planning ranges of £28,000 to £80,000 over 8 to 14 weeks for LLM conversational AI, so set limits and measure cost per conversation early.
What is a RAG chatbot and when does it beat fine-tuning?
RAG stands for retrieval-augmented generation. Instead of relying only on what a language model learned in training, the chatbot first searches your own content for the passages most relevant to the question, then gives those passages to the model and asks it to answer from them. The idea was described in a 2020 research paper and has since become a common pattern for company assistants.
It tends to beat fine-tuning when your information changes often, when you need the chatbot to point to its sources, or when different users may see different documents. With RAG you update an index, not a model. Fine-tuning is better for changing how a model writes or behaves, such as a fixed tone or output format, than for teaching it facts. Many products use both, but most teams should start with RAG.
If you only need a general-purpose assistant with no private knowledge, our guide to building an AI chatbot into a mobile app is the better starting point. This article is for apps where the answers must come from your own material: help articles, policies, product catalogues, case notes or manuals.
How does a RAG chatbot work, step by step?
There are two phases. The first prepares your content. The second runs every time a user asks a question.
In short, the build steps are:
- Ingest your documents from where they live.
- Chunk them into passages that each cover one idea.
- Embed each chunk so its meaning can be searched.
- Store the vectors with source, date and permissions.
- Retrieve the best passages for each question, using permissions.
- Generate a reply from those passages, with sources.
- Check the answer, test with real questions and monitor.
In the preparation phase, you ingest your documents from wherever they live, then chunk them into passages of a sensible size so each one covers a single idea. Each chunk is embedded, which means a model turns the text into a list of numbers that captures its meaning, and the result is stored in a vector database alongside the original text and details such as source, date and who may see it.
At question time, the user’s message is embedded in the same way and the system retrieves the closest passages, usually combining meaning-based search with keyword search so that exact names and codes are not missed. The model then generates a reply from those passages, and a final check applies guardrails: does the answer cite a source, does it stay on topic, and does it say so when the documents do not contain the answer?
Several products can fill each role, and the choice is yours. For example, vector stores include pgvector (an extension for PostgreSQL), Pinecone, Weaviate and Qdrant, and embeddings can come from providers such as OpenAI, Cohere or Google, or from open-source models. These are examples, not recommendations: compare options on a sample of your own documents.
Figure 1: how a RAG chatbot prepares content and answers a question.
Where should RAG sit in a mobile app?
On the server, behind your own API. The phone should never hold model keys, prompts or direct access to your vector database. The app sends the user’s message to your API, the API checks who the user is, retrieves permitted content, calls the model and returns the reply.
Keeping the logic on the server also lets you change models, prompts and retrieval without releasing a new app version, which matters because app store review takes time. It is also where you apply rate limits, logging and cost controls.
For the screen itself, stream the reply as it is generated so users see words appearing within a second or two, not a spinner for ten. Cache answers to frequent identical questions, show the source documents under each reply, and design for weak signal: save the user’s message, show a clear retry, and avoid losing a half-typed question when the connection drops. RAG needs a network connection, so decide in advance what the app does offline, such as showing recent conversations or a short list of common answers stored on the device.
Not every AI feature needs a server round trip. Our guide to on-device AI vs cloud AI for mobile apps explains which parts of a feature can run on the phone and which should stay in the cloud.
Figure 2: the app talks only to your API; retrieval, keys and permissions stay on the server.
RAG, fine-tuning or plain prompting: which should you choose?
The right choice depends on how often your information changes, whether you need sources, and how much engineering you can support. The comparison below is a general guide, not a rule.
| Approach | Best for | Strengths | Limits |
| RAG | Answers from changing company content, with sources | Update an index, not a model; can show sources; can respect user permissions | Quality depends on search; needs a server pipeline and content upkeep |
| Fine-tuning | Fixed tone, format or specialist behaviour | Consistent style; shorter prompts | Poor at keeping facts current; retraining effort; no built-in sources |
| Plain prompting | General help or a small, stable body of information | Fastest and cheapest to start | Limited by prompt length; cannot search a large library; risk of invented answers |
Why do RAG chatbots give wrong answers, and how do you fix them?
Poor answers often come from retrieval as well as from the model. If the right passage is never found, the model has nothing to work from and may guess. The usual causes are easy to name.
Stale or conflicting content. Old policies sit next to new ones and the search returns both. Give every document an owner and a review date, retire superseded files, and store the date with each chunk so recent material can be preferred.
Poor chunking. Passages that are too long dilute the match, and passages that are too short lose context. Chunk along headings and paragraphs, keep titles with their text, and test a few sizes against real questions.
Search that misses exact terms. Meaning-based search can overlook product codes, names and clause numbers. Combine it with keyword search and re-rank the top results before they reach the model.
Confident answers without evidence. Tell the model to answer only from the supplied passages, to say when it cannot find the answer, and to show its sources. Then hand over to a person or a contact form instead of improvising.
Whatever you change, build a test set before launch: a list of real questions with the expected source document. Re-run it after every change to content, chunking or prompts, and read a sample of live conversations each week. Without that, you will not know whether a change helped.
How do you secure a RAG chatbot against prompt injection and data leaks?
Treat everything the chatbot reads as untrusted. Prompt injection is when text inside a document, web page or user message tries to make the model ignore its instructions, and it appears on the OWASP Top 10 for LLM applications. Because a RAG chatbot pulls in text from many sources, it has more openings than a plain chat window.
The most important control is access, not wording. Check the user’s permissions before retrieval, so the search can only return documents that person is allowed to see. Do not rely on the prompt to hide restricted content; once a passage is in the model’s context, it can leak.
OWASP’s 2025 list names two further risks that matter for RAG. Vector and embedding weaknesses cover problems in how embeddings and vector stores are created, stored and searched, including data leaking between users or tenants and poisoned documents being retrieved. Unbounded consumption covers uncontrolled use that drives up cost or degrades the service, so set rate limits, token limits and spend alerts. OWASP updates its list, so check its site for the current edition before relying on these entry names.
Add the usual layers around it: keep model keys and system prompts on the server, limit what any tools or actions the chatbot can trigger, require confirmation before it changes data or spends money, filter outputs for personal data and secrets, and log requests so you can investigate incidents. The NCSC guidelines for secure AI system development give a UK government view of building these controls into design, development, deployment and operation. If the chatbot can take actions in other systems, test it with deliberately hostile inputs before launch, ideally with an independent tester.
What does UK data protection require of a RAG chatbot?
If the chatbot handles personal data, UK GDPR applies as it would to any other system. The ICO’s guidance on AI and data protection is the main UK reference, and it covers lawful basis, fairness, transparency, security and accountability. The ICO notes that this guidance is under review because of changes made by the Data (Use and Access) Act, so check its page for updates before you rely on it.
If the chatbot influences decisions about people, such as eligibility, pricing or access to a service, the automated decision-making rules also matter. The Data (Use and Access) Act replaced the old Article 22 with new rules that came into force on 5 February 2026. They allow significant automated decisions in more circumstances, but expect safeguards: telling people about the decision, letting them make representations, obtaining human intervention and contesting it. Decisions based on special category data remain more tightly restricted. Check the current wording with the ICO or your legal adviser before launch.
Several points come up repeatedly in RAG projects. First, know what personal data is in your documents and in the chat logs, and decide whether you need it there at all. Second, tell users in plain language that they are talking to an AI and what happens to their messages. Third, if an outside provider runs the model, they are likely to be acting as your processor, so you need a written contract that meets the ICO’s controller and processor requirements. Fourth, if data goes outside the UK, check the ICO’s rules on international transfers and ask the provider where processing and storage take place.
Remember deletion. If someone asks you to erase their data, it should also leave the vector index and any logs where the right applies, not only the source database. A data protection impact assessment is often sensible, and may be required where the use is high risk, so involve your data protection lead early. This is general information, not legal advice; take specialist advice for regulated sectors such as health and finance. Our UK GDPR for apps checklist covers the wider app.
What drives the cost of a RAG chatbot?
Cost has a one-off build and a running part that grows with use. The build covers content preparation, the retrieval pipeline, the API, the chat screens, security work and testing. The running costs include model calls, embedding new content, vector database hosting, monitoring and the time spent keeping content current.
Our AI cost guide gives UK planning ranges of £28,000 to £80,000 over 8 to 14 weeks for LLM-powered conversational AI, and £20,000 to £60,000 over 6 to 12 weeks for AI-powered semantic search. A RAG assistant combines elements of both, so ask suppliers to price against your own scope, content volume and security needs. Uncontrolled usage is also a cost and security risk that OWASP lists as unbounded consumption.
Model charges depend on how much text goes in and out of each conversation, so long documents, long chat histories and many retrieved passages all raise the cost per question. Set a budget per conversation, cap history length, cache common answers and test a cheaper model on your own question set before assuming you need the largest one.
For wider UK pricing context, see our guide to what it costs to build an app in the UK. Our article on hidden costs of app development is a useful check for the items that tend to be missed, such as maintenance and compliance. Ask any supplier to separate build cost, running cost and who owns the code and the index; our guide to who owns the code in a UK app project explains why.
Frequently asked questions
What is a RAG chatbot in simple terms?
Is RAG better than fine-tuning for a mobile app?
Can a RAG chatbot run on the phone?
Which vector database should I use?
How do I stop the chatbot making things up?
Does a RAG chatbot need a data protection impact assessment?
How long does it take to build a RAG chatbot?
What does it cost to run a RAG chatbot?
Conclusion
A RAG chatbot is only as good as the content it searches and the controls around it. Start with a narrow, well-maintained set of documents, keep the logic on the server, check permissions before retrieval, and measure answers against real questions. Then widen the scope once the first version is reliable.
If you are planning an AI assistant for your app, our app development brief template helps you set out the scope before you speak to suppliers. To talk through your idea with the Nordstone team, get in touch.