惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

P
Privacy International News Feed
Security Archives - TechRepublic
Security Archives - TechRepublic
The Cloudflare Blog
D
Docker
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
TaoSecurity Blog
TaoSecurity Blog
GbyAI
GbyAI
小众软件
小众软件
C
Cybersecurity and Infrastructure Security Agency CISA
V
Visual Studio Blog
L
LINUX DO - 热门话题
Recorded Future
Recorded Future
W
WeLiveSecurity
Vercel News
Vercel News
N
News and Events Feed by Topic
Y
Y Combinator Blog
N
News and Events Feed by Topic
博客园 - 聂微东
酷 壳 – CoolShell
酷 壳 – CoolShell
The GitHub Blog
The GitHub Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
P
Palo Alto Networks Blog
IT之家
IT之家
Attack and Defense Labs
Attack and Defense Labs
Know Your Adversary
Know Your Adversary
Hugging Face - Blog
Hugging Face - Blog
H
Heimdal Security Blog
C
CERT Recently Published Vulnerability Notes
博客园 - 叶小钗
C
CXSECURITY Database RSS Feed - CXSecurity.com
C
Check Point Blog
阮一峰的网络日志
阮一峰的网络日志
罗磊的独立博客
云风的 BLOG
云风的 BLOG
N
Netflix TechBlog - Medium
The Last Watchdog
The Last Watchdog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
T
Tor Project blog
Last Week in AI
Last Week in AI
S
Security @ Cisco Blogs
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Google Online Security Blog
Google Online Security Blog
Jina AI
Jina AI
T
Tenable Blog
月光博客
月光博客
J
Java Code Geeks
Microsoft Azure Blog
Microsoft Azure Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
S
Schneier on Security
H
Help Net Security

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
RAG Architecture — Prototype to Production in Three Stages
uatgpt · 2026-04-24 · via DEV Community

uatgpt

Hello RAG community, pardon for missing cover image (will revise soon), today's sharing is relating to RAG pipeline and workflow orchestration. For your kind perusal, thank you. Feel free to build on the knowledge base ("KB").

RAG Architecture — Prototype to Production in Three Stages | uatgpt.com

Architecture comparison across naive, advanced, and modular RAG with retrieval quality metrics, chunking strategy performance data, and production scaling patterns.

favicon uatgpt.com

Originally published on uatgpt.com — cross-posted here for the DEV community. The canonical version lives on uatgpt.com; this mirror exists for reader discovery.

Your RAG System Returns the Right Documents 70% of the Time — Here's Why Production Requires 95%

Retrieval-Augmented Generation is the most deployed AI architecture pattern in 2026 — and the most poorly implemented. The gap between a RAG prototype (embed documents, retrieve top-k, generate response) and a production RAG system (handles ambiguous queries, retrieves across document types, maintains freshness, and fails gracefully) is not a few tweaks. It's a fundamentally different architecture. This guide maps the three stages of RAG maturity, provides retrieval quality benchmarks at each stage, and documents the engineering decisions that determine whether your RAG system answers questions or hallucinates confidently.

The Three RAG Maturity Stages

Stage 1 — Naive RAG (Prototype)

Documents → chunk → embed → store in vector DB → retrieve top-k → concatenate into prompt → generate.

Component Typical implementation Quality
Chunking Fixed-size (512 tokens) with overlap Adequate for homogeneous documents
Embedding Single model (text-embedding-3-small) Good general coverage
Retrieval Cosine similarity, top-5 60-75% relevance on diverse queries
Reranking None N/A
Generation Retrieved chunks concatenated into system prompt Answers often include irrelevant information
Evaluation Manual spot-checking No systematic measurement

When Naive RAG is sufficient: Internal knowledge bases with <10,000 documents, homogeneous document types (all PDFs or all markdown), and users who can tolerate occasional irrelevant answers. Prototypes and proof-of-concept demos.

When Naive RAG fails: Ambiguous queries ("What's the policy on returns?" when 15 documents mention returns in different contexts), multi-hop questions requiring synthesis across documents, documents with tables/images/code blocks, and any application where wrong answers have consequences.

Stage 2 — Advanced RAG (Production Minimum)

Adds pre-retrieval optimization, post-retrieval filtering, and systematic evaluation.

Component Typical implementation Quality improvement over Naive
Query transformation Query rewriting, HyDE, multi-query expansion +10-15% retrieval relevance
Chunking Semantic chunking (by section/paragraph) +5-10% chunk quality
Embedding Domain-specific or fine-tuned embedding model +5-8% embedding quality
Retrieval Hybrid (vector + BM25 keyword search) +10-20% recall on keyword-dependent queries
Reranking Cross-encoder reranker (Cohere, BGE) +8-15% precision in top-5
Context management Deduplication, relevance filtering, token budgeting Reduces irrelevant context by 30-50%
Generation Structured prompt with source attribution More faithful answers, traceable to sources
Evaluation Automated metrics (faithfulness, relevance, completeness) Systematic quality tracking

