[Paper Review] Beyond Linearity in Attention Projections: The Case for Nonlinear Queries
The paper replaces the linear Query projection with a nonlinear residual Q(X) = (X + f_theta(X)) / 2, anchored by the identity, and shows improved validation loss over baselines at similar parameter counts on GPT-3 small style models, outperforming a model with 12.5% more non-embedding parameters.
Recent algebraic analysis shows that in decoder-only and encoder-only transformers, the Query projection $W_Q$ may be set to identity without noticeable performance deterioration. This is possible because attention depends on $X$ only through the products $XW_Q, XW_K, XW_V$, allowing basis transformations to be absorbed by adjacent layers and propagated through the network. We replace $W_Q \in \mathbb{R}^{d imes d}$ with a nonlinear residual of the form $Q(X) = X + f_θ(X)$, where $f_θ$ is a bottleneck MLP with $d^2 + O(d)$ parameters. The identity term anchors the nonlinearity to a known-good prior. Experiments on GPT-3 small style models show consistent improvement over the baseline, comfortably outperforming a model with 12.5% more non-embedding parameters. These results motivate investigation at larger scales and across modalities.
Motivation & Objective
- Motivate why linear Q is algebraically redundant in attention and explore whether a nonlinear, residual query can improve expressivity without increasing embedding parameters.
- Propose a concrete nonlinear query design with a bottleneck MLP that preserves stability via an identity anchor.
- Evaluate the approach on a GPT-3 small style setup to establish performance, stability, and parameter-efficiency.
- Discuss implications for scaling, training dynamics, and potential extensions to other attention variants and modalities.
Proposed method
- Replace the query projection with a nonlinear residual: Q(X) = (X + f_theta(X)) / 2, where f_theta is a bottleneck MLP with d^2 + O(d) parameters.
- Implement f_theta as: f_theta(X) = LN(GELU(RMSNorm(X)W1)W2) with W1 in R^{d x r}, W2 in R^{r x d}, and r = d/2.
- Maintain standard linear projections for Keys and Values; use the same attention logits scaling (QK^T / sqrt(d_k)).
- Anchor the nonlinearity to the identity prior to preserve gradient flow and stability (as per prior work suggesting W_Q = I is effective).
- Parametric budget: total parameters for QKV part equal to 2 d r = d^2; normalization layers add O(d) parameters (<0.1% overhead).
- Exploration of normalization variants is acknowledged; stability considerations motivated by identity anchoring.

Experimental results
Research questions
- RQ1Does a nonlinear query projection improve validation loss compared to a baseline with linear Q?
- RQ2Is the nonlinear Q architecture more stable to weight decay and metric choices than the baseline?
- RQ3How does the nonlinear query perform relative to a parameter-equivalent but capacity-increasing (MLP-widened) model?
- RQ4Are the gains robust under extended training beyond common optimization budgets, and at different learning rates/decays?
Key findings
- Nonlinear query achieves consistently lower validation loss than baseline and a widened MLP control.
- At step 59k, validation loss is 2.915 for nonlinear Q versus 2.956 baseline and 2.927/2.928 for MLP variants, corresponding to 1.40% and ~1.24–0.94% relative improvements respectively.
- The nonlinear Q model comfortably outperforms a model with 12.5% more non-embedding parameters.
- The nonlinear variant trains stably at weight decay 2^-5 (~0.03125) with learning rates up to 3e-3, whereas baseline diverges with higher weight decay.
- Best results occur with reduced weight decay and higher learning rate, suggesting implicit regularization from the identity anchor.
- Training dynamics show initial gains that stabilize and then reappear in the final phase.

Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.