Meta-Learning with Few-Shot Transformers
1. Key Concepts in Meta-Learning
1.1 Key Concepts in Meta-Learning
Meta-Learning as Optimization of Learning Algorithms
Meta-learning, or learning to learn, formalizes the process of training models to adapt quickly to new tasks with minimal data. Unlike traditional machine learning, where a model is trained on a fixed dataset, meta-learning optimizes the model's ability to generalize across a distribution of tasks. The core objective is to minimize the expected loss over unseen tasks sampled from a task distribution p(T):
Here, θ represents the meta-parameters, and ℒT(θ) is the loss for task T after adaptation. The adaptation process typically involves a few gradient steps on a support set, followed by evaluation on a query set.
Episodic Training Framework
Meta-learning models are trained using an episodic paradigm, where each episode simulates a few-shot learning scenario. For each episode:
- A task Ti is sampled from p(T).
- The support set Dsi (e.g., k-shot, n-way) is used for adaptation.
- The query set Dqi evaluates the adapted model's performance.
The meta-loss aggregates performance across episodes:
where fθi' is the model adapted to task Ti via parameters θi' = θ − α∇θℒTi(θ, Dsi).
Model-Agnostic Meta-Learning (MAML)
MAML is a foundational algorithm that optimizes for parameter initialization. Given a base model fθ, MAML computes:
The meta-update then adjusts θ to minimize the loss on Dqi after adaptation:
This bi-level optimization encourages θ to reside in a region of parameter space amenable to rapid task-specific fine-tuning.
Metric-Based Approaches
Prototypical Networks and Relation Networks learn embeddings where class separation is maximized in a metric space. For a support set S with n classes, the prototype for class c is:
Query samples are classified via Euclidean or cosine similarity to prototypes. Transformers extend this by replacing fixed metrics with attention-based similarity scoring.
Meta-Learning with Transformers
Few-shot transformers (e.g., ProtoTransformer, MetaFormer) leverage self-attention to dynamically weight support samples based on query relevance. The attention mechanism computes:
where Q, K are query and key projections of support/query embeddings. This enables context-dependent adaptation without explicit gradient steps.

1.2 Few-Shot Learning Paradigms
Few-shot learning (FSL) addresses the challenge of training models with limited labeled examples, typically ranging from one to a few dozen samples per class. Unlike traditional supervised learning, which assumes abundant labeled data, FSL requires models to generalize from sparse supervision. This paradigm is particularly relevant in domains where data acquisition is expensive or impractical, such as medical imaging, rare event detection, and personalized recommendation systems.
Key Few-Shot Learning Approaches
Few-shot learning methods can be broadly categorized into three paradigms: metric-based, optimization-based, and memory-augmented approaches. Each leverages different inductive biases to enable rapid adaptation with minimal data.
Metric-Based Learning
Metric-based approaches learn an embedding space where samples from the same class are clustered together, while dissimilar samples are pushed apart. Given a query sample, classification is performed by computing distances to support examples in this learned space. The prototypical networks framework formalizes this by computing class prototypes as the mean of support embeddings:
where \( S_k \) is the support set for class \( k \), and \( f_\theta \) is the embedding function. The query sample is classified based on the softmax over negative distances to prototypes:
Optimization-Based Meta-Learning
Optimization-based methods, such as Model-Agnostic Meta-Learning (MAML), learn model parameters that can quickly adapt to new tasks with few gradient steps. The meta-objective optimizes for fast adaptation across a distribution of tasks:
This bi-level optimization yields initialization parameters sensitive to task-specific loss landscapes, enabling effective fine-tuning with limited data.
Memory-Augmented Networks
Memory-augmented approaches employ external memory components to store and retrieve task-specific information. For example, the MetaNet architecture uses fast weights generated by a slow-learning meta-learner to rapidly encode new task information. The memory module \( M \) is updated through a combination of content-based addressing and meta-learned memory update rules:
where \( \mathbf{h}_t \) is the hidden state, \( \mathbf{k}_t \) the key, and \( \mathbf{v}_t \) the value to be stored. Retrieval is performed via attention over memory slots.
Few-Shot Learning with Transformers
Transformer architectures have demonstrated strong few-shot learning capabilities due to their self-attention mechanisms, which enable dynamic weighting of relevant support examples. Key adaptations include:
- Cross-attention between support and query sets: The query attends to all support examples, allowing information aggregation without fixed metric assumptions.
- Task-conditioned attention: LayerNorm parameters are modulated by task embeddings to specialize attention patterns per few-shot task.
- Episodic pretraining: Models are trained on synthetic few-shot tasks sampled from base classes to mimic test-time conditions.
The transformer's attention mechanism computes pairwise similarities between query \( \mathbf{q} \) and support \( \mathbf{s}_j \) tokens:
followed by context aggregation \( \mathbf{c}_i = \sum_j \alpha_{ij} \mathbf{s}_j \). This allows the model to dynamically determine which support examples are most relevant for each query.
Evaluation Protocols
Standard few-shot benchmarks use episodic evaluation, where each episode consists of a small support set and query set from novel classes not seen during training. Common configurations include:
- N-way K-shot: N classes with K support examples per class.
- Transductive evaluation: Queries are classified jointly by leveraging statistics across the entire query set.
- Cross-domain evaluation: Testing on datasets with different characteristics than training data to assess generalization.

