# MaLang: A Decentralized Deep Learning Approach for Detecting Abusive Textual Content
## 3 Materials and Methods
### Architecture of the System-Level Module
#### 3.4.2 Deep Learning Model for the Classification of Abusive Content  
To identify abusive textual content, the Hate-speech dataset of [61] was considered. The dataset contains more than 28,000 sentences that were categorized into Normal, Offensive, and Identity-hate. The dataset was modified into two categories, i.e., abusive and non-abusive content. All the sentences were converted into lowercase and cleaned by removing non-alphabetic characters and the HTML content present in them; 25,000 sentences were used as the training set, and 3000 sentences were used for the testing set.  
All the sentences were tokenized using the NLTK package [62] and were cropped to uniform length. These were converted into an array of words for each sentence called entities. Simultaneously, every word from each entity was one-hot encoded, thus obtaining a matrix representing categorical variables as binary vectors. The vectors act as an input to the embedding layer in the CASE deep learning model.  
Figure 7 shows the architecture of the CASE deep learning model. The system-level deep learning model consists of one embedding layer with an input dimension of 21,000 and an output dimension of 300. The input length sequence is 53. The embedding layer is followed by a Bidirectional LSTM layer with 128 cells and a one-dimensional global Max Pooling layer. These are connected to two sets of a fully connected layer and Dropout layer. Finally, a SoftMax function is used as an output layer to predict the probabilities of either of the classes. The model is used to determine whether the sentences collected contain any abusive content. The usage of Bi-LSTM over a traditional RNN such as LSTM provides a solution to two traditional problems associated with abusive text detection:  
1. When dealing with abusive sentences, many phrases might not contain a foil word; however, the sentence might be abusive or offensive when its meaning is considered. Bi-LSTM was chosen as it accesses past information from past words and the future information in the reverse direction, therefore attempting to understand the context and overall meaning of the sentence.
2. Because CASE is deployed locally on the user's mobile device, it should only use minimum storage space and processing power. The current implementation requires 8 megabytes (MB) of storage space. Although transformers fulfill the purpose of understanding the context, they are known to occupy a huge amount of space and computation resources, which is practically infeasible for this purpose. The transformer type of deep learning used in prior research can use up to 200 MB of storage space.  
The application generates a user identification tag. The tag consists of a randomly generated 5-digit text that consists of both alpha and numeric characters. The tag is unique to only one user. After the entities are classified into abusive and non-abusive, the abusive entities are linked with the user identification tag and sent to the cloud-level module. Similarly, all such entities from multiple devices or users are sent to the cloud-level module along with the tagged user's unique identification number.