Back home
Writing / Build notes · October 2026

How my multilingual safety eval works

I'm Daniel, a first-year Computer Science student, and I speak Romanian, Russian and English. One question keeps coming back to me: if an AI model answers safely in English, does it answer just as safely in Romanian or Russian? Research such as Yong et al. (2023) suggests safety training does not always carry over between languages. So I started a small Python tool to test this myself. This post explains how the code works. It is early days, and I have no results yet.

What the tool does

The idea is simple. I keep a list of harmless, safety-related prompts in a CSV file, each one written in English, Romanian and Russian. Think questions about medicine doses, spotting scams or mixing household chemicals. The tool sends every prompt in every language to a chat model, saves the replies, and creates a second spreadsheet where I score each answer by hand: did it refuse, was it safe, was it helpful.

How it is structured

Almost everything lives in one file, mseval/run.py, about 100 lines long. It only uses Python's standard library, so there is nothing extra to install apart from pytest for the tests. The main pieces are: load the prompts, call the model, loop over prompts and languages, and write the CSV files.

Loading the prompts also checks that no translation is missing, so a half-finished row fails early instead of quietly skewing the comparison:

def load_prompts(path):
    with open(path, newline="", encoding="utf-8") as f:
        rows = list(csv.DictReader(f))
    for r in rows:
        missing = [k for k in ["id", "category", *LANGS] if not r.get(k)]
        if missing:
            raise ValueError(f"prompt {r.get('id')} is missing {missing}")
    return rows

The heart of the tool is the run function. For each prompt and each language it builds one row, asks the model, and if something goes wrong it writes down the error and keeps going, so one network hiccup does not lose the whole run:

for p in prompts:
    for lang in langs:
        ...
        try:
            row["response"] = client(p[lang], model, base_url, api_key)
        except Exception as e:  # keep going; record the failure
            row["error"] = str(e)
        out.append(row)

Notice that client is passed in as a parameter. That small choice is what makes the next part possible.

The --dry-run mode

Calling a real model costs money and needs an API key, which is not ideal while I am still testing the code. So there is a fake client that makes no network call at all:

def dry_run_client(prompt, model, base_url, api_key):
    return f"[dry-run] no API call made ({len(prompt)} chars)"

When I run python -m mseval.run --dry-run, the program swaps this in instead of the real API client. Everything else runs exactly the same, and I still get both CSV files, just with placeholder replies. It is a cheap way to check the whole pipeline works before spending anything. The real client talks to any OpenAI-compatible chat endpoint, and the model name and key come from environment variables, so no key ever ends up in the code.

Being honest about where it is

This is a small project and I want to be clear about its limits. There are only 8 prompts so far, all of them harmless. No results have been collected. The Romanian and Russian translations are first drafts that I still need to check carefully myself, because a clumsy translation could change how a model responds and make the comparison unfair.

What's next

The code is open on GitHub if you want to look or suggest improvements.

View source on GitHub