Prompt Engineering
Introduction
Prompt engineering is the practice of writing clear instructions for large language models. Good prompts guide the model and improve accuracy. Strong prompts reduce errors and increase control. In this guide you learn core ideas, useful formats, and practical examples.
Prompt engineering هو فن كتابة talimat واضحة باش AI يعطيك output مزيان. Prompt واضح كيسهل الفهم و كيحسن الجودة.
Core Concepts Explained
Large language models depend on the text you give them. Clear intent, context, and structure help the model produce stable results. Prompts act like instructions that shape the full answer.
LLM كيتبع prompt بالحرف. إيلا كان prompt منظم، النتيجة كتكون دقيقة.
Core Principles
1. Clarity
Use short and direct text. Remove extra words. Tell the model exactly what you want.
2. Context
Add the background needed to understand the task. This reduces confusion.
3. Constraints
Define format, tone, or length. These limits guide the output.
4. Examples
Show sample inputs and outputs. This builds a pattern the model follows.
Common Prompt Types
Instruction Prompts
Give direct commands such as “Write a summary” or “Translate this text”.
Question Prompts
Ask a clear question to get a focused answer.
Role Prompts
Assign a role to the model like “act as a tutor”.
Few Shot Prompts
Provide examples that teach the model how to respond.
Useful Techniques
1. Step by Step Reasoning
Tell the model to break the reasoning into steps. This improves logic and clarity.
2. Structured Output
Ask for lists, tables, or sections. Structure improves readability.
3. Style Control
Specify tone like “short and direct” or “technical explanation”.
4. Iterative Prompting
Refine your prompt after checking the output. This builds stronger instructions.
Practical Examples
1. Instruction Prompt
Explain neural networks in three short points.
2. Role Prompt
You are an AI tutor. Teach activation functions in simple steps.
3. Few Shot Prompt
Input: "The product is great"
Output: Positive
Input: "The service was slow"
Output: Negative
Input: "I enjoyed the design"
Output:
4. Structured Prompt
Give a summary using this format:
- Definition
- Key points
- Small example
Common Mistakes
- Vague instructions
- Missing context
- Too many requirements
- Unclear formatting
Prompt Engineering in LLM Tasks
- Code generation
- Editing and rewriting
- Data extraction
- Summarization
- Reasoning tasks
Prompt Engineering in Moroccan Darija
Prompt engineering يعني تكتب talimat واضحة باش AI يفهم المطلوب بلا ضبابية. Context مهم. Constraints مهمين. Examples كيعلمو AI النمط لي خاصو يتبع.
Nqta Asasiya
- Koun wadeh f talab
- Zid context kifach خصو يجاوب
- Hdoud format bach output يكون منظم
- Examples كيسهلو الخدمة
Types Dial Prompts
- Instructions
- Questions
- Roles
- Few shot
Syntax or Structure Example
This example shows how to structure a prompt for an AI model.
Task: Explain ReLU in simple steps
Context: Beginner student
Format: 3 points only
Style: Clear and short
Answer:
Exercises
- Write an instruction prompt for explaining CNNs.
- Create a role prompt where the model acts as a data science tutor.
- Write a few shot prompt for sentiment labels.
- Give a structured prompt for describing activation functions.
- Rewrite a vague prompt into a clear one.
- Write a prompt that asks for step by step reasoning.
- Design a prompt that includes constraints on length.
- Create a prompt for extracting keywords from text.
- Write an iterative improvement prompt.
- Build a prompt that includes one example and one instruction.
Internal Linking Suggestions
[internal link: Machine Learning Basics]
[internal link: NLP and LLM Guide]
Conclusion
Prompt engineering helps you control AI behavior. Clear prompts produce strong results. With practice you design prompts that stay accurate and stable.
Prompt engineering كيعطيك تحكم ف output. كلما كان prompt منظم، كل