Enhanced Bot Detection on Social Media Platforms Using RoBERTa and Multimodal Features

Okikiola D. Mojoyinola

Abstract

This paper presents an enhanced approach to bot detection on social media platforms, specifically focusing on Twitter data. We propose a system that leverages the roberta-large language model as the foundation for classification, integrating textual data with numerical and boolean user profile features. Our approach combines these multimodal inputs to create a robust detection system that can adapt to evolving bot behaviours. The system architecture emphasizes modularity, configurability via a central config.py, and a comprehensive supervised training and evaluation pipeline. This paper details the system's data processing, model architecture, training strategy, and evaluation capabilities, aiming to provide a clear blueprint for building effective bot detection tools.

Keywords:

Bot Detection, RoBERTa, Transformer Models, Multimodal Learning, Social Media, Natural Language Processing, Deep Learning

1. Introduction

The proliferation of automated accounts (bots) on social media platforms presents significant challenges for platform integrity, information quality, and user experience. Bots can be used for various purposes, from benign automation to malicious activities such as spreading misinformation, manipulating public opinion, and artificially inflating engagement metrics. Detecting these automated accounts is crucial for maintaining the health of online discourse and ensuring the authenticity of social media interactions.

The increasing sophistication of online bots, particularly with the emergence of powerful Large Language Models (LLMs), presents a significant challenge. These advanced bots can generate remarkably human-like text and engage in complex interactions, making their detection more critical and difficult than ever. Incidents such as the undisclosed deployment of AI bots in online forums to influence user opinions [Yang, see references] highlight the urgency of this problem. Therefore, a primary aim of this project is to develop a robust detection mechanism capable of combating such issues. By leveraging the nuanced language understanding capabilities of advanced transformer models like RoBERTa, combined with insightful behavioral features, this work seeks to contribute to more reliable and adaptive bot detection systems that can evolve alongside the ever-improving capabilities of automated entities.

Traditional bot detection approaches have relied on rule-based systems or classical machine learning models using handcrafted features. While these methods have shown some success, they often struggle to adapt to the evolving nature of bot behavior and can be easily circumvented by sophisticated bots. More recent approaches have leveraged deep learning techniques, utilizing the power of models like transformers to understand complex patterns in data.

In this paper, we present a comprehensive bot detection system built upon these advancements. The core of our system is:

  1. roberta-large based classification: We leverage the powerful language understanding capabilities of roberta-large, a variant of BERT, to extract rich semantic representations from tweet text, enabling more accurate detection of bot-generated content.
  2. Multimodal Feature Integration: We combine the textual embeddings from roberta-large with numerical (e.g., follower counts, account age) and boolean (e.g., verified status) features extracted from user profiles to provide a more holistic view for classification.

Our system is designed to be a robust, multi-faceted approach to bot detection that can be deployed and adapted for real-world environments.

2. Related Work

Bot detection on social media has been an active area of research for over a decade. Early approaches focused on rule-based systems and manual feature engineering, while more recent work has increasingly leveraged machine learning and deep learning techniques.

2.1 Feature-Based Approaches

Numerous studies have explored the use of various features for bot detection. These features can be broadly categorized into:

For instance, Varol et al. (2017) developed the BotOrNot (later renamed Botometer) system, which uses over 1,000 features across these categories to classify Twitter accounts. Similarly, Yang et al. (2020) proposed a system that combines user, content, and temporal features for improved detection accuracy.

2.2 Deep Learning Approaches

More recent work has explored the use of deep learning techniques for bot detection. Kudugunta and Ferrara (2018) proposed an LSTM-based approach that combines text and metadata features. Wei and Nguyen (2019) developed a CNN-based model for detecting social bots based on tweet content. Feng et al. (2021) explored the use of transformer-based models for bot detection, showing promising results compared to traditional approaches. Our work aligns with this trajectory, specifically focusing on the roberta-large architecture and its integration with other feature types.

3. Methodology

Our bot detection system consists of several key components: data processing, feature handling, and model architecture. This section describes each component in detail, reflecting the implementation in the bot_detection_project codebase.

3.1 Data Processing (src/data_loader.py)

The system processes labeled Twitter data, used for supervised training. The TwitterDataProcessor class handles preprocessing:

3.2 Feature Handling

Our system leverages multimodal features:

3.3 Model Architecture (src/models/bert_model.py)

The core of our system is the BERTBotDetector model:

  1. Base Model: A roberta-large model (specified by MODEL_NAME in src/config.py) is loaded. To leverage its strong pre-trained knowledge while adapting to the specific task, a partial freezing strategy is employed by default: the RoBERTa embeddings and the initial 20 out of 24 encoder layers are frozen. The top 4 encoder layers and the model's pooler layer remain trainable, allowing for task-specific fine-tuning. The FREEZE_BERT_LAYERS configuration in config.py can be used to adjust this behavior for other BERT-based models if needed, though the RoBERTa default is handled directly in the trainer.
  2. Input: The model takes tokenized text (input_ids, attention_mask), processed numerical features, and processed boolean features.
  3. Text Representation: The [CLS] token output from roberta-large serves as the primary text embedding.
  4. Feature Integration and Classification Head:
    • The text embedding is concatenated with the numerical and boolean feature vectors.
    • This combined vector passes through:
      • torch.nn.LayerNorm for normalization.
      • A fully connected layer (torch.nn.Linear) to a hidden dimension (HIDDEN_SIZE, default 128).
      • torch.nn.ReLU activation.
      • torch.nn.Dropout (DROPOUT_RATE, default 0.3).
      • A final torch.nn.Linear layer to 2 output units (for bot/non-bot logits).

