Key takeaway
- Vision transformer (ViT) vs CNN: how patch attention works, when to pick ViT, Swin or DeiT, what governance applies and what changes in 3 to 5 years.
A vision transformer (ViT) is an image model that splits a picture into fixed-size patches and uses self-attention to relate every patch to every other patch. It is the main alternative to the convolutional neural network (CNN) described in our CNN guide. In the original paper, a pure transformer on image patches matched strong CNNs on image classification once it was pre-trained on large amounts of data, and it needed substantially less compute to train.
For a CTO or head of engineering the decision is not "which is better". It is whether you have the data, the compute and the governance to run a ViT, or whether a CNN, a distilled ViT or a hierarchical variant such as Swin fits your latency and cost limits. This guide gives the architecture, a decision table, what has changed since 2020 and an adoption sequence. It sits inside our wider computer vision workflow.
What is a vision transformer and how does it work?
The ViT paper (Dosovitskiy et al., arXiv 22 October 2020, "An Image is Worth 16x16 Words") treats an image as a sequence. The image is cut into patches, each patch becomes a token, and transformer layers use self-attention so that distant regions of an image can influence each other from the first layer. A CNN instead applies small filters to local regions and builds up context layer by layer.
This is why ViTs suit tasks where context across the whole frame matters. It is also why they need more data. The same paper reports that, trained on ImageNet alone without strong regularisation, ViT models landed a few points below comparably sized ResNets, because transformers lack the locality and translation equivariance that CNNs have built in. Its conclusion was that large-scale training trumps inductive bias.
Vision transformer or CNN: which should you choose?
| Situation | Better fit | Why | Current status |
|---|---|---|---|
| Large labelled or self-supervised data, server-side GPUs | ViT | Pre-training at scale is where ViTs pulled ahead. In the ViT paper, ViT-L/16 pre-trained on JFT-300M reached 87.76% ImageNet top-1, using 0.68k TPUv3-core-days against 9.9k for BiT-L | Mainstream; many pre-trained checkpoints exist |
| Small dataset, no pre-trained backbone | CNN | Built-in locality helps when data is scarce | Mature |
| Only ImageNet-scale data but you want a transformer | DeiT-style ViT | DeiT reached 83.1% top-1 (85.2% with distillation) on ImageNet only, training in under 3 days on one computer | Published 2020 and 2021 |
| Dense tasks (detection, segmentation) at high resolution | Hierarchical ViT such as Swin | Self-attention limited to shifted windows, so cost grows linearly with image size; reported 58.7 box AP on COCO test-dev and 53.5 mIoU on ADE20K | Published 2021 |
| Edge cameras with tight power and latency budgets | Test a CNN or a small distilled ViT on the device | Large ViTs need more compute and memory; measure on the target hardware before committing | Benchmark on your own hardware |
The old rule of thumb, "ViT for accuracy, CNN for efficiency", is now too crude. The practical question is which model family has a good pre-trained starting point for your task and fits your hardware. Our post on computer vision on edge covers the deployment side, and NexaStack is an agentic operating platform for physical AI that runs vision processing at the edge and in the cloud.

