Why I don't use LangChain in production RAG
Frameworks are great for a demo. In production, the abstraction you can't see into costs more than it saves.
Topic
Prompting, context management, streaming, and structured output for real applications.
Frameworks are great for a demo. In production, the abstraction you can't see into costs more than it saves.
RAG became the default reflex for every LLM problem. Often it's the wrong tool. A straight decision framework for RAG vs fine-tuning vs just prompting.
Stream LLM tokens in FastAPI with SSE the moment they arrive, kill buffering layers, and cancel on disconnect so you stop paying for unseen tokens.
CRAG fixes retrieval quality before generation; Self-RAG uses fine-tuned reflection tokens to critique its own output. Here's when to use each.
Structured Outputs with grammar-constrained decoding is the most reliable way to get valid JSON from an LLM. Here's how the three mechanisms compare.
Prompt caching reuses precomputed KV state for identical prompt prefixes, cutting cost up to 90% and latency up to 85% with no quality change.
The stages every production RAG system needs — indexing, query-time retrieval, and always-on evaluation — and how to order them.
Build a production LLM fallback strategy: a cost-ordered chain of models with health checks, backoff, and cross-provider routing.