Deep Dive: Vision Transformers On Hugging Face Optimum Graphcore
A step-by-step walkthrough of fine-tuning a pre-trained ViT model (google/vit-base-patch16-224-in21k) for multi-label disease classification on the NIH ChestX-ray14 dataset using Hugging Face Optimum Graphcore on IPUs. It covers converting text labels to N-hot arrays, building a dataset via a metadata.jsonl file and Arrow format, matching the checkpoint's preprocessing (224x224, grayscale to RGB, 0.5 mean/std normalization), and configuring IPUConfig, IPUTrainingArguments and IPUTrainer. A custom AUC_ROC metric is used for evaluation. Training runs 3 epochs with a 25% warm-up followed by cosine decay, and loss settles around 0.1. Suggested next steps for better accuracy are longer training, optimizer and learning-rate schedule changes, and loss scaling.
Related posts
- Getting Started with Hugging Face Transformers for IPUs with Optimum
Hugging Face mediumAdeptOptimum Graphcore lets Hugging Face Transformers models be fine-tuned on Graphcore IPUs with minimal code changes, starting with an IPU-optimized BERT. The walkthrough covers enabling the Poplar SDK and PopART on an IPU-POD16 in Graphcloud, installing PopTorch and optimum[graphcore], and running the run_qa.py example to fine-tune bert-base-uncased on SQuAD v1.1 via the IPUTrainer class with an ipu_config.json. Three epochs ran in about 368 seconds at roughly 721 samples/s, reaching 80.66 exact match and 88.28 F1.
- Deploying 🤗 ViT on Vertex AI
Hugging Face mediumAdeptA TensorFlow ViT B/16 SavedModel from 🤗 Transformers, with base64 image preprocessing and label postprocessing baked into its signature, can be served on Google Cloud Vertex AI in four SDK steps: upload to the Model Registry, create an Endpoint, deploy with machine/accelerator specs and traffic split, then send prediction requests. Code covers ModelServiceClient, EndpointServiceClient and PredictionServiceClient usage and the required {"b64": ...} request payload format. A Locust load test on an n1-standard-8 with one T4 GPU averaged 646 ms latency over about 17k requests, and hourly pricing is roughly $0.44 for the machine plus $0.40 for the T4.
- Interactively explore your Huggingface dataset with one line of code
Hugging Face mediumAdeptRenumics Spotlight builds interactive visualizations directly on top of Hugging Face datasets, inferring data types and label mappings so a single spotlight.show(ds) call opens an inspection UI. Tabular columns are loaded into memory for client-side analytics while images, audio and video load lazily. Enriching a dataset with model predictions and embeddings, computed with a ViT model via transformers and ds.map, enables similarity maps and confusion-matrix layouts for finding failure clusters. Layouts can be defined through the Python API or hosted by duplicating a Hugging Face Space.
- New ViT and ALIGN Models From Kakao Brain
Hugging Face mediumAdeptKakao Brain has released COYO-700M, an open image-text dataset of roughly 700 million web alt-text pairs, along with ViT and ALIGN models trained on it. The models use Google's original architectures and hyperparameters, and their training data is fully public, unlike Google's JFT-300M and ALIGN 1.8B. Kakao's ALIGN-B7-Base matches Google's on KNN classification and beats it on MS-COCO retrieval despite using far fewer pairs. ViT-L/16 performs similarly on ImageNet and ImageNet-ReaL. Compared with LAION, COYO ships richer per-pair metadata (CLIP similarity, NSFW, watermark, aesthetic and face-count scores), and code examples show how to stream it with 🤗 Datasets and run classification, zero-shot classification and embedding extraction with Transformers.
- Accelerating Hugging Face Transformers with AWS Inferentia2
Hugging Face easyNoviceHugging Face benchmarked popular Transformer models on AWS Inferentia2 (inf2.xlarge) against Inferentia1 (inf1.2xlarge) and an NVIDIA A10G GPU (g5.2xlarge), running 144 p95-latency experiments at batch size 1 across six architectures and sequence lengths from 8 to 512. On average Inferentia2 delivered 4.5x lower latency than the A10G and 4x lower than Inferentia1, with BERT-base about 6x faster up to sequence length 256 and ViT-base about 2x faster than the GPU. The GPU runs were unoptimized fp32. Models compile for Inferentia2 through Optimum Neuron and the AWS Neuron SDK, and instances start at $0.76/hour.