Skip to content
anythingai.space
Design Patternsintermediate15 min · 10 steps

AI Design Patterns

A catalog of reusable patterns for RAG, agents, optimization, reliability and cost: what each looks like, and when it earns its complexity.

NAIVE RAG · MVPSADVANCED RAG · PRODUCTIONstuff top-kQueryVector searchtop-kGenerateRewrite queryHybrid search50 vector + 50 BM25RerankRRF top 20 → best 5+100–200 msGenerate
requestdatatool callsignalresponseheavy workerror
1 / 10
How it worksStep 1 of 10

RAG: start naive, graduate to advanced

Naive RAG: embed the query, search vectors, stuff the top-k into the prompt, generate. Good for MVPs and simple Q&A, but it has no reranking or query rewriting and can retrieve irrelevant chunks.

Advanced RAG adds stages: rewrite the query, run hybrid search (50 vector + 50 BM25 results), fuse with reciprocal rank fusion, rerank the top 20, and generate from the best 5. The guide's rule of thumb: reranking costs 100–200 ms and buys a 10–15% precision gain, which is worth it in production.

What changed
  • +Naive pipeline
  • +Advanced pipeline with rewrite, hybrid search and rerank

Lesson 1 of 2 in Design Patterns