Back to Prompts
🟣MistralBeginner

Mistral AI Prompt Engineering Guide

Best practices for prompting Mistral models, including Mistral Large and Mixtral

View Official Documentation

TL;DR

  • Start simple and iterate based on responses
  • Place key instructions at beginning or end
  • Assign clear roles for targeted responses
  • Balance detail - not too long, not too brief
  • Use system prompts for guardrails
  • Adapt to Mistral's format flexibility

Key Principles

1Begin with simple, concise prompts and iterate
2Place critical instructions at prompt start or end
3Tell Mistral who it should "be" for better answers
4Specify output format (table, bullets, paragraphs)
5Use system prompts to enforce output constraints
6Revise and test until achieving desired results

Start Simple and Iterate

Begin with a simple, concise prompt. This allows you to iterate and refine your approach based on the model's responses. Add complexity only as needed.

Examples

Iterative refinement
Bad:
Write a comprehensive 2000-word analysis of market trends including historical context, current state, future predictions, competitive landscape, and actionable recommendations with citations.
Good:
Start: "What are the top 3 market trends in AI right now?"
Then: "Expand on trend #2 with specific examples."
Then: "What are the implications for startups?"

Breaking into iterations lets you guide the analysis and catch issues early.

Instruction Placement

Mistral models often optimize for instructions at the beginning or end of prompts. Place your most important instructions in these positions for best results.

Examples

Front-load key instructions
Good:
IMPORTANT: Respond in bullet points only. Maximum 5 points.

Explain how photosynthesis works.

Placing format constraints first ensures they're followed.

Role Assignment

Tell Mistral who it should "be" to receive answers better suited to your needs. Roles help establish expertise level and communication style.

Examples

Assign expert role
Good:
You are an expert travel guide specializing in budget travel in Southeast Asia.

A solo traveler asks: "What's the best way to get from Bangkok to Chiang Mai on a budget?"

The role ensures responses include budget-specific advice and local expertise.

Format Flexibility

Mistral adapts to your requested format. Ask for tables, bullet points, numbered lists, or prose - the model will organize information accordingly.

Examples

Request specific formats
Good:
Compare Python and JavaScript for web development.

Format your response as a table with these columns:
| Aspect | Python | JavaScript | Winner |

Specifying table format with columns ensures structured, comparable output.

System Prompts for Guardrails

When building applications, use system prompts to enforce output constraints and safety guardrails. This ensures consistent behavior across user interactions.

Examples

Enforce output constraints
Good:
System: You are a customer service bot for TechCorp. Rules:
- Only answer questions about TechCorp products
- Never discuss competitors
- Always be polite and professional
- If unsure, offer to connect with a human agent

User: {user_message}

System-level rules ensure the bot stays on-topic and maintains brand voice.

Balanced Detail Level

Find the right balance in prompt length. Overly long prompts can overwhelm the model, while overly brief ones may leave it guessing. Aim for necessary and sufficient detail.
#prompt-engineering#mistral#mixtral#system-prompt#guardrails#role-prompting
Last updated: December 1, 2024