How to build a RAG

A 10-step method to build retrieval-augmented generation on your own documents, 8 tools compared on what they really bill, and the cost traps the tutorials skip.

Short answer: to build a RAG, parse your documents into clean text, split them into chunks, turn each chunk into an embedding, and store the embeddings in a vector database. At question time, retrieve the closest chunks and ask an LLM to answer only from them, with citations. For most teams that means LlamaIndex or LangChain to wire the pipeline, Qdrant or Supabase pgvector to store vectors, embeddings from OpenAI or Cohere, and a reranker once the first version works. Start with one use case and 30 to 50 test questions, not with every document you own.

We compared the tools the leading tutorials use most, kept 8, and read their pricing and documentation down to the units: a token, a dimension, a read unit, a GB stored per day, a credit per page parsed. If you only need the storage layer, our best vector database ranking goes deeper on that one choice.

Romain CochardCEO of Hack'celeration
Updated 20268tools compared10steps7cost traps

The ranking is editorial: a sponsored placement is always flagged on its card, and no affiliate link changes a score.

How a RAG works

8 tools to build your RAG

What a RAG is. Retrieval-augmented generation (RAG) makes a language model answer from your documents instead of from what it memorized during training. The model does not learn your data. At each question, a search step finds the few passages that matter, and those passages go into the prompt with an instruction: answer from this, cite it, and say so when the answer is not there. That is why a RAG can answer about a policy updated yesterday, and why keeping it current means updating documents, not retraining a model.

How it works: two pipelines. The indexing pipeline runs ahead of time. It loads each document, parses it into clean text, splits it into chunks, turns each chunk into an embedding (a list of numbers that encodes its meaning) and stores it with its metadata: source, version, who may read it. The query pipeline runs on every question. It embeds the question with the same model, retrieves the nearest chunks (often mixed with a keyword search), optionally reranks them, then sends the best ones to the LLM with the question. Keeping the two apart is what lets you find which stage failed when an answer is wrong.

What to demand from your tools. Four things decide whether a build survives real users. Metadata filters applied inside the search, so nobody retrieves a document they may not read. Hybrid search, because vectors miss exact codes, part numbers and names that a keyword search catches. A clean way to update and delete a document when it changes. And a bill you can predict from your own volumes. The right-hand column of the table says what each tool bills you on.

The units, explained. A token is a piece of a word; embedding models and LLMs bill per million tokens, and a dense page of text is roughly 800 tokens. A dimension is one number in an embedding: OpenAI's text-embedding-3-small returns 1,536 of them, text-embedding-3-large 3,072, and more dimensions mean more storage and memory per chunk. A read unit (Pinecone) measures a query's work: 1 per GB of the namespace searched. GB per day (OpenAI file search) is storage billed daily, not monthly. A credit (LlamaParse) pays for parsing, from 1 to 25 per page depending on the mode. A trace (LangSmith) is one logged run of your pipeline, kept for debugging and evaluation.

A RAG is a stack, not one product. This page ranks three kinds of tools: two frameworks that wire the pipeline (LlamaIndex, LangChain), four vector stores (Qdrant, Supabase pgvector, Pinecone, Chroma) and two model providers for embeddings, reranking and managed retrieval (OpenAI, Cohere). A small team usually picks one framework, one store and one model provider. If the word embedding is new to you, our vector database glossary entry explains how similarity search works.

Other names you will see. Tutorials also use FAISS, an open-source similarity-search library that keeps vectors in memory: perfect in a notebook, but a library rather than a database, so filters, updates and persistence are yours to build. Weaviate and Milvus (sold managed as Zilliz Cloud) are strong vector databases, covered in our vector database ranking and in our Weaviate alternatives. Haystack is a third framework. Ragas is an evaluation library, not a builder. And the cloud suites (Amazon Bedrock Knowledge Bases, Google Vertex AI RAG Engine, Azure AI Search) make sense when your data and contracts already live in that cloud.

