KNN Transformer with Pyramid Prompts for Few-Shot Learning
Wenhao Li, Qiangchang Wang, Peng Zhao, Yilong Yin
Abstract
Few-Shot Learning (FSL) aims to recognize new classes with limited labeled data. Recent studies have attempted to address the challenge of rare samples with textual prompts to modulate visual features. However, they usually struggle to capture complex semantic relationships between textual and visual features. Moreover, vanilla self-attention is heavily affected by useless information in images, severely constraining the potential of semantic priors in FSL due to the confusion of numerous irrelevant tokens during interaction. To address these aforementioned issues, a K-NN Transformer with Pyramid Prompts (KTPP) is proposed to select discriminative information with K-NN Context Attention (KCA) and adaptively modulate visual features with Pyramid Cross-modal Prompts (PCP). First, for each token, the KCA only selects the K most relevant tokens to compute the self-attention matrix and incorporates the mean of all tokens as the context prompt to provide the global context in three cascaded stages. As a result, irrelevant tokens can be progressively suppressed. Secondly, pyramid prompts are introduced in the PCP to emphasize visual features via interactions between text-based class-aware prompts and multi-scale visual features. This allows the ViT to dynamically adjust the importance weights of visual features based on rich semantic information at different scales, making models robust to spatial variations. Finally, augmented visual features and class-aware prompts are interacted via the KCA to extract class-specific features. Consequently, our model further enhances noise-free visual representations via deep cross-modal interactions, extracting generalized visual representation in scenarios with few labeled samples. Extensive experiments on four benchmark datasets demonstrate significant gains over the state-of-the-art methods, especially for the 1-shot task with 2.28% improvement on average due to semantically enhanced visual representations.
Ask about this paper
Your agent reads all of it.
Lune indexed this paper to the last equation, along with the top-tier papers that cite it. Ask a question and the answer quotes them.
Your agent calls
Luneget_paper_fulltext
Free to start. No credit card required.
Terminal
Install the CLIlune papers fulltext 87809c90-30fb-47bb-935f-7e50b8d1b43aCited by top-tier papers7
- VT-FSL: Bridging Vision and Text with LLMs for Few-Shot LearningWenhao Li, Qiangchang Wang, Xianjing Meng, Zhibin Wu et al.NeurIPS 2025 · 10 citations
- Global Prompt Refinement with Non-Interfering Attention Masking for One-Shot Federated LearningZhuang Qi, Pan Yu, Lei Meng, Sijin Zhou et al.NeurIPS 2025 · 4 citations
- DVLA-RL: Dual-Level Vision-Language Alignment with Reinforcement Learning Gating for Few-Shot LearningWenhao Li, Xianjing Meng, Qiangchang Wang, Zhongyi Han et al.ICLR 2026 · 4 citations
- From Pretraining to Pathology: How Noise Leads to Catastrophic Inheritance in Medical ModelsHao Sun, Zhongyi Han, Hao Chen, Jindong Wang et al.NeurIPS 2025 · 4 citations
- CAST-LUT: Tokenizer-Guided HSV Look-Up Tables for Purple Flare RemovalPu Wang, Shuning Sun, Jialang Lu, Chen Wu et al.AAAI 2026 · 2 citations
Builds on40
- Learning Transferable Visual Models From Natural Language SupervisionAlec Radford, Jong Wook Kim, Chris Hallacy, Aditya Ramesh et al.ICML 2021 · 47,906 citations
- Swin Transformer: Hierarchical Vision Transformer using Shifted WindowsZe Liu, Yutong Lin, Yue Cao, Han Hu et al.ICCV 2021 · 31,683 citations
- Segment AnythingAlexander Kirillov, Eric Mintun, Nikhila Ravi, Hanzi Mao et al.ICCV 2023 · 13,211 citations
- ViViT: A Video Vision TransformerAnurag Arnab, Mostafa Dehghani, Georg Heigold, Chen Sun et al.ICCV 2021 · 2,947 citations
- CrossViT: Cross-Attention Multi-Scale Vision Transformer for Image ClassificationChun-Fu (Richard) Chen, Quanfu Fan, Rameswar PandaICCV 2021 · 2,072 citations
Related papers
- Semantic Prompt for Few-Shot Image RecognitionCVPR 2023
- Kernel-Aware Graph Prompt Learning for Few-Shot Anomaly DetectionFenfang Tao, Guo-Sen Xie, Fang Zhao, Xiangbo ShuAAAI 2025 · 24 citations
- Self-Prompt Mechanism for Few-Shot Image RecognitionMingchen Song, Huiqiang Wang, Guoqiang ZhongAAAI 2024
- Visual Prompting for Generalized Few-shot Segmentation: A Multi-scale ApproachMir Rayat Imtiaz Hossain, Mennatullah Siam, Leonid Sigal, James J. LittleCVPR 2024
- DSS-Prompt: Dynamic-Static Synergistic Prompting for Few-Shot Class-Incremental LearningLinpu He, Yanan Li, Bingze Li, Elvis Han Cui et al.ACM MM 2025 · 2 citations
