Hands-On Practice
From the course Mistral AI: European Open Models
Put what you have learned in this course into practice with the structured exercise below. Working through it end-to-end is the single best way to consolidate the concepts.
Concrete Starter Project: Build a Multilingual Customer Support Classifier
This project showcases what Mistral does best: European multilingual tasks, function calling, and structured output — all at low cost using Mistral Small.
What You'll Build
A support ticket classifier that reads incoming emails in any European language, detects the language, classifies the intent (billing, technical, general), assigns a priority, and routes to the correct team — all with a single Mistral Small call.
Step 1 — Define the Classification Function
from mistralai import Mistral
import json
client = Mistral(api_key="your-api-key")
tools = [{
"type": "function",
"function": {
"name": "classify_ticket",
"description": "Classify a customer support ticket",
"parameters": {
"type": "object",
"properties": {
"detected_language": {"type": "string", "description": "ISO 639-1 language code, e.g. 'fr', 'de', 'es'"},
"intent": {"type": "string", "enum": ["billing", "technical", "account", "general", "urgent"]},
"priority": {"type": "string", "enum": ["low", "medium", "high", "critical"]},
"summary_in_english": {"type": "string", "description": "Brief English summary of the issue"},
"suggested_team": {"type": "string", "enum": ["billing-team", "tech-support", "account-management", "general-support"]}
},
"required": ["detected_language", "intent", "priority", "summary_in_english", "suggested_team"]
}
}
}]
Step 2 — Classify Incoming Tickets
def classify_support_ticket(ticket_text: str) -> dict:
response = client.chat.complete(
model="mistral-small-latest", # Cost-effective for classification
messages=[
{
"role": "system",
"content": "You are a multilingual customer support classifier. Analyze tickets in any language and classify them accurately."
},
{
"role": "user",
"content": f"Classify this support ticket:\n\n{ticket_text}"
}
],
tools=tools,
tool_choice="any" # Force tool use for structured output
)
tool_call = response.choices[0].message.tool_calls[0]
return json.loads(tool_call.function.arguments)
# Test with multilingual tickets
tickets = [
"Bonjour, je ne peux pas accéder à mon compte depuis hier soir.", # French
"Hola, me han cobrado dos veces este mes en mi tarjeta.", # Spanish
"Mein Abonnement wurde ohne Vorwarnung gekündigt!", # German
"I cannot connect to the API — getting 503 errors.", # English
]
for ticket in tickets:
result = classify_support_ticket(ticket)
print(f"Language: {result['detected_language']}, Intent: {result['intent']}, Priority: {result['priority']}")
print(f" Summary: {result['summary_in_english']}")
print(f" Route to: {result['suggested_team']}\n")
Step 3 — Benchmark Against GPT-4o-mini
Run the same 20 test tickets through both mistral-small-latest and gpt-4o-mini. Compare:
- Classification accuracy (manually label ground truth first)
- Average latency per request
- Cost per 1000 tickets
- Language detection accuracy across all five supported languages
Mistral Small typically matches GPT-4o-mini on European language tasks and may outperform it on French and German specifically.
Self-Check Questions
- What happens when a ticket mixes two languages (common in Swiss/Belgian markets)?
- How would you handle tickets that are ambiguous between
technicalandbilling(e.g., "my API key was revoked after my payment failed")? - At what volume (tickets per month) does fine-tuning Mistral Small become cheaper than prompting?
Stretch Goal
Add a second Mistral call to draft a reply in the customer's detected language, using the English summary as input. Compare draft quality between Mistral Large and Mistral Small for the reply generation step.
Key Takeaways
- •Hands-on application converts course concepts into real skill
- •Start small with an MVP before optimising
- •Self-check questions catch gaps in understanding before they ship to production
Progress is kept in this browser only.