1.3 Challenges in Traditional Meta-Learning Approaches
Traditional meta-learning methods, such as Model-Agnostic Meta-Learning (MAML) and Prototypical Networks, exhibit several fundamental limitations when applied to few-shot learning scenarios. These challenges stem from architectural constraints, optimization difficulties, and inductive biases that hinder generalization across diverse tasks.
1. Gradient-Based Optimization Instability
MAML and its variants rely on nested gradient updates, where the inner loop adapts to a support set and the outer loop meta-optimizes for task-agnostic initialization. This leads to two critical issues:
- Second-order gradient computation: The meta-update requires backpropagating through the inner-loop optimization path, resulting in computationally expensive Hessian calculations. For a model with parameters θ, the meta-gradient is:
- Vanishing/exploding gradients: Deep architectures compound gradient instability due to repeated differentiation through the inner-loop steps, often necessitating gradient clipping or layer-wise learning rate annealing.
2. Task Ambiguity in Metric-Based Approaches
Prototypical Networks and Relation Networks compute class prototypes as Euclidean centroids in embedding space, which becomes problematic when:
- Class distributions exhibit multi-modal structure (e.g., "dog" category containing distinct breeds).
- Features are non-linearly separable, requiring complex distance metrics that are difficult to meta-learn.
The standard few-shot classification loss for a query point x with label y is:
where cy is the prototype for class y and d(·,·) is a distance metric. This formulation assumes unimodal class distributions, limiting expressivity.
3. Catastrophic Forgetting in Sequential Adaptation
When meta-models are fine-tuned on new tasks, they often overwrite previously learned knowledge due to:
- Lack of mechanisms to preserve task-agnostic features during inner-loop updates.
- Overfitting to the small support set (typically 1-5 examples per class).
Empirical studies show that standard meta-learners lose 30-50% of their initial task performance after adapting to just 5 sequential tasks, as measured by the retention metric:
4. Computational and Memory Bottlenecks
Traditional approaches require maintaining and processing:
- All task-specific parameters during inner-loop adaptation.
- Historical gradient information for meta-optimization.
For a model with N parameters and K inner-loop steps, memory usage scales as O(KN), making it impractical for large-scale architectures like Transformers.
5. Rigidity in Task Representations
Fixed architectural components (e.g., convolutional backbones in MAML) struggle with:
- Cross-domain generalization (e.g., medical images to satellite imagery).
- Variable-input modalities (e.g., few-shot learning across vision, text, and graphs).
This manifests as a 15-25% performance drop when meta-testing on out-of-distribution tasks compared to in-domain evaluation, as shown in cross-domain few-shot benchmarks.

2. Transformer Architecture Overview
Transformer Architecture Overview
The transformer architecture, introduced by Vaswani et al. in 2017, revolutionized sequence modeling by replacing recurrent and convolutional layers with self-attention mechanisms. At its core, the transformer leverages scaled dot-product attention to compute contextual relationships between all positions in a sequence, enabling parallel processing and long-range dependency modeling.
Self-Attention Mechanism
The self-attention mechanism computes a weighted sum of input embeddings, where the weights are derived from pairwise similarity scores. Given input embeddings X ∈ ℝn×d, where n is the sequence length and d is the embedding dimension, the queries (Q), keys (K), and values (V) are computed as:
where WQ, WK, WV ∈ ℝd×dk are learnable projection matrices. The attention scores are then computed as:
The scaling factor √dk prevents gradient saturation in the softmax function for high-dimensional keys.
Multi-Head Attention
To capture diverse feature interactions, transformers employ multi-head attention, where multiple attention heads operate in parallel. Each head applies independent linear transformations to Q, K, and V, and the outputs are concatenated:
where WO ∈ ℝhdv×d projects the concatenated outputs back to the original dimension. This allows the model to attend to different subspaces of the input representation.
Positional Encoding
Since transformers lack recurrence or convolution, they rely on positional encodings to inject sequential order information. The positional encoding P ∈ ℝn×d is defined using sinusoidal functions:
where pos is the position index and i is the dimension index. This encoding enables the model to generalize to varying sequence lengths.
Layer Normalization and Residual Connections
Transformers stabilize training through layer normalization and residual connections. Each sub-layer (attention or feed-forward) is wrapped as:
where Sublayer is either multi-head attention or a position-wise feed-forward network. This architecture mitigates vanishing gradients and accelerates convergence.
Applications in Meta-Learning
In few-shot meta-learning, transformers excel at rapid adaptation by treating support and query examples as a single sequence. The self-attention mechanism enables direct comparison between all examples, allowing the model to infer task-specific relationships without recurrent state updates. Recent variants like ProtoTransformer and MetaFormer further enhance few-shot performance by integrating prototype-based attention or task-conditioned modulation.

