Skip to content
Fondazione ITS INCOM

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

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

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.

All examples