Skip to content

Encoders

Encoders compute the node (and edge) embeddings that are passed to the decoders, whose outputs feed the objectives that compute the loss. They can be GNNs that leverage the graph structure (tgn, graph_attention, sage...), but also a single linear layer like in Velox (none) or a custom MLP (custom_mlp). Several encoders can be chained with training.encoder.used_methods, e.g. tgn,graph_attention.

The main encoders, grouped by what they model, with the systems that use them:

Role Encoders Used by
Message passing within each graph sage, gat, graph_attention, gin, gcn, sum_aggregation, rcaid_gat, magic_gat Flash and ThreaTrace (sage), Kairos, Orthrus and Jbeil (graph_attention), Euler (gcn), NodLink, R-Caid, MAGIC
Edge types and attributes in messages rgcn, rgcn_per_type, argus, egraphsage, lares, gin (GINE, with edge features), shadewatcher OCR-APT (rgcn_per_type), Argus, E-GraphSAGE and Anomal-E (egraphsage), LARES, ShadeWatcher
Identity of each node node_id_embedding, lares Euler, Argus, LARES
Memory across time windows tgn, snapshot_gru Kairos, Orthrus and Jbeil (tgn), Euler and Argus (snapshot_gru)
Sequence of whole-graph embeddings textrcnn ProGrapher
No message passing none (linear layer), custom_mlp Velox
Heterogeneous graphs hetero_graph_transformer

Encoders that learn the identity of nodes are meant for nodes without informative features, such as the hosts of network datasets; encoders that read edge attributes need a dataset that has some, or the edge type in their place (batching.edge_features=edge_type). Any encoder can otherwise be used on provenance and network datasets.

hetero_graph_transformer is a Heterogeneous Graph Transformer (HGT): each node type and edge type gets its own attention parameters. It is not available on OpTC.

gcn
Graph convolutional layers whose edges are weighted by batch.edge_weight, set by the merge_edges transformation (Euler).
argus
GCN layers followed by an edge-conditioned convolution (NNConv) on the edge features, if any (Argus).
lares
A learned embedding of each host's identity, then a single sum-aggregation layer over the messages of the neighbors and the features of their edges (LARES). flow sets the direction of aggregation, and use_node_features adds the node features to the ID embedding.
egraphsage
GraphSAGE layers whose messages include the edge features, aggregated in both directions with undirected (E-GraphSAGE, Anomal-E).
shadewatcher
The recommendation model of ShadeWatcher on a knowledge graph whose triples are the edges, with the edge type and an interact relation. Entities are embedded by a linear layer on their features (size node_hid_dim), and relations by TransR (kg_dim), trained by a pairwise loss against corrupted tails (kg_neg_ratio, kg_margin) that the encoder adds to the loss of the objectives. GNN layers (hidden_dims) then propagate the embeddings from the destinations of the edges of each node, weighted by the TransR attention of their triple, with a GraphSAGE aggregator; the output concatenates the entity embeddings with the normalized output of each layer, projected to node_out_dim if their sizes differ.

node_id_embedding and snapshot_gru wrap another encoder, like tgn (e.g. gcn,node_id_embedding,snapshot_gru), and can't be combined with tgn. node_id_embedding concatenates a learned embedding of each node's identity to its input features; with all_nodes, all the nodes of the dataset are embedded in every graph (edge-level objectives only). snapshot_gru runs a GRU over the successive embeddings of each node, one step per graph (Euler, Argus).

textrcnn
The anomaly detector of ProGrapher. It does not embed nodes: it predicts the graph2vec embedding of each time window (featurization.used_method=graph2vec) from those of the last sequence_length windows, with a TextRCNN (bidirectional RNN of num_layers layers and size node_hid_dim, max-pooling, fully-connected layer). Like snapshot_gru, it keeps a state across graphs (the last embeddings), reset before each training epoch; with fewer previous windows, the sequence is shorter. It requires one graph per time window (no global, intra- or inter-graph batching) and the predict_snapshot_embedding objective.

