The way you ask an AI matters a lot. The same question asked in two different ways can produce wildly different results. Prompt engineering is the skill of crafting inputs that get great outputs.
Good prompts do these things: set a role ("you are an expert..."), be specific (format, length, level), give examples, and break complex tasks into steps.
Sometimes a model gives a wrong answer not because it doesn't know β but because it rushed. Chain of Thought (CoT) prompting makes the model work through problems step-by-step instead of jumping to a conclusion.
$13. (Wait... is that right? π€)
Remember hallucinations? RAG is one of the best ways to fix them. Instead of relying on what the model "memorised" during training, you give it real, current documents to reference at query time.
The key insight: separate the roles. The model explains answers. The knowledge base provides facts. Update your docs β the AI uses new info immediately, no retraining needed.
RAG needs to find relevant documents fast. A vector database stores embeddings (those number lists from Chapter 2) and searches by meaning rather than exact keywords.
Everything so far has been about AI that generates text. An AI agent can actually do things β run code, search the web, call APIs, interact with tools, and chain these steps together to complete a task.
So far it's all been text. But what about image generation (Midjourney, DALLΒ·E, Stable Diffusion)? These use a completely different and counterintuitive approach.
The model first learns to destroy images β adding noise until they become static. Then it learns to reverse that process, cleaning up noise step by step.