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

推荐订阅源

The GitHub Blog
The GitHub Blog
A
About on SuperTechFans
The Cloudflare Blog
G
Google Developers Blog
博客园_首页
Martin Fowler
Martin Fowler
Apple Machine Learning Research
Apple Machine Learning Research
L
LangChain Blog
D
Docker
C
Check Point Blog
T
Tailwind CSS Blog
博客园 - 司徒正美
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Hugging Face - Blog
Hugging Face - Blog
Microsoft Security Blog
Microsoft Security Blog
V
V2EX
博客园 - 叶小钗
T
The Blog of Author Tim Ferriss
酷 壳 – CoolShell
酷 壳 – CoolShell
IT之家
IT之家
M
MIT News - Artificial intelligence
Microsoft Azure Blog
Microsoft Azure Blog
博客园 - 【当耐特】
GbyAI
GbyAI

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
How to Build a Local Agentic Search Pipeline That Actuall...
Alan West · 2026-05-03 · via DEV Community

If you've spent any time building with local LLMs, you've probably hit the same wall I have: your model confidently tells you something that is completely, verifiably wrong. Ask it about a recent API change, a specific library version, or any fact that requires up-to-date knowledge, and you're rolling dice.

The core problem isn't that these models are dumb. It's that they're frozen in time. And for anything requiring factual accuracy — think developer tools, research assistants, or internal knowledge bases — that's a dealbreaker.

But recently, the local LLM community has been closing this gap fast. A post on r/LocalLLaMA demonstrated a fully local agentic search setup reportedly hitting 95.7% on OpenAI's SimpleQA benchmark, running on a single RTX 3090. That's competitive with cloud APIs, and it's running in someone's office. Let's break down how this kind of pipeline works and how you can build one yourself.

Why Vanilla RAG Falls Short for Factual Questions

Before we get into agentic search, let's talk about why the simpler approach — basic retrieval-augmented generation (RAG) — doesn't cut it for high factual accuracy.

Standard RAG works like this: embed a query, find similar chunks in a vector store, stuff them into the context window, and hope for the best. The problems are well-documented:

  • Single-shot retrieval misses context. If the answer requires synthesizing information across multiple sources, one retrieval pass won't get you there.
  • Chunk boundaries break facts. Your crucial detail might be split across two chunks, and the retriever only grabbed one.
  • No verification loop. The model has no way to say "I'm not confident in this, let me look again."

For SimpleQA-style questions — short, factual, verifiable — these limitations matter a lot. You need something smarter.

The Agentic Search Pattern

Agentic search fixes this by giving the model a tool-use loop. Instead of one retrieval pass, the model can:

  1. Decide it needs to search for something
  2. Formulate a specific query
  3. Read the results
  4. Decide if it has enough info or needs to search again
  5. Synthesize a final answer with citations

This is the same pattern behind Perplexity and similar products, but running entirely on your hardware. The key insight is that even a moderately-sized model can orchestrate this loop effectively if you structure the agent correctly.

Here's a simplified version of what the agent loop looks like:

import json

def agentic_search(query, llm, search_fn, max_iterations=5):
    messages = [
        {"role": "system", "content": SYSTEM_PROMPT},
        {"role": "user", "content": query}
    ]

    for i in range(max_iterations):
        response = llm.chat(messages, tools=SEARCH_TOOLS)

        if response.tool_calls:
            for call in response.tool_calls:
                # Model decided it needs more info
                search_query = call.arguments["query"]
                results = search_fn(search_query)
                messages.append({"role": "tool", "content": results})
        else:
            # Model is confident enough to answer
            return response.content

    return "Could not determine a confident answer."

Enter fullscreen mode Exit fullscreen mode

The magic is in letting the model decide when it knows enough. A well-tuned model will search two or three times for complex questions and answer immediately for simple ones.

Running a 27B Model on a Single 3090

A 27B parameter model at full precision needs ~54GB of VRAM. An RTX 3090 has 24GB. So how does this work? Quantization.

With 4-bit quantization (Q4_K_M or similar), that 27B model shrinks to roughly 15-16GB, leaving headroom for KV cache and the search context. Here's how to serve it with llama.cpp:

# Download a Q4_K_M quantized model (check Hugging Face for available quants)
# Then serve it with llama-server
./llama-server \
    -m ./models/your-27b-model-Q4_K_M.gguf \
    --port 8080 \
    --n-gpu-layers 99 \
    --ctx-size 32768 \
    --chat-template chatml

