Gene Cooperman
Author directory2026
Long-Context Demonstration Selection Using State Space Models
Ziniu Zhang | Zhenshuo Zhang | Ruoxuan Xiong | Gene Cooperman | Hongyang R. Zhang
Findings of the Association for Computational Linguistics: EMNLP 2026
Ziniu Zhang | Zhenshuo Zhang | Ruoxuan Xiong | Gene Cooperman | Hongyang R. Zhang
Findings of the Association for Computational Linguistics: EMNLP 2026
We study the problem of demonstration selection, which involves selecting a subset of examples for pre-pending to a query to a language model. This problem is closely related to in-context learning and model inference. Since the inference cost of a transformer model scales quadratically with sequence length, the selection problem becomes especially challenging in a long-context scenario. In this paper, we tackle this problem by building on state space models (SSMs), which has linear inference time given the input embeddings. Our approach works in two stages. First, we learn a small set of SSMs through a distillation procedure — given a (trained) transformer model, we partition all the layers into consecutive (layer) groups — for each group, we learn one SSM to mimic the input-output behavior, thereby capturing structural similarity in adjacent layers. Second, we map the SSM outputs to a small set of tokens, and apply them for downstream demonstration selection. We run extensive experiments in both synthetic and real-world datasets to validate this approach. We show that the SSMs trained from distillation incur a relative approximation error of less than 0.7%. As for downstream demonstration selection, we find that on several text classification and reasoning tasks, our approach reduces FLOPs by 14.2× and improves accuracy by 6.48% relative to baseline selection methods.