U ni P arma at S em E val-2021 Task 5: Toxic Spans Detection Using C haracter BERT and Bag-of-Words Model (2021)

Abstract: With the ever-increasing availability of digital information, toxic content is also on the rise. Therefore, the detection of this type of language is of paramount importance. We tackle this problem utilizing a combination of a state-of-the-art pre-trained language model (CharacterBERT) and a traditional bag-of-words technique. Since the content is full of toxic words that have not been written according to their dictionary spelling, attendance to individual characters is crucial. Therefore, we use CharacterBERT to extract features based on the word characters. It consists of a CharacterCNN module that learns character embeddings from the context. These are, then, fed into the well-known BERT architecture. The bag-of-words method, on the other hand, further improves upon that by making sure that some frequently used toxic words get labeled accordingly. With a ∼4 percent difference from the first team, our system ranked 36 th in the competition. The code is available for further research and reproduction of the results.

## introduction the user generated digital content is increasing rapidly every second of the day. this can include some toxic language whose detection can be difficult due to the complexities of human languages. we address this problem by participating in se-meval workshop 2021 task 5 @xcite . in many cases, the data, which are considered to be toxic, contain words that have not been written in their standard forms. there might also be a lot of misspelling or letter replacements. in addition, usually the words that are considered to be the most offensive are bleeped which makes them difficult to be recognized if we use a model which learns the content representation based on the words. apart from word related issues, the context also plays a crucial role in the meaning that a word conveys since words in different contexts can have various meanings. therefore, in order to cope with these issues, we opt for a recently pre-trained language model which has been trained on character level. @xcite ) is a deep neural network model that has been pre-trained on wikipedia and openwebtext (gokaslan and cohen) corpora using the bert architecture @xcite with an addition of a characteraware convolutional neural network (cnn) @xcite . bert-based models have now become pervasive in many different natural language processing tasks such as reading comprehension @xcite , named entity recognition @xcite , sentiment analysis @xcite , and language understanding @xcite as well as similar ones to toxic language detection such as propaganda detection @xcite . while the bert model is beneficial in extracting the contextual information from the text on the word level, the character-aware cnn attends to the individual letters which helps in dealing with out-of-vocabulary, unknown and rare words. in addition to using a deep language model for detecting toxic language, we employ a very simple bag-of-words model that can achieve a close performance to that of the deep model. by building a dictionary of toxic words from the training data and by taking into account their frequency and ratio of toxicity, we come up with a simple model that performs as closely as about 2 percent difference in performance to the deep model's result. moreover, we improve the results of characterbert by combining it with the output of a version of the bag-of-words model. spans text @xcite @xcite @xcite @xcite @xcite @xcite @xcite @xcite @xcite @xcite @xcite @xcite @xcite @xcite @xcite @xcite another violent and aggressive immigrant killing a innocent and intelligent us citizen.... sarcasm [0, 1, 2, 3] damn, a whole family. sad indeed. @xcite @xcite @xcite @xcite @xcite @xcite what a knucklehead. how can anyone not know this would be offensive?? our system consists of four main stages namely, pre-processing, applying characterbert, applying bag-of-words model, and finally combining the results of the two models. we describe each of these stages in the following subsections. ## conclusion we described the system we utilized to detect toxic language. in our approach, we first fine-tune char-acterbert, a character-level pre-trained language model, on the toxic training data. then using a simple bag-of-words model, we further improve the results of this system. the bag-of-words model labels the words based on their frequency and the ratio of toxicity in the training data. we showed that this model, although extremely simple, gives a close performance to that of characterbert with millions of parameters.