What has changed for vision transformers since 2020?
| Development | What it changed | Source and date |
|---|---|---|
| ViT | Pure transformer on image patches competitive with CNNs after large-scale pre-training | arXiv 2010.11929, 22 Oct 2020 |
| DeiT | Removed the need for hundreds of millions of pre-training images; distillation token | arXiv 2012.12877, 23 Dec 2020 |
| Swin Transformer | Hierarchical, windowed attention with linear cost in image size; general-purpose backbone | arXiv 2103.14030, 25 Mar 2021 |
| Masked autoencoders | Self-supervised pre-training that hides 75% of patches; ViT-Huge reached 87.8% using only ImageNet-1K data | arXiv 2111.06377, 11 Nov 2021 |
| DINOv2 | Self-supervised features from curated data; a 1-billion-parameter ViT distilled into smaller models that outperform OpenCLIP on most benchmarks | arXiv 2304.07193, 14 Apr 2023 |
| SigLIP 2 | Multilingual vision-language encoders in ViT-B, L, So400m and g sizes, built for zero-shot use and transfer to vision-language models | arXiv 2502.14786, 20 Feb 2025 |
The direction is clear: the value has moved from training your own ViT from scratch to choosing a good pre-trained or self-supervised backbone and adapting it. That shifts the work to data quality, evaluation and governance.
Where do vision transformers fit in enterprise vision systems?
ViTs and their variants are used as backbones for classification, segmentation and detection, and as the image encoders inside vision-language models. In medical imaging, where a finding may depend on context across a whole scan, a global-attention model is a reasonable candidate, but you should compare it with a CNN on your own validated data first. See our guide to biomedical image analysis with computer vision. In video, ViT-based encoders feed the search, summarisation and incident-detection pipelines described in agentic AI for real-time video analytics.
NVIDIA describes its Video Search and Summarization blueprint as reference architectures for building vision agents and AI-powered video analytics applications, combining vision microservices, vision-language models and LLMs.
What do vision transformers cost, and what governance do they need?
Data and compute
Pre-training is the expensive step; most teams should fine-tune an existing checkpoint. Budget for labelled data. AgentLabel is a governed data-labelling service that blends machine-assisted tagging with human oversight, so training datasets can be trusted and traced.
Governance and audit
Check the licence of every pre-trained checkpoint before commercial use. Record which model version, dataset and policy produced each decision. The Audit Agent pulls together the decision history, governing policy versions and approval records behind a past choice, so auditors do not have to reconstruct it by hand.
Regulation matters for vision. Under the EU AI Act, high-risk obligations for Annex III use cases such as biometrics apply from 2 December 2027, and for AI in regulated products (Annex I) from 2 August 2028, as published by the European Commission after the AI Omnibus delays entered into force on 27 July 2026. Model choice does not change your obligations; the use case does.
How should you adopt vision transformers?
- Baseline: measure your current CNN on accuracy, latency and cost per image.
- Shortlist: pick two or three pre-trained backbones (a plain ViT, a Swin-style model, a self-supervised model such as DINOv2) and check licences.
- Fine-tune and compare: use the same labelled test set and the same hardware for every model.
- Decide on evidence: choose the ViT only where it wins on your data by a margin that justifies the extra compute.
- Govern: version the model, data and thresholds, log decisions and set a review cycle.
When not to use a ViT: when you have little labelled data and no good pre-trained backbone, when the device cannot hold the model, or when a CNN already meets the accuracy target at lower cost.
What will change in vision transformers over the next 3 to 5 years?
| Prediction | Why we expect it (evidence) | Timeframe | What leaders should do now |
|---|---|---|---|
| Self-supervised and vision-language encoders become the default starting point | DINOv2 (2023), masked autoencoders (2021) and SigLIP 2 (2025) all show strong transfer without task-specific labels. XenonStack's view on the default | Likely by 2028 | Standardise an evaluation set so you can swap backbones quickly |
| Cost per image falls through windowed attention, distillation and smaller checkpoints | Swin (linear cost), DeiT (distillation) and distilled DINOv2 models already point this way. XenonStack's view on the extent | 2026 to 2029 | Benchmark small models on target hardware every six months |
| ViT encoders sit inside video and vision agents rather than standalone classifiers | NVIDIA VSS (documentation 3.3.0) describes vision agents built from vision microservices, VLMs and LLMs. Timing is XenonStack's view | 2026 to 2029 | Plan for agents that search, summarise and act on video, with audit trails |
| Biometric and other high-risk vision systems face full AI Act compliance | European Commission: Annex III from 2 December 2027, Annex I from 2 August 2028 (dated) | 2027 to 2028 | Classify each vision use case by risk tier now |
| Agentic vision projects without risk controls are stopped | Gartner suggests over 40% of agentic AI projects could be cancelled by end of 2027, citing cost, unclear value and weak risk controls (as reported by New Electronics) | By end of 2027 | Tie each project to a measured decision and a named owner |
This would be wrong if compact CNNs kept beating small ViTs on edge hardware in your own benchmarks. What this means for you: choose backbones on measured evidence, and invest in data, evaluation and audit, because those outlast any single architecture.
To map one vision decision your agents should make, and the context and policy it depends on, book a Context Workshop. See what happens in the workshop.
Related on XenonStack
- Edge and vision AI: computer vision agents at the edge.
- AI inference solutions: real-time inference in production.
- NexaStack: agent runtime and inference for private cloud, on-prem and edge.
Vision transformer FAQ
What is a vision transformer?
A vision transformer (ViT) splits an image into fixed-size patches, treats each as a token and applies transformer self-attention across them. It was introduced in the paper "An Image is Worth 16x16 Words" (arXiv, 22 October 2020).
Is a vision transformer better than a CNN?
Not always. After large-scale pre-training, ViTs matched or beat strong CNNs on ImageNet transfer benchmarks. On small datasets without pre-training, the ViT paper found ViTs a few points below comparable ResNets. Test both on your own data and hardware.
Why do vision transformers need so much data?
They lack the built-in locality and translation equivariance of CNNs, so they learn those patterns from data. The ViT paper concluded that large-scale training trumps inductive bias. DeiT showed a transformer can reach 83.1% top-1 on ImageNet alone with the right training recipe.
What is the Swin Transformer?
Swin is a hierarchical vision transformer that limits self-attention to shifted windows, so computational cost grows linearly with image size. It was proposed as a general-purpose backbone for classification, detection and segmentation (arXiv, 25 March 2021).
Can vision transformers run on edge devices?
Large ViTs need more compute and memory than compact CNNs, so test small or distilled models on the target device before committing. Platforms such as NexaStack are designed to run vision at the edge, but latency depends on your hardware.
How will vision transformers change over the next 3 to 5 years?
We expect self-supervised and vision-language encoders to become the default starting point, cheaper models through windowed attention and distillation, and ViT encoders embedded in video agents. EU AI Act high-risk dates of 2 December 2027 and 2 August 2028 will shape biometric and regulated-product use cases.
Follow XenonStack on LinkedIn: XenonStack on LinkedIn for new guides on agentic AI, data and platform engineering.
Ready to put AI agents to work? Explore ElixirClaw, the agentic OS platform to build, orchestrate and govern AI agents.
Explore the XenonStack platform family: ElixirData · ElixirClaw · ElixirHub · NexaStack · MetaSecure · Neural AI · AgentGRC · AgentSRE · AgentAnalyst · AgentInstruct · AgentRAI · AgentScrum · AgentSearch · AgentForce · AI Aviator · SAIF Aviator · CohortIQ · XenonStack AI · XenonStack UAE