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

推荐订阅源

K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
S
SegmentFault 最新的问题
Last Week in AI
Last Week in AI
阮一峰的网络日志
阮一峰的网络日志
Cloudbric
Cloudbric
www.infosecurity-magazine.com
www.infosecurity-magazine.com
S
Security @ Cisco Blogs
月光博客
月光博客
T
Troy Hunt's Blog
H
Help Net Security
Forbes - Security
Forbes - Security
博客园 - 叶小钗
Apple Machine Learning Research
Apple Machine Learning Research
IT之家
IT之家
L
LINUX DO - 最新话题
Hacker News - Newest:
Hacker News - Newest: "LLM"
GbyAI
GbyAI
S
Schneier on Security
Spread Privacy
Spread Privacy
Attack and Defense Labs
Attack and Defense Labs
Blog — PlanetScale
Blog — PlanetScale
N
News | PayPal Newsroom
F
Fortinet All Blogs
Latest news
Latest news
人人都是产品经理
人人都是产品经理
Recent Announcements
Recent Announcements
博客园_首页
Martin Fowler
Martin Fowler
Stack Overflow Blog
Stack Overflow Blog
雷峰网
雷峰网
O
OpenAI News
I
Intezer
S
Security Affairs
罗磊的独立博客
T
Tailwind CSS Blog
小众软件
小众软件
P
Palo Alto Networks Blog
Help Net Security
Help Net Security
V
Vulnerabilities – Threatpost
博客园 - 【当耐特】
F
Full Disclosure
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
J
Java Code Geeks
H
Hackread – Cybersecurity News, Data Breaches, AI and More
博客园 - 聂微东
博客园 - 司徒正美
T
The Exploit Database - CXSecurity.com
L
Lohrmann on Cybersecurity
C
Cisco Blogs
Security Latest
Security Latest

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 Explained for Beginners: How AI Assistants Stop Making Things Up
aashna mahajan · 2026-05-31 · via DEV Community

I once submitted an essay with three citations that I hadn't personally verified. The AI had suggested them, and they sounded right.

None of them existed.

That's not a quirk or a bug — it's exactly how LLMs work. And once you understand why, a technique called RAG starts to make a lot of sense.

AI assistants are remarkably good at sounding right. The model isn't lying — it's doing its best with what it knows. The problem is that what it knows has limits, and it doesn't always know where those limits are. Ask one about a recent event, a niche regulation, or anything from a source it's never seen — and it fills the gap anyway. Confidently.

That's the gap RAG was built to close. Once you understand how it works, you'll have a much clearer picture of why some AI tools are genuinely reliable and others are just very convincing guessers.

Here's what's actually going on.


First, What's the Problem?

Large language models (LLMs)—the technology powering AI assistants like ChatGPT and Claude—are trained on vast amounts of data from across the internet. That training gives them a remarkable ability to reason, summarize, and generate content. But it also comes with some real limitations:

  • They have a knowledge cutoff. An LLM trained last year doesn't know what happened last month.
  • They can hallucinate. When they don't know something, they don't say "I don't know"—they generate a confident-sounding answer anyway. Wrong facts, fake statistics, invented sources. All delivered with a straight face.
  • They don't know your specific sources. Think of a software engineer asking an AI assistant about their company's internal API documentation, deployment runbooks, or architecture decisions. None of that is in the training data. The model has never seen it — and it will still try to answer.

An AI assistant confidently presenting hallucinated information—wrong statistics, a nonexistent date, and made-up data — to a confused user
The model isn't lying — it's generating the most plausible answer it can. It just has no way to know when it's wrong.

So, what do you do when you need an AI that's accurate, current, and knows your specific domain? That's the problem RAG was designed to solve.


What Is RAG?

RAG stands for Retrieval-Augmented Generation.

Here's the plain-English version: Instead of relying purely on what an LLM memorized during training, RAG looks things up first—then uses what it found to answer your question.

Think of it like the difference between two types of students taking a test:

  • Student A (plain LLM): Studied everything months ago and answers purely from memory.
  • Student B (RAG): Gets to bring a set of reference documents to the exam and reads the relevant parts before answering.

Student B is going to be a lot more accurate — especially on recent or niche topics.