Best forWhat you are billed onFree planTeam sizeVisit
1LlamaIndexBest framework for document-heavy RAGCredits per page parsed (1 to 25)4.4/5Framework free (MIT); LlamaParse 10,000 free credits a month, then $1.50 per 1,000 credits; Pro $500/month✓Teams with PDFs, tables and scansVisit →
2QdrantBest vector database for most RAG buildsvCPU, RAM and disk per hour4.4/5Free Tier $0 (0.5 vCPU, 1 GB RAM, 4 GB disk, suspended after 1 week unused); Standard billed hourly on usage; Premium with a minimum spend✓Most teams, self-hosted or cloudVisit →
3Supabase (pgvector)Best if your app already runs on PostgresPlan, compute hours and disk per GB4.3/5Free $0 (500 MB database, paused after 1 week idle); Pro from $25/month ($10 compute credit); Team from $599/month✓Apps already on PostgresVisit →
4LangChainBest framework for agentic RAGSeats plus traces (0.005 LSU each)4.2/5Framework free (MIT); LangSmith Developer $0 (1 seat, 5,000 traces a month); Plus $39 per seat a month✓Teams heading toward agentsVisit →
5OpenAI (embeddings and file search)Fastest managed RAGTokens, GB stored per day, tool calls4.2/5text-embedding-3-small $0.02 per 1M tokens; file search $0.10 per GB a day after 1 GB free, $2.50 per 1,000 calls—Prototypes and small corporaVisit →
6PineconeBest serverless store with nothing to runRead units (1 per GB searched)4.1/5Starter free; Builder $20/month flat; Standard $50/month minimum + usage (reads $16 to $18 per million); Enterprise $500/month minimum✓Teams without a database engineerVisit →
7Cohere (Embed and Rerank)Best reranker to add once retrieval worksTokens embedded and reranked4.1/5Free trial key (no production use); Embed 5 Fast $0.08 and Rerank 5 Fast $0.02 per 1M tokens—Teams tuning retrieval qualityVisit →
8ChromaBest for a local prototypeGiB written, stored and queried4.0/5Open source (Apache 2.0); Cloud Starter $0 + $5 credits, then $2.50 per GiB written, $0.33 per GiB stored a month; Team $250/month + usage✓Solo developers and prototypesVisit →

Prices in US dollars, excluding tax, for each vendor's default region. Usage prices vary with the region, the model and the plan.

Is your tool missing from this page? Email us: hello@hackceleration.com

1
Best framework for document-heavy RAG

LlamaIndex

4.4/5

LlamaIndex is an open-source framework built around one job: connecting your documents to a language model. The library is free under the MIT license and gives you document loaders, chunkers, indexes, retrievers and query engines, and more than 300 integration packages connect it to model providers and vector stores. Its real strength is the part most RAG projects underestimate: getting clean text out of messy files. LlamaParse, its hosted parser and extractor, turns PDFs, tables and scans into clean text before chunking, so a chunk keeps a number next to its label.

Parsing is billed in credits. The Pay-as-you-go plan costs $0 a month and includes 10,000 credits every month, then $1.50 per 1,000 credits; the Pro plan costs $500 a month with 400,000 credits a month, then $1.25 per 1,000. What one page costs depends on the tier you choose: 1 credit in Fast mode, 3 in Cost-effective, 10 in Agentic and 25 in Agentic Plus. That spread is the number to watch. 10,000 pages in Fast mode fit inside the free monthly credits, while the same 10,000 pages in Agentic mode cost about $135.

The weak side is the learning curve. The library has many layers of abstraction and its API moves fast, so code from older tutorials often needs rework. Use it for orchestration, read the current documentation rather than old blog posts, and pin your package versions.

Standout features
  • Framework free under MIT
  • 10,000 parsing credits free each month
  • Parsing from 1 to 25 credits a page
+Pros
  • ✓Strong on PDFs, tables and scans
  • ✓Over 300 integration packages
  • ✓Free credits cover a first corpus
−Cons
  • ✗Many abstractions to learn
  • ✗Agentic parsing gets expensive at volume
  • ✗Fast-moving API, old samples need rework
Verdict

Our first pick when the knowledge base is made of PDFs and tables: free to code with, and its parser fixes the input that sinks most RAG builds.

See LlamaIndex pricing → →
2
Best vector database for most RAG builds

Qdrant

4.4/5

Qdrant is an open-source vector database licensed under Apache 2.0, so you can run it on your own server for free or rent it fully managed. For a RAG, it covers the three jobs a store must do well. It filters by metadata during the search (tenant, document version, access label), so a user never retrieves a chunk they may not read. It runs dense and sparse or keyword queries together and fuses the results inside the database with Reciprocal Rank Fusion (RRF) or DBSF, so you do not merge two result lists in your own code. And it updates or deletes points when a document changes.

