Copyright (c) 2026 MindMesh Academy. All rights reserved. This content is proprietary and may not be reproduced or distributed without permission.
3.4. Prompt Engineering and Fine-Tuning
Prompt Engineering Techniques:
| Technique | Description |
|---|---|
| System prompt | Set persona and rules |
| Few-shot examples | Provide input/output examples |
| Chain-of-thought | Request step-by-step reasoning |
| Output format | Specify JSON, markdown, etc. |
JSON Mode (Structured Output):
response = client.chat.completions.create(
model="gpt-4o",
messages=[...],
response_format={"type": "json_object"} # Forces valid JSON output
)
When to Fine-Tune vs. Prompt Engineer:
| Approach | Use When |
|---|---|
| Prompt Engineering | First approach; sufficient for most cases |
| Fine-Tuning | Consistent style needed; reduce token usage |
| RAG | Need factual/current knowledge (not fine-tuning!) |
⚠️ Exam Trap: Fine-tuning does NOT add new knowledge—use RAG for that.
Written byAlvin Varughese
Founder•15 professional certifications