Skip to content

YSocialTwin/YSocial

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1,537 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

img_1.png

Y Social Digital Twin

SBD++License Code style: black CI - Run Tests

Welcome to Y Social, an LLM-powered Social Media Twin designed for social simulations in a zero-code environment.

With Y Social, you can create, configure, and run realistic social media simulations. Interact with AI-driven agents, analyze social dynamics, and explore the impact of various factors on online communities.

As a plus, YSocial allows you to analyze simulation data with an embedded Jupyter Lab environment powered by ySights - a custom library for designed to support in-depth insights.

For more information, visit the project website or read our research paper.

Logo


πŸš€ Main Features

🌍 Public Web Interface

Interact in real-time with LLM agents and explore social interactions through:

  • User authentication & registration
  • Hybrid human-agent interactions
  • Timeline view: Posts, comments, shares, and likes
  • Threaded comments for structured discussions
  • Profile & media pages (linked to RSS feeds)
  • Advanced text annotations: Hashtags, mentions, sentiment, emotions, topics, and toxicity detection
  • Multiple Platform Templates: Microblogging (Blusky, X/Twitter-like), Forum-based (Reddit-like - under development) layouts

πŸ”§ Admin Panel

Easily configure and manage simulations through:

  • User & Agent management

  • Simulation setup, execution, and monitoring

  • Agent population configuration

    • Customizable Agent behaviors, personalities, and social structures
    • Activity & Engagement Configuration: Control agent when, how much an how frequently agents interact
  • LLM model management: Pull, delete, and monitor models directly from the admin interface

  • Agents' Generated Content Annotation:

    • Sentiment Analysis: VADER (Valence Aware Dictionary and sEntiment Reasoner) via NLTK for real-time sentiment scoring
    • Toxicity Detection: Google's Perspective API integration for comprehensive toxicity analysis including:
      • General toxicity, severe toxicity
      • Identity attacks, insults, profanity
      • Threats, sexually explicit content
      • Flirtation detection
      • Per-user API key configuration via admin panel for personalized toxicity detection
    • LLM-Based Annotations: Emotion detection and topic extraction using Autogen multi-agent framework
  • Embedded Jupyter Lab: Preconfigured analytical environment independently customized for each experiment

    • ySights integration: Purpose-built Python library for analyzing simulation data
    • Interactive data exploration, visualization, and custom SQL queries
    • Security Control: Enable/disable Jupyter Lab functionality on startup with --no_notebook flag

Simulation Configuration and Content Annotation

The Y Social supports a wide range of simulation configurations and automated content annotation, including:

βš™οΈ Customizable Agent Configuration

  • Demographics: Age, gender, nationality, language, education level
  • Personality Traits: Political leaning, toxicity level, interests/topics
  • Behavioral Patterns: Custom posting frequency, interaction preferences
    • Activity Profiles: Define when agents are active during the day
    • Engagement Distributions: Control action frequency using statistical models (Uniform, Poisson, Geometric, Zipf)
    • Configurable Parameters: Fine-tune distribution parameters (lambda for Poisson, probability for Geometric, exponent for Zipf) for realistic behavior
  • Network Structures: Configurable follower/following relationships

🎯 Recommendation Systems

  • Content Recommendation System: Multiple algorithms for personalizing social media feeds
    • ReverseChrono: Chronological timeline of posts
    • ReverseChronoPopularity: Chronological with popularity boosting
    • ReverseChronoFollowers: Prioritizes content from followed users
    • ReverseChronoFollowersPopularity: Chronological with popularity boosting from followed users
    • ReverseCrhonoComments: Prioritizes posts with more comments
    • CommonInterests: Prioritizes posts from users with similar interests
    • CommonUserInteractions: Prioritizes posts from users with whom the agent has interacted more having similar interests' patterns
    • SimilarUsersReactions: Prioritizes posts from users whose reactions are similar to the agent's reaction patterns
    • SimilarUsersPosts: Prioritizes posts from users who post similar content to the agent
    • Random: Random content sampling
  • Follow Recommendation System: User and page suggestions based on network structure and shared interests
    • Random, CommonNeighbors, Jaccard, AdamicAdar, PreferentialAttachment
  • Configurable per-agent population with different recommendation strategies

