Examples · General
One message, three languages
Apertus, the Swiss model, translates a notice for customers into French and German; Ministral, the European model of Mistral AI, checks every translation.
Intermediate · 30 min
The idea
Many companies around here have customers in Switzerland, France and Germany. A notice written in Italian has to reach them in their language, without mistakes in the times and numbers. Two models from two different makers do it better than one: the first writes, the second checks.
The models
- Apertus 70B (
apertus-70b-instruct), the model of the Swiss AI Initiative, trained on Italian, German, French, English and Romansh. It translates. - Ministral 3 14B (
ministral-3-14b), the European model of Mistral AI: quick and precise. It checks.
What you need
A key and the openai library, as in Your first API call in Python.
The program
import os
from openai import OpenAI
client = OpenAI(
base_url="https://api.ai.itsincom.org/v1",
api_key=os.environ["API_KEY"],
)
notice = """Gentili clienti,
sabato 17 ottobre dalle 22:00 alle 02:00 faremo la manutenzione dei server di posta.
In quelle ore i messaggi potrebbero arrivare in ritardo, ma non andranno persi.
Per urgenze chiamate il numero di picchetto 0331 000 000.
Grazie per la pazienza."""
for language in ["French", "German"]:
translation = client.chat.completions.create(
model="apertus-70b-instruct",
temperature=0.2,
messages=[
{"role": "system", "content": f"Translate into {language} for business customers. Keep dates, "
"times and phone numbers exactly. Answer with the translation only."},
{"role": "user", "content": notice},
],
).choices[0].message.content
review = client.chat.completions.create(
model="ministral-3-14b",
temperature=0,
messages=[{"role": "user", "content": (
f"Here is a notice of an Italian company and its {language} translation. Check only for "
"real errors: a changed meaning, a missing sentence, a wrong date, time or number. Do not "
"suggest changes of style. If there are no real errors, answer only OK; otherwise list "
"the errors, one per line.\n\n"
f"Italian:\n{notice}\n\n{language}:\n{translation}"
)}],
).choices[0].message.content
print(f"=== {language}\n{translation}\n\n--- Ministral checks: {review}\n")
What you should see
Two translations, each followed by OK. Look at the word for «numero di picchetto»: when we tried it, Apertus wrote “numéro de piquet” and “Pikettnummer”, the words used in Switzerland. Right for a customer in Lugano, Lausanne or Zurich; for a customer in Germany you would write “Bereitschaftsnummer”. A model trained on Swiss texts writes like the Swiss.
Exercise
- Ask for a version for customers in Germany, and one for customers in France. What changes?
- Put a mistake in a translation on purpose (change 22:00 to 20:00) before the check: does Ministral notice?
- Add
"Romansh"to the list: Apertus is one of the very few models that write it. Can Ministral check it? A checker has to know the language at least as well as the writer. - Write your own notice: the opening hours of a shop in the holidays, or a delay in a delivery.
The check is not about style, on purpose: ask for “only real errors”, or a model will always find something to change. For anything that goes to a real customer, a person who knows the language reads it last.
