Skip to content
AI-powered appsNewChat, vision, voice, generationBookings & schedulingAppointments that book themselvesShops & sellingA storefront in every pocketClient & businessRun the operation from one placeCommunities & clubsA home that is not a group chat
Health & wellnessHabits, tracking and calmGames2D, 3D and multiplayerPersonal & toolsThe tool you wish existedInternal toolsThe tool ops never had time for
See all use cases
ArcadeNewPricingSecurity
EngineThe game engine and World EditorHow it worksFrom one sentence to a live productDocsGuides for building and publishingBlogStories, guides and newsChangelogWhat shipped latelyStatusUptime of every serviceSupportGet help from the team
AI-powered appsBookings & schedulingShops & sellingClient & businessCommunities & clubsHealth & wellnessGamesPersonal & toolsInternal tools
See all use cases
ArcadeNewPricingSecurity
EngineHow it worksDocsBlogChangelogStatusSupport
Language
Blog
GlossaryNovember 22, 20263 min read

What is RAG (retrieval-augmented generation)?

Retrieval-augmented generation is open-book mode for AI: find the right pages first, then answer from them. It is how chatbots answer about your docs without retraining a model.

Startbase Team
Editorial ink illustration of a library book cart with three open books beside a writing desk, the quill in ember orange

Key takeaways

  • RAG retrieves relevant passages from your own content and gives them to a language model as context for its answer.
  • It keeps answers current and specific without retraining, and lets you show sources.
  • Most RAG failures are retrieval failures: bad chunks, missing documents or the wrong passages found.

RAG, short for retrieval-augmented generation, is a technique where an app first searches your own content for the passages most relevant to a question, then sends those passages to a language model along with the question so it answers from them. The model brings the language skills; your documents bring the facts.

An everyday comparison is an open-book exam. A student who memorized the course a year ago will misremember details. The same student allowed to flip to the right page first writes a precise answer and can point to where it came from.

The pipeline, step by step

Ahead of time (indexing):

  1. 01Collect the sources: help articles, policies, product specs, past support answers.
  2. 02Split them into chunks of a few paragraphs, each keeping its title and link.
  3. 03Create an embedding for each chunk and store it with the text (what embeddings are).

At question time:

  1. 01Embed the user's question and fetch the closest chunks, often 3 to 8 as a starting point (many systems also run a keyword search and merge the results).
  2. 02Build the prompt: instructions ("answer only from the sources below, say so if they do not cover it"), the retrieved chunks with their titles, then the question.
  3. 03Generate the answer and show the source links beside it.

Why RAG instead of a bigger prompt or retraining

  • Fresh and editable: update an article and the next answer uses it. Retraining a model for every policy change is slow and costly.
  • Fewer invented answers: grounding the model in real text is the main defense against hallucination.
  • Fits the window: even a large context window is wasted and expensive if you paste the entire knowledge base into every call; sending only relevant passages is cheaper and often more accurate.
  • Permissions: retrieval can filter by who is asking, so a customer never gets an answer built from an internal document.

Building RAG in a Startbase app

The parts map onto Startbase Cloud: documents in the database or file storage, server-side functions for indexing and answering, and the App AI gateway's `invokeLLM` to generate the reply without API keys in your app (AI features docs). The embedding step needs an embedding provider; plan where that runs before building. The docs chatbot prompt is a full, paste-ready brief, and building an AI chatbot app covers the product around it. A shorter starting brief:

Build a help assistant that answers from the articles in my help_articles table. Split each article into chunks of about three paragraphs that keep the article title and URL, and re-index an article whenever it is edited. For each question, retrieve the five most relevant chunks, answer with invokeLLM using only those chunks, and list the source links under the answer. If the chunks do not answer the question, say so and show the contact form. Log each question, the chunks used and whether the user clicked "helpful".

Common confusions and failure points

  • "RAG trains the model on my data." It does not change the model at all; your content is only passed in at question time.
  • Bad chunks. A chunk that splits a table or a step list in half loses its meaning. Chunk along headings.
  • Missing content. If the answer is not in the sources, retrieval cannot find it. The question log shows what to write next.
  • Stale index. Edited documents must be re-embedded, or answers quote the old version.

Frequently asked questions

Is RAG the same as fine-tuning?

No. Fine-tuning changes a model's weights with training examples, which shapes style and behavior. RAG leaves the model unchanged and supplies facts at question time. For answering from documents, RAG is usually the first choice.

How many documents do I need for RAG to be worth it?

If all your content fits comfortably in one prompt, you can just include it. RAG pays off once the content is too large, changes often, or needs per-user permissions.

On this page

  • The pipeline, step by step
  • Why RAG instead of a bigger prompt or retraining
  • Building RAG in a Startbase app
  • Common confusions and failure points

Keep reading

More in Glossary
Editorial ink illustration of a hand-cranked music box drum plucking a metal comb, the crank handle in ember orange
GlossaryNovember 22, 2026

What is a game loop?

Every real-time game runs one repeating cycle: read input, update the world, draw it. Here is what that cycle looks like and why it decides how your game feels.

3 min read
Editorial ink illustration of a brass stopwatch beside a small wind-up toy car, the second hand in ember orange
GlossaryNovember 22, 2026

What is delta time?

Delta time is the number that keeps your game the same speed on every screen. Here is how to use it, where it breaks, and how to spot a game that forgot it.

3 min read

Read less. Ship more.

Everything in this post is one prompt away. Describe your app and watch it build.

Start building

Apps, games, backends and publishing from one conversation.

Product

  • Features
  • Use cases
  • Pricing
  • Changelog

Resources

  • Blog
  • Docs
  • Support
  • Status
  • Security

Contact

  • w@startbase.ai
  • X / Twitter
  • LinkedIn
  • Instagram

Legal

  • Terms
  • Privacy

© 2026 Startbase. All rights reserved.