Qdrant Cloud has a Free Tier that is free forever: a single-node cluster with 0.5 vCPU, 1 GB of RAM and 4 GB of disk, meant for testing and prototypes; an unused free cluster is suspended after 1 week and deleted after 4 weeks of inactivity if you do not reactivate it. The Standard Tier bills what your cluster consumes (vCPU, memory, disk, backups), hourly, with a 99.5% uptime SLA. The Premium Tier adds SSO, private VPC links and a 99.9% SLA against a minimum spend. Our best vector database ranking puts these prices next to Pinecone, Weaviate and Zilliz.

The weak side is sizing. A usage-billed cluster asks you to pick RAM and disk, and the Free Tier runs without high availability. Estimate memory from your vector count and dimensions in the pricing calculator before you move a production index to it.

Standout features
  • Apache 2.0, self-host for free
  • Free Tier: 1 GB RAM, 4 GB disk
  • Hybrid fusion built in (RRF, DBSF)
+Pros
  • ✓Metadata filters inside the search
  • ✓Same engine locally and in the cloud
  • ✓Hourly billing, no plan jump
−Cons
  • ✗You size RAM and disk yourself
  • ✗Free Tier has no high availability
  • ✗Premium needs a minimum spend
Verdict

The store we would pick for most new RAG builds: open source, a real free tier, and hybrid search without glue code in your app.

See Qdrant pricing → →
3
Best if your app already runs on Postgres

Supabase (pgvector)

4.3/5

Supabase is a hosted Postgres platform, and pgvector is the Postgres extension that stores embeddings in an ordinary table column. For a RAG, your chunks, their metadata, your users and their permissions sit in one database, and a single SQL query can filter by tenant and rank by vector distance at the same time. If your product already runs on Postgres, you add a column and an index instead of a new vendor. Our Supabase review covers the rest of the platform.

The Free plan costs $0 and includes a 500 MB database per project, but free projects are paused after 1 week of inactivity, which quietly takes a demo assistant offline. Pro starts at $25 a month and includes $10 a month of compute credits (enough for one Micro instance) and 8 GB of disk per project, then $0.125 per GB. Team starts at $599 a month. Compute is the line that grows, because a vector index wants RAM and larger instances are billed by the hour.

The weak side is the index ceiling. pgvector indexes the vector type up to 2,000 dimensions, so the 3,072 dimensions of OpenAI's text-embedding-3-large must be shortened or stored as halfvec (up to 4,000). Each vector takes 4 bytes per dimension plus 8, so 1,536 dimensions cost about 6 KB per chunk before the text itself. If you are weighing it against a dedicated store, our Pinecone vs Supabase comparison runs the numbers.

Standout features
  • Vectors next to your app data
  • Free plan with a 500 MB database
  • Pro from $25 a month
+Pros
  • ✓One SQL query for filters and similarity
  • ✓No extra vendor if you run Postgres
  • ✓$10 compute credit on paid plans
−Cons
  • ✗Free projects pause after a week idle
  • ✗vector type indexed up to 2,000 dimensions
  • ✗Compute cost grows with the index
Verdict

The right store when your app already lives on Postgres: one database for users, permissions and vectors, as long as you budget RAM for the index.

See Supabase pricing → →
4
Best framework for agentic RAG

LangChain

4.2/5

LangChain is an open-source framework for LLM applications and agents, released under the MIT license, and the stack many RAG tutorials start from. It brings document loaders, text splitters (its RecursiveCharacterTextSplitter shows up in many beginner tutorials), a large library of integrations with model providers, vector stores and retrievers, and LangGraph, its framework for controllable agent workflows. That last piece is why teams pick it for agentic RAG: a graph that retrieves, grades what it found, rewrites the query and searches again when the first pass misses.

The framework is free; the paid part is LangSmith, the tracing and evaluation platform. The Developer plan is $0 for 1 seat with 5,000 base traces a month. Plus costs $39 per seat a month, includes 10,000 traces, and bills 0.005 LSU per additional trace, at $1.00 per LSU: $5 per 1,000 extra traces. Traces are billed monthly in arrears. That matters for a RAG in production, where every question can become a trace. Our LangChain review scores the framework on its own, and our LangChain training teaches it from scratch.

