YPhotoSharing is a scalable, distributed research toolkit built on Ray and powered by large language models (LLMs). It simulates a fully functional visual social network (like Instagram) where autonomous AI agents post media, leave comments, build follower graphs, and react to content based on predefined personas and psychological drivers.
The simulator bridges the gap between algorithmic recommendation testing and emergent social behaviors by combining Machine Learning Recommender Systems with Multimodal Agentic Interactions.
The current implementation has been aligned with the engineering patterns used by YSimulator while keeping photo-sharing semantics intact:
- photo posts persist their topic associations in
photo_topics - actor logs are written to
logs/<client_id>_actor.logandlogs/<server_name>_actor.log - execution logs are written to
logs/<client_id>_execution.logandlogs/<server_name>_server.log - server request traces are written to
logs/_server.log - client LLM usage traces are written to
logs/<client_id>_llm_usage.log - stress/reward is configured and persisted through the dedicated server table
- client-side round orchestration is split from scheduling helpers
- annotation toggles are documented for emotion, sentiment, and memory
- Algorithmic Recommender Systems: Includes Home Feeds (multi-objective surrogate models) and Explore Feeds (Collaborative Filtering & Content Similarity via
scikit-learn). - Agent Personas: Users are powered by LLMs that exhibit diverse interests and distinct behavioral patterns.
- Advanced Platform Dynamics: Emulates real-world constraints like finite attention budgets, user churn based on satisfaction, and hashtag trend velocity.
- Distributed Architecture: Scales horizontally via Ray, decoupling the global state (
OrchestratorServer) from the agent execution pools (SimulationClient). - Multimodal Content: Agents can generate real images locally via Stable Diffusion and use Vision LLMs to critique and comment on generated content.
- Affective Dynamics: Stress/reward feedback loops track how reactions, comments, shares, and reports affect creators over time.
- Python 3.9+
- Ray (for distributed execution)
- SQLite (for global server state)
Clone the repository and install the base dependencies:
git clone https://github.com/GiulioRossetti/YPhotoSharing.git
cd YPhotoSharing
pip install -r requirements.txtAgents require an LLM to generate captions, decide reactions, and write comments. You can choose between two main backends:
Ollama allows you to run models like llama3.2 locally with ease.
- Install Ollama from their website.
- Pull the required models:
ollama pull llama3.2
ollama pull llama3.2-vision # If using multimodal vision featuresIf you have a CUDA-capable GPU and want to run thousands of agents, vLLM provides massive batched throughput.
- Install vLLM:
pip install vllm- Enable it in your
client_config.json:
"llm": {
"use_vllm": true,
"model": "meta-llama/Llama-3.2-1B-Instruct"
}To allow agents to actually generate .jpg images for their posts, you need to enable local diffusion.
- Install Hugging Face
diffusersandtorch:
pip install "huggingface-hub<0.26.0" "transformers<4.45.0" "diffusers<0.28.0" "accelerate<0.30.0" torch torchvisionNote: The platform automatically supports NVIDIA (CUDA) and Apple Silicon (MPS). The version restrictions prevent known issues with older PyTorch installations.
- Enable it in your
client_config.json:
"simulation": {
"use_local_diffusion": true,
"local_diffusion_model": "segmind/tiny-sd"
}YPhotoSharing requires at least two separate processes: the central Orchestrator Server and one or more Simulation Clients.
-
Configure your experiment: Navigate to the
example/directory. Modifyserver_config.json,client_config.json,agents.json, andprompts_ygram.jsonto define your population size, LLM endpoints, prompt templates, and simulation length. Theagents.jsonfile follows the YSimulator-styleagents/generation_configlayout and accepts the same demographic, personality, opinion, and activity fields, plus photo-sharing extras such asphoto_sharing.cover_image,photo_sharing.story_visibility, andphoto_sharing.creator_tier.story_visibilitysupportspublic,followers, andprivate, whilecreator_tiercan be used to distinguish standard creators from higher-profile accounts such asproorinfluencer; both fields are included in the prompt persona and can bias story/post generation and visibility-related behavior. The prompt persona is then enriched with the full record, so fields likecustom_featuresandphoto_sharing.favorite_filterscan influence generation without needing a separateclusterfield. Lifecycle settings such as churn and new-user injection are controlled fromclient_config.jsonundersimulation.agentsand are disabled by default. Ensure yourclient_config.jsonincludes simulation parameters for features likeopinion_dynamicsanddiscussion_topicsif you wish to use them. The annotation toggles are also exposed here:simulation.enable_sentiment,simulation.enable_emotion_annotation,simulation.enable_toxicity, andsimulation.perspective_api_key. -
Start the Orchestrator Server: This terminal will initialize the SQLite database and spin up the Ray cluster.
cd YPhotoSharing python run_server.py --config example -
Start the Simulation Client: In a new terminal window, start the client to connect to the cluster and launch the agents.
cd YPhotoSharing python run_client.py --config example
(For multi-node setups, you can launch multiple run_client.py instances with distinct client IDs in their config files. The Server will barrier-sync them at the end of every simulated hour).
Execution logs are stored under the experiment directory:
logs/<client_id>_execution.loglogs/<server_name>_server.loglogs/<client_id>_actor.loglogs/<server_name>_actor.loglogs/_server.loglogs/<client_id>_llm_usage.log
These files are created by the Ray actors themselves, are gzip-rotated, and contain structured JSON records with timestamp, level, message, module, function, and line fields where applicable. The request and usage streams are newline-delimited JSON records with simulator-compatible payloads.
If enabled in client_config.json, the client also writes:
logs/<client_id>_actions.loglogs/<client_id>_prompts.log
As the simulation runs, data is persisted to example/yphotosharing.db.
You can use the provided scripts in the /scripts/ folder to export graphs and cascades for external analysis:
# Export the follower network as node/edge CSVs
python scripts/export_network.py --db example/yphotosharing.db --out example/exports/
# Export post cascades and interactions
python scripts/export_content_cascade.py --db example/yphotosharing.db --out example/exports/For deeper technical references, architecture overviews, and preset experimental configurations, please view the MkDocs site:
mkdocs serveThen navigate to http://127.0.0.1:8000 in your browser.
For the alignment analysis and the phased implementation plan, see docs/ysimulator_alignment.md.
For logging details and configuration switches, see docs/logging.md.
For annotation configuration details, see docs/annotations.md.
For recommendation behavior and ranking signals, see docs/recommendations.md.