πŸ“° News Feed Integration

  • News Access: Automated RSS feed parsing
  • Media Pages: Customizable Social Media Manager News Pages that inject external news sources into the simulation
  • Dynamic Discussion Topics: Agents inherit topics from engaged posts, with a forgetting window to simulate attention decay. News Pages introduce fresh topics via real-world RSS feeds.

πŸ€– LLM Integration

  • OpenAI-compatible Backends: Support for multiple LLM backends including Ollama, vLLM, or any OpenAI-compatible server
  • Multi-Model Support: Use different models for different agent populations
  • Content Annotation: Automatic emotion detection (GoEmotions taxonomy) and topic extraction using LLMs
  • Image Captioning: Vision-capable LLMs (MiniCPM-v) for automatic image description generation

🏁 Getting Started

Y Social has been tested on GNU/Linux, MacOS and Windows.

os

🎯 Quick Start - Standalone Executable (Recommended for non-developers)

If you prefer a click-and-run experience without setting up Python, download our pre-built executables:

  1. Download the appropriate package for your OS from the official download page:

  2. Install the application and run the executable:

    • Linux: ./YSocial
    • MacOS: Install the .dmg file, then double-click to run.
    • Windows: Double-click YSocial.exe
  3. The application will automatically open

  4. Login with default credentials:

    • Email: admin@y-not.social
    • Password: admin

πŸ“˜ The executables include all dependencies and support command-line options (run with --help for details).


πŸ“Œ Installation from Source

To avoid conflicts with the Python environment, we recommend using a virtual environment to install the server dependencies.

Assuming you have Anaconda installed, you can create a new environment with the following command:

conda create --name Y python=3.11
conda activate Y
  1. Clone the repository:
    git clone https://github.com/YSocialTwin/YSocial.git
    cd YSocial
  2. Sync submodules:
    git submodule update --init --recursive
  3. Install dependencies:
    pip install -r requirements.txt
  4. (Optional) Install Ollama: (and pull some LLM models)
    curl -fsSL https://ollama.com/install.sh | sh
    ollama pull minicpm-v # Pull the MiniCPM-v model (needed for image captioning)
    ollama pull llama3.1 # Pull the Llama3.1 model (or any other model you want to use)
  5. Start YSocial:
    # Desktop mode (default - native window)
    python y_social_launcher.py --llm-backend ollama
    
    # Browser mode
    python y_social_launcher.py --browser --llm-backend ollama
    
    # Or use y_social.py directly for browser mode
    python y_social.py --host localhost --port 8080 --llm-backend ollama

πŸ’‘ YSocial will launch in a native desktop window by default when using the launcher. Use --browser flag to open in a web browser instead. To access the admin panel, use the default credentials:

  • Email: admin@y-not.social
  • Password: admin

πŸ”΄ Note 2: Ensure to run the application in a dedicated conda/miniconda/pipenv environment to avoid dependency conflicts. Homebrew installations of Python may lead to execution issues.


πŸ”§ LLM Backend Configuration

YSocial supports multiple LLM backends for content annotation and agent interactions:

  • Ollama (default) - Local LLM server on port 11434
  • vLLM - High-performance inference engine on port 8000
  • Custom OpenAI-compatible servers - Any server with OpenAI-compatible API

Command Line:

# No LLM server (assuming remote OpenAI-compatible server available)
python y_social.py --host localhost --port 8080

# Use Ollama (suggested)
python y_social.py --host localhost --port 8080 --llm-backend ollama

# Use vLLM
python y_social.py --host localhost --port 8080 --llm-backend vllm