The weak side is complexity. The layers of abstraction make a simple retrieve-then-answer pipeline longer to debug than it should be, and many tutorials online still use retired APIs. For a plain question-answering bot over documents, LlamaIndex is the more focused option, and our LangChain alternatives list the other frameworks.

Standout features
  • Framework free under MIT
  • LangSmith free for 5,000 traces a month
  • LangGraph for retrieval loops
+Pros
  • ✓Plenty of tutorials and examples
  • ✓Loaders and splitters for most formats
  • ✓Tracing and evals in LangSmith
−Cons
  • ✗Abstraction layers slow debugging
  • ✗Older tutorials use retired APIs
  • ✗Tracing every query adds a bill
Verdict

A solid choice when your RAG will grow into an agent that searches several times; for plain document Q&A, LlamaIndex is the more focused tool.

See LangChain pricing → →
5
Fastest managed RAG

OpenAI (embeddings and file search)

4.2/5

OpenAI covers two layers of a RAG. Its embedding models turn chunks into vectors: text-embedding-3-small costs $0.02 per million tokens and returns 1,536 dimensions, text-embedding-3-large costs $0.13 and returns 3,072, which you can shorten with the dimensions parameter. And its file search tool, in the Responses API, is a managed RAG: you upload files to a vector store, OpenAI parses, chunks and embeds them, and the model searches them when it answers.

File search is the fastest route to a working prototype, but it has two meters on top of the model's tokens. Storage costs $0.10 per GB per day beyond the first free GB, and each tool call costs $2.50 per 1,000 calls. By default every file is split into 800-token chunks with 400 tokens of overlap, so consecutive chunks share half their text; you can change both values when you add files. Files are capped at 512 MB and 5,000,000 tokens each, and an expiration policy deletes idle vector stores so they stop billing.

The weak side is control. You tune retrieval through parameters (chunk size, overlap, metadata filters, a ranker and a score threshold) rather than through your own code, and the index lives at OpenAI. When you outgrow it, you can keep OpenAI embeddings and move storage to your own vector database. Our LLM API ranking compares the generation side.

Standout features
  • Embeddings from $0.02 per 1M tokens
  • Managed file search, no database to run
  • Default chunks: 800 tokens, 400 overlap
+Pros
  • ✓Prototype without a vector database
  • ✓Cheap, well-documented embeddings
  • ✓Expiration policies stop idle storage bills
−Cons
  • ✗Storage billed per GB per day
  • ✗$2.50 per 1,000 file search calls
  • ✗Index and tuning stay at OpenAI
Verdict

The quickest route from a folder of files to cited answers; watch the daily storage meter and plan your exit before the index grows.

See OpenAI pricing → →
6
Best serverless store with nothing to run

Pinecone

4.1/5

Pinecone is a fully managed, serverless vector database: there is no cluster to size, you create an index and send vectors. It can also embed and rerank for you (integrated embedding and reranking land on the same invoice), and it supports dense, sparse and full-text indexes for hybrid search. Our Pinecone review scores it in detail.

Starter is free with monthly allowances: up to 2 GB of storage, 1 million read units and 2 million write units. Builder costs $20 a month flat with higher limits (10 GB, 2 million reads, 5 million writes). Standard has a $50 monthly minimum, then pay as you go: read units cost $16 to $18 per million depending on cloud and region, storage $0.33 per GB a month. Enterprise has a $500 minimum. The unit to understand is the read unit: a query uses 1 per GB of the namespace it searches, with a minimum of 0.25, whatever the number of results. Splitting data into one namespace per customer keeps each query small. The full grid is on our Pinecone pricing page.

The weak side is predictability and lock-in. On Starter and Builder, usage past an allowance is blocked rather than billed until the next period, so a demo can stop answering mid-month. And a hybrid search sent as one request counts once, but two searches merged in your own code count twice. If those limits rule it out, our Pinecone alternatives compare the other managed stores.

Standout features
  • Nothing to size or run
  • Builder at $20 a month flat
  • Integrated embedding and reranking
+Pros
  • ✓Serverless, scales without tuning
  • ✓Dense, sparse and full-text indexes
  • ✓Per-tenant namespaces keep reads small
−Cons
  • ✗$50 monthly minimum on Standard
  • ✗Read cost grows with namespace size
  • ✗Free-tier overage is blocked
Verdict

The easiest store to operate when nobody wants to run a database; model your read units per namespace before the first invoice.

See Pinecone pricing → →
7
Best reranker to add once retrieval works