The model is trained using torch.nn.CrossEntropyLoss, with optional class weighting (USE_CLASS_WEIGHTS) to handle class imbalance.

4. Implementation (pipeline.py, src/trainer.py)

4.1 System Components

Our bot detection system is implemented as a modular Python project:

4.2 Training Pipeline

The training pipeline executed by pipeline.py consists of:

  1. Configuration Loading: Parameters are loaded from src/config.py.
  2. Data Loading and Preprocessing: Utilizes TwitterDataProcessor and BotDataset.
  3. Data Splitting: Divides data into train, validation, and test sets.
  4. Model Initialization: Creates and initializes the BERTBotDetector model.
  5. Optimizer and Scheduler Setup: Configures AdamW optimizer with differential learning rates (BERT_LR for RoBERTa layers, LEARNING_RATE for the head) and a learning rate scheduler (get_linear_schedule_with_warmup or ReduceLROnPlateau).
  6. Supervised Training: The ModelTrainer executes the training loop, including gradient accumulation (GRAD_ACCUMULATION_STEPS) and gradient clipping (GRAD_CLIP).
  7. Validation and Early Stopping: Monitors validation loss per epoch and saves the best model. Early stopping (EARLY_STOPPING_PATIENCE) prevents overfitting.
  8. Model Evaluation: After training, the best model is evaluated on the test set using ModelEvaluator.

4.3 Key Hyperparameters (Defaults from src/config.py)

These hyperparameters can be adjusted in src/config.py.

5. Evaluation (src/evaluator.py)

5.1 Evaluation Metrics

The system's performance is evaluated using standard classification metrics, calculated by the ModelEvaluator:

A classification report and confusion matrix are also generated.

Initial evaluation of a model checkpoint from epoch 10 (out of 20 planned training epochs) on sample data yielded the following metrics:

While these early results indicated potential, comprehensive training and more extensive evaluation were unfortunately limited by available computational resources, specifically the constraints of the Google Colab free tier.

6. Limitations and Future Work

While the model demonstrates promising capabilities, its performance and generalizability are subject to certain limitations, primarily related to the dataset:

Future work will prioritize acquiring and incorporating more diverse and extensive datasets. Additionally, we plan to explore more advanced feature engineering and investigate adaptive learning techniques to counteract the evolving nature of bots and improve the model's long-term efficacy.

7. Conclusion

In this paper, we presented a bot detection system that leverages the roberta-large transformer model integrated with multimodal (text, numerical, boolean) user features. The system employs a supervised learning paradigm with a robust training and evaluation pipeline, emphasizing configurability and modularity. By combining advanced NLP capabilities with user profile characteristics, the approach aims to provide effective and adaptable detection of automated accounts on social media platforms.

While the system demonstrates a strong foundational methodology, ongoing research and development are necessary to address challenges such as evolving bot tactics and computational demands. The described framework serves as a solid starting point for further enhancements and practical applications in mitigating the impact of malicious bots.

8. References

  1. Devlin, J., Chang, M. W., Lee, K., & Toutanova, K. (2018). BERT: Pre-training of deep bidirectional transformers for language understanding. arXiv preprint arXiv:1810.04805.
  2. Liu, Y., Ott, M., Goyal, N., Du, J., Joshi, M., Chen, D., ... & Stoyanov, V. (2019). RoBERTa: A Robustly Optimized BERT Pretraining Approach. arXiv preprint arXiv:1907.11692.
  3. Varol, O., Ferrara, E., Davis, C. A., Menczer, F., & Flammini, A. (2017). Online human-bot interactions: Detection, estimation, and characterization. In Proceedings of the International AAAI Conference on Web and Social Media (Vol. 11, No. 1).
  4. Kudugunta, S., & Ferrara, E. (2018). Deep neural networks for bot detection. Information Sciences, 467, 312-322.
  5. Wei, F., & Nguyen, U. T. (2019). Twitter bot detection using bidirectional long short-term memory neural networks and word embeddings. In 2019 IEEE International Conference on Information Reuse and Integration (IRI) (pp. 389-396).
  6. Yang, K. C., Varol, O., Davis, C. A., Ferrara, E., Flammini, A., & Menczer, F. (2020). Arming the public with artificial intelligence to counter social bots. Human Behavior and Emerging Technologies, 1(1), 48-61.
  7. Feng, S., Wan, H., Wang, N., Li, J., & Luo, M. (2021). DeepBot: A transformer-based approach for detecting social bots. In Proceedings of the 2021 Conference on Empirical Methods in Natural Language Processing (pp. 1717-1729).
  8. Yang, A. (2025). Researchers secretly infiltrated a popular Reddit forum with AI bots, causing outrage. NBC News. Retrieved May 15, 2025, from https://www.nbcnews.com/tech/tech-news/reddiit-researchers-ai-bots-rcna203597