Skip to content

AI-powered social media simulation framework using LLMs for modeling Twitter dynamics during crisis events. Built for SBP-BRiMS 2024 Twitter Challenge.

Notifications You must be signed in to change notification settings

Bourn23/twitter_event_simulator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Twitter Event Simulator

A sophisticated social media simulation framework designed to model large-scale Twitter events and social dynamics using AI-driven agents and network analysis.

Overview

This project simulates Twitter-like social media interactions during significant events, specifically modeling environmental protests and social movements. The simulator uses Large Language Models (LLMs) to generate realistic user behaviors, tweets, and social dynamics within a complex network environment.

Key Features

  • AI-Powered Character Generation: Creates realistic Twitter users with distinct personalities, backgrounds, and communication styles
  • Dynamic Social Network Modeling: Builds and analyzes complex social networks with different user types and influence patterns
  • Event-Driven Simulation: Models real-time social media dynamics during significant events (e.g., environmental protests)
  • Multi-Agent System: Supports different user types (core influencers, basic users, organizations) with varying behaviors
  • Sentiment Analysis: Tracks and models sentiment propagation through the network
  • Realistic Content Generation: Produces contextually appropriate tweets, retweets, replies, and interactions

Competition Background

This project was developed for the SBP-BRiMS 2024 Twitter Challenge, where participants were tasked with modeling social media dynamics during significant events. Unlike other challenges that provided pre-built tools or frameworks, the 2024 Twitter Challenge required participants to develop their solutions entirely from scratch.

Challenge Requirements

  • Model realistic Twitter-like social media interactions
  • Simulate large-scale social dynamics during crisis events
  • Demonstrate information propagation and influence patterns
  • Create authentic user behaviors and content generation

Our Innovation

Since no existing tools or frameworks were provided for the challenge, we developed a comprehensive end-to-end solution including:

  1. Custom Tweet Scraper: Built proprietary data collection tools to gather real Twitter data for training and validation
  2. AI-Powered Character Generator: Developed LLM-based systems to create realistic user profiles with authentic personalities and backgrounds
  3. Dynamic Network Constructor: Engineered algorithms to build realistic social network topologies based on interaction patterns
  4. Advanced World Simulator: Created a sophisticated simulation engine with temporal dynamics and multi-agent behaviors

This project represents a complete, novel framework for social media simulation, built specifically to address the unique requirements of modeling environmental protests and crisis communication dynamics.

Architecture

The simulation framework consists of several key components:

1. Character Generation Pipeline

  • Character Creator (00_character_generator.py): Generates diverse user profiles using LLMs
  • JSON Parser (01_character_txt_to_json.py): Converts generated content to structured data
  • Verification System (02_character_verify_parsing.py): Ensures data quality and completeness
  • ID Management (03_fix_ids.py): Resolves duplicate identifiers and maintains consistency

2. Network Construction

  • Tweet Distribution (a_tweet_distribution.py): Models realistic posting patterns and engagement rates
  • Social Graph Generation (b_social_graph_from_tweets.py): Creates network topology based on interaction patterns
  • Network Analysis (c_social_network_analysis.py): Analyzes network properties and identifies key influencers

3. World Simulation Engine

  • Core Simulator (d_world_simulator.py): Main simulation engine with temporal dynamics
  • Behavior Models (behavior_model.py): Models individual user behaviors and decision-making
  • Sentiment Analysis (sentiment_analysis.py): Tracks emotional dynamics across the network

User Types

The simulator models three distinct user categories:

Core Users

  • High-influence accounts with extensive follower networks
  • Generate original content and drive conversations
  • Have detailed personalities and specific expertise areas
  • Powered by advanced LLM decision-making

Basic Users

  • Ordinary users who primarily interact with existing content
  • Engage through likes, retweets, and occasional replies
  • Sentiment influenced by network exposure
  • Simpler behavioral models

Organization Users

  • Official accounts representing institutions, NGOs, and companies
  • Professional communication styles
  • Strategic posting patterns
  • Specific agendas and messaging goals

Scenario: Arctic Climate Crisis Simulation

The current implementation simulates a 2040 environmental crisis scenario:

Setting: Arctic ice caps have melted, leading to increased helicopter tourism over Kong Karls Land, threatening polar bear populations and Arctic ecosystems.

