Don't Take It Literally: An Edit-Invariant Sequence Loss for Text Generation

Guangyi Liu, Zichao Yang, Tianhua Tao, Xiaodan Liang, Junwei Bao +4 more
6/29/2021
cs.CLcs.AI

Official code: guangyliu/EISL (6 stars, Python, MIT, PyTorch, last commit 2026-09-19).

Abstract

Neural text generation models are typically trained by maximizing log-likelihood with the sequence cross entropy (CE) loss, which encourages an exact token-by-token match between a target sequence with a generated sequence. Such training objective is sub-optimal when the target sequence is not perfect, e.g., when the target sequence is corrupted with noises, or when only weak sequence supervision is available.

Show full abstract

To address the challenge, we propose a novel Edit-Invariant Sequence Loss (EISL), which computes the matching loss of a target n-gram with all n-grams in the generated sequence. EISL is designed to be robust to various noises and edits in the target sequences. Moreover, the EISL computation is essentially an approximate convolution operation with target n-grams as kernels, which is easy to implement and efficient to compute with existing libraries. To demonstrate the effectiveness of EISL, we conduct experiments on a wide range of tasks, including machine translation with noisy target sequences, unsupervised text style transfer with only weak training signals, and non-autoregressive generation with non-predefined generation order. Experimental results show our method significantly outperforms the common CE loss and other strong baselines on all the tasks. EISL has a simple API that can be used as a drop-in replacement of the CE loss: https://github.com/guangyliu/EISL.

View on arXivView PDF

Code Implementations(1)

guangyliu/EISLOfficial100%
PyTorchMIT

[NAACL 2022 Oral] Edit-Invariant Sequence Loss: a drop-in replacement for cross-entropy that matches n-grams at every position — robust to noisy / weakly-supervised / unordered targets

60Python, ShellJun 29, 20212 months agoMIT
loss-functionsmachine-translationnaaclnoisy-labelsnon-autoregressive+2 more

Similar Papers

Cite this paper

@article{liu2021dont,
  title  = {Don't Take It Literally: An Edit-Invariant Sequence Loss for Text Generation},
  author = {Guangyi Liu and Zichao Yang and Tianhua Tao and Xiaodan Liang and Junwei Bao and Zhen Li and Xiaodong He and Shuguang Cui and Zhiting Hu},
  year   = {2021},
  eprint = {2106.15078},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2106.15078}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2106.15078.svg)](https://codeofpaper.com/paper/2106.15078)

Discussion