SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2002.09291 · 2020

Transformer Hawkes Process

arXiv · PDF · Open in the Atlas

Code that ran

5 of 5 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 1 honoured the contract we drafted, 0 violated it and 1 has no contract verdict; 3 failures of our instrument; 0 no recorded run), measured 2026-11-21; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2002.09291.json · badge: /api/ran/2002.09291.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
SimiaoZuo/Transformer-Hawkes-Process canonical (classifier label)
classifier basis: census
4 ran · 0 no recorded run
yangalan123/anhp-andtt extension (classifier label)
classifier basis: classifier_2025
1 ran · 0 no recorded run
FunctionStatusWhere it lives
attention Ran
ran; our contract draft was wrong, not the code
yangalan123/anhp-andtt/thp/thp_testing/model/xfmr.py
code served (permissive licence) · get_code("8abbfdabbdf5e708")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Sonnet 4.5, prompt python_fixture_v1) and returned tuple. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import math

torch.manual_seed(0)

# Attention typically works with shape (batch, num_heads, seq_len, d_k)
# We'll use:
# - batch_size = 2
# - num_heads = 3
# - seq_len = 5
# - d_k = 4

batch_size = 2
num_heads = 3
seq_len = 5
d_k = 4

query = torch.randn(batch_size, num_heads, seq_len, d_k)
key = torch.randn(batch_size, num_heads, seq_len, d_k)
value = torch.randn(batch_size, num_heads, seq_len, d_k)

# Mask should be broadcastable to scores shape (batch, num_heads, seq_len, seq_len)
# Typically used for padding or causal masking
# mask > 0 will be filled with large negative value
mask = torch.zeros(batch_size, num_heads, seq_len, seq_len)
# Set some positions to 1 to test masking
mask[0, 0, 0, 3:] = 1
mask[1, 1, 2, 4] = 1

# Dropout is a nn.Module with forward method
dropout = torch.nn.Dropout(p=0.1)

ARGS = {
    'query': query,
    'key': key,
    'value': value,
    'mask': mask,
    'dropout': dropout
}
Setup block drafted by
a language model, Claude Sonnet 4.5, prompt python_fixture_v1
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple — a tuple output has no array shape of its own; none is stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
compute_event Ran
ran; our contract draft was wrong, not the code
SimiaoZuo/Transformer-Hawkes-Process/Utils.py
code served (permissive licence) · get_code("9f0d5b1b034631ff")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Tensor, ndim 2, dtype family float, shape (2, 4) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import math
import torch

torch.manual_seed(0)

# Create event tensor - small batch of event probabilities
# Shape: (2, 4) - batch size 2, 4 event dimensions
event = torch.rand(2, 4) * 0.5 + 0.3  # values between 0.3 and 0.8

# Create non_pad_mask - boolean mask indicating which positions are valid
# Shape: (2, 4) - same shape as event
non_pad_mask = torch.tensor([
    [True, True, False, True],
    [True, False, True, True]
])

