opus-mt-en-de for Kjarni
English to German translation, packaged to run locally with Kjarni: one native library, with no Python runtime, server or cloud service. The model is about 300 MB and downloads on first use.
Usage
Requires Kjarni 0.3.0 or later. Each model translates one direction; for German to
English, use opus-mt-de-en.
Command line
curl -fsSL https://kjarni.ai/install.sh | sh # Windows: irm https://kjarni.ai/install.ps1 | iex
kjarni translate -q -m opus-mt-en-de --src en --dst de -i "Where is the train station?"
Python
# pip install kjarni
from kjarni import Translator
translator = Translator(model="opus-mt-en-de", source="en", target="de")
print(translator.translate("Where is the train station?"))
Rust
// cargo add kjarni tokio anyhow
use kjarni::Translator;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let translator = Translator::new("opus-mt-en-de").await?;
println!("{}", translator.translate("Where is the train station?", "en", "de").await?);
Ok(())
}
C#
// dotnet add package Kjarni
using Kjarni;
using var translator = new Translator("opus-mt-en-de", from: "en", to: "de");
Console.WriteLine(translator.Translate("Where is the train station?"));
C++ (C++23)
#include <kjarni.hpp>
#include <iostream>
int main() {
kjarni::TranslatorOptions options;
options.model = "opus-mt-en-de";
options.from = "en";
options.to = "de";
auto translator = kjarni::Translator::create(options);
if (!translator) return 1;
auto text = translator->translate("Where is the train station?");
if (!text) return 1;
std::cout << *text << "\n";
}
Go
// go get github.com/kjarni-ai/kjarni-go
package main
import (
"fmt"
"log"
kjarni "github.com/kjarni-ai/kjarni-go"
)
func main() {
translator, err := kjarni.NewTranslator("opus-mt-en-de", kjarni.WithLanguages("en", "de"), kjarni.WithQuiet(true))
if err != nil {
log.Fatal(err)
}
defer translator.Close()
text, err := translator.Translate("Where is the train station?")
if err != nil {
log.Fatal(err)
}
fmt.Println(text)
}
See the Kjarni documentation for other languages and installation details.
What changed from the original
This is not a new model. The translation weights are unchanged. Only the packaging differs:
- The weights are stored as safetensors, with the shared embedding kept once rather than duplicated.
- The two SentencePiece tokenizers are converted to one
tokenizer.json.
On a set of 16 test sentences, Kjarni's output on CPU and GPU matches transformers running the original model exactly.
Attribution
The model is Helsinki-NLP/opus-mt-en-de, by the Language Technology Research Group at the University of Helsinki. All credit for the model, its training and its evaluation belongs to them. See the original model card for training data, benchmarks and limitations.
Kjarni and this packaging are not affiliated with or endorsed by the University of Helsinki.
This repository is released under CC BY 4.0, the same license as the original model.
Citation
@InProceedings{TiedemannThottingal:EAMT2020,
author = {J{\"o}rg Tiedemann and Santhosh Thottingal},
title = {{OPUS-MT} -- Building open translation services for the {W}orld},
booktitle = {Proceedings of the 22nd Annual Conference of the European Association for Machine Translation (EAMT)},
address = {Lisbon, Portugal},
year = {2020}
}