Cohere (Embed and Rerank)

4.1/5

Cohere sells the two models that most often lift retrieval quality once a basic RAG works: embedding models (Embed 5 Fast and Embed 5 Pro) and rerankers (Rerank 5 Fast and Rerank 5 Pro). A reranker is a cross-encoder: instead of comparing two vectors computed separately, it reads the question and each candidate chunk together and scores how well the chunk answers. The usual pattern is to retrieve 50 to 100 candidates cheaply, rerank them, and send only the top few to the LLM.

Prices are per million tokens: Embed 5 Fast costs $0.08 and Rerank 5 Fast $0.02. Every account starts with a trial API key that is free, but trial keys are rate limited and may not be used for production or commercial purposes; production keys pay as you go. Read both meters before you size chunks: the price grid bills Rerank 5 per token, but the pricing FAQ still defines a rerank search as one query with up to 100 documents and splits any document over 500 tokens (query included) into chunks that each count as a document, so budget for the stricter of the two. Rerank 5 models read up to 32k tokens of query and document combined, in English and other languages. If you are comparing providers, see our Cohere alternatives.

The weak side: a reranker is not a guaranteed win. One practitioner's A/B over 540 queries on code and technical documents saw the share of right answers in first place fall from 58.3% to 43.0% with a general-purpose reranker. Another, on 11,000 pages of technical books, called reranking 100 candidates the biggest single retrieval gain. Test it on your own questions before you keep it.

Standout features
  • Rerank 5 Fast at $0.02 per 1M tokens
  • Free trial key for prototypes
  • Embed and Rerank from one provider
+Pros
  • ✓Reranking fixes near-miss retrieval
  • ✓Works on top of any vector store
  • ✓Low per-token prices
−Cons
  • ✗Trial key not allowed in production
  • ✗Pricing FAQ splits docs at 500 tokens
  • ✗Gains depend on your domain
Verdict

The stage to add second, not first: once retrieval finds the right chunk somewhere in the top 50, a reranker moves it to the top.

See Cohere pricing → →
8
Best for a local prototype

Chroma

4.0/5

Chroma is an open-source vector database under the Apache 2.0 license, and the store many tutorials use because it runs inside your Python process: no server, no account, a few lines to create a collection, add chunks with their metadata and query them. For a first RAG over a few hundred documents, it removes every infrastructure question so you can focus on parsing, chunking and prompts.

When the prototype needs to be shared, Chroma Cloud bills on usage. The Starter plan is $0 a month with $5 of free credits, then $2.50 per GiB written, $0.33 per GiB stored per month and $0.0075 per TiB queried, plus $0.09 per GiB returned over the network. The Team plan costs $250 a month plus usage, with $100 of credits, SOC II and Slack support. Note the write meter: every time you re-embed your corpus with a new model, you pay to write it again.

The weak side is the path to production. The embedded mode is made for a single developer; for several users, access control and uptime, you move to a Chroma server or to Chroma Cloud, and at that point Qdrant or Pinecone are worth comparing. To wire Chroma without code, our Chroma vector store integration for n8n shows the nodes.

Standout features
  • Apache 2.0, runs in your Python process
  • Cloud Starter with $5 of credits
  • $2.50 per GiB written
+Pros
  • ✓Zero setup for a prototype
  • ✓Metadata stored with each chunk
  • ✓Usage pricing with no minimum on Starter
−Cons
  • ✗Embedded mode is for one developer
  • ✗Re-embedding pays the write meter again
  • ✗Team plan jumps to $250 a month
Verdict

The fastest way to see your first answer on your laptop; plan the move to a server or a managed store before real users arrive.

See Chroma pricing → →
The method

How to build a RAG in 10 steps

Most RAG projects that disappoint fail before the model: wrong documents, broken tables, no test questions, no permissions. Here is the order we recommend for a first build, from the questions to production.

01

1. Pick one use case and write the test questions first

Start with one narrow job: answering support agents from the help center, or employees from the HR policies. Before any code, write 30 to 50 real questions with the document and passage that should answer each one. Include around one question in ten whose answer is not in your documents: they show you later whether the system says it does not know instead of inventing. A practitioner who built a RAG over 11,000 pages of technical books kept about 12% of deliberately unanswerable questions in their test set for that reason.

Test set
30 to 50 questions
Unanswerable
About 1 in 10
02

2. Collect the documents and parse them properly

