Downloads · 30 days
19
3% of all-time downloads
Ik45/mt-en-id-latex-translation
mt-en-id-latex-translation is a machine learning model from Ik45. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for transformers.
Downloads · 30 days
19
3% of all-time downloads
All-time downloads
720
Public
Parameters
72.3M
4.1 GB on disk
Likes
1
Public
Click a slice to open those files.
.safetensors289 MB · 99%
From the Hugging Face model README
English → Indonesian Neural Machine Translation for LaTeX Documents
</div>A specialized neural machine translation model designed to translate natural language text within LaTeX documents from English to Indonesian while rigorously preserving document structure, LaTeX commands, mathematical expressions, and formatting.
This model is particularly suited for:
| Attribute | Specification |
|---|---|
| Base Architecture | MarianMT (Transformer) |
| Encoder Layers | 6 |
| Decoder Layers | 6 |
| Total Parameters | ~72.3M |
| Source Language | English (en) |
| Target Language | Indonesian (id) |
| Model Format | Safetensors + PyTorch |
| License | MIT |
pip install transformers torch
from transformers import MarianTokenizer, MarianMTModel
# Load model and tokenizer
model_name = "Ik45/mt-en-id-latex-translation"
tokenizer = MarianTokenizer.from_pretrained(model_name)
model = MarianMTModel.from_pretrained(model_name)
# Example LaTeX input
latex_text = r"""
The \\textbf{quick brown fox} jumps over the lazy dog.
This is an important \\textit{result}.
We use \\begin{equation} E = mc^2 \\end{equation} in physics.
"""
# Tokenize and translate
inputs = tokenizer(latex_text, return_tensors="pt", padding=True)
translated = model.generate(
**inputs,
max_length=512,
num_beams=5,
early_stopping=True
)
# Decode output
output = tokenizer.decode(translated[0], skip_special_tokens=True)
print(output)
For production-grade translation quality, the following generation parameters are recommended:
translated = model.generate(
**inputs,
max_length=512,
num_beams=8, # Beam search width
num_beam_groups=2, # Diverse beam search
diversity_penalty=0.5, # Encourage lexical diversity
length_penalty=1.2, # Favor longer translations
early_stopping=True,
no_repeat_ngram_size=3 # Prevent repetition
)
For optimal results, integrate this model into a structured pipeline:
┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐
│ Raw LaTeX │───▶│ Text Extraction │───▶│ Translation │
│ Document │ │ (pylatexenc) │ │ (This Model) │
└─────────────────┘ └──────────────────┘ └─────────────────┘
│
┌─────────────────┐ ┌──────────────────┐ │
│ Final Output │◀───│ Reconstruction │◀───────────┘
│ (Indonesian) │ │ & Validation │
└─────────────────┘ └──────────────────┘
| Tool | Purpose | Link |
|---|---|---|
| pylatexenc | LaTeX tokenization and command protection | GitHub |
| LaTeXMT | Structure-preserving translation framework | GitHub |
| latex2text | Extract translatable text from LaTeX | Built-in with pylatexenc |
from pylatexenc.latex2text import LatexNodes2Text
from transformers import MarianTokenizer, MarianMTModel
def translate_latex_document(latex_source: str, model, tokenizer) -> str:
\"\"\"
Translate a LaTeX document while preserving structure.
Args:
latex_source: Raw LaTeX source string
model: Loaded MarianMTModel
tokenizer: Loaded MarianTokenizer
Returns:
Translated LaTeX string with preserved commands
\"\"\"
# Step 1: Extract text nodes
l2t = LatexNodes2Text()
text_nodes = l2t.nodelist_to_text(latex_source)
# Step 2: Translate extracted text
# (Implement your extraction/translation logic here)
# Step 3: Reconstruct LaTeX with translated content
# (Preserve commands, environments, and math mode)
return translated_latex
The model was fine-tuned on a curated parallel corpus of English-Indonesian text with emphasis on:
Helsinki-NLP/opus-mt-en-id)| Scenario | Recommendation |
|---|---|
| Complex nested LaTeX (e.g., heavy TikZ, custom macros) | Manual post-editing strongly advised |
| Mathematical expressions | Verify symbol consistency and notation standards |
| Domain-specific terminology | Cross-reference with field-specific glossaries |
| Bibliographic entries | Translate with caution; preserve citation keys |
| Custom commands | Ensure commands are defined before translation |
Note: While the model preserves LaTeX syntax, manual review is recommended for documents requiring publication-quality accuracy.
| Metric | Score | Dataset |
|---|---|---|
| BLEU | To be evaluated | LaTeX-Academic-Test |
| chrF++ | To be evaluated | LaTeX-Academic-Test |
| TER | To be evaluated | LaTeX-Academic-Test |
Evaluation results will be updated upon completion of benchmark testing.
Contributions are welcome. Areas of interest include:
Please open an issue or submit a pull request on the Hugging Face repository.
This project is licensed under the MIT License. See LICENSE for details.
If you use this model in your research or publication, please cite:
@misc{ik45-mt-en-id-latex-translation,
author = {Ik45},
title = {mt-en-id-latex-translation: English-Indonesian Neural Machine Translation for LaTeX Documents},
year = {2026},
publisher = {Hugging Face},
howpublished = {\\url{https://huggingface.co/Ik45/mt-en-id-latex-translation}},
note = {Accessed: 2026-07-17}
}
Made with ❤️ for the Indonesian academic community.
</div>