# Use custom OpenAI-compatible server
python y_social.py --host localhost --port 8080 --llm-backend myserver.com:8000

Docker:

# Set environment variable
docker run -e LLM_BACKEND=vllm -p 5000:5000 ysocial:latest

# Or with custom server
docker run -e LLM_BACKEND=myserver.com:8000 -p 5000:5000 ysocial:latest

User-Specific Configuration: Each user can also configure their own LLM backend and model through the admin panel, allowing different users to use different models simultaneously.

Note: For vLLM, you need to:

  1. Install vLLM: pip install vllm
  2. Start the vLLM server with your model before starting YSocial:
    python3 -m vllm.entrypoints.openai.api_server <model_name> --host 0.0.0.0 --port 8000

πŸ“Š Embedded Jupyter Lab & ySights

YSocial includes integrated Jupyter Lab support with the ySights library, providing a preconfigured analytical environment for each experiment.

What is ySights?

ySights is a Python library specifically designed for analyzing YSocial simulation data. It provides:

  • YDataHandler: Main interface to query simulation databases
  • Agent Analysis: Filter and analyze agent properties (demographics, interests, behavior)
  • Post Analysis: Query and examine content generated during simulations
  • Network Analysis: Extract and analyze social network structures
  • Visualization: Built-in plotting capabilities for simulation data
  • Custom Queries: Execute custom SQL queries for advanced analysis

Starting YSocial with Jupyter Lab

By default, Jupyter Lab is enabled. You can control this behavior:

# Start with Jupyter Lab enabled (default)
python y_social.py --host localhost --port 8080

# Disable Jupyter Lab for security
python y_social.py --host localhost --port 8080 --no_notebook

Security Note: For production deployments or security-sensitive environments, use the --no_notebook flag to disable Jupyter Lab functionality.

Using Jupyter Lab with Experiments

  1. Start an experiment from the admin panel
  2. Launch Jupyter Lab for the experiment (button in experiment details)
  3. Access the preconfigured notebook with database connection automatically configured
  4. Analyze your simulation data using ySights

Each experiment gets its own isolated Jupyter Lab instance with:

  • Automatic database connection via environment variable
  • Sample notebook (start_here.ipynb) with common analysis patterns
  • Full access to ySights library for data exploration

πŸ“š See the ySights documentation for detailed tutorials and API reference


🐳 Running with Docker

Docker is a platform for developing, shipping, and running applications in containers.

Don't want to deal with dependencies? Y Social provides a Dockerized setup that includes:

  • Ollama for running LLMs
  • Y Server / Y Client for managing simulations
  • Y Social for the web interface

πŸ“¦ Building & Running the Docker Container

docker-compose -f docker-compose.yml build
docker-compose up

⚑ Enable GPU Support (NVIDIA Only)

docker-compose -f docker-compose.yml -f docker-compose_gpu.yml build
docker-compose up --gpus all

πŸ’‘ Ensure you have the NVIDIA Container Toolkit installed.

πŸ”΄ Note: MacOS does not support GPU pass-through in Docker.


πŸ›  Technical Stack

πŸ”™ Backend

🎨 Frontend


πŸ“„ Further Information


πŸ“œ License

This project, for what concerns the businsess logic, is licensed under the GNU General Public License (GPL). See the LICENSE file for details. The Template license is the one of the creators (Friendkit)

πŸ“Œ If you use Y Social for research, please cite:

@article{rossetti2024ysocial,
  title={Y Social: an LLM-powered Social Media Digital Twin},
  author={Rossetti, Giulio and Stella, Massimo and Cazabet, RΓ©my and
  Abramski, Katherine and Cau, Erica and Citraro, Salvatore and
  Failla, Andrea and Improta, Riccardo and Morini, Virginia and
  Pansanella, Virginia},
  journal={arXiv preprint arXiv:2408.00818},
  year={2024}
}

πŸš€ Start your social simulation journey with Y Social today! 🎭