Timeline: May 30 - June 3, 2040

Key Players:

  • Environmental groups ("If Not Now, Then When?", EcoVanguard Solutions)
  • Government officials (Norwegian President, Russian Governor)
  • Helicopter tour company (Heliexpress LTD)
  • Academic experts and activists

Dynamics: Models the buildup to a major environmental protest, including information propagation, sentiment shifts, and coalition building.

Quick Start

Prerequisites

  • Python 3.8+
  • OpenAI API key
  • Required packages: networkx, openai, textblob, python-dotenv

Installation

git clone https://github.com/username/twitter-event-simulator.git
cd twitter-event-simulator
pip install -r requirements.txt

Basic Usage

  1. Generate Characters:
python 00_character_generator.py
python 01_character_txt_to_json.py
python 02_character_verify_parsing.py
python 03_fix_ids.py
  1. Build Social Network:
python a_tweet_distribution.py
python b_social_graph_from_tweets.py
  1. Run Simulation:
python d_world_simulator.py

Configuration

Set your OpenAI API key in a .env file:

OPENAI_API_KEY=your_api_key_here

Adjust simulation parameters in the respective files:

  • User counts and types in a_tweet_distribution.py
  • Network topology in b_social_graph_from_tweets.py
  • Time range and event parameters in d_world_simulator.py

Output and Analysis

The simulator generates:

  • User Profiles: Detailed character descriptions with tweet histories
  • Social Networks: Graph files (.gml format) with network structure
  • Simulation Results: Time-series data of all tweets and interactions
  • Analytics: Network analysis including influence metrics and community detection

Analysis Tools

  • e_analyze_results.py: Post-simulation analysis and visualization
  • learning_rate_visualization.py: Sentiment evolution tracking
  • Network analysis utilities for identifying key influencers and information flow patterns

Research Applications

This simulator is designed for:

  • Social Media Research: Understanding information propagation and influence
  • Crisis Communication: Modeling response to environmental/social crises
  • Behavioral Analysis: Studying collective behavior and sentiment dynamics
  • Policy Research: Evaluating communication strategies and intervention effects
  • AI Safety: Testing large-scale multi-agent systems

Technical Details

LLM Integration

  • Uses GPT-4/GPT-3.5 for character generation and behavioral modeling
  • Context-aware prompt engineering for realistic content generation
  • Sentiment-guided response generation

Network Modeling

  • NetworkX-based graph operations
  • Configurable network topologies (small-world, scale-free, etc.)
  • Dynamic edge weights based on interaction frequency

Temporal Dynamics

  • 15-minute simulation timesteps
  • Event-driven behavioral changes
  • Realistic posting patterns based on time-of-day and user activity cycles

Contributing

Contributions welcome! Areas for improvement:

  • Additional user behavior models
  • Enhanced network dynamics
  • New scenario templates
  • Performance optimizations
  • Visualization tools

License

This project is released under the MIT License. See LICENSE file for details.

Citation

If you use this simulator in your research, please cite:

@software{twitter_event_simulator,
  title = {Twitter Event Simulator: AI-Driven Social Media Dynamics Modeling},
  author = {[Farnod BR, Bagherzadeh AR]},
  year = {2024},
  url = {https://github.com/Bourn23/twitter-event-simulator}
}

Development Notes

LLM Tweet Generation Ideas

Ideas for tweet generation via LLM (it would be interesting to see if it makes a difference whether the user tweet is generated via subjective or objective view by the LLM):

  1. Oracle/social media expert simulation approach
  2. User-perspective simulation approach

TODOs

New TODOs

  • LLM use cases:
    • Create a user personality + tweet history (longer tweets + multimedia information integration)
    • Generate tweet based on personality + tweet history + world event + tweet feed

Completed TODOs

  • Fix user names
  • Connect the world model to LLM for decision-making and tweet generation
  • Use org and core users' extra information (valence, BEND, positions) in simulation
  • Generate organization and core users with BEND values

Acknowledgments

Special thanks to:

About

AI-powered social media simulation framework using LLMs for modeling Twitter dynamics during crisis events. Built for SBP-BRiMS 2024 Twitter Challenge.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •