Social network analysis and content moderation system that detects harmful content, identifies influencers, and analyzes information spread using graph neural networks and natural language processing.
2
stars
3
commits
Python
primary language
Nov 7, 2025
updated
SocialSentinel is a comprehensive, AI-powered platform for analyzing social networks, detecting harmful content, identifying influential users, and tracking information spread using cutting-edge graph neural networks and natural language processing. The system provides researchers and platform moderators with powerful tools to understand network dynamics, mitigate harmful content propagation, and maintain healthy online communities.
In today's interconnected digital landscape, understanding social network dynamics and moderating harmful content has become increasingly critical. SocialSentinel addresses these challenges by integrating state-of-the-art machine learning techniques with robust network analysis methodologies. The platform enables researchers, social media platforms, and community managers to automatically detect harmful content patterns, identify key influencers, analyze community structures, and track information cascades across complex social networks.
The system is designed with scalability and extensibility in mind, supporting multiple social media platforms including Twitter, Reddit, and generic network formats. By combining transformer-based content analysis with graph neural networks for structural analysis, SocialSentinel provides a holistic view of network health and content safety.
SocialSentinel employs a modular, microservices-inspired architecture that separates concerns while maintaining tight integration between components. The system is organized into four primary layers:
┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐
│ Data Sources │────│ Data Processor │────│ Graph Builder │
│ (Twitter, │ │ & Normalizer │ │ & Analyzer │
│ Reddit, etc.)│ │ │ │ │
└─────────────────┘ └──────────────────┘ └─────────────────┘
│ │
▼ ▼
┌──────────────────┐ ┌─────────────────┐
│ Content │ │ Influence │
│ Moderator │ │ Detector │
│ (NLP/Transformers)│ │ (GNN/Graph) │
└──────────────────┘ └─────────────────┘
│ │
▼ ▼
┌──────────────────┐ ┌─────────────────┐
│ Network │ │ ML Models │
│ Dynamics │ │ (GCN, GAT, │
│ Tracker │ │ GraphSAGE) │
└──────────────────┘ └─────────────────┘
│ │
▼ ▼
┌─────────────────────────────────────────┐
│ API & Visualization │
│ (FastAPI, Plotly, Matplotlib) │
└─────────────────────────────────────────┘
SocialSentinel leverages sophisticated mathematical models for network analysis and content understanding. The core algorithms are built upon graph theory, information diffusion models, and modern deep learning architectures.
The GNN models employ message passing and neighborhood aggregation to learn node representations. For a graph $\mathcal{G} = (\mathcal{V}, \mathcal{E})$ with node features $\mathbf{X} \in \mathbb{R}^{|\mathcal{V}| \times d}$, the layer-wise propagation rule is:
$$\mathbf{H}^{(l+1)} = \sigma\left(\mathbf{\hat{D}}^{-1/2}\mathbf{\hat{A}}\mathbf{\hat{D}}^{-1/2}\mathbf{H}^{(l)}\mathbf{W}^{(l)}\right)$$
where $\mathbf{\hat{A}} = \mathbf{A} + \mathbf{I}$ is the adjacency matrix with self-loops, $\mathbf{\hat{D}}$ is the diagonal degree matrix, $\mathbf{W}^{(l)}$ are trainable weights, and $\sigma$ is a non-linear activation function.
The influence detection system uses a multi-faceted approach combining structural centrality measures with content-based signals. The combined influence score for a node $v$ is computed as:
$$I(v) = \alpha \cdot C_{\text{structural}}(v) + \beta \cdot C_{\text{content}}(v) + \gamma \cdot C_{\text{temporal}}(v)$$
where $\alpha + \beta + \gamma = 1$, and each component represents different dimensions of influence:
The platform models information spread using temporal network analysis. The probability of content adoption between users $u$ and $v$ at time $t$ follows:
$$P_{\text{adopt}}(u \rightarrow v, t) = \frac{\text{influence}(u) \cdot \text{susceptibility}(v)}{\text{distance}(u,v)} \cdot e^{-\lambda (t - t_0)}$$
This model accounts for influencer strength, recipient susceptibility, network distance, and temporal decay.
Follow these steps to set up SocialSentinel in your environment. The system requires Python 3.8+ and has been tested on Ubuntu 20.04, Windows 10, and macOS Monterey.
# Clone the repository
git clone https://github.com/mwasifanwar/SocialSentinel.git
cd SocialSentinel
# Create and activate virtual environment
python -m venv socialsentinel_env
source socialsentinel_env/bin/activate # On Windows: socialsentinel_env\Scripts\activate
# Install PyTorch and PyTorch Geometric (platform-specific)
# For CUDA 11.3:
pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu113
pip install torch-scatter torch-sparse torch-cluster torch-spline-conv torch-geometric -f https://data.pyg.org/whl/torch-1.12.0+cu113.html
# For CPU-only:
pip install torch torchvision torchaudio
pip install torch-scatter torch-sparse torch-cluster torch-spline-conv torch-geometric -f https://data.pyg.org/whl/torch-1.12.0+cpu.html
# Install SocialSentinel and dependencies
pip install -r requirements.txt
# Install the package in development mode
pip install -e .
# Download pre-trained models
python -c "
from transformers import AutoTokenizer, AutoModelForSequenceClassification
tokenizer = AutoTokenizer.from_pretrained('cardiffnlp/twitter-roberta-base-offensive')
model = AutoModelForSequenceClassification.from_pretrained('cardiffnlp/twitter-roberta-base-offensive')
print('Content moderation models downloaded successfully')
"
# Set up environment variables
export SOCIAL_SENTINEL_HOST="0.0.0.0"
export SOCIAL_SENTINEL_PORT="8000"
export MODEL_CACHE_DIR="./model_cache"
export DATA_STORAGE_DIR="./data_storage"
# Verify installation
python -c "from src.core.graph_analyzer import GraphAnalyzer; print('SocialSentinel installed successfully')"
SocialSentinel can be used through command-line interface for batch processing or via REST API for real-time analysis and integration.
# Analyze a Twitter network dataset
python main.py --analyze-network data/twitter_network.csv --platform twitter --output results/twitter_analysis --visualize
# Moderate content from a text file
python main.py --moderate-content data/user_posts.txt --output results/moderation_report
# Detect influencers in a Reddit network
python main.py --detect-influence data/reddit_threads.json --platform reddit --output results/influence_ranking
# Generate comprehensive analysis with visualizations
python main.py --analyze-network data/social_network.edges --platform generic --visualize --output results/full_analysis
# Start the API server
python run_api.py
# Or using uvicorn directly for development
uvicorn run_api:create_app --host 0.0.0.0 --port 8000 --reload --workers 4
import requests
import json
# Analyze network structure
network_data = {
"edges": [(1, 2, {"weight": 1.0}), (2, 3, {"weight": 1.0}), (3, 4, {"weight": 1.0})],
"node_features": {1: [1.0, 0.5], 2: [0.8, 0.3], 3: [0.6, 0.7], 4: [0.9, 0.2]}
}
response = requests.post("http://localhost:8000/api/v1/analyze-network",
json=network_data)
print(json.dumps(response.json(), indent=2))
# Moderate content in batch
content_data = {
"texts": [
"This is a great platform for discussion!",
"I hate everyone who disagrees with me",
"Let's work together to build a better community"
],
"language": "en"
}
response = requests.post("http://localhost:8000/api/v1/moderate-content",
json=content_data)
results = response.json()
# Upload and process social media data file
with open('twitter_data.csv', 'rb') as f:
response = requests.post("http://localhost:8000/api/v1/upload-network-data",
files={'file': f},
data={'platform': 'twitter'})
processed_data = response.json()
SocialSentinel provides extensive configuration options through environment variables and configuration files:
SOCIAL_SENTINEL_HOST: API server host address (default: 0.0.0.0)SOCIAL_SENTINEL_PORT: API server port (default: 8000)MODEL_CACHE_DIR: Directory for caching pre-trained models (default: ./model_cache)DATA_STORAGE_DIR: Directory for storing processed data (default: ./data_storage)MAX_FILE_SIZE: Maximum file size for uploads in bytes (default: 100MB)SECURITY_ENABLED: Enable security middleware (default: true)RATE_LIMITING_ENABLED: Enable request rate limiting (default: true)
# Content moderation models
CONTENT_MODERATION_MODELS = {
"offensive": {
"name": "cardiffnlp/twitter-roberta-base-offensive",
"type": "hate_speech",
"max_length": 512
},
"sentiment": {
"name": "cardiffnlp/twitter-roberta-base-sentiment",
"type": "sentiment",
"max_length": 512
}
}
# GNN architecture parameters
GNN_MODELS = {
"GCN": {
"hidden_dim": 128,
"num_layers": 2,
"dropout": 0.3
},
"GAT": {
"hidden_dim": 64,
"num_heads": 8,
"dropout": 0.2
}
}
community_detection.louvain_resolution: Resolution parameter for Louvain community detection (default: 1.0)influence_detection.dbscan_eps: EPS parameter for DBSCAN clustering in influence detection (default: 0.1)network_dynamics.time_window_hours: Time window for temporal network analysis (default: 1 hour)content_moderation.harmful_threshold: Confidence threshold for harmful content classification (default: 0.7)
SocialSentinel/
├── src/ # Main source code package
│ ├── core/ # Core analysis components
│ │ ├── graph_analyzer.py # Network analysis and centrality computation
│ │ ├── content_moderator.py # Harmful content detection and moderation
│ │ ├── influence_detector.py # Influence ranking and community leadership
│ │ └── network_dynamics.py # Temporal analysis and cascade tracking
│ ├── models/ # Machine learning model implementations
│ │ └── gnn_models.py # GNN architectures (GCN, GAT, GraphSAGE)
│ ├── utils/ # Utility functions and helpers
│ │ ├── data_processor.py # Data loading, normalization, and processing
│ │ ├── visualization.py # Network visualization and plotting
│ │ └── metrics_calculator.py # Evaluation metrics and performance tracking
│ └── api/ # API layer and web interface
│ ├── routes.py # REST API endpoint definitions
│ └── middleware.py # Security and rate limiting middleware
├── config/ # Configuration management
│ ├── settings.py # Application settings and environment variables
│ └── model_config.py # Model configurations and hyperparameters
├── tests/ # Comprehensive test suite
│ ├── test_graph_analyzer.py # Graph analysis functionality tests
│ ├── test_content_moderator.py # Content moderation accuracy tests
│ └── test_integration.py # End-to-end integration tests
├── data/ # Sample data and datasets (git-ignored)
├── docs/ # Documentation and usage examples
├── requirements.txt # Python dependencies
├── setup.py # Package installation configuration
├── main.py # Command-line interface entry point
└── run_api.py # API server entry point
SocialSentinel has been extensively evaluated on multiple social network datasets to validate its performance across various metrics and use cases.
The content moderation system achieves state-of-the-art performance in harmful content detection:
The graph analysis components demonstrate robust performance on standard network datasets:
Performance metrics under various load conditions and dataset sizes:
The visualization system produces publication-quality figures and interactive plots:
SocialSentinel builds upon the work of numerous researchers, open-source contributors, and institutions. We extend our gratitude to:
M Wasif Anwar
AI/ML Engineer | Effixly AI
This project is released under the MIT License. We welcome contributions from researchers, developers, and community members to enhance functionality, improve performance, and extend platform support. For questions, issues, or collaboration opportunities, please open an issue on the GitHub repository or contact the development team.
3 commits
Python
100.0%
Social network analysis and content moderation system that detects harmful content, identifies influencers, and analyzes information spread using graph neural networks and natural language processing.
2
stars
3
commits
Python
primary language
Nov 7, 2025
updated
SocialSentinel is a comprehensive, AI-powered platform for analyzing social networks, detecting harmful content, identifying influential users, and tracking information spread using cutting-edge graph neural networks and natural language processing. The system provides researchers and platform moderators with powerful tools to understand network dynamics, mitigate harmful content propagation, and maintain healthy online communities.
In today's interconnected digital landscape, understanding social network dynamics and moderating harmful content has become increasingly critical. SocialSentinel addresses these challenges by integrating state-of-the-art machine learning techniques with robust network analysis methodologies. The platform enables researchers, social media platforms, and community managers to automatically detect harmful content patterns, identify key influencers, analyze community structures, and track information cascades across complex social networks.
The system is designed with scalability and extensibility in mind, supporting multiple social media platforms including Twitter, Reddit, and generic network formats. By combining transformer-based content analysis with graph neural networks for structural analysis, SocialSentinel provides a holistic view of network health and content safety.
SocialSentinel employs a modular, microservices-inspired architecture that separates concerns while maintaining tight integration between components. The system is organized into four primary layers:
┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐
│ Data Sources │────│ Data Processor │────│ Graph Builder │
│ (Twitter, │ │ & Normalizer │ │ & Analyzer │
│ Reddit, etc.)│ │ │ │ │
└─────────────────┘ └──────────────────┘ └─────────────────┘
│ │
▼ ▼
┌──────────────────┐ ┌─────────────────┐
│ Content │ │ Influence │
│ Moderator │ │ Detector │
│ (NLP/Transformers)│ │ (GNN/Graph) │
└──────────────────┘ └─────────────────┘
│ │
▼ ▼
┌──────────────────┐ ┌─────────────────┐
│ Network │ │ ML Models │
│ Dynamics │ │ (GCN, GAT, │
│ Tracker │ │ GraphSAGE) │
└──────────────────┘ └─────────────────┘
│ │
▼ ▼
┌─────────────────────────────────────────┐
│ API & Visualization │
│ (FastAPI, Plotly, Matplotlib) │
└─────────────────────────────────────────┘
SocialSentinel leverages sophisticated mathematical models for network analysis and content understanding. The core algorithms are built upon graph theory, information diffusion models, and modern deep learning architectures.
The GNN models employ message passing and neighborhood aggregation to learn node representations. For a graph $\mathcal{G} = (\mathcal{V}, \mathcal{E})$ with node features $\mathbf{X} \in \mathbb{R}^{|\mathcal{V}| \times d}$, the layer-wise propagation rule is:
$$\mathbf{H}^{(l+1)} = \sigma\left(\mathbf{\hat{D}}^{-1/2}\mathbf{\hat{A}}\mathbf{\hat{D}}^{-1/2}\mathbf{H}^{(l)}\mathbf{W}^{(l)}\right)$$
where $\mathbf{\hat{A}} = \mathbf{A} + \mathbf{I}$ is the adjacency matrix with self-loops, $\mathbf{\hat{D}}$ is the diagonal degree matrix, $\mathbf{W}^{(l)}$ are trainable weights, and $\sigma$ is a non-linear activation function.
The influence detection system uses a multi-faceted approach combining structural centrality measures with content-based signals. The combined influence score for a node $v$ is computed as:
$$I(v) = \alpha \cdot C_{\text{structural}}(v) + \beta \cdot C_{\text{content}}(v) + \gamma \cdot C_{\text{temporal}}(v)$$
where $\alpha + \beta + \gamma = 1$, and each component represents different dimensions of influence:
The platform models information spread using temporal network analysis. The probability of content adoption between users $u$ and $v$ at time $t$ follows:
$$P_{\text{adopt}}(u \rightarrow v, t) = \frac{\text{influence}(u) \cdot \text{susceptibility}(v)}{\text{distance}(u,v)} \cdot e^{-\lambda (t - t_0)}$$
This model accounts for influencer strength, recipient susceptibility, network distance, and temporal decay.
Follow these steps to set up SocialSentinel in your environment. The system requires Python 3.8+ and has been tested on Ubuntu 20.04, Windows 10, and macOS Monterey.
# Clone the repository
git clone https://github.com/mwasifanwar/SocialSentinel.git
cd SocialSentinel
# Create and activate virtual environment
python -m venv socialsentinel_env
source socialsentinel_env/bin/activate # On Windows: socialsentinel_env\Scripts\activate
# Install PyTorch and PyTorch Geometric (platform-specific)
# For CUDA 11.3:
pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu113
pip install torch-scatter torch-sparse torch-cluster torch-spline-conv torch-geometric -f https://data.pyg.org/whl/torch-1.12.0+cu113.html
# For CPU-only:
pip install torch torchvision torchaudio
pip install torch-scatter torch-sparse torch-cluster torch-spline-conv torch-geometric -f https://data.pyg.org/whl/torch-1.12.0+cpu.html
# Install SocialSentinel and dependencies
pip install -r requirements.txt
# Install the package in development mode
pip install -e .
# Download pre-trained models
python -c "
from transformers import AutoTokenizer, AutoModelForSequenceClassification
tokenizer = AutoTokenizer.from_pretrained('cardiffnlp/twitter-roberta-base-offensive')
model = AutoModelForSequenceClassification.from_pretrained('cardiffnlp/twitter-roberta-base-offensive')
print('Content moderation models downloaded successfully')
"
# Set up environment variables
export SOCIAL_SENTINEL_HOST="0.0.0.0"
export SOCIAL_SENTINEL_PORT="8000"
export MODEL_CACHE_DIR="./model_cache"
export DATA_STORAGE_DIR="./data_storage"
# Verify installation
python -c "from src.core.graph_analyzer import GraphAnalyzer; print('SocialSentinel installed successfully')"
SocialSentinel can be used through command-line interface for batch processing or via REST API for real-time analysis and integration.
# Analyze a Twitter network dataset
python main.py --analyze-network data/twitter_network.csv --platform twitter --output results/twitter_analysis --visualize
# Moderate content from a text file
python main.py --moderate-content data/user_posts.txt --output results/moderation_report
# Detect influencers in a Reddit network
python main.py --detect-influence data/reddit_threads.json --platform reddit --output results/influence_ranking
# Generate comprehensive analysis with visualizations
python main.py --analyze-network data/social_network.edges --platform generic --visualize --output results/full_analysis
# Start the API server
python run_api.py
# Or using uvicorn directly for development
uvicorn run_api:create_app --host 0.0.0.0 --port 8000 --reload --workers 4
import requests
import json
# Analyze network structure
network_data = {
"edges": [(1, 2, {"weight": 1.0}), (2, 3, {"weight": 1.0}), (3, 4, {"weight": 1.0})],
"node_features": {1: [1.0, 0.5], 2: [0.8, 0.3], 3: [0.6, 0.7], 4: [0.9, 0.2]}
}
response = requests.post("http://localhost:8000/api/v1/analyze-network",
json=network_data)
print(json.dumps(response.json(), indent=2))
# Moderate content in batch
content_data = {
"texts": [
"This is a great platform for discussion!",
"I hate everyone who disagrees with me",
"Let's work together to build a better community"
],
"language": "en"
}
response = requests.post("http://localhost:8000/api/v1/moderate-content",
json=content_data)
results = response.json()
# Upload and process social media data file
with open('twitter_data.csv', 'rb') as f:
response = requests.post("http://localhost:8000/api/v1/upload-network-data",
files={'file': f},
data={'platform': 'twitter'})
processed_data = response.json()
SocialSentinel provides extensive configuration options through environment variables and configuration files:
SOCIAL_SENTINEL_HOST: API server host address (default: 0.0.0.0)SOCIAL_SENTINEL_PORT: API server port (default: 8000)MODEL_CACHE_DIR: Directory for caching pre-trained models (default: ./model_cache)DATA_STORAGE_DIR: Directory for storing processed data (default: ./data_storage)MAX_FILE_SIZE: Maximum file size for uploads in bytes (default: 100MB)SECURITY_ENABLED: Enable security middleware (default: true)RATE_LIMITING_ENABLED: Enable request rate limiting (default: true)
# Content moderation models
CONTENT_MODERATION_MODELS = {
"offensive": {
"name": "cardiffnlp/twitter-roberta-base-offensive",
"type": "hate_speech",
"max_length": 512
},
"sentiment": {
"name": "cardiffnlp/twitter-roberta-base-sentiment",
"type": "sentiment",
"max_length": 512
}
}
# GNN architecture parameters
GNN_MODELS = {
"GCN": {
"hidden_dim": 128,
"num_layers": 2,
"dropout": 0.3
},
"GAT": {
"hidden_dim": 64,
"num_heads": 8,
"dropout": 0.2
}
}
community_detection.louvain_resolution: Resolution parameter for Louvain community detection (default: 1.0)influence_detection.dbscan_eps: EPS parameter for DBSCAN clustering in influence detection (default: 0.1)network_dynamics.time_window_hours: Time window for temporal network analysis (default: 1 hour)content_moderation.harmful_threshold: Confidence threshold for harmful content classification (default: 0.7)
SocialSentinel/
├── src/ # Main source code package
│ ├── core/ # Core analysis components
│ │ ├── graph_analyzer.py # Network analysis and centrality computation
│ │ ├── content_moderator.py # Harmful content detection and moderation
│ │ ├── influence_detector.py # Influence ranking and community leadership
│ │ └── network_dynamics.py # Temporal analysis and cascade tracking
│ ├── models/ # Machine learning model implementations
│ │ └── gnn_models.py # GNN architectures (GCN, GAT, GraphSAGE)
│ ├── utils/ # Utility functions and helpers
│ │ ├── data_processor.py # Data loading, normalization, and processing
│ │ ├── visualization.py # Network visualization and plotting
│ │ └── metrics_calculator.py # Evaluation metrics and performance tracking
│ └── api/ # API layer and web interface
│ ├── routes.py # REST API endpoint definitions
│ └── middleware.py # Security and rate limiting middleware
├── config/ # Configuration management
│ ├── settings.py # Application settings and environment variables
│ └── model_config.py # Model configurations and hyperparameters
├── tests/ # Comprehensive test suite
│ ├── test_graph_analyzer.py # Graph analysis functionality tests
│ ├── test_content_moderator.py # Content moderation accuracy tests
│ └── test_integration.py # End-to-end integration tests
├── data/ # Sample data and datasets (git-ignored)
├── docs/ # Documentation and usage examples
├── requirements.txt # Python dependencies
├── setup.py # Package installation configuration
├── main.py # Command-line interface entry point
└── run_api.py # API server entry point
SocialSentinel has been extensively evaluated on multiple social network datasets to validate its performance across various metrics and use cases.
The content moderation system achieves state-of-the-art performance in harmful content detection:
The graph analysis components demonstrate robust performance on standard network datasets:
Performance metrics under various load conditions and dataset sizes:
The visualization system produces publication-quality figures and interactive plots:
SocialSentinel builds upon the work of numerous researchers, open-source contributors, and institutions. We extend our gratitude to:
M Wasif Anwar
AI/ML Engineer | Effixly AI
This project is released under the MIT License. We welcome contributions from researchers, developers, and community members to enhance functionality, improve performance, and extend platform support. For questions, issues, or collaboration opportunities, please open an issue on the GitHub repository or contact the development team.
3 commits
Python
100.0%