Pillar 3 of 3
Integration Patterns & Paradigms
Choosing the model is half the job — the other half is wiring it into the enterprise. Two decisions dominate: how the model gets access to your data, securely (RAG), and how much you invest in shaping its behavior (prompting → RAG → fine-tuning, in that order).
RAG — Retrieval-Augmented Generation
RAG connects an LLM to enterprise data without retraining it. Documents are chunked, embedded, and indexed in a vector database; at question time the system retrieves the most relevant chunks and hands them to the LLM inside the prompt. The model answers from what it was shown — not from what it vaguely remembers.
RAG reference architecture
Why architects love it
- Fresh knowledge: update the index, not the model
- Citations → auditable, trust-building answers
- Access control enforced at retrieval time
- No training cost or MLOps pipeline needed
Failure modes to design for
- Answer quality is capped by retrieval quality
- Chunking strategy makes or breaks it
- Context window budgets how many chunks fit
- Stale index = confidently outdated answers
Typical uses
- Support assistant over product documentation
- Policy / legal Q&A with source citations
- Internal "ask our wiki" for employees
Prompt engineering vs RAG vs fine-tuning
These are not competitors — they are an escalation ladder. Each rung buys more capability at roughly ten times the operational burden. Walk up only when the cheaper rung demonstrably fails.
The escalation ladder — decide in this order
| Approach | Effort & time | Cost profile | Best for | Risks |
|---|---|---|---|---|
| Prompt engineering | Hours–days, no ML team | Inference tokens only | Instructions, output format, tone, few-shot classification | Brittle prompts; behavior shifts between model versions — keep an eval set |
| RAG | Days–weeks, app team + data pipeline | Vector DB + ingestion infra + tokens (retrieved chunks bill as input) | Company knowledge, fresh facts, auditable answers with citations | Retrieval quality, chunking strategy, stale index, context budget |
| Fine-tuning | Weeks; needs curated training data + MLOps | Training runs + dedicated hosting; redo when the base model upgrades | Consistent style/format, domain language, making a small cheap model match a big one at volume | Overfitting, catastrophic forgetting, doesn't reliably add facts, ongoing maintenance |