Local-Llm

Building a Self-Evaluating RAG System: Hybrid Search, Routing, and LLM-as-Judge

Building a Self-Evaluating RAG System: Hybrid Search, Routing, and LLM-as-Judge

8 min read

Most RAG systems are demos: they retrieve chunks and generate an answer immediately, with no check on whether the retrieved context is relevant, sufficient, or even correct. When retrieval misses, the model hallucinates. There is no recovery loop, no quality signal, and no way to tell which step produced a bad answer.

This post documents how to build a self-evaluating RAG system that routes queries, retrieves with hybrid search, and evaluates its own answers using LLM-as-judge. It is built in three cooperating parts:

  1. Hybrid search and retrieval — dense + BM25 vectors with int8 quantization in Qdrant, RRF fusion, payload filtering, and multi-year balanced fetch.
  2. Agent and MCP — a LangGraph ReAct loop with routing guardrails, wrapped in FastMCP and exposed through a Streamlit UI.
  3. Observability and evaluation — Arize Phoenix tracing plus LLM-as-judge scoring for hallucination, QA correctness, and context relevance.

The LLM provider layer is shared: Ollama (local llama3.2, nomic-embed-text) or Gemini API (gemini-2.5-flash-lite), switchable via environment variable with no code changes.

Managing Documents with Local LLMs and Self-Hosted Apps

Managing Documents with Local LLMs and Self-Hosted Apps

7 min read

I stopped relying on cloud AI services for document management. Instead, I run a self-hosted stack of Paperless-ngx, Paperless-GPT, and Paperless AI, backed by local LLMs through Ollama. Nothing leaves my network: academic records, certificates, invoices, tax filings, and receipts all stay on my own hardware.

This post documents the stack I built to manage documents locally: how Paperless-ngx serves as the central document hub, how Paperless-GPT handles OCR, how Paperless AI provides RAG-powered chat over the archive, and how everything connects to a local Ollama instance running Qwen 3, MiniCPM-V, and Llama 3.2.