YAML Metadata Warning:empty or missing yaml metadata in repo card
Check out the documentation for more information.
mt-en-id-latex-translation
π Overview
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:
- Academic papers and journal articles
- Theses and dissertations
- Technical books and monographs
- Scientific reports and documentation
ποΈ Model Architecture
| 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 |
π Quick Start
Installation
pip install transformers torch
Basic Usage
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)
Advanced Configuration
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
)
π Recommended LaTeX Translation Workflow
For optimal results, integrate this model into a structured pipeline:
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
β Raw LaTeX βββββΆβ Text Extraction βββββΆβ Translation β
β Document β β (pylatexenc) β β (This Model) β
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
β
βββββββββββββββββββ ββββββββββββββββββββ β
β Final Output ββββββ Reconstruction ββββββββββββββ
β (Indonesian) β β & Validation β
βββββββββββββββββββ ββββββββββββββββββββ
Recommended Tools
| 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 |
Example Pipeline Script
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
π Training Details
Data
The model was fine-tuned on a curated parallel corpus of English-Indonesian text with emphasis on:
- Academic writing (journal articles, conference proceedings)
- Technical documentation (engineering, computer science, mathematics)
- LaTeX-structured content (theses, dissertations, textbooks)
Fine-Tuning Approach
- Base Model: Pre-trained MarianMT (
Helsinki-NLP/opus-mt-en-id) - Specialization: Continual fine-tuning on LaTeX-enriched parallel data
- Objective: Cross-entropy loss with label smoothing
- Validation: BLEU, chrF++, and human evaluation on LaTeX-specific test sets
β οΈ Limitations & Considerations
| 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.
π Evaluation
| 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.
π€ Contributing
Contributions are welcome. Areas of interest include:
- Expanding the training corpus with domain-specific LaTeX data
- Improving handling of complex LaTeX environments
- Developing automated evaluation benchmarks for LaTeX translation
- Creating integration plugins for popular LaTeX editors
Please open an issue or submit a pull request on the Hugging Face repository.
π License
This project is licensed under the MIT License. See LICENSE for details.
π Citation
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.
β Star on Hugging Face Β· π Report Issue Β· π Documentation
- Downloads last month
- 59