Transformer Hawkes Process

Code for Transformer Hawkes Process, ICML 2020.

Transformer Hawkes Process

Source code for Transformer Hawkes Process (ICML 2020).

Run the code


  • Python 3.7.
  • Anaconda contains all the required packages.
  • PyTorch version 1.4.0.


  1. Put the data folder inside the root folder, modify the data entry in accordingly. The datasets are available here.
  2. bash to run the code.


  • Right now the code only supports single GPU training, but an extension to support multiple GPUs should be easy.
  • The reported event time prediction RMSE and the time stamps provided in the datasets are not of the same unit, i.e., the provided time stamps can be in minutes, but the reported results are in hours.
  • There are several factors that can be changed, beside the ones in
    • In, function train_epoch, the event time prediction squared error needs to be properly scaled to stabilize training. In the meantime, also scale the diff variable in function time_loss in
    • In, function log_likelihood, users can select whether to use numerical integration or Monte Carlo integration.
    • In transformer/, class Transformer, there is an optional recurrent layer. This is inspired by the fact that additional recurrent layers can better capture the sequential context, as suggested in this paper. In reality, this may or may not help, depending on the dataset.


Please cite the following paper if you use this code.

  title={Transformer Hawkes Process},
  author={Zuo, Simiao and Jiang, Haoming and Li, Zichong and Zhao, Tuo and Zha, Hongyuan},
  journal={arXiv preprint arXiv:2002.09291},

Get A Weekly Email With Trending Projects For These Categories
No Spam. Unsubscribe easily at any time.