ARGS = {
    "event": event,
    "non_pad_mask": non_pad_mask
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 2, dtype family float, shape (2, 4) — shape (2, 4) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
compute_integral_biased Ran
ran, honoured the contract we drafted
SimiaoZuo/Transformer-Hawkes-Process/Utils.py
code served (permissive licence) · get_code("255c7fc5631b2fe3")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Tensor, ndim 2, dtype family float, shape (2, 3) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import numpy as np

torch.manual_seed(0)

# The function operates on three tensor arguments:
# - all_lambda: shape (batch, seq_len) - intensity values at each time step
# - time: shape (batch, seq_len) - timestamps
# - non_pad_mask: shape (batch, seq_len) - binary mask for padding

batch_size = 2
seq_len = 4

# Create all_lambda tensor: intensity values
all_lambda = torch.randn(batch_size, seq_len)

# Create time tensor: increasing timestamps
time = torch.cumsum(torch.rand(batch_size, seq_len), dim=1)

# Create non_pad_mask: binary mask (1s for valid positions, 0s for padding)
# Make it so some positions are masked out
non_pad_mask = torch.ones(batch_size, seq_len)
non_pad_mask[:, -1] = 0  # mask out last position for at least one sequence

ARGS = {
    "all_lambda": all_lambda,
    "time": time,
    "non_pad_mask": non_pad_mask,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 2, dtype family float, shape (2, 3) — shape (2, 3) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
get_subsequent_mask Ran
ran; our contract draft was wrong, not the code
SimiaoZuo/Transformer-Hawkes-Process/transformer/Models.py
code served (permissive licence) · get_code("5e95e556552625a6")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Tensor, ndim 3, dtype family int, shape (2, 4, 4) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

# The function expects a tensor with size() method that returns (batch_size, sequence_length)
# It accesses seq.device and seq.dtype
seq = torch.ones((2, 4), dtype=torch.uint8)

ARGS = {
    "seq": seq
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 3, dtype family int, shape (2, 4, 4) — shape (2, 4, 4) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
softplus Ran
ran on a synthesized input
SimiaoZuo/Transformer-Hawkes-Process/Utils.py
code served (permissive licence) · get_code("61d4401b78d08587")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Tensor, ndim 2, dtype family float, shape (2, 4) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

x = torch.randn(2, 4)
beta = 2.0

ARGS = {
    "x": x,
    "beta": beta
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 2, dtype family float, shape (2, 4) — shape (2, 4) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block

Also present in other papers' code

Of 5 samples lifted from this paper's linked repositories, 5 carry a function identity and 0 do not. Of the 5 distinct functions with an identity, 5 are also present in other papers whose code we hold (1 with at least one paper dated earlier, 0 the same month, 5 later) and 0 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

FunctionAlso present inEarliest-datedOthers named
attention 4 other papers
4 later
2210.01753 (2022-10)
HYPRO: A Hybridly Normalized Probabilistic Model for Long-Horizon Prediction of Event Sequences
2305.16646 (2023-05)
Language Models Can Improve Event Prediction by Few-Shot Abductive Reasoning
2307.08097 (2023-07)
EasyTPP: Towards Open Benchmarking Temporal Point Processes
and 1 more not named here
get_subsequent_mask 3 other papers
1 dated earlier, 2 later
1706.03762 (2017-06)
Attention Is All You Need
2206.05291 (2022-06)
ProActive: Self-Attentive Temporal Point Process Flows for Activity Sequences
ijcai2024_0790 (2024 (year only))
CausalNET: Unveiling Causal Structures on Event Sequences by Topology-Informed Causal Attention
compute_event 1 other paper
1 later
2206.05291 (2022-06)
ProActive: Self-Attentive Temporal Point Process Flows for Activity Sequences
compute_integral_biased 1 other paper
1 later
2206.05291 (2022-06)
ProActive: Self-Attentive Temporal Point Process Flows for Activity Sequences
softplus 1 other paper
1 later
2206.05291 (2022-06)
ProActive: Self-Attentive Temporal Point Process Flows for Activity Sequences

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-21.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

Modern data acquisition routinely produce massive amounts of event sequence data in various domains, such as social media, healthcare, and financial markets. These data often exhibit complicated short-term and long-term temporal dependencies. However, most of the existing recurrent neural network based point process models fail to capture such dependencies, and yield unreliable prediction performance. To address this issue, we propose a Transformer Hawkes Process (THP) model, which leverages the self-attention mechanism to capture long-term dependencies and meanwhile enjoys computational efficiency. Numerical experiments on various datasets show that THP outperforms existing models in terms of both likelihood and event prediction accuracy by a notable margin. Moreover, THP is quite general and can incorporate additional structural knowledge. We provide a concrete example, where THP achieves improved prediction performance for learning multiple point processes when incorporating their relational information.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2002.09291")
get_code_for_paper("2002.09291")
have("2002.09291")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2002.09291.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2002.09291.svg)](https://syntology.ai/paper/2002.09291)

Connect an agent — have() is free.