Graph Classification with Transformers

📰 Hugging Face Blog

Graph classification with Transformers using the Graphormer model

intermediate Published 14 Apr 2023
Action Steps
  1. Install the required libraries, including Transformers and PyTorch
  2. Load the graph data and preprocess it
  3. Load the Graphormer model and fine-tune it for graph classification
  4. Train and evaluate the model on the graph classification task
Who Needs to Know This

Data scientists and machine learning engineers can benefit from this tutorial to learn graph classification using Transformers, which can be applied to various graph-structured data

Key Insight

💡 The Graphormer model can be used for graph classification tasks using the Transformers library

Share This
🤖 Learn graph classification with Transformers using Graphormer! 📊

Key Takeaways

Graph classification with Transformers using the Graphormer model

Full Article

Published Time: 2023-04-14T00:00:00.204Z

# Graph Classification with Transformers

[![Image 1: Hugging Face's logo](https://huggingface.co/front/assets/huggingface_logo-noborder.svg)Hugging Face](https://huggingface.co/)

* [Models](https://huggingface.co/models)
* [Datasets](https://huggingface.co/datasets)
* [Spaces](https://huggingface.co/spaces)
* [Buckets new](https://huggingface.co/storage)
* [Docs](https://huggingface.co/docs)
* [Enterprise](https://huggingface.co/enterprise)
* [Pricing](https://huggingface.co/pricing)
*
*
* * *

* [Log In](https://huggingface.co/login)
* [Sign Up](https://huggingface.co/join)

[Back to Articles](https://huggingface.co/blog)

# [](https://huggingface.co/blog/graphml-classification#graph-classification-with-transformers) Graph classification with Transformers

Published April 14, 2023

[Update on GitHub](https://github.com/huggingface/blog/blob/main/graphml-classification.md)

[- [x] Upvote 5](https://huggingface.co/login?next=%2Fblog%2Fgraphml-classification)
* [![Image 2](https://cdn-avatars.huggingface.co/v1/production/uploads/noauth/F2BwrOU0XpzVI5nd-TL54.png)](https://huggingface.co/Charletta1 "Charletta1")
* [![Image 3](https://cdn-avatars.huggingface.co/v1/production/uploads/64fddeab8c21ebb3dbc55c0d/HrC0-a57OAqWPdCd2l7w5.png)](https://huggingface.co/ardavey "ardavey")
* [![Image 4](https://huggingface.co/avatars/20f55f31a8c98424cf8fd9d4c2d0346b.svg)](https://huggingface.co/Lucas-Hyun-Lee "Lucas-Hyun-Lee")
* [![Image 5](https://huggingface.co/avatars/5e8727e472bc4e174cb9a5c62fd12982.svg)](https://huggingface.co/sadiiipc "sadiiipc")
* [![Image 6](https://huggingface.co/avatars/45b7f751b8d36e5f7b54a594fad51721.svg)](https://huggingface.co/prmidaghm "prmidaghm")

[![Image 7: Clémentine Fourrier's avatar](https://cdn-avatars.huggingface.co/v1/production/uploads/1644340617257-noauth.png)](https://huggingface.co/clefourrier)

[Clémentine Fourrier clefourrier Follow](https://huggingface.co/clefourrier)

Published April 14, 2023.[Update on GitHub](https://github.com/huggingface/blog/blob/main/graphml-classification.md)

[![Image 8: Gravatar](https://aeiljuispo.cloudimg.io/v7/https://s3.amazonaws.com/moonup/production/uploads/1644340617257-noauth.png?w=200&h=200&f=face) `clefourrier`Clémentine Fourrier](https://huggingface.co/clefourrier)

* [Requirements](https://huggingface.co/blog/graphml-classification#requirements "Requirements")

* [Data](https://huggingface.co/blog/graphml-classification#data "Data")
* [Loading](https://huggingface.co/blog/graphml-classification#loading "Loading")

* [Format](https://huggingface.co/blog/graphml-classification#format "Format")

* [Preprocessing](https://huggingface.co/blog/graphml-classification#preprocessing "Preprocessing")

* [Model](https://huggingface.co/blog/graphml-classification#model "Model")
* [Loading](https://huggingface.co/blog/graphml-classification#loading-1 "Loading")

* [Training or fine-tuning](https://huggingface.co/blog/graphml-classification#training-or-fine-tuning "Training or fine-tuning")

* [Ending note](https://huggingface.co/blog/graphml-classification#ending-note "Ending note")

In the previous [blog](https://huggingface.co/blog/intro-graphml), we explored some of the theoretical aspects of machine learning on graphs. This one will explore how you can do graph classification using the Transformers library. (You can also follow along by downloading the demo notebook [here](https://github.com/huggingface/blog/blob/main/notebooks/graphml-classification.ipynb)!)
At the moment, the only graph transformer model available in Transformers is Microsoft's [Graphormer](https://arxiv.org/abs/2106.05234), so this is the one we will use here. We are looking forward to seeing what other models people will use and integrate 🤗

## [](https://huggingface.co/blog/graphml-classification#requirements) Requirements

To follow this tutorial, you need to have installed `data
Read full article → ← Back to Reads