LLM Engineering Advanced
Multi-Agent Systems with LangGraph
One-line idea: A graph-based pipeline makes retry/validation logic explicit as nodes and edges instead of burying it inside nested if/else statements — the same graph-orchestration idea covered in ai/ai-agents, applied here to a RAG pipeline specifically.
Common mistake + fix: Looping retrieve → generate without a hard cap, trusting the validation check to eventually succeed. Fix: the attempts >= 3 check above exists for exactly this reason — a model that keeps producing a short/unsatisfying answer has no guaranteed reason to improve on attempt 4 just because it didn't on attempts 1-3; cap it and return the best-effort result.
Memory line: A graph makes retry logic a visible, testable path through named nodes — not a loop you have to trace through nested conditionals to understand.
Fine-Tuning vs RAG Decision Framework
One-line idea: RAG changes what the model knows at answer time; fine-tuning changes how the model behaves, permanently — most real systems need one or both, and picking wrong means paying for retraining when a document update would have worked, or fighting prompt length forever when a few training examples would have fixed the format.
| Scenario | Use RAG | Use Fine-tuning |
|---|
|----------|---------|----------------|
| Frequently updated knowledge | YES | No |
|---|---|---|
| Proprietary document Q&A | YES | No |
| Style/tone consistency | No | YES |
| Domain-specific reasoning | YES + FT | YES |
| Reduce hallucinations | YES | No |
| Real-time data | YES | No |
| Reduce prompt length | No | YES |
Common mistake + fix: Trying to bake new factual knowledge into a model permanently through fine-tuning. Fix: fine-tuning is slow and expensive to update and the model can still get facts wrong even after training on them — RAG is almost always the better tool for fact injection specifically; reserve fine-tuning for consistent style, tone, or domain-specific reasoning patterns that prompting alone struggles to achieve reliably.
Observability Setup
One-line idea: Tracing records every step a request took through the pipeline — which node ran, what it returned, how long it took — so a bad answer can be traced back to the specific step that caused it, instead of just seeing the final (wrong) output with no record of how it got there.
Memory line: Tracing turns "the answer was wrong somewhere in there" into "the answer was wrong specifically at this step" — see ai/llmops for the fuller observability picture (spans, token/latency/cost metrics, incident response).
vLLM for Open-Source Model Serving
One-line idea: Self-hosting an open-source model through a server like vLLM trades the convenience of a managed API for control over cost, data residency, and latency — at the cost of managing the serving infrastructure yourself.
Rate Limiting and Budget Caps
One-line idea: A per-user rate limit and a per-user/per-day budget cap solve different problems — one protects your API quota from being exhausted by a single caller, the other protects your bill from one runaway loop or abusive user.
Common mistake + fix: Only rate-limiting requests per minute and assuming that also caps spend. Fix: a user making a few large, expensive requests can still blow a budget while staying well under a request-count limit — track tokens/cost separately from request count.
Memory line: Rate limiting caps how often someone can call you. A budget guard caps how much any single caller can cost you — track both, since neither one substitutes for the other.
Production Checklist
A checklist works as a gate, not a suggestion — each line corresponds to a specific failure mode covered elsewhere on this page or in ai/llmops/ai/ai-agents: prompt versioning (Intermediate) catches silent prompt drift, input/output validation and PII scrubbing (Intermediate's Guardrails) catch unsafe content, fallback/retry (Intermediate) catches transient failures, and cost/latency monitoring (this page, ai/llmops) catches a regression nobody would otherwise notice until the bill or the complaints arrive.
Common mistake + fix: Treating this checklist as a one-time pre-launch exercise instead of an ongoing operational practice. Fix: re-check it whenever the prompt, model, or retrieval index changes significantly — a system that passed every item at launch can silently drift out of compliance with any one of them months later without a single code change triggering the drift (a model provider's own update, a slowly growing user base hitting rate limits differently, a document feed introducing new PII patterns).
Memory line: A production checklist is a recurring audit, not a launch-day formality — the failure modes it guards against don't go away just because the system shipped successfully once.

