Skip to main content
Build a Retrieval-Augmented Generation (RAG) system that lets users ask questions about your own documents. The pipeline embeds your docs, stores the vectors, finds relevant chunks at query time, and passes them to a chat model for grounded answers.

What you’ll build

A production RAG pipeline that:
  1. Chunks and embeds your documents using Runcrate’s embedding models
  2. Stores vectors in any vector database (Postgres pgvector, Pinecone, Weaviate, or in-memory)
  3. Retrieves relevant chunks for each user query
  4. Generates accurate, grounded answers using Runcrate’s chat models

Architecture


Full example (Vercel AI SDK + pgvector)

1. Embed and store documents

2. Query at runtime


Full example (Python SDK + in-memory)

A minimal RAG pipeline using cosine similarity in Python — no vector database needed for small doc sets:

Production tips

  • Chunking matters most. Split documents at semantic boundaries (paragraph breaks, headers), not fixed character counts. Aim for 200–500 tokens per chunk.
  • Hybrid search (vector + keyword BM25) is the single biggest quality improvement over pure vector search.
  • Reranking with a cross-encoder after initial retrieval is the highest-ROI step — retrieve top-50, rerank to top-5, send to LLM.
  • Include metadata (title, source URL, date) in each chunk so the model can cite sources.