Side-by-side illustration: left panel shows a student struggling to answer from memory alone; right panel shows the same student confidently answering with reference books open
Same student, same question — completely different results depending on whether they can consult real sources.

Put it another way: RAG = looking up answers in a book + writing your own answer using what you found.

One thing worth saying upfront: RAG doesn't make an AI system magically correct. It gives the model better material to work with. If the retrieved documents are wrong, outdated, or irrelevant, the answer can still be wrong. The quality of the output is only as good as the quality of the sources.


How RAG Works, Step by Step

Here's the basic flow:

User Question → Retriever → Relevant Documents → Prompt + Context → LLM → Answer

Each step is simpler than it sounds.

Step 1: User Asks a Question

Simple enough. A user types something like, "What's the refund policy for orders over $100?"

Step 2: The Question Gets Turned Into a "Meaning Fingerprint"

Before the system can search anything, it needs to understand what the question means — not just the exact words. So it runs the question through an embedding model, which converts it into a list of numbers called a vector (or embedding).

Think of it as a meaning fingerprint: similar ideas produce similar vectors, even if they're phrased differently. This is how the system can match "refund policy" to a document that says "return and reimbursement guidelines"—same concept, different words.

Embedding model illustration: two similar sentences—
Different words, nearly identical vectors. That's what lets the retriever find the right document even when the user's phrasing doesn't match exactly.

Step 3: The System Retrieves Relevant Information

That vector gets compared against a vector database—a collection of pre-processed document chunks, each already converted into their own meaning fingerprints. The system finds the chunks that are closest in meaning to your question and pulls them up.

The result: a handful of the most relevant text snippets from your knowledge base.

Step 4: The Retrieved Context Gets Added to the Prompt

The system packages the user's question and the retrieved text together into a single prompt:

"Using the following information, answer the user's question. If the answer isn't in the context, say you don't know. Information: [retrieved document text]. Question: What's the refund policy for orders over $100?"

Step 5: The LLM Generates an Answer

Now the LLM responds — but it's grounded in the actual documents, not just its training data. The answer is more accurate, more specific, and far less likely to be hallucinated.

Don't code yet? Skip straight to the concrete example below—you'll understand how RAG works without needing this.

If you do write Python, here's what all five steps look like—the actual library you use (LangChain, LlamaIndex, or plain OpenAI SDK) slots into the same shape:

# Step 1–2: Load your documents, chunk them, convert to vectors, store
chunks = load_and_chunk("support_docs/")
vector_db = embed_and_store(chunks)

# Step 3: User asks a question — find the most relevant chunks
query = "Does AcmeSoft support two-factor authentication?"
relevant_chunks = vector_db.search(query, top_k=3)

# Steps 4–5: Build a grounded prompt, send to the LLM
prompt = f"""
Answer using only the context below.
If the answer isn't there, say you don't know.

Context: {relevant_chunks}
Question: {query}
"""
answer = llm.generate(prompt)

# → "Yes, AcmeSoft supports 2FA for enterprise accounts via the Security tab..."

The shape is always the same: load → embed → retrieve → prompt → answer. The library you pick just fills in the blanks.


A Concrete Example

Let's make this tangible.

User asks, "Does AcmeSoft support two-factor authentication for enterprise accounts?"

