A sophisticated social media simulation framework designed to model large-scale Twitter events and social dynamics using AI-driven agents and network analysis.
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.
- 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
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.
- 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
Since no existing tools or frameworks were provided for the challenge, we developed a comprehensive end-to-end solution including:
- Custom Tweet Scraper: Built proprietary data collection tools to gather real Twitter data for training and validation
- AI-Powered Character Generator: Developed LLM-based systems to create realistic user profiles with authentic personalities and backgrounds
- Dynamic Network Constructor: Engineered algorithms to build realistic social network topologies based on interaction patterns
- 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.
The simulation framework consists of several key components:
- 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
- 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
- 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
The simulator models three distinct user categories:
- 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
- Ordinary users who primarily interact with existing content
- Engage through likes, retweets, and occasional replies
- Sentiment influenced by network exposure
- Simpler behavioral models
- Official accounts representing institutions, NGOs, and companies
- Professional communication styles
- Strategic posting patterns
- Specific agendas and messaging goals
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.
- Python 3.8+
- OpenAI API key
- Required packages:
networkx
,openai
,textblob
,python-dotenv
git clone https://github.com/username/twitter-event-simulator.git
cd twitter-event-simulator
pip install -r requirements.txt
- 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
- Build Social Network:
python a_tweet_distribution.py
python b_social_graph_from_tweets.py
- Run Simulation:
python d_world_simulator.py
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
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
e_analyze_results.py
: Post-simulation analysis and visualizationlearning_rate_visualization.py
: Sentiment evolution tracking- Network analysis utilities for identifying key influencers and information flow patterns
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
- Uses GPT-4/GPT-3.5 for character generation and behavioral modeling
- Context-aware prompt engineering for realistic content generation
- Sentiment-guided response generation
- NetworkX-based graph operations
- Configurable network topologies (small-world, scale-free, etc.)
- Dynamic edge weights based on interaction frequency
- 15-minute simulation timesteps
- Event-driven behavioral changes
- Realistic posting patterns based on time-of-day and user activity cycles
Contributions welcome! Areas for improvement:
- Additional user behavior models
- Enhanced network dynamics
- New scenario templates
- Performance optimizations
- Visualization tools
This project is released under the MIT License. See LICENSE
file for details.
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}
}
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):
- Oracle/social media expert simulation approach
- User-perspective simulation approach
- 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
- 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
Special thanks to:
- The SBP-BRiMS 2024 organizing committee
- theTejMahal/twitter repository for inspiration