Sam Babichenko

Reading notes / Foundation models for transaction data

Temporal graphs and real-time serving

Ten papers on learning from timestamped edges between entities and serving such models inside a fraud decision. They bear on a fraud model pretrained on login, connection and transfer events and on an entity graph of devices, accounts, identities and sessions, which a per-user transformer and a separate graph traversal currently read separately. A temporal graph is a list of (source, destination, time, features) events. Models are tested on telling held-out future edges from fake ones (negatives), and are inductive if they handle nodes unseen in training and transductive if they do not.

JODIE (Kumar, Zhang, Leskovec, 2019). In a user-item stream both sides change, and a user's state drifts between events. Two coupled recurrent networks update the user and item embeddings after every interaction and predict the next item's embedding, so the model learns the dynamics without sampling negatives. MRR (mean of 1/rank of the true item) was 0.726 on Reddit against 0.603 for the next-best baseline, but one-hot IDs make it transductive. In practice: the coupled update fits user-device logins, and adding a rare ban-label loss to the self-supervised one suits a fraud head.

TGAT (Xu et al., Walmart Labs, 2020). A model that stores a vector per node cannot embed a node it never saw. TGAT embeds a node at query time by attending over its earlier neighbors, with a learnable Fourier encoding of each time gap, so any node with neighbors gets an embedding. AP (area under the precision-recall curve) on Walmart's grocery graph was 86.32 against 84.95 for GraphSAGE with the same time encoding, but each extra hop multiplies the online cost. In practice: this is how to score a device first seen this morning.

TGN (Rossi et al., Twitter, 2020). Attention over raw neighbors needs several hops, and each hop multiplies the cost. TGN gives each node a memory, a GRU-updated summary of its interactions, and since a neighbor's memory already summarizes that neighbor's own neighborhood, one attention layer over recent neighbors is enough. Memory added about 4 AP on Wikipedia, and training applies only earlier batches' messages to the memory to avoid leakage (seeing the edges it predicts). In practice: the per-user transformer state can take the place of the memory.

GraphMixer (Cong et al., Penn State and Meta, 2023). Temporal graph models stacked RNNs and attention without testing whether either was needed. GraphMixer summarizes each node's K most recent links with a plain MLP and a fixed cosine time encoding, since learned frequencies get gradients that scale with t. The fixed encoding alone lifted TGAT's LastFM AP from 54.77 to 76.26, but under TGB ranking on Wikipedia GraphMixer scored 0.118 MRR against 0.571 for a lookup table. In practice: test a fixed relative-time encoding against the per-user transformer's learned one.

DyGFormer and DyGLib (Yu et al., Beihang, 2023). Scoring a link from each endpoint's history separately misses what the two share. DyGFormer runs one transformer over both endpoints' first-hop histories with a neighbor co-occurrence encoding, counts of each neighbor's appearances in each history. It had the best average rank across 13 datasets with random negatives, but under historical negatives (pairs seen before and absent now) it called 89.28% of Wikipedia negatives positive. In practice: co-occurrence learns shared infrastructure, but takeovers happen on known pairs, so train and test against historical negatives.

Towards Better Evaluation for Dynamic Link Prediction (Poursafaei et al., McGill and Mila, 2022). The standard test pairs each true future edge with one random fake, which in a sparse, repetitive graph is almost never real. So EdgeBank, a parameter-free lookup that calls any seen edge positive, scores well (LastFM AUC 0.84 against 0.73 for TGN), and historical negatives expose the gap. With them the models' average AUC fell by 10 points or more on most datasets, though none was trained on them. In practice: EdgeBank per edge type is the baseline to beat for account-data edges.

Temporal Graph Benchmark (Huang et al., Mila, McGill and others, 2023). Small graphs and one random negative per edge made most models look near perfect. TGB ranks each true edge against many fixed fakes, half historical, on graphs up to 67 million edges, with test edges updating memories but not weights (streaming), as in production. On tgbl-coin, a stablecoin transfer graph, TGN beat a recent-window lookup by only 0.006 MRR, inside TGN's own spread of 0.037 across runs. In practice: judge a learned transfer model against lookups and the current trees under this protocol.

APAN (Wang et al., Ant Group and SJTU, 2021). At Alipay a transfer waits for the fraud check, and a synchronous multi-hop graph query is too slow for that wait. APAN scores each event from the endpoints' mailboxes of recent messages and pushes the event to two-hop neighbors after the decision. It ran 8.7 times faster than TGN at similar accuracy, but each decision sees the neighborhood one step late. In practice: measure that lag with deliberately delayed memory, since a burst of identities on one device can arrive before the first mails are delivered.

