TransIns: Document Translation with Markup Reinsertion

Jörg Steffen, Josef van GenabithEMNLP 2021 · OpenReview

TL;DR

This paper introduces TransIns, a system that tackles the challenge of translating complex documents (like web pages or presentations) while preserving their original formatting. It achieves this by cleverly reinserting markup tags into the translated text, outperforming existing methods and even popular commercial translation services in terms of markup accuracy.

What Problem Does This Paper Address?

Machine translation (MT) models are typically trained on plain text. However, many real-world documents contain rich formatting (bold text, italics, lists, links, etc.) embedded as markup tags. Simply translating the raw text and ignoring the markup results in a loss of structure and readability. The core challenge is to translate the textual content while ensuring that the markup is correctly reapplied to the corresponding parts of the translated text, even when sentence structures and word orders differ significantly between languages. Existing approaches often struggle with complex nesting, contiguous source markup that becomes non-contiguous in the target, or simply fail to handle these cases accurately.

Methods

TransIns builds upon the Okapi framework, a robust system for localization and translation processes, and integrates with Marian NMT, a state-of-the-art neural machine translation toolkit. The key innovation lies in their markup reinsertion strategies.

The general workflow involves:

  1. Preprocessing: Extracting text content from the document and removing markup.
  2. Translation: Using Marian NMT to translate the de-marked text, crucially obtaining token-level alignments between source and target sentences.
  3. Reinsertion: This is the core contribution. TransIns develops several strategies to reinsert the original markup into the translated text based on the obtained alignments.
  4. mtrain Strategy: A baseline approach that maps tags to the following token and attempts to move them. It struggles with differing word orders.
  5. mtrain++ Strategy: An improvement that handles tag order and nesting better, and also addresses issues with unaligned tags.
  6. Complete Mapping Strategy (CMS): The most advanced approach. It compiles down tag pairs to their minimal scopes, effectively mapping each tag to all tokens within its original scope. This "complete mapping" ensures that markup is transferred more robustly, as tags "travel" with token alignments. CMS also incorporates a "tag interpolation" scheme to fill gaps where markup might be missing due to alignment issues.
  7. Postprocessing: Cleaning up the translated text and reassembling the document with the reinserted markup.

A significant technical detail is the use of a "Sentence Collector Pipeline" to enable efficient batch processing of sentences, reducing overhead compared to processing sentences one by one.

Datasets

The paper uses existing parallel corpora for training and evaluating the MT models. For evaluation, they collected 10 complex web pages from spiegel.de, containing a total of 378 sentences with inline markup. This dataset was converted to MS Office documents for evaluation. They also mention using hand-corrected perfect alignments for a subset of their evaluation data to isolate errors stemming from alignments versus reinsertion strategies.

Key Insights and Ideas

  • Markup is a first-class citizen: The paper strongly advocates for treating document markup as integral to translation, not an afterthought.
  • Alignments are key: The quality of token-level alignments from MT models is crucial for accurate markup reinsertion.
  • "Complete Mapping" is powerful: Compiling markup down to its minimal scope (CMS) is a highly effective strategy for robustly transferring markup, especially across languages with different word orders.
  • Tag interpolation fills the gaps: Even with good alignments, gaps in markup can occur. Tag interpolation provides a smart way to infer and apply missing markup based on neighboring tags.
  • Batch processing matters for efficiency: Optimizing the translation pipeline for batch processing significantly improves throughput.

Key Results

  • CMS outperforms others: The Complete Mapping Strategy (CMS) consistently produced the fewest markup errors across different alignment qualities and translation directions (de->fr, de->en).
  • Better than commercial services: TransIns, particularly with CMS, produced less than half the markup errors compared to popular commercial MT services.
  • mtrain++ shows significant improvement: The mtrain++ strategy reduced errors by about two-thirds compared to the baseline mtrain.
  • Tag interpolation trade-offs: While tag interpolation helps correct alignment errors, it can introduce new errors if not carefully managed (e.g., with a maximum gap size of 0).

Limitations and Future Work

  • Alignment quality dependency: The accuracy of markup reinsertion is still fundamentally dependent on the quality of the MT model's alignments.
  • Tag interpolation risks: While beneficial, tag interpolation can introduce errors if the inferred markup is incorrect. The paper notes that omitting tag interpolation can sometimes lead to fewer overall errors, suggesting a trade-off.
  • Future work: The authors suggest that further improvements could be made by exploring more sophisticated alignment strategies and potentially developing markup-aware MT models that can handle markup directly during translation. They also highlight the need for standard evaluation datasets for markup transfer.

Summary updated

BibTeX
@inproceedings{steffen2021transins,
  author = {Jörg Steffen and Josef van Genabith},
  title = {{TransIns: Document Translation with Markup Reinsertion}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2021},
  url = {https://openreview.net/forum?id=G2UxYIjRenI},
}
Figure