Retrieved document snippet (from AcmeSoft's internal support docs):

"Enterprise accounts on AcmeSoft can enable two-factor authentication (2FA) through the Security tab in Account Settings. Both TOTP apps (like Google Authenticator) and SMS-based verification are supported."

Prompt sent to the LLM:

"Using the following information, answer the user's question. If the answer isn't here, say you don't know. Information: [snippet above]. Question: Does AcmeSoft support two-factor authentication for enterprise accounts?"

LLM's answer:

"Yes! AcmeSoft supports two-factor authentication for enterprise accounts. You can enable it from the Security tab in your Account Settings. They support both authenticator apps (like Google Authenticator) and SMS verification."

That answer is accurate, grounded in real documentation, and actually useful. Without RAG, the LLM would have no idea what AcmeSoft's features are.

Three-panel illustration of the RAG process: a woman asking a question at her laptop, a robot arm retrieving files from a cabinet, and a robot writing a grounded answer
Ask → Retrieve → Answer. The robot isn't guessing — it's reading the filing cabinet first.


The Tools That Make RAG Happen

The good news: you don't have to build any of this from scratch. Several popular libraries handle the heavy lifting:

  • LangChain — A popular Python and JavaScript framework for building RAG pipelines.
  • LlamaIndex — Connects LLMs to your private data; great for document-heavy use cases.
  • Haystack — An open-source framework built specifically for search and question-answering systems.
  • FAISS — A fast vector search library from Meta, often used for local or custom setups.
  • Chroma — A lightweight vector database that's beginner-friendly for small projects.
  • Pinecone / Weaviate — Cloud-hosted vector databases commonly used for production-scale RAG systems.

If you're just starting out, LangChain or LlamaIndex are the most beginner-friendly—the others become relevant as you scale.

An open toolbox containing the core RAG building blocks: wrenches labeled as frameworks, gears for processing, a magnifying glass for retrieval, a database for vector storage, and index cards for document chunks
The RAG toolbox—pick the pieces that match your use case. You rarely need all of them at once.


Real-World Use Cases

RAG is already quietly powering some very practical tools across industries:

Six-panel illustration showing RAG in real-world contexts: a customer support agent, a doctor reviewing clinical notes, a lawyer reading contracts, a student asking questions from textbooks, a developer querying internal docs, and a researcher analyzing papers
Customer support, healthcare, legal, education, engineering, research — the same pattern works across all of them.

  1. Customer support bots — A chatbot that answers product questions using your actual support documentation, not guesses.
  2. Company knowledge assistants — An internal AI that lets employees search HR policies, engineering wikis, or onboarding guides through natural conversation.
  3. Research assistants — Tools that help academics or analysts quickly find and synthesize information from large document libraries.
  4. Legal and compliance Q&A — AI that answers questions about contracts or regulations while citing the exact clause it's drawing from.
  5. Healthcare knowledge bases — Systems that help clinical staff query medical literature or hospital protocols accurately.
  6. Educational tutoring — Q&A bots that answer student questions directly from course textbooks and materials.

In every case: bring in domain-specific knowledge, ground the AI's answers in it, and dramatically reduce the risk of wrong or outdated responses.


RAG Is Powerful — But Not Perfect

RAG works best when:

  • Your documents are accurate, well-organised, and up to date.
  • The question clearly maps to something in the knowledge base.
  • You want transparent, source-grounded answers.

RAG can still struggle when:

  • The source documents are bad. Garbage in, garbage out — if your knowledge base has outdated or incorrect information, the LLM will use it anyway.
  • The retriever misses the mark. If the system can't find the right chunks, the LLM has nothing useful to work with and may still hallucinate.
  • Too much irrelevant context gets retrieved. Noisy or off-topic chunks can confuse the LLM and dilute the answer.

Illustration of the garbage-in, garbage-out problem: a conveyor belt feeding chaotic, messy documents into a processing machine, and a confused robot on the other side holding a paper full of errors and wrong answers
Feed it bad documents, and you get bad answers—confidently delivered. RAG doesn't fix bad data, it amplifies it.

Knowing the failure modes is half the battle. A well-built RAG system spends just as much effort on clean data and good retrieval as it does on the LLM itself.


Next Steps: Want to Build Your Own?

You don't need to start big. A few entry points depending on how comfortable you are with code:

  • Try a no-code tool first. Platforms like Dify or Flowise let you build a basic RAG chatbot with drag-and-drop interfaces — no coding required.
  • Follow a LangChain RAG tutorial. The official docs have beginner walkthroughs that are surprisingly approachable if you know a bit of Python.
  • Experiment with LlamaIndex. Their starter tutorial gets a simple Q&A system running over your own documents in under 30 lines of code.
  • Start small. Pick a single topic — your own notes, a product FAQ, a short research paper — and build a basic question-answering tool over it. The concepts will click fast once you see it working.
  • Understand the infrastructure underneath. RAG systems rely on the same distributed data concepts that power production backends—vector databases, caching, and scaling decisions. If those feel unfamiliar, this system design primer is a good place to close that gap.

Once you understand how RAG works—retrieve, augment, generate—you'll start seeing it everywhere.

And now you know what it actually means.


Found this useful? I write about AI, system design, and real engineering. Follow along—more coming.