Prefix-Tuning for Arbitrary Output Sequences on Pretrained Transformers
Organizations: Huawei Technologies Canada Co., Ltd.
Abstract
Prefix-tuning is a parameter-efficient fine-tuning method for large language models (LLMs) that steers model outputs by prepending task-specific prefix representations to the input sequence. Despite its practical success, the theoretical understanding of the expressiveness of prefixes remains incomplete. In particular, the following question remains open: Given a pretrained autoregressive Transformer, for any input-output sequence pair , does there always exist a prefix such that prepending to induces the model to generate the target output ? In this work, we prove that under the assumption that is in the range of the pretrained Transformer, such a prefix exists and can be explicitly computed by solving multiple linear systems. We further show that this assumption is necessary, in the sense that such a prefix may not exist when the assumption fails, thereby providing a complete answer to the above question. Our analysis is constructive and the obtained theoretical results hold under fairly general assumptions on model architecture. Extensive experiments on GPT-2 and Qwen3-4B demonstrate that our algorithm produces prefixes with strong control over model outputs.
Figures & tables
| Dataset | OutLen | InLen | ||||
|---|---|---|---|---|---|---|
| 5 | 10 | 20 | 50 | 100 | ||
| and | 1 | 1.0000 | 0.9931 | 0.9865 | 0.9804 | 0.9653 |
| 5 | 0.9559 | 0.9857 | 0.9220 | 0.9127 | 0.7812 | |
| 10 | 0.8110 | 0.9722 | 0.9127 | 0.7857 | 0.6710 | |
| but | 1 | 1.0000 | 1.0000 | 1.0000 | 0.9992 | 0.9865 |
| 5 | 1.0000 | 1.0000 | 0.8702 | 0.9355 | 0.9282 | |
| and | but | comma | dot | |
|---|---|---|---|---|
| 0.9977 | 0.9966 | 0.9950 | 0.9968 | |
| 1.0000 | 1.0000 | 1.0000 | 1.0000 |
Appendix figures & tables3 assets
Supplementary material from the paper’s appendix.
Appendix
| InLen | 5 | 10 | 20 | 50 | 100 |
|---|---|---|---|---|---|
| Success Rate | 1.00 | 1.00 | 1.00 | 1.00 | 0.92 |
| Method | Success rate |
|---|---|
| No prefix | 0.0351 |
| Repeated target, | 0.1660 |
| Repeated target, | 0.1700 |
| System prompt, short | 0.5547 |
| System prompt, long | 0.8462 |
| Attention matching (ours), | 0.9966 |