Adapting Transformers for Few-Shot Learning
Transformers, originally designed for sequence modeling, require architectural and optimization adaptations to excel in few-shot learning scenarios. The key challenge lies in enabling rapid generalization from limited labeled examples while preserving the model's ability to capture long-range dependencies. Two primary approaches dominate this adaptation: parameter-efficient fine-tuning and meta-learning integration.
Parameter-Efficient Fine-Tuning Strategies
Traditional fine-tuning of all transformer parameters is infeasible in few-shot settings due to overfitting risks. Instead, methods like adapter layers and prefix tuning modify only small subsets of parameters:
where Wdown ∈ ℝd×r and Wup ∈ ℝr×d form a bottleneck architecture (typically r ≪ d). The original transformer weights remain frozen during adaptation.
Meta-Learning Enhanced Transformers
Model-Agnostic Meta-Learning (MAML) frameworks adapt transformer initialization for few-shot tasks through bi-level optimization:
where inner updates (α) adapt to individual tasks and outer updates (β) optimize the meta-parameters. Transformers benefit from this through:
- Task-specific attention pattern formation
- Cross-task key/value memory sharing
- Gradient-based hypernetworks for prompt generation
Architectural Modifications
Successful few-shot transformer variants incorporate:
- Hybrid attention mechanisms: Combining content-based attention with task-conditioned positional biases
- Dynamic projection heads: Task-specific output layers generated through hypernetworks
- Episodic batch normalization: Separate normalization statistics per few-shot episode
The Prototypical Transformer architecture demonstrates these principles by computing class prototypes ck in the attention space:
where Sk is the support set for class k and Kproto are learnable prototype keys.
Practical Implementation Considerations
Effective deployment requires:
- Contrastive pretraining on diverse base classes
- Episodic training with task randomization
- Gradient checkpointing for memory efficiency
- Learned temperature scaling for attention logits
Recent benchmarks show adapted transformers achieving 72.3% 5-way 1-shot accuracy on miniImageNet, outperforming convolutional meta-learners by 11.2 percentage points while using 23% fewer parameters.

Self-Attention Mechanisms for Meta-Learning
The self-attention mechanism, first popularized by the Transformer architecture, computes dynamic weightings between elements in a sequence by measuring pairwise compatibility. In meta-learning, this allows the model to automatically focus on the most relevant features across different tasks, enabling efficient knowledge transfer.
Mathematical Formulation
Given an input sequence X ∈ ℝn×d where n is the sequence length and d is the embedding dimension, self-attention first projects X into query (Q), key (K), and value (V) matrices:
where WQ, WK, WV ∈ ℝd×dk are learnable projection matrices. The attention weights are computed as:
The output is a weighted sum of the value vectors:
Meta-Learning Adaptation
For few-shot meta-learning, self-attention enables the model to:
- Dynamically reweight features based on task-specific relevance
- Capture long-range dependencies across the support set
- Attend to discriminative patterns that generalize across tasks
In practice, meta-learning transformers often employ multi-head attention, where multiple attention heads operate in parallel:
where each head computes independent attention:
Task-Conditioned Attention
Advanced meta-learning variants modify the attention mechanism to explicitly incorporate task context. One approach computes task-specific queries:
where fφ is a task encoder and 𝒯 represents the support set. The attention then becomes:
This allows the model to focus on features most relevant to the current task during both meta-training and adaptation.
Computational Considerations
The quadratic complexity O(n2d) of self-attention can be prohibitive for large support sets. Recent work addresses this through:
- Sparse attention patterns that limit the attention field
- Memory-efficient variants like Reformer's locality-sensitive hashing
- Linear attention approximations that decompose the softmax operation
These modifications maintain the benefits of self-attention while scaling to larger few-shot learning scenarios.

