---
title: "Deep Dive: Vision Transformers On Hugging Face Optimum Graphcore"
description: "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."
url: "https://swe.quest/articles/deep-dive-vision-transformers-on-hugging-face-optimum-graphcore-597be81d9fc267ef"
canonical: "https://huggingface.co/blog/vision-transformers"
source: "Hugging Face"
published: "2022-08-18"
difficulty: "medium"
kind: "How-to"
reading_minutes: 12
tags: ["computer-vision","model-training","hardware","python"]
---

# Deep Dive: Vision Transformers On Hugging Face Optimum Graphcore

A post on [Hugging Face](https://swe.quest/sources/hugging-face.md), published 2022-08-18, 12 min read, How-to. Original: [https://huggingface.co/blog/vision-transformers](https://huggingface.co/blog/vision-transformers)

## Summary

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.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Computer vision](https://swe.quest/tags/computer-vision.md) (AI & ML)
- [Model training](https://swe.quest/tags/model-training.md) (AI & ML)
- [Hardware](https://swe.quest/tags/hardware.md) (Infrastructure)
- [Python](https://swe.quest/tags/python.md) (Languages)

## Prerequisites

- PyTorch basics
- Hugging Face Transformers Trainer
- Transformer models

## Keywords

Vision Transformer, Hugging Face Optimum, Graphcore IPU, ChestX-ray14, PopTorch, IPUTrainer, ImageNet-21k

## Related posts

- [Getting Started with Hugging Face Transformers for IPUs with Optimum](https://swe.quest/articles/getting-started-with-hugging-face-transformers-for-ipus-with-optimum-3d978b21929278d8.md): Hugging Face · 2021-11-30 · Medium · 6 min read · Model training, Hardware, Python
  Optimum Graphcore lets Hugging Face Transformers models be fine-tuned on Graphcore IPUs with minimal code changes, starting with an IPU-optimized BERT.
- [Deploying 🤗 ViT on Vertex AI](https://swe.quest/articles/deploying-vit-on-vertex-ai-1cefa91d85f70e80.md): Hugging Face · 2022-08-19 · Medium · 10 min read · Inference & serving, Cloud platforms, ML platforms, Computer vision, Python
  A 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.
- [Interactively explore your Huggingface dataset with one line of code](https://swe.quest/articles/interactively-explore-your-huggingface-dataset-with-one-line-of-code-be90cdc319132a31.md): Hugging Face · 2023-10-25 · Medium · 5 min read · Machine learning, Python, Developer tools, Computer vision
  Renumics 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.
- [New ViT and ALIGN Models From Kakao Brain](https://swe.quest/articles/new-vit-and-align-models-from-kakao-brain-6a7608672b06935f.md): Hugging Face · 2023-03-06 · Medium · 11 min read · Computer vision, Machine learning, Python, Open source
  Kakao 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.
- [Accelerating Hugging Face Transformers with AWS Inferentia2](https://swe.quest/articles/accelerating-hugging-face-transformers-with-aws-inferentia2-732d2daf15bc9874.md): Hugging Face · 2023-04-17 · Easy · 5 min read · Inference & serving, Hardware, Performance engineering, Cloud platforms
  Hugging 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.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
