What you’ll build
A production RAG pipeline that:- Chunks and embeds your documents using Runcrate’s embedding models
- Stores vectors in any vector database (Postgres pgvector, Pinecone, Weaviate, or in-memory)
- Retrieves relevant chunks for each user query
- 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.