RAG (Retrieval-Augmented Generation)

BytapaScript

Also known as: RAG, Retrieval Augmented Generation

In a nutshell

Giving an LLM your own documents so it answers from them.

What it means

An approach where AI searches relevant external information before generating an answer.

💡 An open-book examination where a student looks up relevant information before answering.

Code example

// 1. embed the query
const q = await embed("What is RAG?");
// 2. find similar chunks in the vector DB
const chunks = await vectorDB.search(q, { topK: 3 });
// 3. answer using those chunks as context
const answer = await llm.chat({ question: "What is RAG?", context: chunks });

Why it matters

It lets applications answer using company documents, private databases and up-to-date knowledge without retraining the model.

Common misconception

RAG is not fine-tuning: RAG looks things up at query time, while fine-tuning bakes knowledge into model weights.

When to use it

  • Answering questions over your docs
  • Support chatbots
  • Company knowledge bases

Further reading

Related terms

Learn Full Stack

with tapaScript

By clicking Sign Up you re confirming that you agree with our Terms and Conditions.

newsletter

Don't forget to connect with us on