3. Model Architectures and Design Choices
3.1 Model Architectures and Design Choices
Transformer-Based Meta-Learning Architectures
The core innovation in few-shot meta-learning with Transformers lies in their ability to model relationships between support and query examples through self-attention. Unlike conventional meta-learners that process tasks sequentially, Transformer-based architectures compute task-adapted representations in parallel. The key components include:
- Cross-attention between support and query sets - Enables direct information flow from labeled support examples to unlabeled queries
- Positional encodings for few-shot tasks - Maintains the permutation invariance of support examples while preserving their distinct identities
- Task-conditioned attention masks - Restricts attention to only relevant support-query pairs within each episode
where M is the task-specific attention mask and dk is the key dimension. The Hadamard product (⊙) with mask M ensures each query only attends to its corresponding support set.
Architectural Variants
Several architectural variants have emerged for few-shot learning scenarios:
1. Prototypical Transformers
Extends prototypical networks by replacing Euclidean distance with attention-based similarity:
where ck is the Transformer-generated class prototype and similarity is computed through multi-head attention.
2. Memory-Augmented Meta-Transformers
Incorporates external memory banks to store and retrieve task-specific information. The memory update rule follows:
where γ is a learnable scaling factor and Wm projects concatenated attention heads to memory space.
Critical Design Choices
The effectiveness of few-shot Transformers depends on several key design decisions:
- Attention Span Configuration - Full attention becomes computationally expensive for large support sets. Sparse attention patterns or local windows improve scalability.
- Normalization Strategies - Layer normalization placement (pre-attention vs post-attention) significantly affects few-shot adaptation dynamics.
- Positional Encoding Schemes - Learned positional embeddings often outperform fixed sinusoidal encodings in meta-learning scenarios.
Computational Considerations
The computational complexity of a standard Transformer scales quadratically with sequence length N:
For few-shot learning where N = Nsupport + Nquery, this motivates hybrid architectures that process support examples independently before cross-attention with queries, reducing complexity to:

3.2 Training Strategies for Few-Shot Adaptation
Effective few-shot adaptation in transformer-based meta-learning requires specialized training strategies that balance rapid task adaptation with stable generalization. The key challenge lies in optimizing the model's ability to quickly adapt its attention patterns and feature representations to new tasks with minimal examples while preventing catastrophic forgetting of meta-learned priors.
Episodic Training with N-way K-shot Tasks
The standard meta-learning paradigm trains models on synthetic few-shot tasks sampled from a larger meta-training dataset. For transformers, this involves constructing episodic batches where each episode contains:
- Support set: K labeled examples per class (typically 1-5 shots)
- Query set: Different examples from the same classes for evaluation
where θ represents the transformer parameters adapted on the support set, N is the number of classes, and Q is the number of query examples per class.
Gradient-Based Meta-Optimization
Modern few-shot transformers employ bi-level optimization similar to MAML but adapted for attention mechanisms:
- Inner loop: Task-specific adaptation via gradient steps on the support set
- Outer loop: Meta-update of initialization parameters using query set loss
The adaptation process for a transformer with parameters θ can be formalized as:
Followed by the meta-update:
Attention-Specific Adaptation Techniques
Transformer-specific strategies focus on efficient adaptation of attention mechanisms:
- Prefix tuning: Learns task-specific prefix vectors prepended to keys/values in attention layers
- Adapter layers: Inserts small bottleneck MLPs between transformer layers for task adaptation
- Attention mask modulation: Learns to dynamically adjust attention patterns based on few-shot examples
Example: Prefix Tuning for Few-Shot Adaptation
Given a transformer with L layers, prefix tuning learns task-specific parameters {P_l} where each P_l ∈ ℝm×d (m prefix tokens, d embedding dim). The adapted key/value matrices become:
This allows adaptation without modifying the core attention parameters, preserving the meta-learned knowledge while enabling rapid task specialization.
Regularization Strategies
Critical techniques to prevent overfitting in few-shot scenarios:
- Attention dropout: Randomly drops attention weights during meta-training
- Feature whitening: Normalizes activations across adaptation steps
- Gradient clipping: Constrains the magnitude of inner-loop updates
where γ controls the maximum update size during adaptation.
Memory-Augmented Adaptation
Advanced approaches incorporate external memory mechanisms:
- Neural Turing Machines: Stores and retrieves few-shot examples via differentiable memory
- Sparse memory access: Uses locality-sensitive hashing for efficient example retrieval
- Dynamic memory networks: Updates memory representations during adaptation
The memory retrieval process can be formalized as:
where M is the memory matrix, q is the query representation, and k_j are memory key projections.

