Skip to content

Temporal graph network

Temporal graph networks learn from timed interactions using node memory, messages and time encodings. See why prediction must precede the target-event update.

A temporal graph network (TGN) is a neural framework that learns node representations from a sequence of timestamped graph events, using persistent node memory and graph-based computation. For financial interaction data, it offers a way to represent how an account, issuer or counterparty's history changes as new events arrive. The forecasting value depends on preserving the information order: an event cannot help predict itself.

The graph is a stream

A payment graph can contain several transfers between the same accounts. Collapsing them into one static edge discards their order and spacing. TGN instead processes timed interactions; a task-specific decoder uses the resulting representations to predict an interaction or classify a node. This is the event-stream setting of Rossi et al.'s original paper, Sections 2–3, rather than a requirement to rebuild daily graph snapshots.

Three objects have different jobs:

  • Memory is a persistent vector associated with a node, compressing its processed history.
  • Messages are event-derived inputs to a memory update. They can combine the source and destination memories, event attributes and an encoding of elapsed time. Multiple messages for one node may be aggregated.
  • An embedding is the representation requested for a prediction time. It can combine memory with information from the node's temporal neighbours.
The PyTorch Geometric memory interface makes the memory/message distinction explicit: its message module combines both endpoint memories, raw event data and time encoding; its aggregator reduces messages for the same destination. Memory is learned state, not an account balance or a complete event archive.
Memory and embedding need not be identical. A node's own memory can remain unchanged while it is inactive; an embedding module can incorporate more recent neighbour information. This addresses one form of staleness described in Section 3.1, without recovering events absent from the data.

First predict, then incorporate the event

Consider a fictional scalar ledger, with dimensionless values. Immediately before an event at time 10, one node has memory s(10−)=2s(10^-)=2. Once observed, the event supplies a stipulated message m=3m=3. Define an additive teaching update:
s(10)=s(10−)+m=2+3=5.s(10)=s(10^-)+m=2+3=5.
This addition is not the TGN GRU update equation. Real TGN configurations use learned vector updates; the scalar example isolates information flow.
To predict that event before observing it, the memory input must be 2. Using 5 would include the message derived from the very event being predicted: look-ahead bias. A later prediction may use 5 after the event has become eligible. Here “2” and “5” are states, not probabilities or financial forecasts.
Fictional scalar ledger: pre-event memory 2 predicts the time-10 event; incoming message 3 then updates memory to 5. A record occurring at second 10 and usable at second 12 is excluded from a second-11 decision.
Fictional scalar ledger: pre-event memory 2 predicts the time-10 event; incoming message 3 then updates memory to 5. A record occurring at second 10 and usable at second 12 is excluded from a second-11 decision.
Prediction precedes incorporation of the target event. The lower timeline separates event occurrence from financial information availability.

The prediction target matters. Classifying an already observed transfer using its amount is a different task from predicting whether that transfer will occur. Features legitimate for the former may reveal the answer to the latter.

Time encoding does not enforce time order

Elapsed-time features tell the model how long it has been since an interaction. The authors' time encoder maps a scalar interval through learned cosine features. The raw-message implementation concatenates endpoint memories, edge features and an encoding of the source node's elapsed time. “Source” here identifies an edge endpoint; it does not mean the data vendor.

Time units and clock conventions must therefore be explicit. An interval in seconds and the same numerical input interpreted as days describe different histories. Encoding time does not stop a neighbour sampler from selecting a future edge. Nor does it establish an order between tied timestamps: preserve a trustworthy source sequence where available, and declare how genuine ties or ambiguous ordering are handled.

In the paper's training scheme, earlier-batch messages update memory before current-batch predictions, permitting gradients without target-event leakage. Current interactions supply later updates. Predictions share memory within each batch: a later event can lack an earlier event's update. This is minibatch staleness, not future information. Rossi et al., Section 3.2.

Financial events have more than one clock

A transfer can occur at second 10 but become usable by a risk system only at second 12, after receipt and validation. At a second-11 decision it must be excluded, even though its occurrence timestamp is in the past. All three times here use one synchronised clock.

For financial replay, retain occurrence time, usable time and source ordering. Advance the observable state only as records become usable; retain occurrence-time intervals as separate features if the model needs them. Late arrivals and corrections require an explicit policy. Silently sorting today's corrected archive by occurrence time reconstructs a history the system may never have observed.

The Observation, Event and Availability Timestamps lesson develops this timing contract (public preview; full lesson requires membership). The same cutoff must govern graph edges, node attributes, entity mappings and fitted transformations. Chronological prediction rows cannot repair embeddings trained on later disclosures.

Finally, interaction prediction does not establish causal contagion, calibrated default risk or trading profitability. Specify the financial target, candidate interactions and evaluation horizon, and compare against simpler dated baselines. TGN supplies a representation mechanism; the research design determines what evidence its output provides.

Sources

Last updated
  • temporal graphs
  • graph neural networks
  • node memory
  • event streams
  • point in time data
← Back to the glossaryBack to top ↑