List the sources (help center, Drive, Notion, PDFs, tickets), keep only current and approved versions, and convert them into clean text. Parsing is where most quality is won or lost: a PDF parser that splits a table row from its header gives the model numbers without labels, and no embedding model fixes that afterwards. Use a layout-aware parser for PDFs and scans (LlamaParse, Docling, Unstructured) and check its output on your ugliest files: in one public benchmark of 200 PDFs in 2026, the converters scored from 0.589 to 0.892 against hand-checked references. One team that spent three months on an internal assistant estimated 5% of its time on the LLM and 95% on data engineering.

Check
Tables and headings
Effort
Mostly data work
03

3. Chunk by structure, then tune the size

Split each document along its own structure (sections, headings, list items) and keep a rule with its exception in the same chunk. A sensible start is 300 to 800 tokens with 10 to 20% overlap, then adjust on your test questions. Fancy is not always better: a benchmark of seven chunking strategies on 50 academic papers found that the simple strategies beat the hyped ones once each got the same context budget. Attach the document title and section heading to every chunk, so a passage like "see the table above" still makes sense on its own.

Start
300 to 800 tokens
Overlap
10 to 20%
04

4. Pick one embedding model and record it

Every chunk and every question must be embedded with the same model, so the choice is sticky: changing it means re-embedding the whole corpus. Record the model name and its dimension count with each chunk. For most English corpora, OpenAI's text-embedding-3-small (1,536 dimensions) or Cohere Embed 5 Fast is plenty to start; a larger model only pays off if your test questions show it. Check that your vector store indexes the dimension you pick: pgvector indexes the vector type only up to 2,000 dimensions.

Rule
Same model for chunks and questions
Switching
Re-embed everything
05

5. Store vectors with their metadata

Load the chunks into your vector store with their metadata: source ID, version, effective date, language, tenant and access label. Metadata is what lets you filter at query time, delete an outdated version and audit an answer. A team indexing 13,000 pages of company filings in 2026 got more from reading company, year and document type out of the question and filtering on them than from switching embedding models. Testing one change at a time, that project took the share of questions whose right page appears in the top 10 from 41% to 93%. One fintech team kept two versions of the same risk policy in the index and saw its RAG retrieve the wrong one with great confidence; deleting the old PDF from a folder is not knowledge-base management. Our vector database ranking compares the stores in depth.

Must have
Version and access label
On update
Delete old chunks
06

6. Retrieve with filters and hybrid search

At query time, apply the user's permissions and the current-version filter inside the search, not after it. Then combine a vector search (meaning) with a keyword search such as BM25 (exact terms like an error code or an invoice number) and fuse the two lists with Reciprocal Rank Fusion. Fetch more candidates than you need: a practitioner running hybrid search in production pulls five times the final count from each engine before fusion, so enough good chunks survive the merge. Measure it, though: on annual filings that repeat the same wording every year, the same 13,000-page project found that hybrid search surfaced last year's look-alike pages and hurt results.

Filters
Inside the query
Fusion
RRF
07

7. Rerank, then keep the top few

