AI Personal Learning
and practical guidance
CyberKnife Drawing Mirror

GAG: Generating a Social Relationship Graph Using a Large Model to Simulate Human Behavior

General Introduction

GraphAgent is an open source framework hosted on GitHub and developed by Ji-Cather. It uses the Large Language Model (LLM) to simulate human behavior and generate dynamic, social graphs with textual attributes. This tool is suitable for scenarios such as online social media, e-commerce, and essay creation, helping users to deeply analyze interactions in the web. It not only generates graph structures that match real-world characteristics, but also verifies the accuracy of the simulation by comparing it to real graphs.GraphAgent's code is free and open, and can be downloaded, modified, and used for research in sociology, network science, and more.

GAG: Generating a Social Relationship Graph Using a Large Model to Simulate Human Behavior-1


 

Function List

  • Human Behavior Simulation: Generate social relationship graphs by simulating real human interactions with large models.
  • Dynamic Social Graph Generation: Create dynamic diagrams with text attributes based on input data or user prompts.
  • Graph Structure Verification: Compare generated plots with real plots to assess the accuracy of macro and micro features.
  • Large Scale Graph Extension: Support for generating very large graphs containing 100,000 nodes or 10 million edges.
  • Open Source Adjustment: Full code is provided and users can customize the features according to their needs.

 

Using Help

GraphAgent is an open source tool based on GitHub and requires some technical foundation to install and use. Below is a detailed installation and operation guide to ensure that you can get started quickly.

Installation process

  1. Preparing the environment
    • Install Python 3.9 (recommended version). In the terminal, type python --version Check the version.
    • Install Git. For Windows users, download it from the official website, and for Mac users, download it with the brew install gitThe
    • To create a virtual environment: In the terminal, type conda create --name LLMGraph python=3.9and then activate conda activate LLMGraphThe
  2. Download GraphAgent
    • Enter it in the terminal:git clone https://github.com/Ji-Cather/GraphAgent.gitThe
    • Go to the project catalog:cd GraphAgentThe
  3. Installation of dependencies
    • Install the AgentScope library:
      • importation git clone https://github.com/modelscope/agentscope/The
      • Access to the catalog cd agentscopeand then run git reset --hard 1c993f9 Locked version.
      • Installation:pip install -e . [distribute]The
    • Install project dependencies: run in the GraphAgent directory pip install -r requirements.txtThe
  4. Configuring API Keys
    • show (a ticket) LLMGraph/llms/default_model_configs.json Documentation.
    • Add your model API key, such as OpenAI's gpt-3.5-turbo-0125 maybe VLLM (used form a nominal expression) llama3-70BThe
    • Example Configuration:
      {
      
      "config_name": "gpt-3.5-turbo-0125", "model_name": "gpt-3.5-turbo-0125", "model_type": "openai_chat",
      
      "api_key": "sk-your key",
      "generate_args": {"max_tokens": 2000, "temperature": 0.8}
      }
      
    • After saving the file, make sure the key is valid.
  5. Running Projects
    • In the terminal, type export PYTHONPATH=. / Setting environment variables.
    • Select the model tip template, e.g. export MODEL=gpt(with GPT template).

Data preparation

  • Download sample data:
    • importation git clone https://oauth2:RxG7vLWFP_NbDhmB9kXG@www.modelscope.cn/datasets/cather111/GAG_data.gitThe
    • The data includes samples of tweets, movie ratings, and essay citations.

Main Functions

1. Human behavior simulation and social graph generation

  • Generating graphs from data::
    • Tweets Network:python main.py --task tweets --config "small" --build --launcher_save_path "LLMGraph/llms/launcher_info_none.json"The
    • Movie Ratings Network:python main.py --task movielens --config "small" --build --launcher_save_path "LLMGraph/llms/launcher_info_none.json"The
    • Essay Citation Network:python main.py --task citeseer --config "small" --build --launcher_save_path "LLMGraph/llms/launcher_info_none.json"The
  • Generating graphs from user input::
    • Example:python main.py --user_input "I want to simulate author-paper interactions and generate highly clustered citation networks" --buildThe
  • output result: The generated file is under a specified path and can be viewed with a visualization tool such as Gephi.

2. Parallel accelerated operations

  • Starting Parallel Services: Run in a terminal python start_launchers.py --launcher_save_path "LLMGraph/llms/launcher_info.json"The
  • operate: In another terminal, run python main.py --task tweets --config "small" --build --launcher_save_path "LLMGraph/llms/launcher_info.json"The
  • dominance: 90.41 TP3T speedup for large-scale graph generation.

3. Figure structure validation

  • Run the evaluation script::
    • Social Networking:python evaluate/social/main.pyThe
    • Movie Network:python evaluate/movie/main.pyThe
    • Citing the Web:python evaluate/article/main.pyThe
  • Analysis of results: Generate reports showing macroscopic features (e.g., power-law distributions) and microstructures (lifting 11%) of the graph.

operating skill

  • debug mode: Running with a single port (e.g. --launcher_save_path "LLMGraph/llms/launcher_info_none.json") to facilitate troubleshooting.
  • Customized Functions: Modification main.py or configuration files to adjust model parameters or graph generation rules.
  • View Help: Run python main.py --help Get command details.

caveat

  • Ensure that the API key is valid, otherwise the program will not be able to call the big model.
  • Large-scale graph generation requires a high-performance computer with at least 16GB of RAM recommended.
  • The project is continuously updated, check GitHub regularly for the latest version.

 

application scenario

  1. Social Media Analytics
    Modeling user interactions and generating attention networks to help research impact propagation.
  2. E-commerce recommendation study
    Optimizing recommender system design through user-item interaction graphs.
  3. Academic Citation Network
    Generate citation maps of papers and analyze research trends and scholarly relationships.
  4. A sociological experiment
    Using simulated data to study human behavioral patterns and explore the laws of network evolution.

 

QA

  1. How big a graph can GraphAgent generate?
    Supports large-scale graphs with 100,000 nodes or 10 million edges, which are fast and can be accelerated in parallel.
  2. Do I have to pay for it?
    The framework is free, but calling large models may require an API fee (e.g. OpenAI).
  3. Is Chinese data available?
    Yes, both Chinese and English are supported as long as they are in text format.
  4. What about runtime errors?
    Check the Python version, dependency installation, and API configuration, or ask for help at GitHub Issues.
May not be reproduced without permission:Chief AI Sharing Circle " GAG: Generating a Social Relationship Graph Using a Large Model to Simulate Human Behavior

Chief AI Sharing Circle

Chief AI Sharing Circle specializes in AI learning, providing comprehensive AI learning content, AI tools and hands-on guidance. Our goal is to help users master AI technology and explore the unlimited potential of AI together through high-quality content and practical experience sharing. Whether you are an AI beginner or a senior expert, this is the ideal place for you to gain knowledge, improve your skills and realize innovation.

Contact Us
en_USEnglish