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.
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
- 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 git
The - To create a virtual environment: In the terminal, type
conda create --name LLMGraph python=3.9
and then activateconda activate LLMGraph
The
- Install Python 3.9 (recommended version). In the terminal, type
- Download GraphAgent
- Enter it in the terminal:
git clone https://github.com/Ji-Cather/GraphAgent.git
The - Go to the project catalog:
cd GraphAgent
The
- Enter it in the terminal:
- Installation of dependencies
- Install the AgentScope library:
- importation
git clone https://github.com/modelscope/agentscope/
The - Access to the catalog
cd agentscope
and then rungit reset --hard 1c993f9
Locked version. - Installation:
pip install -e . [distribute]
The
- importation
- Install project dependencies: run in the GraphAgent directory
pip install -r requirements.txt
The
- Install the AgentScope library:
- 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-70B
The - 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.
- show (a ticket)
- Running Projects
- In the terminal, type
export PYTHONPATH=. /
Setting environment variables. - Select the model tip template, e.g.
export MODEL=gpt
(with GPT template).
- In the terminal, type
Data preparation
- Download sample data:
- importation
git clone https://oauth2:RxG7vLWFP_NbDhmB9kXG@www.modelscope.cn/datasets/cather111/GAG_data.git
The - The data includes samples of tweets, movie ratings, and essay citations.
- importation
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
- Tweets Network:
- Generating graphs from user input::
- Example:
python main.py --user_input "I want to simulate author-paper interactions and generate highly clustered citation networks" --build
The
- Example:
- 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.py
The - Movie Network:
python evaluate/movie/main.py
The - Citing the Web:
python evaluate/article/main.py
The
- Social Networking:
- 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
- Social Media Analytics
Modeling user interactions and generating attention networks to help research impact propagation. - E-commerce recommendation study
Optimizing recommender system design through user-item interaction graphs. - Academic Citation Network
Generate citation maps of papers and analyze research trends and scholarly relationships. - A sociological experiment
Using simulated data to study human behavioral patterns and explore the laws of network evolution.
QA
- 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. - Do I have to pay for it?
The framework is free, but calling large models may require an API fee (e.g. OpenAI). - Is Chinese data available?
Yes, both Chinese and English are supported as long as they are in text format. - What about runtime errors?
Check the Python version, dependency installation, and API configuration, or ask for help at GitHub Issues.