V4ieecon2025 Bert
V4ieecon2025 Bert
Abstract— The increasing volume of user-generated content As governments, organizations, and law enforcement agencies
on global online platforms has made it very crucial to detect and intensify efforts to combat online threats, effective, scalable
moderate harmful content like criminal activities, illegal content moderation systems are critical. In 2023, U.S.
substances, extremist codewords, and other prohibited authorities removed over 9,000 accounts linked to extremism
materials across multiple languages. In this study, we present an and criminal activity from social media platforms while the
intelligent system for detecting flagged content using advanced European Union identified more than 17,000 instances of
transformer-based models such as BERT, RoBERTa, XLNet, illegal content across various online platforms [1] [2]. This
and T5. These models have been further trained to very
underscores the urgency of tackling criminal and extremist
accurately and effectively detect from illegal activities to
activities that increasingly rely on digital spaces for
extreme language and drug related content. Our method
surpasses previous methods of content moderation achieving
recruitment, propaganda, and illicit trade. This paper
great improvements in classification accuracy, precision, recall introduces an advanced flagged content detection system
and F1-score. Furthermore, the implemented system enables based on transformer models, such as BERT, RoBERTa,
offline or online real-time process and therefore large-scale XLNet, and T5. These models are capable of detecting a wide
throughput. It also gives a detailed overview of the architectural range of harmful content, including criminal activities,
designs of the model, training processes and other problems extremist language, illegal substances and terrorist
faced during the model development stage. The results illustrate propaganda. The proposed system leverages the deep
the power of transformer-based models in offering a robust contextual understanding of transformers, enabling real-time,
strategy for automated detection of flagged content across high-precision content identification across multiple
languages to help in cultivating better online safety. This languages. It can be deployed in fast-paced, dynamic
research also contributes to SDG 16 by enhancing online environments, offering a robust solution for content
security and SDG 10 by promoting fairer digital spaces. The moderation. Law enforcement agencies and global security
study concludes with a discussion on potential applications in organizations play a key role in combating illegal and
social media moderation, law enforcement, and global security extremist content. As these agencies increasingly turn to
agencies and future research aimed at improving detection automated systems, the need for accurate and multilingual
capabilities. detection tools has become more pressing. This system aims
to support these efforts by providing a scalable, efficient, and
Keywords—— flagged content detection, transformer models,
BERT, content moderation, extremist words, multilingual
real-time solution for detecting flagged content worldwide.
detection, illegal activities, real-time processing The paper outlines the system’s architecture, model training,
and evaluation, highlighting how transformer-based models
I. INTRODUCTION can contribute to securing digital spaces and supporting SDG
16 for peace, justice, and strong institutions, as well as SDG
In recent years, the rapid growth of the internet and digital
10 for reduced inequalities by promoting inclusive and fair
platforms has significantly improved communication,
online environments.
connectivity and information sharing. However, this
expansion has facilitated the spread of harmful, illegal and II. LITERATURE REVIEW
extremist content across the web. From organized crime
syndicates and drug trafficking to extremist groups and The vast scale and complexity of online content generation
terrorist activities, flagged content poses severe risks to have made moderating harmful material increasingly difficult.
individual safety and global security. Over 60% of the global Traditional content moderation systems, relying on keyword
population is now online with more than 4.7 billion social filtering and rule-based approaches, often fail to capture the
media users contributing to an immense volume of user- nuanced and context-dependent nature of harmful content,
generated content that is challenging to monitor and regulate such as extremist language, illegal activities and
particularly in multilingual environments. misinformation. As a result, researchers have increasingly
i. BERT (Bidirectional Encoder Representations from TABLE 1: HYPERPARAMETERS FOR TRANSFORMER MODELS USED IN
Transformers) was chosen because of its ability to FLAGGED CONTENT DETECTION
understand context from both directions (left-to-right and Hyperparameter BERT RoBERTa XLNet T5
right-to-left) which is crucial for analyzing content with
subtle meanings or hidden intents. This bidirectional Learning Rate 2e-5 2e-5 3e-5 1e-4
nature allows BERT to understand the entire context of a
Batch Size 16 32 32 16
sentence making it highly effective for detecting
extremist language and illegal activities, where context Epochs 3 3 4 3
plays a vital role. Optimizer AdamW AdamW AdamW AdamW
ii. RoBERTa (A Robustly Optimized BERT Pretraining
Approach) was selected for its enhanced pretraining Weight Decay 0.01 0.01 0.01 0.1
techniques that improve the model’s performance by Max Sequence 256 256 512 512
dynamically masking words and using larger training Length
datasets. RoBERTa’s improved efficiency in processing
Warm-up Steps 500 500 500 1000
large-scale text makes it well-suited for handling the vast
amount of user-generated content across diverse Gradient 1 2 2 2
platforms offering superior generalization capabilities Accumulation
and high accuracy in detecting flagged content. Dropout Rate 0.2 0.2 0.2 0.3
iii. XLNet builds on BERT's architecture by incorporating
permutation-based training which allows it to better
capture complex dependencies in text. XLNet was chosen These hyperparameters were selected to maximize the
because of its ability to model long-range interactions models' ability to generalize across a wide range of flagged
between words, improving the detection of nuanced and content scenarios. The learning rate ensures that the models
subtle references to extremist codewords and illegal converge at an optimal pace while the batch size supports
activities that might be missed by other models. effective parallelization of training. The number of epochs
was set to a value that prevents overfitting while allowing
iv. T5 (Text-to-Text Transfer Transformer) was selected due sufficient training for each model. The AdamW optimizer
to it’s versatility in handling a wide variety of natural commonly used for transformer models, It was chosen for its
language processing tasks. T5 converts every task into a stability and effectiveness in handling large datasets.
text-to-text format, making it extremely flexible and Furthermore, the weight decay and dropout rates were
adaptable for various forms of flagged content detection, adjusted to regularize the models and prevent overfitting,
crucial for maintaining performance when deployed in high- content, surpassing the other models in terms of overall
volume and dynamic environments. The max sequence length performance. Specifically for the non-flagged class, T5
was adjusted based on the average length of content typically achieved a precision of 0.98 and recall of 0.99, while for the
encountered, while warm-up steps and gradient accumulation flagged class, its precision and recall were both 0.99 and 0.98,
were tuned to enhance the training process and improve model respectively. These results underscore T5’s ability to correctly
convergence without excessive computational costs. The identify flagged content with minimal false positives and false
combination of these hyperparameters and transformer negatives making it highly suitable for real-time content
architectures ensures the system’s ability to detect flagged moderation systems.
content with high precision while providing the flexibility and
scalability required for deployment in multilingual and real-
time content moderation systems across a range of online
platforms.
E. Model Evaluation
The performance of the proposed flagged content
detection system was evaluated using several key metrics,
including accuracy, precision, recall, F1-score and area under
the curve (AUC). To assess the classification performance,
confusion matrices were generated to show the distribution of
true positives (TP), false positives (FP), true negatives (TN),
and false negatives (FN) for each model. This allowed for a
clear understanding of the model's ability to correctly identify
harmful or flagged content and avoid misclassifications.
Additionally, the receiver operating characteristic (ROC)
curve was used to evaluate the trade-off between the true
positive rate (TPR) and false positive rate (FPR) while the Figure 2. Confusion Matrix For BERT
AUC provided a quantitative measure of the model's ability to
distinguish between flagged and non-flagged content. The The confusion matrices for each model (shown in Figures
evaluation process ensured that all models were rigorously 2, 4, 5, and 6) corroborate these findings. For example, T5
tested for their ability to handle flagged content detection correctly identified 1055 true negatives and 1139 true
effectively in a multilingual and diverse context. These positives, misclassifying only 9 non-flagged and 23 flagged
evaluation metrics offer a comprehensive analysis of the instances. The low number of misclassifications (false
models' overall performance in detecting extremist, criminal, positives and false negatives) highlights T5’s strong
and illegal content as well as their robustness across various classification performance as per Figure 6. While BERT
languages and contexts. exhibited the lowest overall performance with an accuracy of
0.97, it still demonstrated robust detection capabilities.
IV. RESULTS AND DISCUSSION Specifically, BERT showed slightly lower recall for both non-
In this study, we evaluated the performance of four flagged (0.97) and flagged (0.97) content compared to other
transformer-based models—BERT, RoBERTa, XLNet, and models. The confusion matrix for BERT (Figure 2) revealed
T5 on the task of detecting flagged content related to that it misclassified 37 non-flagged instances as flagged and
extremism, crime and illegal activities. The models were 26 flagged instances as non-flagged. Despite these
assessed using standard evaluation metrics: Precision, Recall, misclassifications, BERT’s performance remains sufficient
F1-Score, and Accuracy. These metrics are summarized in for many practical applications.
Table 2, while the training performance metrics, including
loss, runtime, and processing speed, are shown in Table 3.
TABLE 2: PRECISION, RECALL, F1-SCORE, AND ACCURACY FOR ALL
MODELS
Model Class Precision Recall F1- Accurac
Score y
Non- 0.98 0.97 0.97
BERT Flagged 0.97
Flagged 0.97 0.98 0.97
Non- 0.98 0.99 0.98
RoBERTa Flagged 0.98
Flagged 0.99 0.98 0.98
Non- 0.97 0.99 0.98
XLNet Flagged 0.98
Flagged 0.99 0.97 0.98
Non- 0.98 0.99 0.99
T5 Flagged 0.99 Figure 3. ROC Curve with AUC For BERT, RoBERTa, XLNet,
Flagged 0.99 0.98 0.99 T5
RoBERTa achieved an accuracy of 0.98 and showed a
slight advantage in recall for non-flagged content (0.99). It
All models performed exceptionally well, demonstrating their exhibited balanced performance across both flagged and non-
efficacy in identifying flagged content while minimizing flagged classes with precision values of 0.99 for flagged
misclassifications. Among the models, T5 achieved the content and 0.98 for non-flagged content. As depicted in
highest accuracy (99%) for both flagged and non-flagged Figure 4, the confusion matrix for RoBERTa reveals that it
misclassified only 9 non-flagged instances as flagged and 27 values of approximately 0.98, indicating that they are also
flagged instances as non-flagged. highly capable of making these distinctions.
The training performance metrics including loss, runtime,
samples per second, and steps per second, are summarized in
Table 3. RoBERTa exhibited the lowest training loss (0.0890)
and achieved the fastest processing speed, processing 159.17
samples per second, making it the most efficient model in
terms of training. T5, despite having a slightly higher loss
(0.0873), demonstrated strong processing capabilities,
processing 150.78 samples per second while achieving the
highest accuracy. XLNet and BERT processed fewer samples
per second (132.88 and 128.50, respectively) with BERT
having the highest loss (0.1718), but both models still
demonstrated solid performance in content detection.
TABLE 3: MODEL TRAINING PERFORMANCE INCLUDING LOSS, RUNTIME, Smuggling cocaine is a serious crime and Flagged
AND PROCESSING SPEED
punishable by law.
XLNet
The sports team is training for the upcoming Non-
Model Loss Runtime Samples Steps Epoch championship. Flagged
(seconds) per per
Second Second The terrorist group was funding their Flagged
BERT 0.1718 8.19 128.50 16.42 3 activities with drug sales.
RoBERTa 0.0890 13.99 159.17 19.95 3 The new technology will help reduce carbon Non-
XLNet 0.0995 8.72 132.88 17.47 3 T5 emissions. Flagged
T5 0.0873 15.68 150.78 18.63 3
Kegiatan penyeludupan dadah boleh Flagged
memberi kesan kepada keselamatan negara.
To assess the discriminatory power of each model, we (Translation: "Drug smuggling activities
evaluated the Receiver Operating Characteristic (ROC) curve can affect national security.")
and Area Under the Curve (AUC) scores. As shown in Figure
3, all models demonstrated strong discriminatory power with
AUC values close to 1. T5 achieved the highest AUC score of The results of this evaluation demonstrate that all four models
0.99, reflecting its superior ability to distinguish flagged (BERT, RoBERTa, XLNet, and T5) are highly effective at
content from non-flagged content across different thresholds. detecting harmful, extremist, and criminal content. T5
RoBERTa, XLNet and BERT followed closely with AUC outperformed the others in terms of overall accuracy and AUC
scores, making it the most suitable model for real-time flagged and MobileBERT) will be explored to achieve better
content detection. RoBERTa and XLNet also showed scalability without sacrificing performance. Furthermore, it's
excellent performance offering highly accurate and efficient adapting the system to detect and mitigate emerging threats,
solutions for content moderation tasks. BERT, while slightly including misinformation, deepfakes, and evolving coded
lower in performance still provided reliable results and could language. It is essential for maintaining its relevance and
be considered for deployment in certain applications where efficacy. By focusing on these areas, the system's efficiency,
slightly lower accuracy is acceptable. The low false positive fairness and usability will be significantly enhanced. It ensures
and false negative rates combined with high AUC values, the adaptability and impact in dynamic online environments
suggest that these models can be confidently deployed in
while contributing to safer and more equitable digital spaces
production environments. Their ability to handle diverse
globally.
languages and contexts makes them suitable for global content
moderation and law enforcement applications. Furthermore, ACKNOWLEDGMENT
the results highlight the importance of scalable, real-time
content detection systems that can be effectively deployed
across online platforms to enhance digital safety. Future work I sincerely thank Dr. Thawseak Yingthawornsuk for his
should focus on fine-tuning these models for new forms of guidance and support, as well as King Mongkut’s University
harmful content, such as misinformation and hate speech, as of Technology Thonburi and AMET University for providing
well as expanding their capabilities to handle more complex valuable resources and a supportive research environment.
and multilingual datasets. The models could also be integrated
into real-time law enforcement and security. The table 4 REFERENCES
presents a set of samples classified by different transformer
models (BERT, RoBERTa, XLNet, T5). It highlights flagged [1] Europol. (2023). EU Internet organised crime threat assessment
content involving illegal drugs (methamphetamine, fentanyl, (IOCTA) 2023. [Link]
cocaine, heroin) and non-flagged content such as educational services/main-reports/internet-organised-crime-threat-assessment-
and technological discussions. The models accurately iocta
differentiate harmful content, demonstrating their [2] Statista. (2023). Number of social media users worldwide from 2010
effectiveness in real-world moderation tasks. to 2023 (in billions).
[Link]
social-network-users
V. CONCLUSION
[3] Whittaker, M. (2019). AI and the ethics of decision making: A study
This study demonstrates the effectiveness of transformer- on bias in machine learning. The AI Ethics Journal.
based models—BERT, RoBERTa, XLNet, and T5 in [4] Devlin, J., Chang, M. W., Lee, K., & Toutanova, K. (2018). BERT:
detecting flagged content related to extremism, crime, and Pre-training of deep bidirectional transformers for language
illegal activities. Among the models, T5 achieved the highest understanding. Proceedings of NAACL-HLT 2019 (pp. 4171–4186).
performance, outperforming the others in accuracy, precision, [5] Conneau, A., Kruszewski, G., Lample, G., Barrault, L., & Lecun, Y.
recall, and AUC scores making it the most suitable choice for (2020). Unsupervised cross-lingual representation learning.
Proceedings of the 58th Annual Meeting of the Association for
real-time content moderation. While RoBERTa and XLNet Computational Linguistics (ACL 2020).
provided efficient and highly accurate solutions, BERT, [6] Vaswani, A., Shazeer, N., Parmar, N., Uszkoreit, J., Jones, L., Gomez,
despite being slightly less accurate, still showed robust A. A., Kaiser, Ł., & Polosukhin, I. (2021). Attention is all you need.
performance. The low false positive and false negative rates Proceedings of the 31st Conference on Neural Information Processing
across all models along with high AUC values, suggest their Systems (NeurIPS 2021).
viability for deployment in real-world content detection [7] Pires, T., Schlinger, E., & Almeida, D. (2019). Multilingual BERT for
systems. These models’ ability to operate effectively in translation and content detection. Proceedings of the 2019 Conference
on Empirical Methods in Natural Language Processing (EMNLP
diverse contexts and languages highlights their potential in 2019).
global security and law enforcement applications. Future work [8] Chakraborty, A., Roy, P., & Singh, A. (2021). Hybrid deep learning
could focus on fine-tuning these models for emerging harmful models for detecting terrorist content on social media platforms.
content types and expanding their capabilities for multilingual International Journal of Information Security, 20(2), 173–189.
datasets, further enhancing their utility in online content [9] Zhao, S., Wang, X., & Zhang, C. (2022). Illicit content detection in
moderation. social media using transformer-based models. Proceedings of the 2022
IEEE International Conference on Big Data (BigData 2022), 1575–
VI. FUTURE DIRECTIONS 1584.
[10] Bhardwaj, P., Sahu, A., & Gupta, A. (2022). Reducing false positives
This study provides a strong foundation for scalable flagged in content moderation with transformer-based models. Proceedings of
content detection with significant potential for expansion to the 30th International Conference on Computational Linguistics
support low-resource and linguistically diverse languages. It (COLING 2022).
enhances its global applicability, and it also addresses cultural [11] Alatawi, S., Alshahrani, M., & Alshahrani, A. (2022). Extremism
detection using deep learning and natural language processing. IEEE
and linguistic biases, which remain crucial to ensuring fairness Access, 10, 15205-15217.
and inclusivity across varied user groups. Incorporating [12] Howard, J., & Ruder, S. (2018). Universal language model fine-tuning
explainable AI techniques such as SHAP, LIME, or attention for text classification. arXiv preprint arXiv:1801.06
visualization will provide greater transparency, improve [13] Yang, Z., et al. (2019). XLNet: Generalized Autoregressive Pretraining
interpretability, and build trust among stakeholders. To for Language Understanding. Advances in Neural Information
optimize the system for real-time, high-traffic scenarios, Processing Systems, 32.
advanced techniques such as model quantization, pruning and [14] Al-Garawi, H., Abed, A., & Dhiab, A. (2018). A machine learning
approach to detect extremist texts. Journal of Cybersecurity.
the adoption of lightweight transformers (e.g., DistilBERT