Evaluation Metrics and Benchmarks
Key Metrics for Few-Shot Learning
Evaluating meta-learned few-shot transformers requires specialized metrics that capture both adaptation speed and final task performance. The most widely adopted metric is N-way K-shot accuracy, where N represents the number of classes and K the number of training examples per class. For a 5-way 1-shot task, the model must correctly classify novel examples after seeing just one example per class.
where Q is the number of query examples per class, $$\hat{y}_{ij}$$ is the predicted label, and $$y_{ij}$$ is the ground truth. This metric is computed across multiple meta-test episodes to obtain stable estimates.
Benchmark Datasets
Standardized benchmarks enable fair comparison across meta-learning approaches:
- miniImageNet: A 100-class subset of ImageNet with 600 images per class, commonly evaluated in 5-way configurations.
- Omniglot: Contains 1,623 handwritten characters from 50 alphabets, often used for 20-way classification.
- Meta-Dataset: A multi-domain benchmark combining 10 datasets including ImageNet, Omniglot, and Quick Draw.
Cross-Domain Generalization
Beyond in-domain accuracy, meta-learning systems must demonstrate cross-domain adaptability. The meta-generalization gap measures performance drop when transferring between domains:
where source and target represent different data distributions. State-of-the-art few-shot transformers like MetaFormer achieve $$\Delta < 5\%$$ when transferring from natural images to medical imaging domains.
Computational Efficiency
Few-shot learning systems must balance accuracy with computational demands. Key metrics include:
- Adaptation latency: Time required for task-specific parameter updates
- Memory footprint: Peak GPU memory usage during meta-testing
- Forward pass FLOPs: Computational cost per inference
Recent work shows transformer-based meta-learners can achieve sub-100ms adaptation latency on consumer GPUs while maintaining >75% 5-way accuracy.
Baselines and SOTA Comparisons
Meaningful evaluation requires comparison against established baselines:
| Method | miniImageNet 5-way 1-shot | Omniglot 20-way 1-shot |
|---|---|---|
| Matching Networks | 43.56% | 88.32% |
| Prototypical Networks | 49.42% | 92.14% |
| Meta-Transformer (2023) | 68.91% | 96.23% |
These comparisons reveal the 2-3x accuracy improvements enabled by attention-based meta-learning architectures.
4. Natural Language Processing Tasks
4.1 Natural Language Processing Tasks
Few-shot learning in NLP leverages transformer-based meta-learning to generalize from minimal labeled examples. The core challenge lies in adapting pretrained language models to new tasks with limited supervision while preserving their generalization capabilities. Key approaches include optimization-based meta-learning (e.g., MAML) and metric-based methods (e.g., Prototypical Networks), adapted for sequential data.
Architectural Adaptations for NLP
Transformers in few-shot NLP require modifications to handle variable-length inputs and task-specific embeddings. The standard self-attention mechanism is augmented with:
- Task-conditioned embeddings: Learned embeddings that encode task-specific context.
- Cross-attention adapters: Lightweight modules that modulate attention weights based on few-shot examples.
- Dynamic prompt tuning: Soft prompts generated from support examples to steer model behavior.
where M is a task-specific mask derived from support set similarities.
Meta-Training Strategies
Effective meta-training for NLP involves:
- Episodic training: Constructing synthetic few-shot tasks from large corpora by sampling N-way k-shot classification problems.
- Gradient-based adaptation: Using MAML-style updates with language-specific modifications:
where inner-loop updates use truncated backpropagation through time for sequential data.
Benchmark Performance
State-of-the-art few-shot transformers achieve:
| Model | 5-way 1-shot (Accuracy) | 5-way 5-shot (Accuracy) |
|---|---|---|
| ProtoBERT | 42.3% | 58.7% |
| Meta-FT | 47.1% | 63.2% |
| MPNN | 51.4% | 67.9% |
Practical Implementation
The HuggingFace Transformers library provides building blocks for few-shot adaptation. Key implementation steps include:
from transformers import AutoModelForSequenceClassification
import torch
class FewShotTransformer(torch.nn.Module):
def __init__(self, model_name="bert-base-uncased"):
super().__init__()
self.encoder = AutoModelForSequenceClassification.from_pretrained(model_name)
self.task_embedding = torch.nn.Embedding(100, 768) # Example task embedding dimension
def forward(self, input_ids, attention_mask, task_id):
task_emb = self.task_embedding(task_id).unsqueeze(1)
outputs = self.encoder(
input_ids=input_ids,
attention_mask=attention_mask,
inputs_embeds=task_emb.expand(-1, input_ids.size(1), -1)
)
return outputs.logits
Emerging Challenges
Current limitations include:
- Domain shift: Performance degradation when test tasks differ substantially from meta-training distribution.
- Long-range dependencies: Difficulty capturing contextual relationships in very long sequences with few examples.
- Multilingual generalization: Most methods assume English-only tasks, with limited cross-lingual transfer.

