MoverScore: Text Generation Evaluating with Contextualized Embeddings and Earth Mover Distance
Wei Zhao, Maxime Peyrard, Fei Liu, Yang Gao, Christian M. Meyer, Steffen Eger
Introduction
The choice of evaluation metric has a significant impact on the assessed quality of natural language outputs generated by a system. A desirable metric assigns a single, real-valued score to the system output by comparing it with one or more reference texts for content matching. Many natural language generation (NLG) tasks can benefit from robust and unbiased evaluation, including text-to-text (machine translation and summarization), data-to-text (response generation), and image-to-text (captioning) Gatt and Krahmer (2018). Without proper evaluation, it can be difficult to judge on system competitiveness, hindering the development of advanced algorithms for text generation.
It is an increasingly pressing priority to develop better evaluation metrics given the recent advances in neural text generation. Neural models provide the flexibility to copy content from source text as well as generating unseen words See et al. (2017). This aspect is hardly covered by existing metrics. With greater flexibility comes increased demand for unbiased evaluation. Diversity-promoting objectives make it possible to generate diverse natural language descriptions Li et al. (2016); Wiseman et al. (2018). But standard evaluation metrics including BLEU Papineni et al. (2002) and ROUGE Lin (2004) compute the scores based primarily on n-gram co-occurrence statistics, which are originally proposed for diagnostic evaluation of systems but not capable of evaluating text quality Reiter (2018), as they are not designed to measure if, and to what extent, the system and reference texts with distinct surface forms have conveyed the same meaning. Recent effort on the applicability of these metrics reveals that while compelling text generation system ascend on standard metrics, the text quality of system output is still hard to be improved Böhm et al. (2019).
Our goal in this paper is to devise an automated evaluation metric assigning a single holistic score to any system-generated text by comparing it against human references for content matching. We posit that it is crucial to provide a holistic measure attaining high correlation with human judgments so that various neural and non-neural text generation systems can be compared directly. Intuitively, the metric assigns a perfect score to the system text if it conveys the same meaning as the reference text. Any deviation from the reference content can then lead to a reduced score, e.g., the system text contains more (or less) content than the reference, or the system produces ill-formed text that fails to deliver the intended meaning.
We investigate the effectiveness of a spectrum of distributional semantic representations to encode system and reference texts, allowing them to be compared for semantic similarity across multiple natural language generation tasks. Our new metric quantifies the semantic distance between system and reference texts by harnessing the power of contextualized representations Peters et al. (2018); Devlin et al. (2018) and a powerful distance metric Rubner et al. (2000) for better content matching. Our contributions can be summarized as follows:
We formulate the problem of evaluating generation systems as measuring the semantic distance between system and reference texts, assuming powerful continuous representations can encode any type of semantic and syntactic deviations.
We investigate the effectiveness of existing contextualized representations and Earth Mover’s Distance Rubner et al. (2000) for comparing system predictions and reference texts, leading to our new automated evaluation metric that achieves high correlation with human judgments of text quality.
Our metric outperforms or performs comparably to strong baselines on four text generation tasks including summarization, machine translation, image captioning, and data-to-text generation, suggesting this is a promising direction moving forward.
Related Work
It is of fundamental importance to design evaluation metrics that can be applied to natural language generation tasks of similar nature, including summarization, machine translation, data-to-text generation, image captioning, and many others. All these tasks involve generating texts of sentence or paragraph length. The system texts are then compared with one or more reference texts of similar length for semantic matching, whose scores indicate how well the systems perform on each task. In the past decades, however, evaluation of these natural language generation tasks has largely been carried out independently within each area.
Summarization A dominant metric for summarization evaluation is ROUGE Lin (2004), which measures the degree of lexical overlap between a system summary and a set of reference summaries. Its variants consider overlap of unigrams (-1), bigrams (-2), unigrams and skip bigrams with a maximum gap of 4 words (-SU4), longest common subsequences (-L) and its weighted version (-W-1.2), among others. Metrics such as Pyramid Nenkova and Passonneau (2004) and BE Hovy et al. (2006); Tratz and Hovy (2008) further compute matches of content units, e.g., (head-word, modifier) tuples, that often need to be manually extracted from reference summaries. These metrics achieve good correlations with human judgments in the past. However, they are not general enough to account for the relatedness between abstractive summaries and their references, as a system abstract can convey the same meaning using different surface forms. Furthermore, large-scale summarization datasets such as CNN/Daily Mail Hermann et al. (2015) and Newsroom Grusky et al. (2018) use a single reference summary, making it harder to obtain unbiased results when only lexical overlap is considered during summary evaluation.
Machine Translation A number of metrics are commonly used in MT evaluation. Most of these metrics compare system and reference translations based on surface forms such as word/character n-gram overlaps and edit distance, but not the meanings they convey. BLEU Papineni et al. (2002) is a precision metric measuring how well a system translation overlaps with human reference translations using n-gram co-occurrence statistics. Other metrics include SentBLEU, NIST, chrF, TER, WER, PER, CDER, and METEOR Lavie and Agarwal (2007) that are used and described in the WMT metrics shared task Bojar et al. (2017); Ma et al. (2018). RUSE Shimanaka et al. (2018) is a recent effort to improve MT evaluation by training sentence embeddings on large-scale data obtained in other tasks. Additionally, preprocessing reference texts is crucial in MT evaluation, e.g., normalization, tokenization, compound splitting, etc. If not handled properly, different preprocessing strategies can lead to inconsistent results using word-based metrics Post (2018).
Data-to-text Generation BLEU can be poorly suited to evaluating data-to-text systems such as dialogue response generation and image captioning. These systems are designed to generate texts with lexical and syntactic variation, communicating the same information in many different ways. BLEU and similar metrics tend to reward systems that use the same wording as reference texts, causing repetitive word usage that is deemed undesirable to humans Liu et al. (2016). In a similar vein, evaluating the quality of image captions can be challenging. CIDEr Vedantam et al. (2015) uses tf-idf weighted n-grams for similarity estimation; and SPICE Anderson et al. (2016) incorporates synonym matching over scene graphs. Novikova et al. Novikova et al. (2017) examine a large number of word- and grammar-based metrics and demonstrate that they only weakly reflect human judgments of system outputs generated by data-driven, end-to-end natural language generation systems.
Metrics based on Continuous Representations Moving beyond traditional metrics, we envision a new generation of automated evaluation metrics comparing system and reference texts based on semantics rather than surface forms to achieve better correlation with human judgments. A number of previous studies exploit static word embeddings Ng and Abrecht (2015); Lo (2017) and trained classifers Peyrard et al. (2017); Shimanaka et al. (2018) to improve semantic similarity estimation, replacing lexical overlaps.
In contemporaneous work, Zhang et al. Zhang et al. (2019) describe a method comparing system and reference texts for semantic similarity leveraging the BERT representations Devlin et al. (2018), which can be viewed as a special case of our metrics and will be discussed in more depth later. More recently, Clark et al. (2019) present a semantic metric relying on sentence mover’s similarity and the ELMo representations Peters et al. (2018) and apply them to summarization and essay scoring. Mathur et al. (2019) introduce unsupervised and supervised metrics based on the BERT representations to improve MT evaluation, while Peyrard (2019a) provides a composite score combining redundancy, relevance and informativeness to improve summary evaluation.
In this paper, we seek to accurately measure the (dis)similarity between system and reference texts drawing inspiration from contextualized representations and Word Mover’s Distance (WMD; Kusner et al., 2015). WMD finds the “traveling distance” of moving from the word frequency distribution of the system text to that of the reference, which is essential to capture the (dis)similarity between two texts. Our metrics differ from the contemporaneous work in several facets: (i) we explore the granularity of embeddings, leading to two variants of our metric, word mover and sentence mover; (ii) we investigate the effectiveness of diverse pretrained embeddings and finetuning tasks; (iii) we study the approach to consolidate layer-wise information within contextualized embeddings; (iii) our metrics demonstrate strong generalization capability across four tasks, oftentimes outperforming the supervised ones. We now describe our method in detail.
Our MoverScore Meric
We have motivated the need for better metrics capable of evaluating disparate NLG tasks. We now describe our metric, namely MoverScore, built upon a combination of (i) contextualized representations of system and reference texts and (ii) a distance between these representations measuring the semantic distance between system outputs and references. It is particularly important for a metric to not only capture the amount of shared content between two texts, i.e., intersect(A,B), as is the case with many semantic textual similarity measures Peters et al. (2018); Devlin et al. (2018); but also to accurately reflect to what extent the system text has deviated from the reference, i.e., union(A,B) - intersect(A,B), which is the intuition behind using a distance metric.
Word Mover’s Distance (WMD) Kusner et al. (2015), a special case of Earth Mover’s Distance Rubner et al. (2000), measures semantic distance between texts by aligning semantically similar words and finding the amount of flow traveling between these words. It was shown useful for text classification and textual similarity tasks Kusner et al. (2015). Here, we formulate a generalization operating on -grams. Let and be two sentences viewed as sequences of -grams: and . If we have a distance metric between -grams, then we can define the transportation cost matrix such that is the distance between the -th -gram of and the -th -gram of . The WMD between the two sequences of -grams and with associated -gram weights and is then given by:
where is the transportation flow matrix with denoting the amount of flow traveling from the -th -gram in to the -th -gram in . Here, denotes the sum of all matrix entries of the matrix , where denotes element-wise multiplication. Then is the minimal transportation cost between and where -grams are weighted by and .
In practice, we compute the Euclidean distance between the embedding representations of -grams: where is the embedding function which maps an -gram to its vector representation. Usually, static word embeddings like word2vec are used to compute but these cannot capture word order or compositionality. Alternatively, we investigate contextualized embeddings like ELMo and BERT because they encode information about the whole sentence into each word vector.
We compute the -gram embeddings as the weighted sum over its word embeddings. Formally, if is the -th -gram from sentence , its embedding is given by:
where is the IDF of word computed from all sentences in the corpus and is its word vector. Furthermore, the weight associated to the -gram is given by:
where is a normalizing constant s.t. ,
In the limiting case where is larger than the sentence’s size, contains only one -gram: the whole sentence. Then reduces to computing the distance between the two sentence embeddings, namely Sentence Mover’s Distance (SMD), denoted as:
where and are the size of sentences.
In contemporaneous work, BERTScore (Zhang et al., 2019) also models the semantic distance between system and reference texts for evaluating text generation systems. As shown in Figure 1, BERTScore (precision/recall) can be intuitively viewed as hard alignments (one-to-one) for words in a sentence pair, where each word in one sequence travels to the most semantically similar word in the other sequence. In contrast, MoverScore goes beyond BERTScore as it relies on soft alignments (many-to-one) and allows to map semantically related words in one sequence to the respective word in the other sequence by solving a constrained optimization problem: finding the minimum effort to transform between two texts.
The formulation of Word Mover’s Distance provides an important possibility to bias the metric towards precision or recall by using an asymmetric transportation cost matrix, which bridges a gap between MoverScore and BERTScore:
BERTScore (precision/recall) can be represented as a (non-optimized) Mover Distance , where is a transportation cost matrix based on BERT and is a uniform transportation flow matrix.See the proof in the appendix.
2 Contextualized Representations
The task formulation naturally lends itself to deep contextualized representations for inducing word vectors . Despite the recent success of multi-layer attentive neural architectures Devlin et al. (2018); Peters et al. (2018), consolidating layer-wise information remains an open problem as different layers capture information at disparate scales and task-specific layer selection methods may be limited Liu et al. (2018, 2019). Tenney et al. (2019) found that a scalar mix of output layers trained from task-dependent supervisions would be effective in a deep transformer-based model. Instead, we investigate aggregation functions to consolidate layer-wise information, forming stationary representations of words without supervision.
where is the aggregated representation of the word .
We study two alternatives for : (i) the concatenation of power means Rücklé et al. (2018) as a generalized pooling mechanism, and (ii) a routing mechanism for aggregation Zhao et al. (2018, 2019). We relegate the routing method to appendix, as it does not yield better results than power means.
where exponentiation is applied elementwise. This generalized form can induce common named means such as arithmetic mean () and geometric mean (). In extreme cases, a power mean reduces to the minimum value of the set when , and the maximum value when . The concatenation of -mean vectors we use in this paper is denoted by:
where is vector concatenation; are exponent values, and we use with in this work.
3 Summary of MoverScore Variations
We investigate our MoverScore along four dimensions: (i) the granularity of embeddings, i.e., the size of for -grams, (ii) the choice of pretrained embedding mechanism, (iii) the fine-tuning task used for BERTELMo usually requires heavy layers on the top, which restricts the power of fine-tuning tasks for ELMo. (iv) the aggregation technique (-means or routing) when applicable.
We used and as well as full sentences ( size of the sentence).
Embedding Mechanism
We obtained word embeddings from three different methods: static embedding with word2vec as well as contextualized embedding with ELMo and BERT. If , -gram embeddings are calculated by Eq. (1). Note that they represent sentence embeddings when size of the sentence.
Fine-tuning Tasks
Natural Language Inference (NLI) and paraphrasing pose high demands in understanding sentence meaning. This motivated us to fine-tune BERT representations on two NLI datasets, MultiNLI and QANLI, and one Paraphrase dataset, QQP—the largest datasets in GLUE Wang et al. (2018). We fine-tune BERT on each of these, yielding different contextualized embeddings for our general evaluation metrics.
Aggregation
For ELMo, we aggregate word representations given by all three ELMo layers, using -means or routing (see the appendix). Word representations in BERT are aggregated from the last five layers, using -means or routing since the representations in the initial layers are less suited for use in downstream tasks Liu et al. (2019).
Empirical Evaluation
In this section, we measure the quality of different metrics on four tasks: machine translation, text summarization, image captioning and dialogue generation. Our major focus is to study the correlation between different metrics and human judgment. We employ two text encoders to embed -grams: , which uses a 12-layer transformer, and , which uses a 3-layer BiLSTM. We use Pearson’s and Spearman’s to measure the correlation. We consider two variants of MoverScore: word mover and sentence mover, described below.
Word Mover We denote our word mover notation containing four ingredients as: WMD-Granularity+Embedding+Finetune+Aggregation. For example, WMD-+BERT+MNLI+PMEANS represents the semantic metric using word mover distance where unigram-based word embeddings fine-tuned on MNLI are aggregated by -means.
Sentence Mover We denote our sentence mover notation with three ingredients as: SMD+Embedding+Finetune+Aggregation. For example, SMD+W2V represents the semantic metric using sentence mover distance where two sentence embeddings are computed as the weighted sum over their word2vec embeddings by Eq. (1).
We select multiple strong baselines for each task for comparison: SentBLEU, METEOR++ Guo et al. (2018), and a supervised metric RUSE for machine translation; ROUGE-1 and ROUGE-2 and a supervised metric Peyrard et al. (2017) for text summarization; BLEU and METEOR for dialogue response generation, CIDEr, SPICE, METEOR and a supervised metric LEIC (Cui et al., 2018) for image captioning. We also report BERTScore Zhang et al. (2019) for all tasks (see §2). Due to the page limit, we only compare with the strongest baselines, the rest can be found in the appendix.
1 Machine Translation
We obtain the source language sentences, their system and reference translations from the WMT 2017 news translation shared task Bojar et al. (2017). We consider 7 language pairs: from German (de), Chinese (zh), Czech (cs), Latvian (lv), Finnish (fi), Russian (ru), and Turkish (tr), resp. to English. Each language pair has approximately 3,000 sentences, and each sentence has one reference translation and multiple system translations generated by participating systems. For each system translation, at least 15 human assessments are independently rated for quality.
Results
Table 1: In all language pairs, the best correlation is achieved by our word mover metrics that use a BERT pretrained on MNLI as the embedding generator and PMeans to aggregate the embeddings from different BERT layers, i.e., WMD-1/2+BERT+MNLI+PMeans. Note that our unsupervised word mover metrics even outperforms RUSE, a supervised metric. We also find that our word mover metrics outperforms the sentence mover. We conjecture that important information is lost in such a sentence representation while transforming the whole sequence of word vectors into one sentence embedding by Eq. (1).
2 Text Summarization
We use two summarization datasets from the Text Analysis Conference (TAC)http://tac.nist.gov: TAC-2008 and TAC-2009, which contain 48 and 44 clusters, respectively. Each cluster includes 10 news articles (on the same topic), four reference summaries, and 57 (in TAC-2008) or 55 (in TAC-2009) system summaries generated by the participating systems. Each summary (either reference or system) has fewer than 100 words, and receives two human judgment scores: the Pyramid score Nenkova and Passonneau (2004) and the Responsiveness score. Pyramid measures how many important semantic content units in the reference summaries are covered by the system summary, while Responsiveness measures how well a summary responds to the overall quality combining both content and linguistic quality.
Tables 2: We observe that lexical metrics like ROUGE correlate above-moderate on TAC 2008 and 2009 datasets. In contrast, these metrics perform poorly on other tasks like Dialogue Generation Novikova et al. (2017) and Image Captioning Anderson et al. (2016). Apparently, strict matches on surface forms seems reasonable for extractive summarization datasets. However, we still see that our word mover metrics, i.e., WMD-1+BERT+MNLI+PMeans, perform better than or come close to even the supervised metric .
3 Data-to-text Generation
We use two task-oriented dialogue datasets: BAGEL Mairesse et al. (2010) and SFHOTEL Wen et al. (2015), which contains 202 and 398 instances of Meaning Representation (MR). Each MR instance includes multiple references, and roughly two system utterances generated by different neural systems. Each system utterance receives three human judgment scores: informativeness, naturalness and quality score Novikova et al. (2017). Informativeness measures how much information a system utterance provides with respect to an MR. Naturalness measures how likely a system utterance is generated by native speakers. Quality measures how well a system utterance captures fluency and grammar.
Tables 3: Interestingly, no metric produces an even moderate correlation with human judgments, including our own. We speculate that current contextualizers are poor at representing named entities like hotels and place names as well as numbers appearing in system and reference texts. However, best correlation is still achieved by our word mover metrics combining contextualized representations.
4 Image Captioning
We use a popular image captioning dataset: MS-COCO Lin et al. (2014), which contains 5,000 images. Each image includes roughly five reference captions, and 12 system captions generated by the participating systems from 2015 COCO Captioning Challenge. For the system-level human correlation, each system receives five human judgment scores: M1, M2, M3, M4, M5 (Anderson et al., 2016). The M1 and M2 scores measure overall quality of the captions while M3, M4 and M5 scores measure correctness, detailedness and saliency of the captions. Following Cui et al. (2018), we compare the Pearson correlation with two system-level scores: M1 and M2, since we focus on studying metrics for the overall quality of the captions, leaving metrics understanding captions in different aspects (correctness, detailedness and saliency) to future work.
Table 4: Word mover metrics outperform all baselines except for the supervised metric LEIC, which uses more information by considering both images and texts.
5 Further Analysis
Hard and Soft Alignments BERTScore is the harmonic mean of BERTScore-Precision and BERTScore-Recall, where both two can be decomposed as a combination of “Hard Mover Distance” (HMD) and BERT (see Prop. 1).
We use the representations in the 9-th BERT layer for fair comparison of BERTScore and MoverScore and show results on the machine translation task in Table 5. MoverScore outperforms both asymmetric HMD factors, while if they are combined via harmonic mean, BERTScore is on par with MoverScore. We conjecture that BERT softens hard alignments of BERTScore as contextualized embeddings encode information about the whole sentence into each word vector. We also observe that Wmd-bigrams slightly outperforms Wmd-unigrams on 3 out of 4 language pairs.
Distribution of Scores In Figure 2, we take a closer look at sentence-level correlation in MT. Results reveal that the lexical metric SentBLEU can correctly assign lower scores to system translations of low quality, while it struggles in judging system translations of high quality by assigning them lower scores. Our finding agrees with the observations found in Chaganty et al. (2018); Novikova et al. (2017): lexical metrics correlate better with human judgments on texts of low quality than high quality. Peyrard (2019b) further show that lexical metrics cannot be trusted because they strongly disagree on high-scoring system outputs. Importantly, we observe that our word mover metric combining BERT can clearly distinguish texts of two polar qualities.
Correlation Analysis In Figure 3, we observe existing metrics for MT evaluation attaining medium correlations (0.4-0.5) with human judgments but high inter-correlations between themselves. In contrast, our metrics can attain high correlations (0.6-0.7) with human judgments, performing robust across different language pairs. We believe that our improvements come from clearly distinguishing translations that fall on two extremes.
Impact of Fine-tuning Tasks Figure 4 compares Pearson correlations with our word mover metrics combining BERT fine-tuned on three different tasks. We observe that fine-tuning on closely related tasks improves correlations, especially fine-tuning on MNLI leads to an impressive improvement by 1.8 points on average.
6 Discussions
We showed that our metric combining contextualized embeddings and Earth Mover’s Distance outperforms strong unsupervised metrics on 3 out of 4 tasks, i.e., METEOR++ on machine translation by 5.7 points, SPICE on image captioning by 3.0 points, and METEOR on dialogue response generation by 2.2 points. The best correlation we achieved is combining contextualized word embeddings and WMD, which even rivals or exceeds SOTA task-dependent supervised metrics across different tasks. Especially in machine translation, our word mover metric pushes correlations in machine translation to 74.3 on average (5.8 points over the SOTA supervised metric and 2.4 points over contemporaneous BERTScore). The major improvements come from contextualized BERT embeddings rather than word2vec and ELMo, and from fine-tuning BERT on large NLI datasets. However, we also observed that soft alignments (MoverScore) marginally outperforms hard alignments (BERTScore). Regarding the effect of -grams in word mover metrics, unigrams slightly outperforms bigrams on average. For the effect of aggregation functions, we suggested effective techniques for layer-wise consolidations, namely -means and routing, both of which are close to the performance of the best layer and on par with each other (see the appendix).
Conclusion
We investigated new unsupervised evaluation metrics for text generation systems combining contextualized embeddings with Earth Mover’s Distance. We experimented with two variants of our metric, sentence mover and word mover. The latter has demonstrated strong generalization ability across four text generation tasks, oftentimes even outperforming supervised metrics. Our metric provides a promising direction towards a holistic metric for text generation and a direction towards more ‘human-like’ (Eger et al., 2019) evaluation of text generation systems.
In future work, we plan to avoid the need for costly human references in the evaluation of text generation systems, and instead base evaluation scores on source texts and system predictions only, which would allow for ‘next-level’, unsupervised (in a double sense) and unlimited evaluation (Louis and Nenkova, 2013; Böhm et al., 2019).
Acknowledgments
We thank the anonymous reviewers for their comments, which greatly improved the final version of the paper. This work has been supported by the German Research Foundation as part of the Research Training Group Adaptive Preparation of Information from Heterogeneous Sources (AIPHES) at the Technische Universität Darmstadt under grant No. GRK 1994/1. Fei Liu is supported in part by NSF grant IIS-1909603.
References
Appendix A Supplemental Material
In this section, we prove Prop. 1 in the paper about viewing BERTScore (precision/recall) as a (non-optimized) Mover Distance.
where and . Here, and denote vectors of weights for each -gram of and .
Then, can be formulated in a “quasi” WMD form:
where and is the size of -grams in . Similarly, we can have in a quasi WMD form (omitted). Then, can be formulated as harmonic-mean of two WMD forms of and .
A.2 Routing
In this section, we study the aggregation function with a routing scheme, which has achieved good results in other NLP tasks Zhao et al. (2018, 2019). Specifically, we introduce a nonparametric clustering with Kernel Density Estimation (KDE) for routing since KDE bridges a family of kernel functions with underlying empirical distributions, which often leads to computational efficiency Zhang et al. (2018), defined as:
where is a distance function, denotes the underlying closeness between the aggregated vector and vector in the -th layer, and is a kernel function. Some instantiations of Wand and Jones (1994) are:
One typical solution for KDE clustering to minimize is taking Mean Shift Comaniciu and Meer (2002), defined as:
Firstly, can be updated while is fixed:
Intuitively, can be explained as a final aggregated vector from contextualized layers. Then, we adopt SGD to update :
where is a hyperparameter to control step size. The routing process is summarized in Algorithm 1.
Table 6 compares our word mover based metric combining BERT representations on different layers with stronger BERT representations consolidated from these layers (using -means and routing). We often see that which layer has best performance is task-dependent, and our word mover based metrics (WMD) with -means or routing schema come close to the oracle performance obtained from the best layers.
Experiments
Table 7, 8 and 9 show correlations between metrics (all baseline metrics and word mover based metrics) and human judgments on machine translation, text summarization and dialogue response generation, respectively. We find that word mover based metrics combining BERT fine-tuned on MNLI have highest correlations with humans, outperforming all of the unsupervised metrics and even supervised metrics like RUSE and . Routing and -means perform roughly equally well.