Downloads · 30 days
10
11% of all-time downloads
johnlockejrr/marianmt-smp-sam-onnx
marianmt-smp-sam-onnx is a translation model from johnlockejrr. Use it when you need text moved from one language to another. The card lists the license as mit.
This is the ONNX (Open Neural Network Exchange) format version of the bidirectional translation model fine-tuned from Helsinki-NLP/opus-mt-sem-sem for translating between Samaritan Hebrew (smp) and Samaritan Aramaic (…
Downloads · 30 days
10
11% of all-time downloads
All-time downloads
88
Public
Repo size
649 MB
Likes
0
Public
Click a slice to open those files.
.onnx648 MB · 99%
From the Hugging Face model README
This is the ONNX (Open Neural Network Exchange) format version of the bidirectional translation model fine-tuned from Helsinki-NLP/opus-mt-sem-sem for translating between Samaritan Hebrew (smp) and Samaritan Aramaic (sam). The model supports both translation directions using special language tags (>>smp<< and >>sam<<).
This ONNX conversion enables:
For the original PyTorch model, see: johnlockejrr/marianmt-smp-sam
>>smp<< and >>sam<<)The dataset contains parallel biblical texts in Samaritan Hebrew and Samaritan Aramaic (Targumic), with both directions included in the training data to enable bidirectional translation.
Training was conducted with:
Note: The ONNX model was converted from the trained PyTorch model and preserves the same performance metrics.
These metrics are identical to the original PyTorch model, as the ONNX conversion is lossless.
pip install onnxruntime transformers
For GPU acceleration (optional):
pip install onnxruntime-gpu
import numpy as np
from transformers import AutoTokenizer
import onnxruntime as ort
# Load tokenizer
tokenizer = AutoTokenizer.from_pretrained("johnlockejrr/marianmt-smp-sam-onnx")
# Load ONNX model
session = ort.InferenceSession("model.onnx")
# Translate from Samaritan Hebrew to Samaritan Aramaic
text_smp = "אחר הדברים האלה היה דבר יהוה אל אברם"
input_text = f">>smp<< {text_smp}"
inputs = tokenizer(input_text, return_tensors="np", max_length=313, truncation=True)
# Prepare inputs for ONNX (convert to numpy arrays)
onnx_inputs = {
"input_ids": inputs["input_ids"].astype(np.int64),
"attention_mask": inputs["attention_mask"].astype(np.int64),
}
# Run inference
outputs = session.run(None, onnx_inputs)
output_ids = outputs[0]
# Decode the output
translation = tokenizer.decode(output_ids[0], skip_special_tokens=True)
print(translation)
from optimum.onnxruntime import ORTModelForSeq2SeqLM
from transformers import AutoTokenizer
# Load model and tokenizer
model = ORTModelForSeq2SeqLM.from_pretrained("johnlockejrr/marianmt-smp-sam-onnx")
tokenizer = AutoTokenizer.from_pretrained("johnlockejrr/marianmt-smp-sam-onnx")
# Translate from Samaritan Hebrew to Samaritan Aramaic
text_smp = "אחר הדברים האלה היה דבר יהוה אל אברם"
input_text = f">>smp<< {text_smp}"
inputs = tokenizer(input_text, return_tensors="pt", max_length=313, truncation=True)
# Generate translation
outputs = model.generate(**inputs, max_length=313, num_beams=4, length_penalty=0.6)
translation = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(translation)
# Translate from Samaritan Aramaic to Samaritan Hebrew
text_sam = "בתר ממלליה אלין הוה מלל יהוה עם אברם"
input_text = f">>sam<< {text_sam}"
inputs = tokenizer(input_text, return_tensors="pt", max_length=313, truncation=True)
outputs = model.generate(**inputs, max_length=313, num_beams=4, length_penalty=0.6)
translation = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(translation)
from optimum.onnxruntime import ORTModelForSeq2SeqLM
from transformers import AutoTokenizer
model = ORTModelForSeq2SeqLM.from_pretrained("johnlockejrr/marianmt-smp-sam-onnx")
tokenizer = AutoTokenizer.from_pretrained("johnlockejrr/marianmt-smp-sam-onnx")
texts = [
">>smp<< אחר הדברים האלה היה דבר יהוה אל אברם",
">>sam<< בתר ממלליה אלין הוה מלל יהוה עם אברם"
]
inputs = tokenizer(texts, return_tensors="pt", padding=True, max_length=313, truncation=True)
outputs = model.generate(**inputs, max_length=313, num_beams=4, length_penalty=0.6)
translations = tokenizer.batch_decode(outputs, skip_special_tokens=True)
for translation in translations:
print(translation)
The model uses special language tags to indicate translation direction:
>>smp<< - Prefix for Samaritan Hebrew (source) → Samaritan Aramaic (target)>>sam<< - Prefix for Samaritan Aramaic (source) → Samaritan Hebrew (target)These tags must be included at the beginning of the input text for proper direction control.
If you use this model, please cite:
@misc{marianmt-smp-sam-onnx,
title={MarianMT ONNX Model for Samaritan Hebrew ↔ Samaritan Aramaic Translation},
author={johnlockejrr},
year={2025},
howpublished={\url{https://huggingface.co/johnlockejrr/marianmt-smp-sam-onnx}}
}
For questions, issues, or contributions, please refer to the model repository at https://huggingface.co/johnlockejrr/marianmt-smp-sam-onnx.