Code for the paper Where Would I Go Next? Large Language Models as Human Mobility Predictors.
The code is provided for reproducing the main results presented in the paper. However, the results may not be 100 per cent same as presented in the paper, due to the randomness of LLMs and the frequent update of OpenAI's GPT models. That being said, we anticipate that the difference is minimal.
The data is hosted in /data
. As mentioned in our paper, we strictly follow the same data preprocessing steps in Context-aware multi-head self-attentional neural network model for next location prediction. All the data files are generated from the data preprocessing scripts available here.
If you already have an account and have set up API keys, skip this step. Otherwise, go to OpenAI API website and sign up. Once you have an account, create an API key here. You may also need to set up your payment here in order to use the API.
Specify your OpenAI API Key in the beginning of the script llm-mob.py
, change the parameters in the main function if necessary and start the prediction process by simply running the sripts
python llm-mob.py
The log file will be stored in /logs
and prediction results will be stored in /output
.
We provide the actual prediction results obtained in our experiments in /results
.
To calculate the evaluation metrics, check the IPython notebook metrics.ipynb
and run the scripts therein.
OpenAI has recently released a new major version of their API, therefore the code in this repo has been updated accordingly. For more information regarding how the update affect the old code and how we should proceed, check out their v1.0.0 Migration Guide.
@misc{wang2023i,
title={Where Would I Go Next? Large Language Models as Human Mobility Predictors},
author={Xinglei Wang and Meng Fang and Zichao Zeng and Tao Cheng},
year={2023},
eprint={2308.15197},
archivePrefix={arXiv},
primaryClass={cs.AI}
}