Standard Neural Machine Translation (NMT) models excel at translating plain text sequences. However, real-world documents rarely exist as unformatted text. They are filled with inline markup tags (HTML, XML), markdown tables, or complex 2D spatial layouts (multi-column PDFs, forms, and financial reports).
When a standard NMT model encounters these structural elements, it treats them as ordinary text tokens. This creates a fundamental tension: while semantic text must be translated and reordered according to target-language syntax, structural markers must remain intact and map precisely to their corresponding translated segments. Without specialized handling, standard models frequently drop, hallucinate, or misplace tags, rendering the output incompatible with automated publishing pipelines. Early work by Yaser Alonaizan et al. in the TIPS: A Translingual Information Processing System framework and diagnostics by Mikko Aulamo et al. (OpusTools and Parallel Corpus Diagnostics) highlighted this exact limitation: standard processing pipelines lack native support for inline markup, leading to broken document integrity.
To solve this, researchers have developed mechanisms that separate, anchor, or visually ground structural metadata during the translation process.
Handling Textual Markup: Anchors and Placeholders
When translating a sentence with inline formatting, the word order changes. For example, translating an adjective-noun pair from English to French requires flipping the word order, meaning any formatting tags wrapping the adjective must move with it.
English: The <b> red </b> apple
French: La pomme <b> rouge </b>
To prevent the model from corrupting these tags during reordering, researchers use two primary strategies:
1. Tag Masking and Injection
Instead of forcing the model to process raw markup syntax, tags can be replaced with abstract placeholders. Greg Hanneman (How Should Markup Tags Be Translated?) demonstrated that representing tags as masked placeholders, combined with tag-injection data augmentation during training, teaches the model to treat formatting as structural variables rather than translatable text.
2. Copy Mechanisms and Structural Anchors
Alternatively, the model's architecture can be modified to treat tags as immutable constraints. Kazuma Hashimoto et al. (Building Salesforce Neural Machine Translation System) implemented a specialized copy mechanism within a Transformer architecture. This approach treats XML tags as structural anchors, forcing the model to copy them directly to the target sequence based on alignment weights rather than generating them from vocabulary probabilities.
When explicit copy mechanisms are absent, models struggle to distinguish between translatable text and fixed structural markers. As shown by Maosong Sun et al. (A Template-based Method for Constrained Neural Machine Translation), framing translation as a two-step planning process—generating a structural template first, then filling in the text—prevents the corruption of document constraints. A simpler variant of this idea, reviewed by Toshiaki Nakazawa et al. (Overview of the 9th Workshop on Asian Translation), involves stripping the tags entirely before translation and using an external word-alignment model to re-insert them into the target text.
From 1D Sequences to 2D Spatial Layouts
For visually rich documents like PDFs, scanned forms, or images, structure is defined by spatial geometry rather than text tags. Standard translation approaches fail here because they flatten the text into a 1D sequence, discarding the physical positioning of elements. As Tengchao Lv et al. (XFUND: A Benchmark Dataset for Multilingual Visually Rich Form Understanding) pointed out, losing this 2D context makes it impossible to reliably interpret non-linear elements like multi-column text, sidebars, or key-value pairs in forms.
To preserve visual topology, translation pipelines must bind text to its spatial coordinates:
[Scanned Document] ➔ [OCR + Bounding Boxes] ➔ [Layout-Aware Translation] ➔ [Re-rendered Target Document]
- Bounding Box Mapping: Ayush Maheshwari et al. (UDAAN - Machine Learning based Post-Editing tool for Document Translation) addressed this by mapping Optical Character Recognition (OCR) bounding boxes to unique identifiers directly within the translation workflow. This maintains a strict link between the text and its original geometric coordinates, eliminating the need for manual re-formatting post-translation.
- End-to-End Markup Generation: Rather than treating layout preservation as a post-processing step, modern frameworks generate structured markup natively. Yupu Liang et al. (Document Image Machine Translation with Dynamic Multi-pre-trained Models Assembling) introduced an end-to-end framework that dynamically assembles OCR, layout analysis, and translation models to output directly into structured Markdown. This allows the model to encode visual hierarchies (like headers and lists) directly within the text stream. To optimize this process, Yupu Liang (Single-to-mix Modality Alignment with Multimodal Large Language Model for Document Image Machine Translation) developed a "single-to-mix" modality alignment strategy, allowing smaller models to mimic the layout-aware internal representations of massive Multimodal Large Language Models (MLLMs).
Despite these architectural improvements, complex structural elements remain a significant bottleneck. For instance, Mariam Nakhlé et al. (DOLFIN - Document-Level Financial Test-Set for Machine Translation) found that financial translation models frequently break Markdown tables by misinterpreting structural characters like horizontal dividers. Similarly, Ahmed Heakl et al. (KITAB-Bench: A Comprehensive Multi-Domain Benchmark for Arabic OCR and Document Understanding) demonstrated that even state-of-the-art vision-language models struggle with high-fidelity PDF-to-Markdown conversions.
To resolve these chaotic layouts, the authors of From Chaotic OCR Words to Coherent Document: A Fine-to-Coarse Zoom-Out Network for Complex-Layout Document Image Translation proposed modeling human reading patterns. By progressively zooming out from word-level features to sentence-level organization and document-level topology, their framework ensures that spatial context guides the translation flow.
Leveraging Structure for Cross-Lingual Label Projection
An elegant side effect of structure-preserving translation is its utility in cross-lingual data annotation. If an NMT model can reliably preserve structural tags across language barriers, those tags can be repurposed as entity markers to transfer span-level annotations (such as Named Entity Recognition labels) from resource-rich languages to resource-poor ones.
Source (Annotated): The [ORG] Google [/ORG] headquarters.
Target (Projected): Les quartiers généraux de [ORG] Google [/ORG].
This insight forms the basis of several cross-lingual transfer techniques:
- Span Preservation via Fine-Tuning: Yang Chen et al. (Frustratingly Easy Label Projection for Cross-lingual Transfer) demonstrated that wrapping entity labels in simple square brackets and fine-tuning a standard translation model for a few hundred steps forces the model to natively project span boundaries onto the target language without relying on complex external word-alignment tools.
- Automated Dataset Scaling: Elisa Bassignana et al. (Multi-CrossRE A Multi-Lingual Multi-Domain Dataset for Relation Extraction) scaled this concept to relation extraction by embedding entity markers within document formatting that translation engines are inherently optimized to maintain, creating high-quality multilingual datasets.
- Sequence Labeling Preservation: Similarly, Dongming Sheng et al. (Test-Time Code-Switching for Cross-lingual Aspect Sentiment Triplet Extraction) wrapped multi-word phrases in structural tags prior to translation to ensure that entity boundaries remain intact for downstream sequence labeling tasks.
This structural preservation is also critical for benchmark adaptation. As shown by Ibrahim Tolga Öztürk et al. (How Different Is Stereotypical Bias Across Languages?), preserving structural tokens and task-specific formatting during translation ensures that probing mechanisms, such as fill-in-the-blank evaluation tasks, remain fully functional when translated into different linguistic structures.
Key Foundational Work
TIPS: A Translingual Information Processing System (2003) — contributed 1 concept elements to this direction.
Various Representations of Text Proposed for Eurotra (1985) — contributed 1 concept elements to this direction.