Generative AI & agentic solutions Β· 30β35%
Optimize & operationalize
The 3 strategies β pick by symptom
| Symptom | Fix | Cost |
|---|---|---|
| Wrong tone/format, needs instructions | Prompt engineering | Low |
| Lacks knowledge / stale / invents facts | RAG | Medium |
| Ignores style rules despite good prompts | Fine-tuning | High |
Order of attack: start with prompt engineering; add RAG when accuracy is the problem; fine-tune when consistency is. Combine freely (fine-tune = style, RAG = facts, prompt = per-session rules).
Prompt engineering patterns
Prompt engineering is designing and refining the text you send the model β instructions, examples, structure β to improve its output without touching the model itself.
- Persona ⠓You are a seasoned marketing pro⦔
- Format template β show the output structure wanted.
- Chain-of-thought β “step by step” (non-reasoning models only).
- Few-shot β example pairs (zero-shot = none, one-shot = 1).
- Delimiters β
---/ headings / XML tags separate instructions from content. - Recency bias β models weight prompt end more; repeat key instruction at the end.
- System message checklist, in order: state the role, set boundaries, specify the output format, and add a “when unsure” policy.
Parameters
- Temperature β = creative, β = deterministic (0.2 factual / 0.7 creative).
- Top_p β probability-mass cutoff. Adjust temperature OR top_p, not both.
max_output_tokenscaps length (and cost).
Fine-tuning facts
Fine-tuning is additional training of a pretrained model on your own examples, so the desired style or format gets baked into its weights.
- Uses LoRA (Low-Rank Adaptation) β updates small subset of weights; cheaper than full retraining.
- Data: JSONL of message conversations, same system message throughout (blank = worse accuracy; reuse it at inference), hundreds+ examples.
- Types: SFT (labeled pairs), RFT (grader rewards, complex reasoning), DPO (preferred vs non-preferred pairs, lighter than RL). Combinable (SFT then DPO).
- Also good for: distillation (use a big model’s outputs to train a small one), shortening prompts, better tool selection.
- Costs: training + hourly hosting + retrain on base-model updates. Always baseline first.
Reflection & self-critique
- Model reflection / self-critique loops β model reviews its own output against criteria, revises.
- Chain-of-thought evaluations β evaluate reasoning steps, not only the final answer.
- Hybrid orchestration β route: rules engine for deterministic parts, LLM for open-ended; or a small model triages requests and passes the hard ones to a big model.
Observability
Observability means you can see what your AI system did and why β every step, token, and delay.
Implement tracing (OpenTelemetry via Foundry SDK) to capture: each step of a flow, token analytics (usage per call), safety signals (filter hits), latency breakdowns (TTFT, per-step). Enable tracing on the project client; view traces in Foundry portal.