https://docs.mistral.ai/models/best-practices/prompt-engineering
Summary of Mistral Prompt Engineering Best Practices
The official documentation covers key strategies for crafting effective prompts to maximize model performance:
-
System vs. User Prompts: Use system prompts to set global context, role behavior, and constraints, while user prompts provide specific tasks or immediate context.
-
Providing a Purpose (Roleplaying): Define a clear persona or purpose right at the beginning (e.g., “You are a , your task is to ”).
-
Clear Structure: Organize instructions hierarchically with clear sections and headings. Write as if the reader has no prior context.
-
Effective Formatting: Use Markdown or XML-style tags to structure your prompt because they are human-readable, machine-parsable, and familiar to the model.
-
Example Prompting (Few-Shot): Provide input-output examples to improve accuracy and enforce specific output formats.
-
Structured Outputs: Enforce JSON formatting to ensure predictable responses for downstream processing.
What to Avoid
-
Avoid Subjective Words: Avoid vague adjectives like “too long”, “too short”, “many”, or “better”. Use explicit metrics instead.
-
Avoid Contradictions: Prevent logic clashes in long system prompts by using clear decision trees.
-
Do Not Make LLMs Count Words: Instead of asking the model to split text by length, provide character counts or metadata as input.
-
Do Not Generate Too Keep Tokens: Keep generation tasks concise and only ask for necessary output tokens.
-
Prefer Worded Scales: Use descriptive qualitative scales instead of numeric ones for better accuracy (e.g., “Very Low” to “Very Good”).