Enter fullscreen mode Exit fullscreen mode

A few things to note:

  • --n-gpu-layers 99 offloads everything to the GPU. With Q4 on 24GB, you should have enough room.
  • --ctx-size 32768 gives you a decent context window for search results. You can go higher if your model supports it, but watch your VRAM.
  • The Qwen model family supports tool/function calling natively, which is critical for the agent loop.

Alternatively, if you prefer a Python-native stack, vllm handles quantized models well:

from vllm import LLM, SamplingParams

llm = LLM(
    model="your-model-path",
    quantization="awq",       # or gptq, depending on your quant
    gpu_memory_utilization=0.9,
    max_model_len=32768,
    enable_prefix_caching=True  # helps with repeated search contexts
)

Enter fullscreen mode Exit fullscreen mode

The Search Backend

Your search component needs to be fast and return clean, relevant text. You have a few options:

  • SearXNG — self-hosted metasearch engine. This is the fully local option. It aggregates results from multiple search engines and returns them in a clean API format. Runs in Docker, no API keys needed.
  • Brave Search API — has a generous free tier and returns well-structured results. Not fully local, but the search itself isn't where your privacy concerns usually lie.
  • Local index with Tantivy or Meilisearch — if you're searching over a known corpus (docs, codebase, internal wiki), a local search index is faster and more reliable.

For the agentic loop to work well, you want to return snippets, not full pages. Parse the results and keep only the relevant paragraphs. This saves context space and reduces noise.

System Prompt Engineering (This Part Actually Matters)

The system prompt for your search agent needs to do three things:

  1. Tell the model when to search. Be explicit: "If you are not certain about a factual claim, use the search tool before answering."
  2. Tell it when to stop. Without this, some models will search in circles. Add something like: "Once you have found a consistent answer from at least one reliable source, provide your final answer."
  3. Enforce citation discipline. "Always indicate which search result supports your answer."

Here's a minimal but effective system prompt:

You are a factual research assistant with access to a search tool.

Rules:
- If you are unsure about ANY factual claim, search before answering.
- Formulate specific, targeted search queries. Avoid vague terms.
- You may search up to 5 times per question.
- Once you have a well-supported answer, respond concisely.
- If search results conflict, note the disagreement.
- Never guess. If you cannot find the answer, say so.

Enter fullscreen mode Exit fullscreen mode

That last line is crucial. On benchmarks like SimpleQA, saying "I don't know" when you actually don't know is scored favorably. Models that hedge correctly instead of hallucinating see significant score improvements.

Why This Works So Well Now

Three things have converged to make local agentic search viable:

  • Better tool-calling in open models. The latest generation of open-weight models (Qwen, Llama, Mistral) have been specifically trained on function-calling data. They reliably produce structured tool calls without constant coaxing.
  • Quantization without quality collapse. Modern quantization techniques (AWQ, GGUF Q4_K_M) preserve model quality surprisingly well. The gap between FP16 and Q4 has shrunk to a few percentage points on most benchmarks.
  • Mature serving stacks. llama.cpp and vLLM both handle tool calling, streaming, and context management reliably now. Two years ago, this was held together with duct tape.

Practical Tips From Setting This Up

A few things I've learned the hard way:

  • Prefill your KV cache with the system prompt if your serving framework supports it. The system prompt stays the same across queries, so caching it saves real time.
  • Cap your search iterations. Five is a good default. Without a cap, edge cases can make your model search endlessly and burn through your context window.
  • Monitor VRAM during long sessions. The KV cache grows with context length. If you're stuffing multiple search results into one conversation, you can OOM on queries that seem fine individually.
  • Test with SimpleQA yourself. The dataset is publicly available from OpenAI. It's a great way to measure whether your changes are actually improving factual accuracy or just making you feel better.

The Bigger Picture

A year ago, getting reliable factual answers from a local model felt like a pipe dream. You either used cloud APIs or accepted the hallucinations. The fact that the community is now hitting cloud-competitive accuracy on consumer hardware is a genuine inflection point.

Is it perfect? No. A 27B quantized model with agentic search is still slower than hitting an API endpoint, and there are edge cases where it'll stumble. But for privacy-sensitive workloads, offline environments, or just not wanting a per-token bill, this is real and it works.

The bottleneck has shifted from model quality to engineering. How you structure the agent loop, how you process search results, and how you prompt the model matters more than raw parameter count. And that's the kind of problem developers are good at solving.