Manuscript Offprint

arXiv:2611.07749

ConvPE: Convolutional Position Embedding Improves Transformers

Zehao Wang

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

ABSTRACT

ConvPE (Convolutional Position Embedding) improves both the performance and efficiency of Transformer models in language modeling, long-context extension, and vision. It injects a windowed, content-dependent bias into attention scores through a lightweight causal convolution over a low-dimensional projection of the hidden states. As a lightweight plug-in, ConvPE is compatible with RoPE, attention masks, and KV concatenation. It also supports high-dimensional position embeddings via high-dimensional convolutions. In a reproduction, ConvPE outperforms five 1D baselines and eight 2D baselines. The code is publicly available at https://github.com/wzhagi/convpe.

Keywords Position Embedding · Language Models · Transformers · Attention · Vision Transformers

1 Introduction

Transformers¹ are insensitive to input order, whereas word order is crucial for language understanding and the spatial layout of image patches matters for vision. Explicit or implicit position embeddings are therefore needed to inject order information into the model²,³,⁴. How this information is injected affects accuracy as the context length grows.

Position information is currently injected at one of three points. First, absolute position embeddings, whether fixed or learnable, add a position vector to token representations¹,²,³. Second, rotary position embedding (RoPE)⁴ rotates queries and keys so that attention scores depend on relative distance; RoPE has been widely adopted in modern large language models. Extending these methods to longer contexts requires interpolation or frequency rescaling⁵. Third, attention-score-bias methods add a term directly to the score matrix: ALiBi⁶ uses a fixed linear decay but performs worse on downstream tasks as the context length increases⁷. CABLE⁸ learns to modulate a fixed distance-penalty skeleton. The Composite method⁹ adds convolution-based relative-position terms similar to ours but performs worse. DAPE¹⁰ convolves the full score map, which is effective but incurs high computational overhead.

ConvPE follows this score-bias route and generates the bias locally. It applies a causal convolution to the hidden state projections and adds the resulting windowed bias directly to the attention scores. Beyond the window the bias is exactly

zero, following NoPE methods⁷, so distant keys are not penalized by construction. As a lightweight plug-in, ConvPE is compatible with RoPE, attention masks, and KV concatenation. It also supports high-dimensional position embedding through high-dimensional convolutions.

We evaluate ConvPE on language-model pretraining, downstream evaluation, long-context extension, and image classification. Figure 1 summarizes the relative changes with respect to the RoPE baseline. Compared with RoPE,

Figure

Figure 1: ConvPE relative to the RoPE baseline (dashed line at 1.0). Blue bars are lower-is-better metrics; green bars are higher-is-better metrics.

ConvPE achieves lower training and validation perplexity and higher benchmark accuracy, with minimal additional parameters and computational overhead. It reaches the baseline's final loss using fewer training tokens and less wall-clock time. After context-extension training to 8K tokens, the gap widens. As a plug-in, it also improves pretrained RoPE models during context-extension training. This demonstrates the potential of ConvPE for long-context language modeling. In vision, ConvPE2D improves CIFAR-100 accuracy over eight baselines.

The main contributions of this paper are as follows:

  • We propose ConvPE, a convolutional attention-score-bias position embedding that combines strong performance with broad compatibility.

  • We study the influence of ConvPE hyperparameters and architecture choices, identifying a simple default configuration with a favorable performance-efficiency balance.

  • We demonstrate that ConvPE improves training efficiency, token efficiency, and long-context extrapolation in language models.

  • We verify the effectiveness of ConvPE2D in vision transformers on CIFAR-10 and CIFAR-100.

  • We develop high-performance TileLang 11^{11} kernels for ConvPE.

References (35)