4.2 Computer Vision Applications
Few-shot transformers have demonstrated remarkable success in computer vision tasks by leveraging meta-learning to generalize from limited labeled examples. The key innovation lies in their ability to model long-range dependencies while adapting rapidly to new tasks through gradient-based optimization or attention-based conditioning.
Architectural Adaptations for Vision Tasks
Standard transformer architectures require modifications to process 2D image data effectively. The most common approach replaces the standard self-attention mechanism with spatial attention, where keys, queries, and values are computed across image patches. Given an input image I ∈ ℝH×W×C, it is first divided into N non-overlapping patches of size P×P, which are then flattened and projected into a D-dimensional embedding space:
where E ∈ ℝD×(P²·C) is the patch embedding matrix, xi is the i-th patch, and pi is a learned positional encoding.
Few-Shot Learning Strategies
Two dominant paradigms have emerged for few-shot adaptation:
- Optimization-Based Meta-Learning (MAML Variants): The model parameters θ are meta-trained to enable fast adaptation via a few gradient steps on support set examples. The loss for a task Ti with support set Si is:
- Conditioning-Based Approaches: The model processes both support and query examples through a shared transformer, with cross-attention mechanisms allowing the query features to attend to support set prototypes.
Key Applications and Performance
State-of-the-art results have been achieved in:
- Few-Shot Image Classification: Models like MetaFormer achieve 5-way 1-shot accuracy of 82.3% on miniImageNet by combining patch embeddings with task-specific attention modulation.
- Object Detection: DETR-style architectures adapted for few-shot learning demonstrate 35.2 mAP on COCO with just 10 examples per novel class.
- Medical Image Analysis: Applications in tumor segmentation show Dice coefficients >0.85 with 5 annotated examples, crucial for domains with scarce labeled data.
Challenges and Current Research Directions
Despite promising results, key limitations persist:
- Computational Cost: The quadratic complexity of self-attention limits application to high-resolution images. Recent work explores hierarchical attention or token pruning to address this.
- Domain Shift: Performance degrades when test distributions differ significantly from meta-training data. Hybrid approaches combining transformers with domain adaptation techniques show promise.
- Interpretability: The black-box nature of attention mechanisms complicates deployment in sensitive applications like medical diagnostics.
Emerging solutions include dynamic attention sparsity and prototype-based interpretability modules that maintain performance while improving transparency. The field continues to evolve rapidly, with transformer-based architectures consistently pushing the boundaries of few-shot visual recognition.

Cross-Domain Adaptation
Cross-domain adaptation in meta-learning addresses the challenge of transferring knowledge from a source domain with abundant labeled data to a target domain with limited or no labeled examples. Few-shot transformers excel in this setting by leveraging their self-attention mechanisms to capture domain-invariant features while minimizing distributional shifts.
Domain-Invariant Feature Learning
The core objective is to learn a shared embedding space where features from both domains align. Let Xs and Xt represent samples from source and target domains respectively. The transformer's self-attention weights WQ, WK, WV are optimized to minimize the Maximum Mean Discrepancy (MMD) between domains:
where ϕ(·) denotes the feature mapping induced by the transformer's hidden layers, and ℋ is the reproducing kernel Hilbert space. The MMD loss is backpropagated through the transformer's attention heads to encourage domain-agnostic representations.
Adversarial Domain Alignment
An alternative approach employs gradient reversal layers (GRLs) to adversarially train the feature extractor. The transformer's encoder E and domain classifier D engage in a minimax game:
In practice, this is implemented by inserting a GRL between the transformer's final hidden layer and the domain classifier. The layer inverts gradients during backpropagation, causing the feature extractor to learn representations that confuse the domain discriminator.
Prototypical Networks for Cross-Domain Few-Shot Learning
When adapting prototypical networks across domains, the class prototypes ck must account for domain shift. The modified prototype computation incorporates domain-adaptive batch normalization:
where BNγ represents domain-specific batch normalization parameters learned separately for source and target domains. This technique prevents the collapse of feature norms across domains while maintaining discriminative power.
Real-World Applications
- Medical Imaging: Adapting models trained on high-resolution MRI scans to low-field portable devices
- Autonomous Vehicles: Transferring driving policies from simulation to real-world conditions
- Multilingual NLP: Few-shot adaptation of language models to low-resource languages
Recent benchmarks demonstrate that transformer-based meta-learners achieve 15-20% higher accuracy compared to convolutional approaches on cross-domain few-shot tasks like miniImageNet → CUB-200 (birds) and Omniglot → EMNIST (handwriting) transfers.

