AI applicationsGraph machine learning

Graph machine learning

Memgraph has been a popular choice in the AI world for a while now, especially for the use cases around machine learning (ML). The MAGE library aims to provide the most commonly used graph algorithms, and that includes graph ML algorithms as well.

Many other MAGE algorithms are building blocks for AI applications too. For example, GraphRAG uses PageRank, Leiden community detection and deep path traversals to retrieve context for an LLM. See Retrieval pipelines.

Node embeddings

Supervised machine learning is a subset of ML where algorithms try to learn from data. Modeling the interactions between entities as graphs has enabled researchers to understand the various networks systematically. For the computer to understand these networks, embedding a large graph in low dimensional space is necessary, creating node embeddings. It has been demonstrated that graph embedding is superior to alternatives in many supervised learning tasks, such as node classification and link prediction, which are usually used for friendship or content recommendations and advertisement.

Algorithms

Here are the MAGE algorithms which create node embeddings:

  • node2vec: An algorithm for calculating node embeddings on a static graph.
  • node2vec_online: An algorithm for calculating node embeddings on a dynamic graph.

Resources

In case you’d like to learn more about the topic and see practical examples, check out the following resources:

Graph neural networks

Using the node2vec algorithm to determine node embeddings works well, but graph neural networks (GNNs) are more precise. GNNs aim to get the node representations automatically and efficiently by iteratively aggregating the representations of node neighbors and combining them with their representation from the previous iteration. GNNs can inductively learn about your dataset, which means that after training is complete, you can apply their knowledge to a similar use case, meaning you don’t have to retrain the whole algorithm.

gnn

Algorithms

Here are the MAGE algorithms that are using GNNs:

  • Link prediction with GNN: Module for predicting links in the graph by using GNNs.
  • Node classification with GNN: GNN-based node classification module.
  • gnn: Export graph data from Memgraph to PyTorch Geometric (PyG) or TensorFlow GNN (TF-GNN) to train your own GNN, and write the results back to Memgraph.

Resources

In case you’d like to learn more about the topic and see practical examples, check out the following resources:

Temporal graph networks

Temporal graph networks (TGNs) are GNNs which work on temporal graph networks, meaning they deal with continuous-time dynamic graphs.

tgn

Algorithms

Here is the MAGE algorithm that uses TGNs:

Resources

In case you’d like to learn more about the topic, check out the following resource:

Learn more

To learn more, check out Enhancing AI with graph databases and LLMs bootcamp and on-demand resources. Stay up to date with Memgraph events and watch videos from the AI, LLMs and GraphRAG YouTube playlist.