Topic 02 / 8
Prompt Engineering Fundamentals
The Anatomy of a Good Prompt
A good prompt provides clear instructions, necessary context, and a desired output format. The more specific you are, the better the result.
- Persona/Role: “Act as a senior Python developer.”
- Task: “Write a function to parse this CSV data.”
- Context: “The data comes from a legacy system and might have missing fields.”
- Format: “Output only the code, with type hints and docstrings.”
Techniques for Better Results
Few-Shot Prompting: Give the model examples of the input and the desired output. This is often the most effective way to steer its behavior.
Translate English to French:
apple -> pomme
dog -> chien
house ->Chain of Thought (CoT): Ask the model to “think step-by-step”. This forces it to break down complex problems and significantly improves reasoning capabilities.
Avoiding Hallucinations
LLMs are designed to generate plausible text, even if it’s factually incorrect. Always provide the necessary facts within the prompt, and explicitly instruct the model to say “I don’t know” if the answer isn’t in the provided text.