Lexical substitution is the task of generating meaningful substitutes for a word in a given textual context. Contextual word embedding models have achieved state-of-the-art results in the lexical substitution task by relying on contextual information extracted from the replaced word within the sentence. However, such models do not take into account structured knowledge that exists in external lexical databases. We introduce LexSubCon, an end-to-end lexical substitution framework based on contextual embedding models that can identify highly-accurate substitute candidates. This is achieved by combining contextual information with knowledge from structured lexical resources. Our approach involves: (i) introducing a novel mix-up embedding strategy to the target word's embedding through linearly interpolating the pair of the target input embedding and the average embedding of its probable synonyms; (ii) considering the similarity of the sentence-definition embeddings of the target word and its proposed candidates; and, (iii) calculating the effect of each substitution on the semantics of the sentence through a fine-tuned sentence similarity model. Our experiments show that LexSubCon outperforms previous state-of-the-art methods by at least 2% over all the official lexical substitution metrics on LS07 and CoInCo benchmark datasets that are widely used for lexical substitution tasks. Lexical Substitution (McCarthy and Navigli, 2007) is the task of generating appropriate words which can replace a target word in a given sentence without changing the sentence's meaning. The increased research interest in Lexical Substitution is due to its utility in various Natural Language Processing (NLP) fields including data augmentation, paraphrase generation and semantic text similarity. Contextual word embedding models (such as ELMo (Peters et al., 2018) and BERT (Devlin et al., 2019)) have achieved state-of-art results in many NLP tasks. These models are usually pre-trained on massive corpora and the resulting context-sensitive embeddings are used in different downstream tasks (Howard and Ruder, 2018). Zhou et al. (2019) have achieved state-of-the-art results on the lexical substitution task by improving the BERT's standard procedure of the masked language modeling task. However, the current state-of-the-art contextual models have yet to incorporate structured knowledge that exists in external lexical database into their prediction process. These lexical resources could boost the model's performance by providing additional information such as the definitions of the target and candidate words (in order to ensure that the candidate word is semantically similar to the target word and not only appropriate for the sentence's context) or by enriching the proposed candidate word list so it will not only be based on the vocabulary of the contextual model. In this paper, we present and publicly release 1 a novel framework for the lexical substitution task. Specifically, (i) we are the first, to the best of our knowledge, to propose a novel mix-up embedding strategy that outperforms the previous state-of-the-art strategy of word embedding dropout for the input embedding of the target word in a contextual model (Zhou et al., 2019) for the task of predicting accurate candidate words; (ii) we propose the combined usage of features from contextual embedding models and external lexical knowledge bases in order to determine the most appropriate substitution words without modifying the meaning of the original sentence, such as introducing a new gloss (definition) similarity metric which calculates the similarity of the sentence-definition embeddings of the target word and its proposed candidates; (iii) we generate a highly accurate fine tuned sentence similarity model by taking advantage of popular data augmentation techniques (such 1 https://github.com/gmichalo/LexSubCon 1226 as back translation), for calculating the effect of each candidate word in the semantics of the original sentence; and, (iv) finally, we show that LexSubCon achieves state-of-the-art results on two popular benchmark lexical substitution datasets (McCarthy and Navigli, 2007; Kremer et al., 2014). The lexical substitution task consists of two subtasks: (i) generating a set of meaning preserving substitute candidates for the target word and (ii) appropriately ranking the words of the set by their ability to preserve the meaning of the initial sentence (Giuliano et al., 2007; Martinez et al., 2007). However, lexical substitution models can also be tested in a simpler problem where the set of substitute candidates is composed of human-suggested words and the task is to accurately rank the substitute words that are provided (Erk and Pad, 2010). The authors in (Melamud et al., 2015b) proposed the use of a word2vec model which utilizes word and context embeddings to represent the target word in a given context. Their model ranked the candidate substitutions by measuring their embedding similarity. In (Melamud et al., 2016) the context2vec model was introduced where the context representation of the word was calculated by combining the output of two bidirectional LSTM models using a feed-forward neural network. Peters et al. (2018) introduced contextualized word embeddings in a bidirectional language model (ELMo). This allowed the model to change the embedding of a word based on its imputed meaning which is derived from the surrounding context. Subsequently, Devlin et al. (2019) proposed the Bidirectional Encoder Representations from Transformers (BERT) which uses bidirectional transformers (Vaswani et al., 2017) to create context-dependent representations. The authors in (Gar Soler et al., 2019) used ELMo in the lexical substitution task by calculating the cosine similarity between the ELMo embedding of the target word and all the candidate substitutes. In addition, Zhou et al. (2019) achieved state-of-the-art results on the lexical substitution task by applying a dropout embedding policy to the target word embedding and by taking into account the similarity between the initial contextualized representation of the context words and their representation after replacing the target word by one of the possible candidate words. An analysis of state-of-the-art contextual model on the lexical substitution task was presented in (Arefyev et al., 2020). Finally, external knowledge from knowledge bases has been used to enhance the performance of deep learning models. Sense-BERT (Levine et al., 2020) was pre-trained to predict the semantic class of each word by incorporating lexical semantics (from the lexical database WordNet (Miller, 1995)) into the model's pre-training objective. Furthermore, Faruqui et al. (2015) and Bahdanau et al. (2017) used external knowledge (namely WordNet) in order to enhance word embeddings and to create more accurate representations of rare words. In the lexical substitution task, a model aims to firstly generate a set of candidate substitutions for each target word and secondly to create an appropriate ranking of the elements of the candidate set. In addition, there are two main conditions for a lexical substitute model to satisfy: (i) to be semantically similar to the target word and (ii) and to be compatible with the given context (sentence) (Melamud et al., 2015b). We present the LexSubCon framework which achieves state of the art results on the lexical substitution task by combining contextual information with knowledge from structured external lexical resources. The architecture of LexSubCon is depicted in Figure 1. The key characteristic of LexSubCon is its capability of unifying different substitution criteria such as contextualized representation, definition and sentence similarity in a single framework in order to accurately identify suitable candidates for the target words in a specific context (sentence). The standard BERT architecture (Devlin et al., 2019) can be used in the lexical substitution task by masking the target word and letting the model to propose appropriate substitute candidates that preserve the initial meaning of the sentence. Zhou et al. (2019) argued that applying embedding dropout to partially mask the target word is a better alternative than masking the whole word. This is because the model may generate candidates that are semantically different but appropriate for the context of the initial sentence. Their experiments showed that this policy is indeed more beneficial than completely masking, or not masking, the target word. However, in this paper we demonstrate that a mix-up embedding strategy can yield even better results. The main disadvantage of dropout embedding is that it sets random positions in the embedding vector of the target words to zero. We propose that by using external knowledge, we can obtain probable synonyms of the target word and use that knowledge in a mix-up scenario (Zhang et al., 2018) through linearly interpolating the pair of the target input embedding and the average embedding of its synonyms. This allows the model to generate a new synthetic input embedding by repositioning the target embedding around the neighborhood of the embedding of its synonyms. In order to obtain appropriate synonyms we use WordNet (Miller, 1995) which is an extensive lexical database where words are grouped into sets of synonyms (synsets). In our experiments, the best performance was achieved when the list of synonyms was extracted from the complete set of synsets for each word as it minimizes the chance of having a synonym set that only includes the target word itself. Finally, we use a mix-up strategy to calculate a new input embedding for the target word X  target as shown in equation 1: X  target = X target + (1   ) X synonyms (1) Where X target is the initial input embedding of the target word, X synonyms is the average embedding of all the synonyms. It should be noted that Wordnet does not contain information about some words, such as pronouns, conjunctions, or nouns that are not commonly used in the English vocabulary. To address this limitation, whenever a target word cannot be found in the WordNet database, we replace the mix-up strategy by injecting Gaussian noise to the input embedding of the target word. This produces a similar effect as the mix-up strategy since the target embedding is re-positioned around itself in the embedding space (equation 2): X  target = X target + e (2) where e is a Gaussian noise vector with components e i  N (  i ,  2 i ) . We use the BERT architecture to calculate the proposal score for each candidate. The input embedding vectors pass through multiple attention-based transformer layers where each layer produces a contextualized embedding of each token. For each target word x t , the model outputs a score vector y t  RD , where D is the length of the model's vocabulary. We calculate the proposal score s p for each candidate word x c , using the score vector y t of the BERT's language modeling process, as the probability for the BERT model to propose the word x c over all the candidates words x  c when the target word's sentence is provided as input to it: s p ( x c ) = exp ( y t [ x c ]) (cid:80) x  c exp ( y t [ x  c ]) (3) 3.2 Gloss-Sentence Similarity Score In the previous section, we analyzed our model which ranks candidate substitute words by calculating their individual proposal scores. However, Zhou et al. (2019) and Arefyev et al. (2020) showed that the proposal score does not provide sufficient information about whether the substitute words will modify the sentence's meaning. Thus, in this section, we present a new metric which ranks the candidate words by considering the gloss (a dictionary-style definition) of each word. By extracting the appropriate information from the Wordnet database, a list of potential glosses is created for each target or candidate word. In addition, we can determine the most appropriate gloss based on the word and its specific context (sentence) by taking advantage of recent fine-tuned contextual models that have achieved state-of-the-art results in the Word Sense Disambiguation (WSD) task (Huang et al., 2019). As the glosses are sentences (sequence of words) they can be represented in a semantic space through a sentence embedding generating model. A ranking of each candidate word is produced by calculating the cosine similarity between the gloss sentence embedding of the target word and the gloss sentence embedding of each candidate word. There are many methods for generating sentence embeddings, such as calculating the weighted average of its word embeddings (Arora et al., 2017). We select the sentence embeddings of the stsb-roberta-large model in (Reimers and Gurevych, 1228 2019) which has been shown to outperform other state-of-the-art sentence embeddings methods. Given a sentence s , a target word x t and a candidate word x c , our model first identifies the most appropriate gloss g t for the target word given its context. After replacing the target word with the candidate x c to create a new sentence s  , the most appropriate gloss g c for the candidate word is also determined. A gloss-similarity score s g for each candidate is then calculated as the cosine similarity between the two glosses-sentences embeddings. We also chose to calculate the effect of each substitution in the semantics of the original sentence by calculating the semantic textual similarity between the original sentence s and the updated sentence s  (a sentence where we have replaced the target word with one of its substitutions). In order to accurately calculate a similarity score between s and s  , we fine-tune a semantic textual similarity model based on the stsb-roberta-large model (Reimers and Gurevych, 2019) by using the training portion of the dataset in order to create pairs of sentences between the original sentence and an updated sentence where we have substitute the target word with one of its proposed candidates. Using the methods that we described in section 3.2, we can identify the most appropriate synset (from WordNet) for each target word and create a new pair of sentences between the original sentence and an updated sentence where we have updated the target word with the synonyms of the previous mentioned synset. However, due to the limited size of the training dataset, our model is still not provided with enough training data in order to be fully fine-tuned. This is the reason why we employ a data augmentation technique in order to produce the examples needed for this task. Specifically, we create a back-translation mechanism in order to generate artificial training data. Back-translation or round-trip translation is the process of translating text into another language (forward translation) and then translating back again into the original language (back translation) (Aiken and Park, 2010). Back-translation has been used in different tasks in order to increase the size of training data (Sennrich et al., 2016; Aroyehun and Gelbukh, 2018). In our case, we provide to the back-translation module the initial sentence s and it produces a sightly different updated' sentence s  u . For the s  u sentences that still contain the target word we can create pair of sentences between the s  u and an alternative version of the s  u sentence ( s  u ) where the target word is substituted with one of the candidate words or synonyms that we mentioned in the above paragraph. The main disadvantage of this techniques is that it may return the same initial sentence without any changes. In this case, we add a second translation level where the initial sentence is translated into two different languages before being translated back. In our experiments we have also included the substitute candidate validation metric from (Zhou et al., 2019) as it has been shown to have a positive affect on the performance of a lexical substitution model. The substitute candidate validation metric is represented as the weighted sum of the cosine similarities between the contextual representation of each token in the initial and in the updated sentence where the weight of the cosine similarity of the token i is calculated as the average self-attention score of all heads in all layers from the token of the target word to token i . As mentioned in (Zhou et al., 2019), this metric evaluates the influence of the substitution on the semantic of the sentence. Finally, LexSubCon uses a linear combination of the above mentioned features to calculate the final score for each candidate word. The candidates for each target word are extracted using the external lexical resource of WordNet and the BERT-based lexical substitution approach where the model provides probabilities for each candidate based on the context (sentence). We create a list of candidates based on the synonyms, the hypernyms, and hyponyms of each target word that could be identified in WordNet. In addition, we include in the list the candidate words with the higher probability that could be identified using the mixup strategy that we described in section 3.1. We chose to include candidates from WordNet because we do not want our model to only include candidates words from the BERT vocabulary and we also include candidates words from a BERT-based model because target words may not be included in WordNet. We evaluate LexSubCon on the English datasets SemEval 2007 (LS07) 2 (McCarthy and Navigli, 2007) and Concepts-In-Context (CoInCo) 3 (Kre-mer et al., 2014) which are the most widely used datasets for the evaluation of lexical substitution models. (i) The LS07 dataset is split into 300 train and 1710 test sentences where for each of the 201 target words there are 10 sentences (extracted from http://corpus.leeds.ac.uk/internet.html). The gold standard was based on manual annotation where annotators provided up to 3 possible substitutes. (ii) The CoInCo dataset consists of over 15K target word instances (based on texts provided in the Open American National Corpus) where 35% are training and 65% are testing data. Each annotator provided at least 6 substitutes for each target word. Our experiments with all datasets are consistent with their intended use, as they were created for research purposes. We manually investigate the existence of information that names individuals or offensive content, however, we did not find any indication of either of them. In order to have a fair comparison with the previous state-of-the-art models, for both datasets we used their processed versions as used in (Melamud et al., 2015b, 2016). All-ranking task: In this task no substitution candidates are provided. We use the official metrics that the organizers provided in the original lexical substitution task of SemEval-2007 4 . These were best and best-mode which validate the quality of the model's best prediction and both oot (out-of-ten) and oot-mode to evaluate the coverage of the gold substitute candidate list by the 10-top predictions. We also use P recision @1 to have a complete comparison with the model in (Zhou et al., 2019). Candidate ranking task: In this task the list of candidates are provided and the goal of the model is to rank all the candidate words. For the candidate ranking task we follow the policy of previous works and construct the candidate list by merging all the substitutions of the target lemma and 2 license: https://tinyurl.com/semeval-license 3 license: CC-BY-3.0-US 4 www.dianamccarthy.co.uk/files/task10data.tar.gz POS tag over the whole dataset. For measuring the performance of the model we use the GAP score (Kishida, 2005) 5 which is a variant of the MAP (Mean Average Precision). Following (Melamud et al., 2015b), we discard all multi-words from the gold substitutes list and remove the instances that were left with no gold substitutes. We use the uncased BERT large model (Devlin et al., 2019) for the calculation of the proposal score and candidate validation score. For the identification of the most appropriate glosses we employ the pre-trained model in (Huang et al., 2019) which has achieved the state-of-the-art results in the Word Sense Disambiguation (WSD) task. Finally, the sentence-similarity metric is computed by fined-tuning the stsb-roberta-large model in (Reimers and Gurevych, 2019) and by employing the OPUS-MT models (Tiedemann and Thottingal, 2020) (namely opus-mt-en-romance, opus-mt-fr-es and opus-mt-romance-en) for the creation of the back-translated sentences. We use the LS07 trial set for training the sentence similarity metric model (for 4 epochs) and for fine-tuning the parameters of our framework based on the best score. Empirically, the  parameter of the mix-up strategy was set to 0 . 25 and the weights to 0 . 05 , 0 . 05 , 1 , 0 . 5 for the proposal score, gloss-sentence similarity score, sentence similarity score and candidate validation score respectively (with the search space for all the parameters being [0 , 1] 6 ). Finally, for the Gaussian noise we choose a mean value of 0 and standard deviation 0.01. We propose 30 candidates for each target word. In order to achieve more robust results, we run LexSubCon on five different (random) seeds and we provide the average scores and standard deviation. All the contextual models are implemented using the transformers library (Wolf et al., 2019) on PyTorch 1.7.1. All experiments are executed on a Tesla K80 GPU with 64 GB of system RAM on Ubuntu 18.04.5 LTS. It should be noted that LexSubCon contains 1136209468 parameters. To enable direct comparison and to isolate gains due to improvements solely on the post-processing strategy that each model uses (which has the potential to change its performance (Arefyev et al., 2020)), we opt to reproduce and use the same strat-5 egy for the tokenization of the target words from Bert s p ,s u (Zhou et al., 2019). We focus our comparison on Bert s p ,s u as it has achieved impressive state of the art results on both benchmark datasets 7 . The results of LexSubCon and the previous state-of-the art results in both LS07 and CoInCo benchmark datasets are presented in Table 1. LexSubCon outperformed the previous methods across all metrics in the LS07 and the CoInCo datasets due to the fact that all features have a positive contribution on its performance (see ablation details in section 4.5) as they encourage LexSubCon to take into consideration different substitution criteria. The standard deviation of the results of LexSubCon is not zero due to the fine-tuning process of the sentence similarity model. However, the results indicate that there are no large fluctuations. LexSubCon and our implementation of Bert s p ,s u had a running time of 74k and 30k for LS07 and 580K and 266K seconds for the CoInCo dataset respectively. In order to evaluate the mix-up strategy for the input embedding of the proposal model, we study the effect of different input embedding policies. The results of this study are listed in Table 2. It 7 Note that the method proposed by (Zhou et al., 2019) was implemented to the best of our abilities to be as faithful to the original work as possible using elements of code that the method's authors kindly provided upon request. However, the authors could not make the complete original code available to us. can be observed that even the simpler strategy of injecting Gaussian noise to the input embedding outperformed the standard policy of masking the input word. These results indicate that a contextual model needs information from the embedding of the target word in order to predict accurate candidates but it may over-rely on this information when it is provided with an intact input embedding. Fur-1231 thermore, the mix-up strategy outperformed all the other policies and specifically the dropout embedding strategy (Zhou et al., 2019) as the mix-up strategy re-positions the target embedding around the neighborhood of the embedding of its synonyms and it does not erase a part of the embedding that the model can learn from. In order to evaluate the effect of each feature on the performance of LexSubCon, we conducted an ablation study. The results are presented in Table 3. As Table 3 shows, LexSubCon achieved its best performance when it has access to information from all the features described in section 3. By testing the performance of the individual features, we observe that the gloss sentence similarity feature achieves the worst performance out of all the features. This is likely because many candidate words cannot be identified in Wordnet and thus we assign a zero value to their gloss sentence score. Another factor is that the models that were used for the selection of the most appropriate gloss for each word may introduce noise in the process of the gloss-similarity score model as they may select not-optimal glosses. We also evaluate LexSubCon in the candidate ranking task for both the LS07 an CoInCo dataset. In this sub-task the candidate substitution words are provided and the main task of the system is to create the most appropriate ranking of the candidates. Table 4 provides the evaluation results in the candidate ranking task of LexSubCon and of the previous state-of-the art models. We report the results both on the test set and on the entire dataset (trial+test), in order to have a complete comparison as some of the previous state of the art models were evaluated on the entire datasets and some were evaluated only in the testing portion of the datasets. It can be observed that all the features have a positive effect on the performance of LexSubCon thus allowing it to outperform the previous state-of-the-art methods. Specifically, the results demonstrate the 1232 Word Sentence Gold Ranking LexSubCon BERT based terrible positive effect of the features on accurately ranking a list of potential candidates as LexSubCon outperforms the previous methods even in the scenario where they are all provided with the same substitution candidate list. In Table 5, we provide different examples of target words and their top lexical substitutes proposed by LexSubCon and the BERT based model in order to demonstrate the effect of external lexical resources on the performance of a contextual model. As it can be observed, for the target word terrible , the BERT based model proposes a candidate word ( positive ) which may fit in the sentence but has the opposite meaning of the target word. However, LexSubCon provides semantically similar candidates by using information from different signals (e.g comparison of the definition of each word). In addition, for the target word return , our model identifies appropriate candidates that are not in the vocabulary of the contextual model (the word regress ) by introducing candidates from a external lexical database. These examples showcase that enriching contextual models with external lexical knowledge can assist the model to provide more accurate candidates. We evaluate the performance of LexSubCon in the context of textual data augmentation. Specifically, we conduct experiments on a popular benchmark text classification tasks of the English sub-jectivity/objectivity dataset (SUBJ) (Pang and Lee, 2004) 8 . The SUBJ dataset contains 5000 subjective and 5000 objective processed sentences (movie reviews). We train the LSTM model (with the same hyperparameters) which was used in (Wei and Zou, 2019) to measure the effect of different data augmentation techniques. We compare our method with previous state-of-the-art lexical 8 license: https://tinyurl.com/t-license substitution models and with other popular textual data augmentation techniques: (i) the back-trans-lation technique (described in section 3.3) (ii) the EDA framework (Wei and Zou, 2019) which utilizes four operations of Synonym Replacement and Random Insertion/Swap/Deletion in order to create new text. Following the data generation algorithm in (Arefyev et al., 2020), LexSubCon creates new examples by sampling one word for each sentence, generating the appropriate substitute list for this word and sampling one substitute with probabilities corresponding to their substitute scores (which were normalized by dividing them by their sum) to replace the original word with the sampled substitute. Figure 2 demonstrates how data augmentation affects the classification depending on the size of the training set (Arefyev et al., 2020; Wei and Zou, 2019). As it is expected the effect of each text augmentation technique on the performance of the model becomes more significant while the size of the train set is reduced. Figure 2 also shows that the data created with lexical substitution have a more positive effect to the performance of the model than the other data augmentation techniques since back translation techniques may provide text that does not follow the syntactic rules of the target language and the EDA framework may create examples that could confuse the model by changing the structure of the sentence due the random insertion and 1233 swapping of words. Finally, since LexSubCon can create more accurate substitution candidates than the standard BERT model and the Bert s p ,s u model, the texts that were created with LexSubCon have a more positive effect on the model's performance. This paper presents LexSubCon, an end-to-end lexical substitution framework based on contextual embedding models. LexSubCon establishes a new mix-up embedding strategy that outperforms the previous SOTA strategy of word embedding dropout for the embedding of the target word for the task of predicting accurate candidate words. LexSubCon introduces the combined usage of features from contextual embedding models and external lexical knowledge bases in order to calculate accurately the semantic similarity between a target word and its candidates. We confirm that these features can improve the LexSubCon's performance as it outperforms other state-of-the-art results on two benchmark datasets. As for future work, we plan to address the limitations of this study including: (i) examining the effect of using other models as the basis of our features (e.g. Albert (Lan et al., 2020)); (ii) exploring other candidate features for the ranking of the candidates (e.g. parser information (Szarvas et al., 2013a)) (iii) testing LexSubCon in datasets of other languages using multi-language lexical databases (e.g. MultiWordNet (Pianta et al., 2002) or Balka-Net (Oflazer et al., 2001)) to investigate further the model's general availability. Lexical substitution can be useful in various natural language processing (NLP) tasks such as textual data augmentation, paraphrase generation and text simplification. The results that we present in this paper suggest that contextual word embeddings models, such as our framework (LexSubCon), can be a valuable tool for providing accurate substitution candidates that can be further used in a variety of down-stream tasks. We believe that there are many benefits of using our contextual embeddings models. For example, LexSubCon can be used as a data augmentation tool to provide artificial training data for tasks where the lack of sufficient training data may hurt the performance of the model. However, there are potential risks of over-relying on any lexical substitution tool. Particularly, a lexical substitution model can unintentionally change the meaning of the original text thus leading to erroneous conclusions.
abstain abstain abstain method abstain abstain abstain abstain abstain result abstain abstain abstain abstain abstain abstain abstain objective abstain abstain objective other result other other other other other other other other other other other other other other other other abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain method abstain abstain other abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain method abstain abstain method method method abstain abstain method method abstain method abstain abstain abstain abstain abstain method method method abstain other abstain abstain abstain abstain abstain abstain abstain method abstain method abstain other method method method method abstain method abstain abstain abstain abstain abstain method method method abstain abstain abstain abstain abstain result abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain abstain result abstain abstain abstain abstain abstain result abstain abstain abstain abstain abstain abstain abstain abstain method method abstain method other abstain abstain abstain abstain abstain abstain abstain method abstain abstain result abstain method abstain abstain abstain abstain method abstain abstain abstain