Encoding Sentence Position in Context-Aware Neural Machine Translation with Concatenation

Lorenzo Lupo, Marco Dinarelli, Laurent Besacier

TL;DR

This paper explores how to explicitly inform neural machine translation (NMT) models about the position of sentences within a concatenated document context. While the idea is intuitive, the authors find that simply adding sentence position information doesn't consistently improve translation quality, except when combined with a specific context-discounted training loss on Russian, suggesting that the effectiveness is highly dependent on the training setup and language pair.

What Problem Does This Paper Address?

Current state-of-the-art neural machine translation (NMT) systems excel at translating individual sentences. However, translating entire documents presents a greater challenge. A common approach to incorporate document context is "sentence concatenation," where multiple consecutive sentences are fed into the NMT model as a single sequence. While effective, this method can overwhelm the Transformer architecture, leading to a loss of focus on the current sentence to be translated. This paper investigates whether explicitly encoding the position of each sentence within the concatenated context can help the model better discern sentence boundaries and improve translation quality, particularly for discourse phenomena that rely on inter-sentential understanding.

Methods

The core idea is to inject information about sentence position into the NMT model's input representations. The authors explore several methods:

  • Segment-Shifted Position Embeddings: A modification of standard positional embeddings where positions are shifted based on sentence boundaries.
  • Segment Embeddings: Vector representations for each sentence's position within the context window. This includes:
  • One-hot embeddings: Simple binary vectors.
  • Sinusoidal embeddings: Similar to positional embeddings but for sentence positions.
  • Learned embeddings: Embeddings learned directly during training, inspired by BERT.
  • Persistent Encodings: A technique where sentence position information is not just added at the input layer but is propagated and added at the input of every Transformer block, aiming to maintain focus throughout the model.
  • Position-Segment Embeddings (PSE): A novel approach that concatenates token position embeddings and segment embeddings into a single vector. This is done by reducing the dimensionality of each component so their sum equals the model's embedding dimension, allowing for a clearer distinction between token and sentence positions.

Datasets

The authors train and evaluate their models on two language pairs:

  • English-Russian (En→Ru): Using movie subtitles from the Voita et al. (2019) dataset.
  • English-German (En→De): Using TED talk subtitles from the IWSLT17 dataset.

They also utilize specialized contrastive test sets for evaluating specific discourse phenomena:

  • Voita et al. (2019) set: For inter-sentential deixis, lexical cohesion, verb-phrase ellipsis, and inflectional ellipsis.
  • ContraPro (Müller et al., 2018): For evaluating the translation of context-dependent ambiguous pronouns.

Key Insights and Ideas

  • Intuition vs. Reality: The paper validates the intuitive idea that explicit sentence position encoding should help, but the empirical results are nuanced. Simply adding this information isn't a silver bullet.
  • Context-Discounted Loss is Key: The most significant improvements were observed when sentence position encodings were combined with a "context-discounted loss" (proposed by Lupo et al., 2022b). This loss function down-weights the contribution of context sentences to the overall loss, forcing the model to prioritize the current sentence.
  • Language and Domain Dependence: The effectiveness of these methods is highly dependent on the language pair and domain. What works for En→Ru does not necessarily transfer to En→De.
  • Persistence Matters: Making sentence position encodings persistent across Transformer layers seems to offer a consistent, albeit small, benefit, especially when combined with the context-discounted loss.
  • PSE Trade-offs: The proposed Position-Segment Embeddings (PSE) offer a way to combine token and sentence position information distinctly. However, allocating more dimensions to segment embeddings (beyond what's needed for basic encoding) can actually hurt performance, suggesting a need for careful dimensionality tuning.

Key Results

  • En→Ru:
    • Vanilla sentence position encodings (without context-discounted loss) showed negligible improvements or even degradation on the Voita contrastive set.
  • When combined with the context-discounted loss, persistent segment-shifted position embeddings and persistent learned segment embeddings provided notable accuracy gains (+2.52 and +2.14 points, respectively) on the Voita contrastive set.
  • The best performing model, s4to4+CD+shift+pers, achieved the highest accuracy on the Voita contrastive set among those tested.
  • En→De:
    • The proposed sentence position encoding methods generally did not improve performance, even when using a context-discounted loss and a high-resource setting. This suggests that the benefits are not universal.
  • Even with significantly more training data for En→De, the sentence position encodings did not yield improvements.

Limitations and Future Work

  • Limited Generalizability: The primary limitation is the inconsistent performance across language pairs and domains. The benefits observed on En→Ru did not transfer to En→De.
  • Need for More Research: The authors emphasize that more empirical studies are needed to clearly define the conditions under which these approaches are beneficial.
  • Future Directions: They encourage practitioners to test persistent segment-shifted positions, especially in conjunction with context discounting, for their CANMT systems. Further investigation into why En→De did not benefit is warranted.

Summary updated

BibTeX
@inproceedings{lupo2023encoding,
  author = {Lorenzo Lupo and Marco Dinarelli and Laurent Besacier},
  title = {{Encoding Sentence Position in Context-Aware Neural Machine Translation with Concatenation}},
  booktitle = {EACL},
  year = {2023},
}
Figure