SuperAPI AI Directory

Agent4Rec

Agent4Rec is a recommender system simulator implemented based on the paper "On Generative Agents in Recommendation" (SIGIR 2024 perspective). It contains 1,000 LLM-powered generative agents initialized from the MovieLens-1M dataset, with diverse social characteristics and preferences. Each agent interacts with personalized movie recommendations in a page-by-page manner and performs actions such as watching, rating, reviewing, exiting, and being interviewed. The simulator aims to explore the potential of LLM-empowered generative agents to simulate realistic, independent human behavior in recommendation environments, and supports multiple recommender systems (such as Random, Pop, MF, MultVAE, LightGCN) and different simulation configurations.

Open website

About this tool

Agent4Rec is the implementation of the paper "On Generative Agents in Recommendation" (SIGIR 2024 perspective), a recommender system simulator with 1,000 LLM-empowered generative agents. These agents are initialized from the MovieLens-1M dataset and embody different social characteristics and preferences. Each agent interacts with personalized movie recommendations in a page-by-page manner and performs various actions such as watching, rating, reviewing, exiting, and being interviewed. Through Agent4Rec, one can explore the potential of LLM-empowered generative agents to simulate realistic, independent human behavior in recommendation environments.

Main capabilities:

  • Supports simulation of 1,000 generative agents.
  • Agents are initialized from the MovieLens-1M dataset and have diverse social characteristics and preferences.
  • Each agent interacts with personalized movie recommendations page by page and performs actions such as watching, rating, reviewing, exiting, and being interviewed.
  • Supports multiple recommender systems: Random (randomly recommend items), Pop (randomly recommend popular items), MF (pre-trained matrix factorization model with BPR loss), MultVAE (pre-trained MultVAE model), LightGCN (pre-trained LightGCN model with BPR loss).
  • Supports different simulation configurations, such as the number of agents, items per page, maximum number of browsing pages, parallel mode, etc.

Usage:

  1. Prepare the environment:
    • Install requirements.txt. It is recommended to set up a virtual environment and manually install PyTorch. The experiments were tested with Python 3.9.12 and PyTorch 1.13.1+cu117. Python versions higher than 3.10 may cause bugs in the 'reckit' package.
    • Install the necessary environment: enter the recommenders/ directory (which contains setup.py) and run the relevant code to install the tools required to accelerate recommendation evaluation.
  2. Run the simulation:
    • Make sure you are in the main directory (which contains main.py), export the OpenAI API key: export OPENAI_API_KEY=<Your OpenAI API key>, and replace <Your OpenAI API key> with your own OpenAI API key.
    • Run the following command to start a toy simulation containing 3 agents. The agents' responses to recommended items will be printed in the terminal and it will finish in about 3 minutes.
    • Supports multiple recommender systems and configurations: for example, run a simulation named MyExp, with 10 agents, each agent browsing at most 5 pages, 4 items per page, using MF as the recommender, and accelerating the experiment in parallel mode. You can choose the recommender by modifying --modeltype <model_name>.
  3. View the results:
    • The simulation results are saved in the storage/ml-1m/<model_name>/<experiment_name> directory. For example, the results of the above command are saved in the storage/ml-1m/MyExp directory. All interaction history of agent 0 is recorded in storage/ml-1m/MF/MyExp/running_logs/0.txt.

Simulation cost: All experiments are driven by ChatGPT-3.5. The cost of a complete simulation involving 1,000 users is about $16 ($0.016 per user).