Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Hugging Face 6 min read How-to mediumAdept

Graph Classification with Transformers

Graph classification with Hugging Face Transformers uses Microsoft's Graphormer, fine-tuned on the ogbg-molhiv dataset from the Open Graph Benchmark. The walkthrough covers loading graph datasets from the Hub, the expected jsonl graph format (edge_index, num_nodes, y, node_feat, edge_attr), and Graphormer preprocessing that computes degree and shortest-path features, either upfront or on the fly in the data collator for large graphs. It then loads a pretrained checkpoint with a new classification head and trains it with Trainer and GraphormerDataCollator. Batch size and gradient accumulation need tuning to avoid OOMs, and 20 epochs take about a day on a CPU. A reader comment notes the module has since moved under transformers.models.deprecated.

Assumes: PythonHugging Face Transformers basicsgraph data structures

Related posts

  • Introduction to Graph Machine Learning

    Hugging Face easyNovice

    Graphs (nodes linked by edges) underpin tasks from molecule generation to recommendation, and learning on them requires permutation-invariant/equivariant models because shuffling an adjacency matrix or edge list yields the same graph. The survey moves from pre-neural engineered features (centrality, clustering coefficient, graphlets, Katz index) and walk-based embeddings like Node2Vec to Graph Neural Networks built on message passing, comparing aggregation schemes in GCN, GAT, GraphSAGE and GIN. It explains the oversmoothing problem that limits GNN depth, with mitigations such as fewer layers, skip connections and non-message-passing layers, then reviews Graph Transformers like SAN, GRPE and Graphormer that adapt attention and positional encodings to graphs.

  • How to train a Language Model with Megatron-LM

    Hugging Face hardMaster

    Megatron-LM, NVIDIA's GPU-optimized framework for pre-training transformers, can train a GPT2-style model end to end: environment setup in an NGC PyTorch container, preprocessing data into tokenized binary mmap files, launching distributed training, and converting checkpoints to Hugging Face Transformers. Its speed comes from a DataLoader that pre-computes shuffled sequence indexes across epochs and from fused CUDA kernels, including Apex's fused AdamW, which cut memory movement. A 110M-parameter CodeParrot model trains in about 12 hours on 8 GPUs with data parallelism, and tensor and pipeline parallelism are available for larger models. The extra preprocessing and conversion overhead makes it worth using mainly for pre-training or extended fine-tuning rather than short fine-tunes.

  • Introducing TabFM: A zero-shot foundation model for tabular data

    Google Research easyNovice

    TabFM is a foundation model that treats tabular classification and regression as in-context learning, so it predicts on an unseen table in a single forward pass with no training, hyperparameter tuning or feature engineering. Its hybrid architecture combines TabPFN-style alternating row and column attention, compression of each row into a dense vector, and a TabICL-style Transformer over the compressed rows to keep compute low on larger tables. It is pretrained entirely on hundreds of millions of synthetic datasets generated from structural causal models. On TabArena (38 classification and 13 regression datasets, 700 to 150K rows), it is reported to beat tuned tree-based baselines in Elo, and an ensemble variant adds cross and SVD features, NNLS weighting and Platt scaling. It is available on Hugging Face and GitHub and through BigQuery's AI.PREDICT.

  • Perceiver IO: a scalable, fully-attentional model that works on any modality

    Hugging Face hardMaster

    Perceiver IO avoids the quadratic cost of self-attention by running attention over a small fixed set of latent variables (e.g. 256×1280). Inputs of any modality enter only through cross-attention, where the latents supply the queries, and outputs are produced by cross-attention with trainable decoder queries. Walking through the Hugging Face Transformers implementation, the post traces tensor shapes through preprocessors, the latent encoder, decoders and postprocessors. Examples cover byte-level text classification and masked language modeling, which reaches 81.8 on GLUE without a tokenizer, and image classification with learned, Fourier or convolutional preprocessing.

  • Introducing ModuleLens: Zooming into PyTorch Modules for Human and Agentic Engineering

    Pinterest Engineering hardMaster

    ModuleLens lets Pinterest ML engineers capture any PyTorch module from a sharded multi-GPU recommendation model and rebuild it locally within seconds, replacing full-model initialization with a "module-first" workflow. A ModuleTracer uses forward hooks to record inputs, outputs, state_dicts and runtime metadata. It captures __init__ arguments by patching Python's __import__ and stops tracing after a single post-warmup training step, logging only shapes for large tensors and deduplicating shared ones. Captured modules are versioned in a Weights & Biases Registry, indexed by a hash of model and module name, and consumed through a Jupyter extension, an IPython CLI, and Agent Skills for LLM agents. Internal uses include a training bottleneck analyzer, an LLM-driven GPU kernel generator, and scaling-law ROI tooling.

The quest for software engineering knowledge.

Look:
Layout: