1\documentclass[11pt]{article}
2\usepackage[margin=25mm]{geometry}
3\usepackage{amsmath,amssymb}
4\usepackage{booktabs}
5\usepackage{graphicx}
6\usepackage[numbers]{natbib}
7\usepackage{todonotes}
8\usepackage{hyperref}
9
10\newcommand{\R}{\mathbb{R}}
11\newcommand{\norm}[1]{\left\lVert #1 \right\rVert}
12\newcommand{\method}{RGSA}
13\DeclareMathOperator*{\topk}{top\text{-}k}
14
15\title{Retrieval-Gated Sparse Attention for Long Documents}
16\author{Ada Lindqvist \and Jonas Berg}
17\date{October 2026}
18
19\begin{document}
20\maketitle
21
22\begin{abstract}
23Transformers attend to every token, so their cost grows quadratically with
24document length. We propose \method{}, which lets a lightweight retriever
25choose the blocks each query may attend to. On long-document question
26answering \method{} raises recall while running nearly three times faster
27than dense attention.
28\end{abstract}
29
30\section{Introduction}\label{sec:intro}
31Self-attention~\cite{vaswani2017attention} made sequence models remarkably
32general, but its memory grows with the square of the input. Sparse patterns
33such as hashed buckets and sparse global tokens~\citep{kitaev2020reformer,zaheer2020bigbird}
34reduce the cost, yet they fix in advance which tokens may interact.
35Retrieval-augmented models~\citet{lewis2020rag} take the opposite view and
36fetch what is relevant at run time. We combine the two: Section~\ref{sec:method}
37describes the gate and Section~\ref{sec:results} reports the results.
38\todo{Add a sentence on streaming inputs.}
39
40\section{Method}\label{sec:method}
41Let $X \in \R^{n \times d}$ be the token representations, split into blocks
42of size $b$. A dual encoder~\cite{karpukhin2020dpr} scores every block
43against each query, and attention is restricted to the best $k$ blocks:
44\begin{equation}
45 \operatorname{Attn}(q) = \sum_{j \in \topk(s(q))} \frac{\exp(q^\top k_j)}{Z}\, v_j,
46 \qquad
47 \mathcal{L} = \mathcal{L}_{\text{task}} + \lambda \norm{s}_1 .
48 \label{eq:loss}
49\end{equation}
50The penalty in Equation~\eqref{eq:loss} keeps the gate sparse.
51Figure~\ref{fig:architecture} shows the full pipeline.
52% TODO: report the value of lambda used in every run.
53
54\begin{figure}[t]
55 \centering
56 \fbox{\parbox[c][1.4in][c]{0.8\linewidth}{\centering Retriever $\rightarrow$ gate $\rightarrow$ sparse attention}}
57 \caption{\method{} scores blocks with a retriever, keeps the top $k$, and
58 attends only within them.}
59 \label{fig:architecture}
60\end{figure}
61
62\section{Results}\label{sec:results}
63Table~\ref{tab:results} compares RGSA with dense attention and two sparse
64baselines on 16k-token inputs. RGSA improves recall@10 by 5.1 points over
65dense attention while cutting latency by a factor of 2.9, and the gap
66widens as documents grow. Ablations are in Appendix~\ref{sec:appendix}.
67Recent hierarchical approaches~\cite{guo2025hierarchical} report similar
68trends, though at higher memory cost.
69
70\begin{table}[t]
71 \centering
72 \caption{Recall@10 and latency on 16k-token documents.}
73 \label{tab:results}
74 \begin{tabular}{lcc}
75 \toprule
76 Method & Recall@10 & Latency (ms) \\
77 \midrule
78 Dense~\cite{vaswani2017attention} & 0.712 & 412 \\
79 Reformer~\cite{kitaev2020reformer} & 0.698 & 188 \\
80 BigBird~\cite{zaheer2020bigbird} & 0.704 & 201 \\
81 RGSA (ours) & \textbf{0.763} & \textbf{143} \\
82 \bottomrule
83 \end{tabular}
84\end{table}
85
86\section{Conclusion}\label{sec:conclusion}
87Letting retrieval decide where attention goes keeps long-document models
88accurate and fast. Future work will learn the block size jointly with the gate.
89
90\bibliographystyle{plainnat}
91\bibliography{references}
92\end{document}