opus-mt-de-en for Kjarni
German to English 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 English to
German, use opus-mt-en-de.
Command line
curl -fsSL https://kjarni.ai/install.sh | sh # Windows: irm https://kjarni.ai/install.ps1 | iex
kjarni translate -q -m opus-mt-de-en --src de --dst en -i "Wo ist der Bahnhof?"
Python
# pip install kjarni
from kjarni import Translator
translator = Translator(model="opus-mt-de-en", source="de", target="en")
print(translator.translate("Wo ist der Bahnhof?"))
Rust
// cargo add kjarni tokio anyhow
use kjarni::Translator;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let translator = Translator::new("opus-mt-de-en").await?;
println!("{}", translator.translate("Wo ist der Bahnhof?", "de", "en").await?);
Ok(())
}
C#
// dotnet add package Kjarni
using Kjarni;
using var translator = new Translator("opus-mt-de-en", from: "de", to: "en");
Console.WriteLine(translator.Translate("Wo ist der Bahnhof?"));
C++ (C++23)
#include <kjarni.hpp>
#include <iostream>
int main() {
kjarni::TranslatorOptions options;
options.model = "opus-mt-de-en";
options.from = "de";
options.to = "en";
auto translator = kjarni::Translator::create(options);
if (!translator) return 1;
auto text = translator->translate("Wo ist der Bahnhof?");
if (!text) return 1;
std::cout << *text << "\n";
}
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-de-en, 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 the Apache License 2.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}
}