This is post 4 of my series on the AWS Certified AI Practitioner exam (AIF-C01), and part 2 of Domain 3, "Applications of Foundation Models", the biggest domain at 28%. In part 1 I covered RAG. Now: prompts, customizing a model, and checking if it works.
1. Prompt engineering: giving clear instructions
A prompt is how you talk to a model. Think of giving instructions to a new intern: the clearer you are, the better the result.
A good prompt can include:
- Instruction: what you want done
- Context: the background the model needs
- Negative prompt: what the model should not do
Techniques to recognize:
- Zero-shot: you ask with no examples
- Single-shot: you give one example
- Few-shot: you give a few examples, which helps when you need a consistent format
- Chain-of-thought: you ask the model to reason step by step, like "show your work" in math
- Prompt templates: reusable prompts with blanks to fill in
There is also a setting called temperature. A lower value gives more predictable answers, and a higher one gives more varied, creative answers.
Prompts can also be attacked. The risks I need to know are prompt injection or hijacking (sneaking in instructions the model should ignore), jailbreaking (tricking the model past its rules), poisoning and exposure of private information. This is why guardrails matter.
2. Customizing a model: a ladder
From cheapest and easiest to most expensive:
- Prompt engineering: better instructions, no training
- RAG: give the model your documents to read (see part 1)
- Fine-tuning: extra training with your own examples, so the model learns a style or specialty
- Continued pre-training: more training on large amounts of domain data
My rule of thumb: try the cheaper steps first.
Fine-tuning has a few flavors. Instruction tuning teaches the model to follow instructions. Domain adaptation specializes it for a field, like finance. Transfer learning reuses what a model already learned. The data matters a lot: it needs to be curated and labeled, and some methods use human feedback (RLHF).
3. Checking if it works
You can measure a model in different ways:
- ROUGE: compares a generated summary with a reference summary
- BLEU: compares a translation with a human translation
- BERTScore: compares meaning, using embeddings
- Human evaluation and benchmark datasets: real people or standard tests
Numbers aren't enough. The real question is whether the model helps the business goal, like saving time or making users happier.
My takeaway
Domain 3 is about choosing the right tool: better prompts first, then RAG, then fine-tuning if you really need it, and then measuring the result.
If you had to improve a chatbot's answers with a small budget, which step of the ladder would you try first?
Loading article