LZ 1904 at S em E val-2021 Task 5: B i- LSTM - CRF for Toxic Span Detection using Pretrained Word Embedding (2021)

Abstract: Recurrent Neural Networks (RNN) have been widely used in various Natural Language Processing (NLP) tasks such as text classification, sequence tagging, and machine translation. Long Short Term Memory (LSTM), a special unit of RNN, has the benefit of memorizing past and even future information in a sentence (especially for bidirectional LSTM). In the shared task of detecting spans which make texts toxic, we first apply pretrained word embedding (GloVe) to generate the word vectors after tokenization. And then we construct Bidirectional Long Short Term Memory-Conditional Random Field (Bi-LSTM-CRF) model by Baidu research to predict whether each word in the sentence is toxic or not. We tune hyperparameters of dropout rate, number of LSTM units, embedding size with 10 epochs and choose the best epoch with validation recall. Our model achieves an F1 score of 66.99 percent in test dataset.

## introduction detecting toxic words plays a critical role in social media to ensure healthy online discussions. in previous study, some tasks @xcite only identify offensive language based on the whole sentence or post. most of them do not detect specific spans of words that make the sentence or post offensive. in semeval-2021 task 5: toxic spans detection @xcite , the data was collected from civil comments @xcite . each post is in string format, and a word is marked as toxic span in the form of its characters' offsets in the string. the goal of the task is to classify whether each word in a sentence is toxic or not. if so, the indices of characters in the word should be returned. the task is evaluated by f1 score based on the character offsets among all posts. the challenges of this task include: the models we explore in this task include wordbased conditional random field (crf), wordbased bidirectional long short term memory (bi-lstm) with and without pretrained word embedding, bidirectional lstm-crf with pretrained word embedding. we choose bi-lstm-crf as final submission, since it performs the best during our experiments. the structure of this paper is organized as follows: toxic span detection is a type of sequence labeling tasks and is similar to name entity recognition tasks with only two categories. @xcite surveyed various sequence labeling tasks in terms of methodologies and applications. they also reviewed a few extensions of sequence classification including early classification and semi-supervised learning on sequences. @xcite compared different learning algorithms such as conditional random fields (crf), support vector machine (svm), and perceptron for sequence labeling tasks. @xcite proposed a new type of embedding called contextual string embedding for sequence labeling tasks. a comparison between multiple word embedding methods were conducted by @xcite for sentiment classification and sequence labeling tasks. for name entity recognition (ner), @xcite presented a machine learning based approach called fuzzy support vector machine. recent advanced deep learning models were summarized by @xcite in various shared tasks. currently, models that are widely used in various nlp tasks include crf, lstm, rnn, and transformers. also, word embedding such as word2vec @xcite , glove @xcite ## experiment results we split proportion of training and validation dataset into 9:1. the evaluation results on validation set are summarized in based on the model evaluation table, we choose bi-lstm-crf with pretrained glove-twitter-100 embedding as our final model. the model achieves an f1 score of 0.6699 in final submission. the confusion matrix for test data can be found in ## conclusion detecting toxic words in texts is critical to furnish a healthy environment on social media. sequence labeling task for finding specific offensive words is more difficult than sentiment classification on sentence level, since it requires models to locate the positions or indices of words in sentences. in addition, the task also places restrictions on feature engineering, because we cannot delete or add words in sentences. our experiment shows pretrained word embedding can improve model performance compared with randomized embedding weights. this verifies the concept of transfer learning where we can borrow the outputs from other resources and use them as inputs to achieve specific goals. another finding is the benefit of model stacking where we add an extra layer of crf after bi-lstm that further enhances predictability. in such case, when a single model does not work well in nlp tasks, combining different models with pretrained word embedding can be a good option to explore. however, there are still a lot of false positive examples in test set where the model predicts toxic words that in fact are not toxic.