Prompt Engineering — How to Talk to AI Effectively
The same AI model gives completely different results depending on how you ask. That is the essence of prompt engineering — and it is heavily tested on the AIF-C01 exam.
---
What Is Prompt Engineering?
Prompt engineering is the practice of designing inputs to AI models so they produce the outputs you actually want. It is not just asking a question — it is structuring the question so the AI has the right context, understands the format you need, and knows what to avoid.
---
The 4 Components of a Good Prompt
| Component | Role | Example | |---|---|---| | Instructions | What to do | "Summarize the following in 3 sentences" | | Context | Background info | "You are a senior AWS solutions architect" | | Input Data | The actual content to process | Log file, customer review, etc. | | Output Indicator | Desired format | "Respond in JSON format" |
---
Inference Parameters
Temperature (0–1) Low (0.2): Predictable, consistent — use for legal/technical docs High (0.9): Creative, diverse — use for brainstorming
Top P (0–1) Low: Only highest-probability words considered High: Broader word pool, more variety
Top K Low (e.g., 10): Limits candidates to top 10 words High (e.g., 500): More diverse outputs
Exam trap: Temperature, Top P, and Top K do NOT affect latency. Only model size and token count affect response speed.
---
Prompting Techniques
| Technique | How It Works | Best For | |---|---|---| | Zero-Shot | Direct instruction, no examples | Quick tasks with general knowledge | | Few-Shot | Provide 2–5 examples first | Consistent output format | | Chain of Thought | "Think step by step" | Complex multi-step reasoning | | RAG | Retrieve external docs and include in prompt | Latest or domain-specific info |
---
Prompt Injection
An attack where malicious user input overrides the original system prompt. Defense: add explicit safety instructions telling the model to ignore out-of-scope directives.
---
Exam Key Points
Good prompt = Instructions + Context + Input Data + Output Format. Temperature/Top P/Top K affect creativity, NOT latency. Zero-Shot (no examples) vs Few-Shot (with examples) vs CoT (step-by-step reasoning). RAG retrieves external information to augment the prompt. Prompt injection bypasses original instructions via malicious input.