This work is licensed under a Creative Commons Attribution 4.0 International License. License details: http://creativecommons.org/licenses/by/4.0/.
In terms of visual communication such as social media posts (posters, flyers, and ads) and motivational messages, text emphasis is crucial in that it facilitates the comprehension of written text and that it helps convey the author’s intent. Therefore, it is expected that the development of an automatic system that recommends which part to emphasize in the text of visual media will bring significant advantages; e.g., it is possible to accelerate the making process of posters and videos for advertisement. In this paper, we attempt to devise such a system solely with the aid of pre-trained language models (PLMs) without any task-specific laborious training.
Recently, there has been a substantial amount of work in the literature to figure out what knowledge Transformer [vaswani2017attention] based PLMs such as BERT [devlin2019bert] contain and why they perform surprisingly well on various downstream tasks [goldberg2019assessing, kovaleva2019revealing, rogers2020primer]. Among these, a group of studies has focused on analyzing PLMs’ self-attention distributions to find some evidence that supports the existence of linguistic knowledge within the pre-trained weights of PLMs. Specifically, clark2019does investigated BERT’s individual attention heads to probe its ability to parse dependency trees, while Kim2020Are proposed an unsupervised constituency parsing method applicable on top of the distributions.
Following the same philosophy shared by the work mentioned above, we propose a zero-shot emphasis selection method, assuming that during pre-training, some attention heads in PLMs are inspired to recognize which words are more important than others. We test our method on a carefully designed dataset [shirani2020semeval], and it records the ranking score 0.690 on the validation set, which outperforms an intuitive baseline adopting the term frequency-inverse document frequency (TF-IDF) strategy [jones1972statistical]. Furthermore, our method operates in a fully zero-shot manner, not leveraging gold-standard annotations provided by the dataset at all, implying its universal applicability in a low/zero-resource regime.
This paper aims to present a tractable solution to the SemEval 2020 shared task 10 [shirani2020semeval]. The dataset provided by this task consists of short English sentences obtained from Adobe Spark. It contains a variety of subjects featured in flyers, posters, and advertisements or motivational memes on social media—for example, “In honor of the brave” [shirani2019learning].
In detail, as shown in Table 1, each word of a sentence in the dataset is provided with nine binary labels (I/O tags) that correspond to the decisions of nine annotators, each indicating whether to emphasize the target word or not. Here we define the emphasis frequency () of the word in the sentence as the average of these nine labels, where treating ‘I’ as 1 and ‘O’ as 0. Our goal is to construct a model that predicts the correct ranking of words based on each word’s gold emphasis frequency.
For evaluation, we use the score which is calculated as:
where is a set of top- high emphasis frequency words in an input sentence of a dataset .; e.g., would be [’honor’, ’brave’]. is a set of top- high emphasis frequency words based on our model’s prediction. corresponds to the number of elements in a set. Moreover, we introduce the as an aggregated measure that averages all possible scores:
In this section, we propose three ways to induce the emphasis frequency () of each word in a sentence using a PLM’s111We consider the following PLMs as candidates for our method: BERT [devlin2019bert], DistilBERT [sanh2019distilbert] , GPT-2
, GPT-2[radford2018improving], RoBERTa [liu2019roberta], XLNet [yang2019xlnet], and XLM [conneau2019cross] attention maps. The intuition behind our approach is that the more one word draws attention from other words, the more suitable this word as a target to be emphasized. In other words, the words contribute the most to construct the intermediate representations of other words for the next layer of PLMs should have high values. As we only resort to the inherent knowledge of PLMs rather than learning a separate model from scratch, we do not need any further training based on supervision from gold-standard annotations to implement our approach. This characteristic is attractive in a perspective that the annotations required to build gold-standard labels are too expensive and even somewhat subjective.
To reduce the ambiguity, here we define terminology. We denote a sentence as a set of words, , where stands for the number of words in the sentence. When a sentence is fed to a PLM, an attention map, which is a set of attention distributions of a particular self-attention head, can be extracted. We define as a set of attention maps extracted from a PLM; i.e., , where is an attention map of the th attention head on the th layer, and and are the numbers of layers and attention heads per layer, respectively. The reason why we add to is to consider two special tokens, [CLS] and [SEP]. In Figure 1, there is a sample attention map of the example sentence, where each row represents an attention distribution of the corresponding word; e.g., The row is an attention distribution of the word ’honor’ over other words.
There are some pre-processing procedures to obtain proper attention maps which can be utilized for our methods. First, we add special tokens [CLS] and [SEP] to an input sentence.—for example, “[CLS] In honor of the brave [SEP]” as described in devlin2019bert. Then, we can extract attention maps after feeding an input sentence to a PLM. Since most PLMs tokenize a sentence into subword-level, we convert token-level attention maps to word-level attention maps by averaging each group of the attention weights of subword tokens that belong to the same word following clark2019does and Kim2020Are.
For each attention head, we consider three options to derive : Words2Target, CLS2Target and SEP2Target. Each option is depicted in Figure 2.
Given a particular attention head (the th attention head on the th layer extracted from a PLM), the emphasis frequency of a word can be calculated as an average over other words’ attention weights on the target word:
This equation has a meaning of how much the th word,
, is influential when constructing the hidden representations of other words. It also can be thought of as the average of values on theth column of the attention map as shown in Figure 2 - (a).
3.2 CLS2Target and SEP2Target
Including BERT, many PLMs use special tokens ([CLS], [SEP]) to encode a sentence representation or the relation of two input sentences. The attention weight of a special token on means how much the contributes to sentence representation. Thus, when a PLM is given an input sequence ([CLS], , , , , [SEP]), we induce222These methods can’t be applied to GPT-2 model because it doesn’t use special tokens. from the attention weight of on both special tokens, as expressed in Figure 2 - (b), (c):
3.3 Best Configuration Selection
For a single PLM, there are possible configurations because can be computed in three ways of for all . For instance, in the case of the BERT-base, which consists of 12 layers and 12 attention heads per layer, there are 12 12 3 432 possible configurations. We compute and scores for every pair and select the best configuration for the PLM based on the .
To evaluate the performance of our method more precisely, we propose a reasonable baseline using Term Frequency-Inverse Document Frequency (TF-IDF) as follows:
where and are sets of sentences of the training set and validation set, and and are sentences sampled respectively from these datasets. means the number of occurrences of in the sentence . is the number of words in . The more occurs in the sentence and less included in the whole training set, the larger TF-IDF for in the sentence will be. This is why the TF-IDF is considered a statistical measure of word specialty in a particular document. Word counting method assigns which leads to rare words having larger values. In addition, the random baseline method randomly gives value of the target word. In experiments, we show that the TF-IDF model performs better than the other two methods, making it a suitable option as a reasonable baseline.
|Model||L||A||Method||M1||M2||M3||M4||R dev||R test|
|English Pre-trained LMs|
|Multilingual Pre-trained LMs|
In Table 2, we report the results of our method to various PLMs on the validation set and test set. Note that without a few exceptions, our method combined with PLMs performs better than baselines, including the one with TF-IDF (0.5145 ranking score). Among PLMs, the BERT-large-uncased and DistilBERT-base-uncased models record the best performance.
Here we mention several takeaways from our results. First, particular PLMs (GPT-2, XLNet) report comparably lower ranking scores against the other PLMs and the TF-IDF baseline. Since GPT-2 adopts a Transformer decoder to its architecture, its attention distribution is leaned on the first word of a sentence [vig2019visualizing]. This results in a sub-optimal solution where each first word for all 390 sentences in the validation set becomes the top- high score word. On the other hand, XLNet model tends to focus more on punctuation marks such as period (.) and comma (,). Specifically, the XLNet-base model predicts that a period should be one of the top- high words for 289 sentences in the validation set, even though the prediction is correct only for 48 cases.
Second, although the results from our method record relatively lower score than that of the supervised baseline model (DL-BiLSTM+ELMo model) proposed in shirani2019learning, we find that it generates quite meaningful emphasis selections.
|Models||S1: “Beauty is not in the face ; beauty is a light in the heart . ”||S2: “The bird a nest , the spider a web , man friendship . ”|
|Gold||heart(1), Beauty(2), light(3), in(4), the(4)||friendship(1), bird(2), nest(2), man(2)|
|Ours||light(1), face(2), Beauty(3), beauty(4)||friendship(1), web(2), a(3), nest(4)|
|M1 / M2 / M3 / M4 / R||0.0 / 0.0 / 0.6667 / 0.5 / 0.2917||1.0 / 0.5 / 0.3333 / 0.5 / 0.5833|
In Table 3, the DistilBERT-base-uncased model selects nest, a, web, friendship to emphasize in S2, which results in “The bird a nest , the spider a web , man friendship . ”. Instead, the gold generates “The bird a nest , the spider a web , man friendship . ”, and it seems that our model’s result is also valuable.
Third, the DistilBERT models achieve high performance despite its small number of model parameters. We conjecture that the distillation techniques applied to build the DistilBERT model function as an ensemble of the attention heads from its parent model. Besides, uncased models show better performance than cased models. We hypothesize that preserving a word’s capital letters is meaningful when selecting proper words to be emphasized.
Lastly, ensembling several PLMs is certainly beneficial. We ensemble the top-5 models by averaging over their values and achieve the 0.6898 ranking score, which is significantly higher than those of individual PLMs.
For further analysis, we investigate how many attention heads are capable of selecting proper words to emphasize. In the case of the top-2 models (DistilBERT-base-uncased and BERT-large-uncased), we probe the layer-wise ranking scores of individual attention heads. We find that there exist attention heads specialized for word emphasis (ones recording high ranking scores). For both cases, it seems that there is a gap between topmost attention heads and the others. For instance, the configuration with secondary ranking score reports 0.5975, which is 0.0445 lower than the score of top- in the BERT-large-uncased model.
We have proposed a zero-shot emphasis selection method, focusing on investigating whether pre-trained language models contain enough knowledge to select proper words to be emphasized. We have found that some PLMs report comparable performance, confirming that some specialized attention heads of PLMs have ability to detect meaningful words.
We would like to thank Jihun Choi and the anonymous reviewers for their thoughtful and valuable comments. This work was supported by the National Research Foundation of Korea (NRF) grant funded by the Korea government (MSIT) (NRF2016M3C4A7952587).