5. Key Research Papers
5.1 Key Research Papers
- PDF Meta-Learning of Neural Architectures for Few-Shot Learning — Few-Shot Learning via Meta-Learning Few-Shot Learning refers to the problem of learning to solve a task (e.g., a classification problem) from just a few training examples. This problem is challenging in combination with deep learning as neural networks tend to be highly over-parameterized and therefore prone to overfitting when
- PDF Few-shot Sequence Learning with Transformers - meta-learn.github.io — 1University of Michigan, 2Facebook AI Research, 3Google Brain Abstract Few-shot algorithms aim at learning new tasks provided only a handful of training examples. In this work we investigate few-shot learning in the setting where the data points are sequences of tokens and propose an efficient learning algorithm based on Transformers.
- PDF Meta-Transfer Learning for Few-Shot Learning - CVF Open Access — Few-shot learning methods can be roughly categorized into two classes: data augmentation and task-based meta-learning. Data augmentation is a classic technique to in-crease the amount of available data and thus also use-ful for few-shot learning [21]. Several methods propose to learn a data generator e.g. conditioned on Gaussian noise [28, 43, 53].
- Meta-Transfer Learning for Few-Shot Learning - ResearchGate — PDF | On Jun 1, 2019, Qianru Sun and others published Meta-Transfer Learning for Few-Shot Learning | Find, read and cite all the research you need on ResearchGate
- Meta-transfer-adjustment learning for few-shot learning — Data augmentation and meta-learning methods are the two primary types of few-shot learning methods. Data augmentation [2], [3] is a well-known method for increasing available data and achieving satisfactory results on few-shot tasks. There is a variety of methods for creating learning data, such as increasing sample quantity in the training set by converting all samples into many samples with ...
- Meta transfer evidence deep learning for trustworthy few-shot ... — Meta-learning (Finn et al., 2017, Santoro et al., 2016, Snell et al., 2017) is a new learning paradigm for few-shot sample scenarios.Their goal is to obtain prior knowledge, using multiple related learning tasks. Then, leveraging the learned prior knowledge and a few training data, the model can quickly adapt to new tasks, improving prediction performance.
- PDF Few-Shot Learning with Semi-Supervised Transformers for Electronic ... — state-of-the-art results in few-shot learning while remaining on par with BERT in settings where more labeled data is accessible. 3. Methods In this study, we propose a novel architecture for semi-supervised learning of medical pre-diction tasks in an adversarial setting, using both labeled and unlabeled data which proved to be key in few-shot ...
- Leveraging Continuous Prompt for Few-Shot Named Entity Recognition in ... — Meta-learning has become a popular method in research on few-shot learning. This type of method [11, 12] utilizes the nearest neighbor criterion to assign entity types. Typically, this depends on the similarity patterns of entities between the source and target domains without updating the network parameters for the NER task.
- Few-Shot Learning with Semi-Supervised Transformers for Electronic ... — In this study, we have presented CEHR-GAN-BERT, a semi-supervised transformer-based architecture for few-shot learning on electronic health records. Our adversarial architecture allows us to leverage knowledge from both in-cohort and out-of-cohort patients overcoming the ubiquitous challenge in applications of machine learning in healthcare of ...
- CDFormer: Cross-Domain Few-Shot Object Detection Transformer Against ... — The method specifically tackles feature confusion through two key modules: object-background distinguishing (OBD) and object-object distinguishing (OOD). ... X. Yan, Z. Chen, et al. Meta r-cnn: Towards general solver for instance-level few-shot learning. In ICCV, 2019. [27] Y. Zang ... G. Zhang, Z. Luo, et al. Meta-DETR: Image-level few-shot ...
5.2 Open-Source Implementations
- PDF Meta-Baseline: Exploring Simple Meta-Learning for Few-Shot Learning — effectiveness of both objectives in few-shot learning. 2. Related Work Most recent approaches for few-shot learning follow the meta-learning framework. The various meta-learning ar-chitectures for few-shot learning can be roughly catego-rized into three groups. Memory-based methods [18, 14, 22, 12, 13] are based on the idea to train a meta-learner
- PDF Few-Shot Open-Set Recognition Using Meta-Learning - CVF Open Access — Few-shot [25, 3, 33, 29] Small No Open-set [5, 1] Large Yes Few-Shot Open-set Small Yes Table 1. Comparison between different recognition tasks. to substantial performance degradation. Well known exam-ples include few-shot learning [25, 3, 33, 29], where only a few training examples are available per class, domain adap-
- Meta Evidential Transformer for Few-Shot Open-Set Recognition - OpenReview — Few-shot Open-set Recognition. There are recent OSR models specifically developed for few-shot learning under the meta-learning setting. Liu et al. propose an oPen set mEta LEaRning (PEELER) model that leverages ProtoNet for few shot open-set recognition (Liu et al.,2020), which makes an assumption that the unknown samples are avail-
- PDF Few-Shot Learning With Embedded Class Models and Shot-Free Meta Training — 2. Stratification of Few-shot Learning Models Starting from the most general form of few-shot learn-ing described thus far, we restrict the model until there is no few-shot learning left, to capture the modeling choices made in the literature. 2.1. Meta Training In general, during meta-training for few-shot learning, one solves some form of ...
- Meta-transfer-adjustment learning for few-shot learning — Data augmentation and meta-learning methods are the two primary types of few-shot learning methods. Data augmentation [2], [3] is a well-known method for increasing available data and achieving satisfactory results on few-shot tasks. There is a variety of methods for creating learning data, such as increasing sample quantity in the training set by converting all samples into many samples with ...
- PDF Few-shot Sequence Learning with Transformers - meta-learn.github.io — Few-shot algorithms aim at learning new tasks provided only a handful of training examples. In this work we investigate few-shot learning in the setting where the data points are sequences of tokens and propose an efficient learning algorithm based on Transformers. In the simplest setting, we append a token to an input
- PDF Bi-Level Meta-Learning for Few-Shot Domain Generalization - CVF Open Access — The core idea of most current popular few-shot methods is the episodic learning simulating few-shot scenarios. In few-shot studies, meta-training and meta-testing data con-sist of a large number of tasks (episodes) {Ttrain t} M t=1 and {Ttest t} M t=1 sampled from base classes and novel classes of D, respectively. Each task Tcontains a support ...
- MetaTrans-FSTSF: A Transformer-Based Meta-Learning Framework for Few ... — In contrast to the aforementioned methods, task-based few-shot learning, such as meta-learning, extracts meta-knowledge from both data and tasks . Meta-knowledge leverages experience from previous tasks to improve learning capabilities for new tasks, enabling the model to quickly adapt and optimize performance in novel scenarios or contexts [ 53 ].
- Meta Evidential Transformer for Few-Shot Open-Set Recognition — To address these challenges, we propose a novel Meta Evi-dential Transformer (MET) based FSOSR model that uses an evidential open-set loss to learn more compact closed-set class representations by ...
- Empowering few-shot learning: a multimodal optimization framework — The development of transformer-based models has significantly advanced research in natural language processing and computer vision, allowing us to create models with excellent results across various domains. However, in real-world scenarios, the model may lack generalization ability and perform poorly due to data distribution shifts, insufficient training data, or low-quality data. This work ...
5.3 Recommended Courses and Tutorials
- PDF Meta-Baseline: Exploring Simple Meta-Learning for Few-Shot Learning — effectiveness of both objectives in few-shot learning. 2. Related Work Most recent approaches for few-shot learning follow the meta-learning framework. The various meta-learning ar-chitectures for few-shot learning can be roughly catego-rized into three groups. Memory-based methods [18, 14, 22, 12, 13] are based on the idea to train a meta-learner
- PDF Few-shot Natural Language Processing by Meta-learning Without Labeled Data — and meta-train models for few-shot learning using this task distribution. This leads to better representation learning, learning key hyper-parameters like learning rates, can be combined with supervised tasks to regularize supervised meta-learning, and leads to accurate few-shot learning on a diverse set of NLP classification tasks. We further
- PDF Few-Shot Learning With Embedded Class Models and Shot-Free Meta Training — φw(x), for use later for few-shot training. During few-shot training, we use N(k)samples for each new category 1The number of ways K is a-priori unknown and potentially un-bounded. It typically ranges from a few to few hundreds, while N(k) is anywhere from one to a few thousands. The meta-training set has typi-
- Meta-transfer-adjustment learning for few-shot learning — Data augmentation and meta-learning methods are the two primary types of few-shot learning methods. Data augmentation [2], [3] is a well-known method for increasing available data and achieving satisfactory results on few-shot tasks. There is a variety of methods for creating learning data, such as increasing sample quantity in the training set by converting all samples into many samples with ...
- PDF Few-shot Sequence Learning with Transformers - meta-learn.github.io — Few-shot algorithms aim at learning new tasks provided only a handful of training examples. In this work we investigate few-shot learning in the setting where the data points are sequences of tokens and propose an efficient learning algorithm based on Transformers. In the simplest setting, we append a token to an input
- Multi-attention meta learning for few-shot fine-grained image ... — The goal of few-shot image recognition is to distinguish different categories with only one or a few training samples. Previous works of few-shot learning mainly work on general object images. ... In this work, we propose a multiattention meta-learning (MattML) method for few-shot fine-grained image recognition (FSFGIR). Instead of using only ...
- Uncertainty-Aware Active Meta-Learning for Few-Shot Text Classification ... — Meta-learning techniques are designed to learn from small data quantities and generalize tasks efficiently [4,5], addressing the increasingly common issue of few-shot learning problems in machine learning. In few-shot learning problems, models must make accurate predictions based on limited data, a task at which traditional models often struggle.
- Leveraging Continuous Prompt for Few-Shot Named Entity Recognition in ... — In order to further improve the model's few-shot learning capability, a meta-learning strategy is used to train the model. Experimental results show that the proposed approach achieves the best results in a few-shot electric Chinese power named entity recognition dataset compared to several traditional named entity approaches.
- Few-Shot Transfer Learning for SAR Image Classification Without Extra ... — Deep learning-based synthetic aperture radar (SAR) image classification is an open problem when training samples are scarce. Transfer learning-based few-shot methods are effective to deal with this problem by transferring knowledge from the electro-optical (EO) to the SAR domain. The performance of such methods relies on extra SAR samples, such as unlabeled novel class's samples or labeled ...
- Chapter 3 Multimodal architectures | Multimodal Deep Learning — Labeling data is indeed costly: this is why the ability of a model to generalize well when exposed to just few training examples has been steadily gaining importance as evaluation metric. This was the so called few-shot learning. Moreover, Transformer-based models have "universal vocation": they tend to be multimodal and multi-task ...