Arguments

  • tgn
    • tgn_memory_dim: int
    • tgn_time_dim: int
    • use_node_feats_in_gnn: bool
    • use_memory: bool
    • use_time_order_encoding: bool
    • project_src_dst: bool
    • mode: str
    • use_residual_norm: bool (1)
  • graph_attention
    • activation: str
    • num_heads: int
    • concat: bool
    • flow: str
    • num_layers: int
    • final_activation: bool (2)
  • sage
    • activation: str
    • num_layers: int
  • gcn
    • activation: str
    • num_layers: int (3)
  • node_id_embedding
    • dim: int (4)
    • all_nodes: bool (5)
  • snapshot_gru
    • hidden_dim: int (6)
    • dropout: float (7)
  • textrcnn
    • sequence_length: int (8)
    • num_layers: int (9)
    • rnn_type: str (10)
  • lares
    • flow: str (11)
    • use_node_features: bool (12)
  • egraphsage
    • activation: str
    • num_layers: int (13)
    • undirected: bool (14)
  • argus
    • num_layers: int (15)
  • shadewatcher
    • hidden_dims: str (16)
    • kg_dim: int (17)
    • kg_neg_ratio: int (18)
    • kg_margin: float (19)
  • gat
    • activation: str
    • num_heads: int
    • concat: bool
    • flow: str
    • num_layers: int
  • gin
    • activation: str
    • num_layers: int
  • rgcn
    • activation: str
    • num_layers: int
  • rgcn_per_type
    • activation: str
    • num_layers: int
  • sum_aggregation
  • rcaid_gat
    • num_layers: int (20)
    • num_heads: int (21)
  • magic_gat
    • num_layers: int
    • num_heads: int
    • negative_slope: float
    • alpha_l: float
    • activation: str
  • glstm
  • custom_mlp
    • architecture_str: str
  • none
  • hetero_graph_transformer
    • activation: str (22)
    • num_heads: int (23)
    • num_layers: int (24)
  1. Adds the projected input node features to the output of the GNN wrapped by TGN, followed by dropout and LayerNorm.
  2. Applies activation to the output of the last layer too, as in Kairos.
  3. Number of GCN layers. Edges are weighted by batch.edge_weight (see the merge_edges transformation).
  4. Size of the learned embedding of each node's identity, concatenated to its input features (as the one-hot node IDs of Euler, Argus and LARES).
  5. Embeds all the nodes of the dataset in every graph, as Euler and Argus (nodes absent from the graph only get their ID embedding). Combined with snapshot_gru, the state of every node is updated at every graph, and with uniform negative sampling, negative edges reach all nodes. Only for edge-level objectives.
  6. Size of the GRU state, projected to node_out_dim (0: node_out_dim).
  7. Dropout applied to the input of the GRU.
  8. Number of previous snapshots (graphs) whose graph2vec embeddings form the input sequence (ProGrapher's L). Shorter sequences are used when fewer snapshots were seen.
  9. Number of layers of the bidirectional RNN (hidden size: node_hid_dim).
  10. Bidirectional RNN computing the left and right contexts of each snapshot: rnn is the ReLU recurrence of the TextRCNN equations, lstm and gru are gated.

    Available options (one selection):
    lstm
    gru
    rnn
  11. target_to_source (LARES): hosts aggregate the messages of the destinations of their outgoing edges; source_to_target: of the sources of their incoming edges.

    Available options (one selection):
    target_to_source
    source_to_target
  12. Adds a projection of the node features to the node ID embedding (LARES only uses node IDs).
  13. Number of E-GraphSAGE layers, whose messages include the edge features.
  14. Aggregates each edge in both directions, as E-GraphSAGE and Anomal-E (default: True).
  15. Number of layers: GCN layers followed by a last edge-conditioned convolution (NNConv) if edge features are used.
  16. Comma-separated output sizes of the GNN layers propagating the TransR entity embeddings (of size node_hid_dim) over the knowledge graph (ShadeWatcher: 32,16). The output concatenates the entity embeddings and the output of each layer, projected to node_out_dim if their sizes differ.
  17. Size of the relation space of TransR (relation embeddings and projections).
  18. Number of corrupted triples per triple of the TransR loss.
  19. Margin between the distances of valid and corrupted triples in the TransR loss.
  20. Number of layers (local + root attention, then MLP update).
  21. Number of attention heads (averaged) of each attention.
  22. Unused: the input projections always use ReLU.
  23. Number of attention heads of each Heterogeneous Graph Transformer (HGT) layer.
  24. Number of HGT layers. Each node and edge type gets its own parameters; not available on OpTC.