Total quality improvement: Naive RAG at 65% retrieval relevance → Advanced RAG at 85-90% retrieval relevance. The 20-25 percentage point improvement comes from cumulative gains across every component.

Stage 3 — Modular RAG (Scale Architecture)

Decomposes RAG into independently scalable modules with routing, caching, and fallback patterns.

Component Implementation Quality improvement over Advanced
Router Query classifier routes to specialized retrieval pipelines +5-10% on domain-specific queries
Multi-index Separate indexes per document type (technical docs, FAQs, policies) +5-8% relevance through index specialization
Adaptive retrieval Decide at runtime: retrieve, generate from knowledge, or ask for clarification Eliminates unnecessary retrieval (20-30% of queries don't need it)
Cache layer Semantic cache for repeated/similar queries 30-60% latency reduction, 40-70% cost reduction
Feedback loop User feedback updates retrieval ranking and chunk quality scores +3-5% relevance improvement per quarter
Fallback chain Primary retrieval → expanded retrieval → web search → "I don't know" Reduces hallucination on out-of-scope queries by 60-80%

Chunking Strategy Performance

Chunking is the most impactful decision in RAG architecture — bad chunks guarantee bad retrieval regardless of everything downstream.

Strategy How it works Best for Retrieval relevance Failure mode
Fixed-size (512 tokens) Split at token count with overlap Homogeneous text documents 65-75% Cuts sentences mid-thought; tables broken across chunks
Fixed-size (256 tokens) Smaller chunks, more granular FAQ-style, short-answer queries 70-78% Too granular for complex topics; loses context
Sentence-based Split on sentence boundaries Well-structured prose 72-80% Single sentences lack context for complex queries
Paragraph-based Split on paragraph boundaries Articles, reports, documentation 75-83% Paragraphs vary wildly in size (50-500 tokens)
Semantic (embedding similarity) Group sentences by embedding similarity Mixed-format documents 78-85% Computationally expensive; may group unrelated but similar text
Document-section Split on headings (H1, H2, H3) Structured documents (docs, wikis) 80-88% Requires well-structured source documents
Recursive (parent-child) Small chunks for retrieval, parent chunks for context Complex topics needing both precision and context 82-90% Implementation complexity; storage overhead (2x)
Agentic (LLM-generated) LLM identifies natural chunk boundaries Unstructured, heterogeneous documents 83-90% Expensive ($0.01-0.05 per document); slow ingestion

Chunk Size vs. Retrieval Quality

Chunk size (tokens) Recall@5 Precision@5 Best use case
128 82% 60% Factoid questions (who, what, when)
256 78% 68% Short-answer questions with moderate context
512 72% 75% Questions requiring paragraph-level context
1024 65% 80% Complex questions requiring full section context
2048 55% 82% Questions about entire document themes

The tradeoff: Smaller chunks have higher recall (more relevant chunks found) but lower precision (more irrelevant chunks in the top-k). Larger chunks have higher precision (each chunk is more self-contained) but lower recall (fewer distinct chunks match). The recursive parent-child strategy resolves this: retrieve small chunks for precision, expand to parent for context.

Retrieval Quality Benchmarks

What "Good" Looks Like

Metric Definition Prototype target Production target Excellent
Retrieval relevance % of retrieved chunks relevant to query >60% >85% >92%
Answer faithfulness % of answer claims supported by retrieved context >70% >90% >95%
Answer completeness % of relevant information included in answer >50% >75% >85%
Hallucination rate % of answers containing unsupported claims <30% <10% <5%
Latency (p50) Median end-to-end response time <5s <3s <1.5s
Latency (p95) 95th percentile response time <15s <8s <4s
Cost per query Total inference + retrieval cost <$0.10 <$0.03 <$0.01

Component-Level Benchmarks

RAG component Metric Baseline (naive) Target (advanced) Target (modular)
Embedding Recall@10 on eval set 70% 82% 88%
Retrieval NDCG@5 0.55 0.72 0.80
Reranker Precision@3 (post-rerank) N/A 85% 90%
Generation Faithfulness (RAGAS) 0.65 0.85 0.92
Generation Relevance (RAGAS) 0.60 0.80 0.88

Embedding Model Selection

The embedding model determines the quality ceiling of your retrieval. No amount of reranking or query transformation compensates for a bad embedding.

Model Dimensions MTEB score Speed (tokens/sec) Cost Best for
text-embedding-3-small (OpenAI) 1536 62.3 10,000+ $0.02/1M tokens Cost-optimized, high volume
text-embedding-3-large (OpenAI) 3072 64.6 5,000+ $0.13/1M tokens Quality-sensitive applications
voyage-3 (Voyage AI) 1024 67.3 4,000+ $0.06/1M tokens Code and technical documentation
embed-v4.0 (Cohere) 1024 66.2 6,000+ $0.10/1M tokens Multilingual, search-optimized
BGE-large-en-v1.5 (BAAI) 1024 64.2 3,000+ Free (self-hosted) Privacy-sensitive, on-premise
Nomic Embed v1.5 768 62.3 5,000+ Free (self-hosted) Open-source, variable dimension
GTE-Qwen2 (Alibaba) 1536 67.2 3,000+ Free (self-hosted) High quality, self-hosted
jina-embeddings-v3 1024 65.5 4,000+ $0.02/1M tokens Task-specific adapters (retrieval, classification)

Selection decision: If using a hosted vector database (Pinecone, Weaviate Cloud) and cost is secondary to quality, use voyage-3 or text-embedding-3-large. If self-hosting and privacy matters, use GTE-Qwen2 or BGE-large. For high-volume, cost-optimized pipelines, text-embedding-3-small at $0.02/1M is hard to beat.

Hybrid Retrieval — Vector + Keyword

Pure vector search misses keyword-dependent queries. Pure keyword search misses semantic queries. Hybrid retrieval combines both:

Query type Vector search relevance BM25 relevance Hybrid relevance
Semantic ("How does photosynthesis work?") 85% 55% 87%
Keyword ("error code E_CONN_REFUSED") 40% 92% 90%
Mixed ("troubleshoot slow database queries") 72% 68% 82%
Acronym/jargon ("RBAC vs ABAC comparison") 50% 85% 86%
Conceptual ("best practice for API authentication") 80% 60% 84%

Hybrid retrieval achieves 82-90% relevance across all query types where either individual method has blind spots. The standard implementation: retrieve top-20 from each method, merge with Reciprocal Rank Fusion (RRF), take top-5.

Cost Architecture at Scale

Monthly queries Naive RAG cost Advanced RAG cost Modular RAG cost
10K $25-50 $40-80 $50-100
100K $250-500 $300-600 $200-400 (cache reduces cost)
1M $2,500-5,000 $2,000-4,000 $800-1,500 (cache + routing)
10M $25,000-50,000 $15,000-30,000 $5,000-12,000

The crossover: Modular RAG costs more at low volume (infrastructure overhead) but dramatically less at high volume (semantic caching eliminates 40-70% of LLM calls, routing sends simple queries to cheaper models). The breakeven is around 100K-500K monthly queries.

Cost Breakdown per Query (Advanced RAG)

Component Cost per query % of total
Embedding (query) $0.000002 <1%
Vector search $0.0001-0.001 2-5%
Reranking $0.001-0.005 10-25%
LLM generation $0.005-0.05 60-80%
Infrastructure (DB, compute) $0.001-0.005 5-15%
Total $0.008-0.06 100%

LLM generation dominates cost. The most impactful cost optimization is reducing unnecessary generation (via caching) and reducing context size (via better chunking and reranking).

Related Reading

How to Apply This

Use the token-counter tool to measure your retrieved context size — this is the dominant input cost in every RAG query. Reducing top-k from 10 to 5 with a reranker can cut input tokens by 50%.

Start with Stage 1 (Naive RAG) and measure. Build the simplest pipeline, establish quality baselines on your actual queries, then add components that address specific measured gaps.

Invest in chunking before anything else. Switching from fixed-size to semantic or document-section chunking typically delivers the highest quality improvement per engineering hour.

Add hybrid retrieval when keyword queries fail. If your users search for error codes, product names, or specific terminology, pure vector search will miss 30-50% of these queries.

Implement evaluation before scaling. A RAG system without automated evaluation is a system that degrades silently. RAGAS faithfulness and relevance scores on 100+ representative queries is the minimum.

Retrieval Costing

MTEB scores measure general embedding quality; domain-specific performance can differ by 10-20 points. Retrieval relevance percentages are based on English-language benchmarks; multilingual retrieval quality is typically 10-15% lower. Chunking performance data assumes clean, well-formatted source documents — real-world documents with mixed formatting, tables in images, and inconsistent structure perform worse. Cost projections assume stable API pricing — embedding costs have dropped 50-80% annually. The "Modular RAG saves money at scale" claim assumes effective caching, which depends on query diversity — highly diverse query distributions benefit less from caching. Hybrid retrieval adds BM25 indexing infrastructure; the complexity cost is real.


Transparency: This article was authored and reviewed by the uatgpt.com editorial team. Cross-posted to DEV with AI assistance used for formatting and canonical-link attribution. The canonical version and any updates live at uatgpt.com.