Once the right chunk shows up somewhere in the top 50, a reranker can move it to the top. Retrieve 50 to 100 candidates, rerank them with a cross-encoder (Cohere Rerank, which also exists as a Cohere reranker node in n8n, an open-source cross-encoder, or Pinecone's integrated reranking), and pass the top 3 to 8 to the model. Measure before and after on your test set: rerankers help most when first-stage retrieval is weak and can hurt when it is already good.

Rerank
50 to 100 candidates
Send to the LLM
Top 3 to 8
08

8. Write a grounded prompt with citations

Tell the model to answer only from the retrieved passages, to cite the source ID of each claim, and to answer "I don't know" when the passages do not cover the question. Treat retrieved text as data, never as instructions: a document that says "ignore previous instructions" must not change what the model does. Have code, not the model, compute numbers that a database can give exactly (a remaining budget, a date difference), and return the source link with every answer.

Rule
Answer from context or abstain
Output
Answer plus sources
09

9. Evaluate retrieval and answers separately

Run your test set after every change and score two layers apart. Retrieval: does the right chunk appear in the top k (recall@k), and how high (MRR)? Answers: is the answer correct, and is it faithful to the retrieved text? Ragas ships ready-made metrics for both layers (context precision, context recall, faithfulness), and LangSmith or another tracer stores each run so you can see which chunk led to a bad answer. If the right passage never comes back, no prompt will fix it. Our guides to evaluating LLM answers and to LLM observability tools go further.

Retrieval
Recall@k, MRR
Answers
Correctness, faithfulness
10

10. Secure, refresh and monitor

Sync permissions from the source systems so a revoked access stops retrieval at once, schedule re-indexing of changed documents, and delete superseded versions. Log questions, retrieved chunk IDs, latency and cost per question, and review the questions that got "I don't know" every week: they tell you which documents are missing. If you would rather wire the pipeline without code, an automation tool like n8n has nodes for Qdrant, Pinecone and Supabase, and our guide to building an AI agent without code shows the pattern.

Refresh
Scheduled re-index
Weekly
Review unanswered questions
Traps and tips

The cost traps the tutorials do not price

Tutorials stop at the first answer. The bill and the failures start after, in units and defaults that the guides skip. Here are the ones we found, with the numbers.

01

On Pinecone, a big namespace makes every query cost more

A Pinecone query uses 1 read unit per GB of the namespace it searches, whatever the number of results. Put 50 GB of chunks in one namespace and serve 500,000 questions a month, and that is 25 million read units, or $400 to $450 at $16 to $18 per million on Standard. Split the same data into one namespace per customer of about 0.5 GB, and each query uses 0.5 read unit: 250,000 units, about $4 to $4.50, well inside the $50 monthly minimum. Check the plan ceiling first: an index holds 100 namespaces on Starter, 1,000 on Builder and 100,000 on Standard, so one namespace per customer pushes a growing SaaS to Standard. And send hybrid search as one request: two searches merged in your code are billed twice. Writes have a floor too, 5 write units per request, so batch your upserts.

50 GB, 500,000 queries
$400 to $450/mo
0.5 GB namespaces
About $4 to $4.50
03

pgvector will not index 3,072 dimensions as a plain vector

pgvector indexes the vector type up to 2,000 dimensions, and OpenAI's text-embedding-3-large returns 3,072 by default. Either request 1,024 or 1,536 dimensions with the dimensions parameter, or store them as halfvec (indexed up to 4,000). Size matters too: a vector takes 4 bytes per dimension plus 8, so 1,536 dimensions weigh 6,152 bytes. On Supabase's free 500 MB database, that is about 81,000 vectors at most, before the chunk text, the metadata and the index take their share.

vector index limit
2,000 dimensions
1,536 dims
6,152 bytes each
04

Parsing can cost hundreds of times more than embedding

Embedding is cheap: 10,000 pages at about 800 tokens each is 8 million tokens, or $0.16 with text-embedding-3-small. Parsing the same pages with LlamaParse depends entirely on the mode. In Fast mode (1 credit a page) they fit in the 10,000 free credits. In Agentic mode (10 credits) it is 100,000 credits, about $135 after the free ones. In Agentic Plus (25 credits), about $360. Use the cheap mode for clean text documents and save the agentic modes for scans and complex tables.

Embed 10,000 pages
$0.16
Parse them, Agentic
About $135
05

Tracing every production question is a second bill

LangSmith Plus includes 10,000 traces a month, then charges 0.005 LSU per trace, at $1 per LSU: $5 per 1,000 traces. A RAG that answers 100,000 questions a month and traces all of them pays 90,000 × 0.005 = 450 LSU, so $450 plus the $39 seat, about $489 a month for observability alone. Trace everything in development, then sample in production (every error, every thumbs-down, and a few percent of the rest).

100,000 traces
About $489/mo
Included
10,000 a month
06

Free tiers that stop instead of billing

Five free or capped plans behave differently from what a demo needs. Supabase pauses free projects after 1 week of inactivity, so a pilot that nobody uses over a holiday goes dark. Qdrant suspends an unused free cluster after 1 week and deletes it after 4 weeks of inactivity. Pinecone Starter and Builder block usage past their monthly allowance until the next period instead of billing it. Chroma Cloud pauses the service when a usage limit is reached, whether you set it or Chroma did. And a Cohere trial key is free but rate limited and not allowed for production or commercial use. Move anything a customer sees to a paid tier, even the cheapest one.

Supabase Free
Paused after 1 week idle
Pinecone Starter
Blocked past allowance
Chroma Cloud
Paused at a usage limit
07

A reranker can make results worse, and long chunks cost more

A general-purpose reranker can push good answers down on code or very technical text: one A/B test over 540 queries saw the right answer in first place drop from 58.3% to 43.0% with the reranker on. Keep it only if your own test set improves. And size chunks for it: Cohere's pricing FAQ counts any document over 500 tokens (query included) as several documents, so 1,000-token chunks double the document count, while its price grid bills Rerank 5 per token; check which meter your invoice uses.

First place, with reranker
58.3% to 43.0%
Cohere FAQ split
Every 500 tokens
Questions

What people also ask

  • What is the difference between RAG and fine-tuning?

    RAG gives the model your documents at question time; fine-tuning changes the model's weights by training it on examples. RAG is the right tool for knowledge that changes (prices, policies, product docs), because updating it means re-embedding the changed pages: 1,000 pages of about 800 tokens cost $0.016 to re-embed with text-embedding-3-small. Fine-tuning bakes patterns into the weights and needs a new training run for each change, so it suits a style, a format or a narrow task better than facts that move. Many production systems use both: a fine-tuned or well-prompted model on top of a RAG.

  • Which embedding model should you use for RAG?

    Start with a small, cheap general model and only move up if your test questions show a gain. OpenAI's own figures put text-embedding-3-small at about 62,500 pages per dollar and 62.3% on the MTEB benchmark, against about 9,615 pages per dollar and 64.6% for text-embedding-3-large: six and a half times the price for 2.3 points. For multilingual corpora, test a multilingual model on your own questions, and remember the choice is sticky: switching means re-embedding everything.

  • Is RAG still useful now that context windows are huge?

    Yes, for cost, freshness and permissions. Sending 100,000 tokens of documents with every question costs about $0.20 per question at $2.00 per million input tokens (gpt-6.2-sol), while five retrieved chunks of 800 tokens cost about $0.008: twenty-five times less. Long context also does not tell you which user may see which document. It works well for one-off analysis of a few files; for a knowledge base that thousands of people query, retrieval stays cheaper and auditable.

  • How long does it take to build a RAG system?

    A demo takes days; a system people trust takes months. One enterprise team had a working demo in its first week, then spent more than 80 more days on the last 20%: duplicate document versions, permissions and connectors that broke when folders moved. Plan the first week for a prototype on one use case, then budget most of the project for data cleanup, access control and evaluation, not for the model. If you would rather hand the build to a team, see our LangChain agency page.

  • Does caching help a RAG?

    Yes, at three levels, and the savings are large. Parse once: LlamaParse caches parsed files for 48 hours, and re-parsing a cached file in that window costs 0 credits. Put the fixed part of the prompt (instructions, format rules) first and keep it identical from one call to the next, because requests that share the same prompt prefix reuse the cache: on gpt-6.2-sol, cached input costs $0.10 per million tokens against $2.00 for fresh input, twenty times less. And store the embedding of frequent questions, so a repeated question skips the embedding call and goes straight to retrieval.

  • Can you run a RAG entirely on your own machine?

    Yes. Qdrant and Chroma are open source under Apache 2.0 and run locally, and local embedding and chat models run through tools like Ollama. One developer built a fully offline RAG over 27 books and about 11,000 pages on a single machine, with hybrid search and a local reranker. The trade-off is hardware and speed: large local models need a lot of memory. Our guide to deploying an open-source model covers that side.

  • When is agentic RAG worth it?

    When questions need several searches that depend on each other, such as comparing two contracts or tracing a rule through several documents. In agentic RAG, an agent decides what to search, reads the results, and searches again. One team running both in production measured agentic workflows at roughly 2 to 3 times the cost for 25 to 30% better accuracy. For single-fact questions, a well-tuned simple pipeline is faster and cheaper, so route only the complex questions to the agent.

  • How do you stop a RAG from making things up?

    Measure it first, with questions your documents cannot answer, then constrain what the model writes. One developer's test set had about 12% deliberately unanswerable questions and about 10% with a false premise, and scored the hallucination rate on the unanswerable ones with a judge from a different model family than the one answering. For exact values, a trading team found that quoting the source sentence almost verbatim, "ugly but grounded", beat a polished rewrite that drifted from the source. Citations help users check, but they do not prove the passage supports the claim.

Your answers are buried in a thousand PDFs?

Start with LlamaIndex's free parsing credits, one vector store and 30 test questions: one use case answered this week, the rest one step at a time.