Giter Club home page Giter Club logo

agent4rec's Introduction

On Generative Agents in Recommendation

license

world

Agent4Rec, a recommender system simulator with 1,000 LLM-empowered generative agents. These agents are initialized from the MovieLens-1M dataset, embodying varied social traits and preferences. Each agent interacts with personalized movie recommendations in a page-by-page manner and undertakes various actions such as watching, rating, evaluating, exiting, and interviewing. With Agent4Rec, we would like to explore the potential of LLM-empowered generative agents in simulating the behavior of genuine, independent humans in recommendation environments.

📋 Catalogue

⚙️ Preparations

Step 1. Install requirements.txt

Set up a virtualenv and install the pytorch manually. After that, install all the dependencies listed in the requirements.txt file by running the following command:

pip install -r requirements.txt

Our experiments have been tested on Python 3.9.12 with PyTorch 1.13.1+cu117. Python version over 3.10 may lead to some bugs in the package 'reckit'.

Step 2. Set up necessary environments

Make sure you are in the directory of recommenders/ (where setup.py can be found), and run the following code.

python setup.py build_ext --inplace

The command will install necessary tools for accelerating recommender evaluation.

⌛️ Simulation

Make sure you are in the main directory (where main.py can be found).

Export your OpenAI API key first:

export OPENAI_API_KEY=<Your OpenAI API key>

Replace <Your OpenAI API key> with your own OpenAI API key.

Quick Start

By running the following command, you will start a toy simulation with 3 agents.

python main.py

The response of agents to recommended items will be printed in the terminal. This simulation will take around 3 minutes to finish.

Explore Various Recommender Settings

Agent4Rec supports various recommendation systems and different simulation configurations.

python main.py --simulation_name MyExp --modeltype MF --n_avatars 10 --max_pages 5 --items_per_page 4 --execution_mode parallel

By running this code, you will start a simulation named MyExp with 10 agents, each agent will browse max to 5 pages with 4 items on a single page. The recommender used in this example is Matrix Factorization (short for MF). And the experiment will be executed in parallel model to speed up the simulation.

You can choose the employed recommender by modifying --modeltype <model_name> in the command. You can replace <model_name> with the following supported recommenders:

  • Random: Randomly recommend items to users.
  • Pop: Randomly recommend popular items to users.
  • MF: Pretrained Matrix Factorization model with BPR loss.
  • MultVAE: Pretrained MultVAE model.
  • LightGCN: Pretrained LightGCN model with BPR loss.

See the Results

The results of the simulation will be saved in storage/ml-1m/<model_name>/<experiment_name> directory. As for the command in Section Explore Various Recommender Settings, the results will be saved in storage/ml-1m/MyExp directory. All the interaction history of agent 0 is documented in storage/ml-1m/MF/MyExp/running_logs/0.txt

💰 Simulation Cost

🛎️ Note that all the experiments are powered by ChatGPT-3.5, and a complete simulation involving 1000 users would cost approximately $16. ($0.016/User)

agent4rec's People

Contributors

chenyuxin1999 avatar lehengthu avatar leolee99 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

agent4rec's Issues

About figure 13 in the paper

Sorry for the interruption. According to $S_{act}^u$ provided in appendix C.2. It seems that since $\hat y_{i}\in {0, 1}$, $S_{act}^u$ should be an integer. However, in Figure 13 (b), some agents corresponds to a non-integral $S_{act}^u$ (see the red lines in the picture, the lines may not be precise but sufficient to show the problem). Could you please provide some explanation on it?

Screenshot 2024-05-09 at 14 05 21

真人交互

如果我想要实现真人和游戏里的NPC进行交流应该怎么做呢

使用的reckit版本可能比较旧了,在 Python 3.10中,'Iterable`类型已经从`collections`模块中移除,而应该从'collections.abc`模块中导入。

省流:

建议自行修改 "myvenv/lib/python3.10/site-packages/reckit/util/decorators.py"

删除
from collections import Iterable

增加
from collections.abc import Iterable

别的没了,整体代码都比较清楚,一目了然,就不多赘述了。
以及如果有时间的话,建议把reckit直接换掉,因为reckit从202006开始到202011,然后就没有再维护过了,以后还可以出现更多的问题(当然,发完paper以后没什么时间维护,当我没说(手动狗头

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.