Abstract
Adapting large language models (LLMs) to specific tasks is increasingly challenging due to the prevalence of black-box APIs and the high computational cost of fine-tuning. This paper introduces BT-Classifier, a novel framework for few-shot text classification that operates without gradient access. BT-Classifier utilizes a frozen LLM as a feature extractor, specifically pooling hidden states from the [MASK] token across multiple layers. To overcome data scarcity, a smaller "teacher" model is employed to generate high-quality augmented data via prompt-based learning. Experimental results across eight benchmarks demonstrate that BT-Classifier significantly outperforms existing black-box methods and achieves performance comparable to state-of-the-art white-box fine-tuning, while maintaining high computational efficiency.
Introduction
The rapid scaling of language models has shifted the paradigm of NLP towards few-shot adaptation. However, many state-of-the-art models are only accessible via black-box APIs, hiding internal gradients and architectures. Existing adaptation strategies like In-Context Learning (ICL) and Derivative-Free Optimization (DFO) often suffer from instability or extreme computational overhead. Parameter-Efficient Tuning (PET) typically requires "white-box" access. BT-Classifier addresses these limitations by treating the LLM as a static feature extractor and leveraging a small auxiliary model for data augmentation.
Methodology
BT-Classifier follows a two-stage pipeline designed for efficiency and robustness in few-shot scenarios ($K=16$ examples per class).
Feature Extraction
Instead of relying on the standard [CLS] token, BT-Classifier uses prompt templates to elicit task-specific information. The frozen LLM (e.g., RoBERTa-Large) processes inputs containing a [MASK] token. The hidden states corresponding to this token are extracted from the last four layers ($L_{n}$ to $L_{n-3}$) and max-pooled to create a rich semantic representation. This approach captures both syntactic and high-level semantic features more effectively than the final layer alone.
Prompt-Based Data Augmentation
To mitigate the lack of labeled data, a smaller "teacher" model (e.g., DeBERTa-Base) is fine-tuned on the available few-shot samples using prompt-based learning. This teacher model then labels a large pool of unlabeled, in-distribution text. Only pseudo-labels with a confidence score exceeding 90% are retained for training the final classifier. This "small teacher" provides the volume of data necessary for the final classifier to generalize.
Classification
A 2-layer Multi-Layer Perceptron (MLP) is trained on the union of the original labeled set and the high-confidence pseudo-labeled data. This setup ensures stability, as the MLP learns the underlying data distribution rather than being sensitive to specific prompt examples used in ICL.
Experimental Results
The framework was evaluated on eight benchmarks, including single-sentence tasks (TREC, AGNews, Yelp, SST-2) and sentence-pair tasks (MRPC, QQP, QNLI, SNLI).
As shown in the results table, BT-Classifier achieved an average accuracy of 80.3%, a substantial improvement over the previous black-box state-of-the-art, BBTv2 (70.9%). Notably, it matches the performance of LM-BFF, a white-box method that requires full gradient access. The method proved particularly robust on tasks like TREC, where it nearly doubled the performance of competing black-box learners (78.4% vs. ~40%). Furthermore, BT-Classifier is computationally efficient; for the AGNews task, it required only 37 minutes to train compared to 88 minutes for DFO methods.
Conclusion
BT-Classifier demonstrates that high-performance few-shot classification is possible without white-box model access. By combining multi-layer feature extraction from masked prompts with a small-model teacher for data augmentation, the framework provides a stable, efficient, and powerful alternative to existing black-box adaptation methods. Future work will explore the use of general-domain text for augmentation to further reduce dependency on in-domain unlabeled data.
Summary updated