Which inductive biases does a convolution build in, and what changes with a vision transformer? When would you expect each to win, including on-device?
Answer
Model answer, written in a candidate's voice
In short
- Conv priors: locality, weight sharing, translation equivariance (invariance only approximately, via pooling); receptive field grows with depth.
- ViT: patches plus global attention, weak spatial priors, needs lots of data/pretraining/augmentation.
- Hybrids combine conv locality with global attention.
- Compute/memory: conv scales roughly with pixels; ViT attention scales with tokens squared.
- On-device: latency, memory and int8 quantisation favour conv/hybrid; ViT needs distillation/quantisation/efficient attention.
In full
A convolution builds in locality, weight sharing and translation equivariance: the same small kernel is applied across the image, so nearby pixels interact and a shifted input produces a shifted response (equivariance; pooling and global averaging add only approximate translation invariance), while stacking layers and strides grows the receptive field hierarchically. A ViT removes most of that prior: it turns the image into patches, embeds them, and lets global self-attention mix tokens, so it can capture long-range structure but has weak spatial bias and generally needs large-scale pretraining, augmentation and more data to learn what convolutions get for free. Expect convolutions to win when data is limited, the task is local or texture-heavy, or the model must run on-device; expect ViTs to win with abundant data and compute, high-resolution or global-context tasks, or when strong pretrained backbones are available. Per resolution, conv cost scales roughly with pixels times kernel and channel work, whereas ViT attention scales with the square of token count, so high-resolution ViTs get expensive unless patch size, windowing or distillation is used. On mobile-class hardware (Arm CPUs, phone NPUs), latency, activation memory and int8 quantisation usually favour conv or hybrid/windowed designs; a ViT is attractive only after pruning, distillation, quantisation and efficient attention, otherwise its attention maps and large activations are hard to fit.
What a strong answer covers
- Convolutions bring locality, weight sharing and translation equivariance; the receptive field grows with depth.
- ViTs use patches plus global attention and have weak priors, so they need lots of data or pretraining and augmentation.
- Hybrid designs exist.
- Compute and memory per resolution.
- On-device constraints (Arm, Samsung): latency, memory, quantisation.
Common mistakes
- Calling CNNs translation-invariant without the pooling caveat.
- Claiming ViTs always win.