Black-Box Tuning for Language-Model-as-a-Service
Tianxiang Sun Yunfan Shao Hong Qian Xuanjing Huang Xipeng Qiu
Abstract
Extremely large pre-trained language models (PTMs) such as GPT-3 are usually released as a service. It allows users to design task-specific prompts to query the PTMs through some black-box APIs. In such a scenario, which we call Language-Model-as-a-Service (LMaaS), the gradients of PTMs are usually unavailable. Can we optimize the task prompts by only accessing the model inference APIs? This paper proposes the black-box tuning framework to optimize the continuous prompt prepended to the input text via derivative-free optimization. Instead of optimizing in the original high-dimensional prompt space, which is intractable for traditional derivative-free optimization, we perform optimization in a randomly generated subspace due to the low intrinsic dimensionality of large PTMs. The experimental results show that the black-box tuning with RoBERTa on a few labeled samples not only significantly outperforms manual prompt and GPT-3’s in-context learning, but also surpasses the gradient-based counterparts, i.e., prompt tuning and full model tuning.
中文速览
大型预训练语言模型(如GPT-3)通常以API服务形式对外开放,用户无法获取模型参数和梯度,只能通过手工设计提示词来使用,这严重限制了对标注数据的利用效率。为此,论文提出了"黑盒调优"(Black-Box Tuning, BBT)框架:在模型输入前拼接一段连续的提示向量,通过随机线性投影将其映射到一个低维子空间,再用无需梯度的进化算法(CMA-ES)在该子空间内迭代优化,从而绕开反向传播的限制。实验表明,仅凭少量标注样本,BBT在多个语言理解任务上不仅大幅超越手工提示和GPT-3的上下文学习,甚至优于需要梯度的提示微调和全量模型微调方法。这项工作的意义在于,它让普通用户在没有GPU、无法访问模型内部的情况下,也能高效地把大模型"调教"成自己需要的样子,为"语言模型即服务"场景下的个性化适配开辟了新路径。
原文 arXiv:2201.03514;中英对照 + 大白话阅读 https://aha.fim.ai/paper/2201.03514v4