Prompt Engineering Guide
Write better prompts, get better results. This guide covers techniques that work across all SovereignEG models.
The system prompt
The system prompt is the most important parameter. It sets the model's persona, constraints, and output format:
response = client.chat.completions.create(
model="...",
messages=[
{
"role": "system",
"content": """You are a senior financial analyst specializing in MENA markets.
Rules:
- Always cite specific data points
- Express uncertainty when data is insufficient
- Format numbers with proper units
- Respond in the same language as the user's query"""
},
{"role": "user", "content": "Analyze Egypt's tech startup ecosystem in 2025"}
]
)Technique 1: Be specific
# ❌ Vague
"Write about AI"
# ✓ Specific
"Write a 200-word overview of how AI is being adopted in MENA healthcare, focusing on diagnostic imaging and patient triage. Include one specific example from Egypt or the UAE."Technique 2: Give examples (few-shot)
messages = [
{"role": "system", "content": "Classify customer feedback as positive, negative, or neutral."},
{"role": "user", "content": "The delivery was incredibly fast!"},
{"role": "assistant", "content": "positive"},
{"role": "user", "content": "Product broke after one week."},
{"role": "assistant", "content": "negative"},
{"role": "user", "content": "It arrived on time, nothing special."},
# Model will classify this based on the examples
]Technique 3: Chain of thought
For complex reasoning, tell the model to think step by step:
response = client.chat.completions.create(
model="...",
messages=[{
"role": "user",
"content": """A company has 150 employees. 40% work in engineering, 25% in sales,
and the rest in operations. If the company hires 30 more engineers,
what percentage of the total workforce is now in engineering?
Think step by step before giving the final answer."""
}]
)Technique 4: Output format control
response = client.chat.completions.create(
model="...",
messages=[
{
"role": "system",
"content": "Respond ONLY with valid JSON. No markdown, no explanation."
},
{
"role": "user",
"content": 'Extract entities: "Ahmed from Cairo signed a $50K deal with TechCorp"'
}
]
)
# Returns: {"person": "Ahmed", "location": "Cairo", "amount": "$50K", "company": "TechCorp"}Technique 5: Role-based prompting
# The model performs better with a clear role
{"role": "system", "content": "You are a Python expert who writes clean, production-quality code."}
{"role": "system", "content": "You are a legal advisor specializing in UAE commercial law."}
{"role": "system", "content": "You are a data scientist who explains concepts to non-technical stakeholders."}Temperature guide
| Temperature | Behavior | Use for |
|---|---|---|
| 0.0 | Deterministic, focused | Data extraction, classification, code |
| 0.3-0.5 | Slightly creative | Business writing, analysis |
| 0.7-0.9 | Creative, varied | Creative writing, brainstorming |
| 1.0-1.5 | Very creative, unpredictable | Poetry, storytelling |
Common mistakes
| Mistake | Fix |
|---|---|
| Prompt too long | Move context to separate messages; use RAG instead |
| Conflicting instructions | Be consistent; don't say "be concise" and "explain in detail" |
| No output format | Always specify format: JSON, bullet points, table, etc. |
| Ignoring model strengths | Match task to live catalog: smaller models for speed, larger for reasoning, multilingual models for Arabic |