BRIGHT (Lu et al., eBay, 2022). An end-to-end graph network for checkout fraud spent most of its 251 ms P99 latency (99th-percentile request time) on the graph query. BRIGHT stores daily per-entity embeddings, and since the request already names the address, device, phone and token, one graph layer over looked-up embeddings replaces the query. Latency fell to 72.6 ms and AP rose to 0.4420 from 0.4201 for LightGBM, though daily embeddings are stale for burst fraud. In practice: that lift is a realistic prior for a graph model over the current trees.

GLNN (Zhang, Liu, Sun, Shah, Snap and UCLA, 2022). Fetching neighbors makes graph networks slow to serve. GLNN trains an MLP on node features alone to match a graph teacher's predicted class probabilities (knowledge distillation), so serving needs no graph. Inference for ten nodes fell from 2,071 ms to 7.56 ms at accuracy near the teacher's (75.77 against 76.60 on ogbn-products), but on Pokec, where labels follow structure, the student scored 61.32 against 80.54 for a graph-only model. In practice: distill a temporal graph teacher into the sequence model and add a few one-hop aggregates, since fraud-ring labels are structural.

What the papers say together. The useful signal is in each node's recent first-hop history, whether read as memory plus one neighbor layer, as a sequence of recent links, or as the neighbors two endpoints share. The dispute over recurrent memory is mostly an evaluation artifact. With one random negative per edge nearly every model looks perfect, and under ranking with historical negatives a parameter-free lookup beats many of them. BRIGHT finds a modest lift over a strong tree, and the industrial papers serve from stored state and accept some staleness. Training on historical negatives, many-type graphs at scale, burst staleness and adaptive fraudsters remain untested.

A temporal edge model for account data. Nodes are identities, devices, bank accounts, institutions, client apps and IPs, and edges are logged events (logins, account links, identity verifications, transfers) with their existing embeddings. The user's state is the per-user transformer, and devices, accounts and IPs get a cheap memory or a GraphMixer-style encoder. An event is scored by one transformer over both endpoints' recent histories with co-occurrence counts, plus one TGN layer over the counterparty's neighbors. Pretraining adds future-link ranking against random, historical and inductive negatives to CPC and RTD, under chronological splits and TGN's message store. Online, the model reads stored states of the entities in the request, adding single-digit milliseconds on GPU. It must beat EdgeBank per edge type and trees on traversal features plus the sequence score under TGB's streaming protocol, and can be distilled into the sequence model if online reads are unacceptable.

Terms

temporal graph
stream of (source, destination, time, features) edges
memory (TGN)
per-node vector, updated by a GRU at each event
raw message store
apply earlier batches' messages, then predict; no self-leakage
JODIE
two coupled RNNs update user and item; projection drifts in time
TGAT
attention over past neighbors + Fourier time encoding; inductive
GraphMixer
MLP-Mixer over K recent links; fixed time encoding
DyGFormer
one transformer over both endpoints' histories + co-occurrence
EdgeBank
no parameters: positive if the edge was seen before
historical negative
an edge seen before but absent now
surprise index
share of test edges never seen in training
TGB streaming
memories update on test edges, weights frozen; MRR ranking
APAN
decide from the mailbox; push mails to 2-hop neighbors afterward
BRIGHT
daily entity embeddings in a KV store + one real-time layer
GLNN
distill a GNN into an MLP; fails when labels are structural

Quiz

  1. For ban prediction, JODIE adds a label cross-entropy term to its embedding-prediction loss instead of training on the ban label alone. Why?
  2. Suppose TGN updated each node's memory with the current batch's edges and only then predicted those same edges. What goes wrong?
  3. Why does TGN train with small batches (a few hundred events) even though larger batches would be faster?
  4. GraphMixer reported near-perfect AP on Wikipedia but scored far below a lookup table on the same kind of data under TGB. What best explains the gap?
  5. DyGFormer's co-occurrence encoding breaks down under historical negatives. Why does that matter for account takeover detection?
  6. Why is TGB's streaming setting the right offline proxy for a fraud model in production?
  7. On TGB's stablecoin transfer graph, TGN beat a recent-window lookup of past edges by a tiny margin. What does this imply for a bank transfer model?
  8. How does BRIGHT avoid a graph query at decision time?
  9. Why expect GLNN-style distillation of a graph teacher into a per-user sequence model to recover only part of the graph's fraud lift?

Sources