Give your ideas a page of their own.

CoreTeX is an AI LaTeX studio for Mac and the web. Bring your notes, sources and data, watch every step, and leave with the PDF and the editable source.

Invitation beta. Invited accounts get 2,000 free credits.

See CoreTeX work, start to finish.

A real run, then the studio around it. Under a minute, no sound.

The film shows a real CoreTeX run. A prompt asks for a four-page research paper on retrieval-augmented generation. The agent card researches and keeps four arXiv sources, plans the outline, writes 2,787 words, compiles six pages and reviews every page, a run of 4 minutes 22 seconds played back fast. A lab report run shows a compile error fixed with one targeted edit. Then real documents made with CoreTeX: papers, slides, an A2 poster and a certificate. The studio follows: Source and PDF side by side, the References, Outline, Problems and Stats panes, and completion in the Source editor. CoreTeX runs on the Mac and in the browser on Windows and Linux with the same account, runs several generations at once, exports to Word, EPUB, HTML and Markdown, and connects reference folders and MCP servers. It ends with: Write, research and compile in one beautiful studio.

Read what the film shows
  1. A prompt asks for a four-page research paper on retrieval-augmented generation.
  2. The agent researches and keeps four arXiv sources, plans, writes 2,787 words, compiles six pages and reviews each one. The real run took 4 minutes 22 seconds.
  3. In a lab report run, a compile fails at line 136. The agent reads the log and fixes it with one edit.
  4. Papers, slides, a poster and a certificate from real runs, at page sizes from A6 to A0.
  5. The studio on the Mac: Source and PDF side by side, then References, Outline, Problems and Stats, then completion in the Source editor.
  6. The same studio in a browser on Windows or Linux, with one account.
  7. Several runs at once, export to Word, EPUB, HTML and Markdown, and your own sources through a folder or MCP.

Made for you plays the same film built from other real runs: a problem set and slides, a paper, a long-form essay, a lab report and a thesis chapter. The research paper in the film is a test document. Check any draft before you rely on it.

Write, research and compile in one beautiful studio.

Tabs and split panes, research beside your draft, and a PDF that jumps to the line. Try it.

main.texLaTeXCompiled · 2 warnings
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}
Page 2of 3−100%+

3Results

Table 1 compares RGSA with dense attention and two sparse baselines on 16k-token inputs. RGSA improves recall@10 by 5.1 points over dense attention while cutting latency by a factor of 2.9, and the gap widens as documents grow. Ablations are in Appendix ??. Recent hierarchical approaches [?] report similar trends, though at higher memory cost.

Table 1: Recall@10 and latency on 16k-token documents.

MethodRecall@10Latency (ms)
Dense [4]0.712412
Reformer [1]0.698188
BigBird [5]0.704201
RGSA (ours)0.763143

4Conclusion

Letting retrieval decide where attention goes keeps long-document models accurate and fast. Future work will learn the block size jointly with the gate.

References

  1. [1]Nikita Kitaev, Łukasz Kaiser, and Anselm Levskaya. Reformer: The efficient transformer. In International Conference on Learning Representations, 2020.
  2. [2]Vladimir Karpukhin, Barlas Oguz, Sewon Min, et al. Dense passage retrieval for open-domain question answering. In Proceedings of EMNLP, pages 6769–6781, 2020.
  3. [3]Patrick Lewis, Ethan Perez, Aleksandra Piktus, et al. Retrieval-augmented generation for knowledge-intensive NLP tasks. In Advances in Neural Information Processing Systems, 2020.

2

A working recreation of the studio, built from the sample paper the app ships with. Click the tabs, drag the divider, or jump from Outline and Problems to the line.

Every pane is a tab. Any two, side by side.

Open anything from the + picker or the keyboard, and send any tab to the side.

  • New pane⌘T
  • Jump to a tab⌘1
  • Last tab⌘9
  • Open to the side⌥↩

Tools that actually read your LaTeX.

References

What you cite, what you never use, and what is missing.

Outline

Every section, figure and TODO, one click from its line.

Problems

Caught as you type, before your reviewer does.

Stats

Words without the markup, and a goal that keeps you honest.

New in 0.9.17

Explore a sample

Open a finished lab report from the studio's welcome screen, with its PDF, source, files and steps. No account needed.

Never lose a draft

A document is kept the moment it compiles. If the final review finds a layout problem, you choose: use the draft or check the layout again.

Undo a run

Take back everything a run changed in one click. The undo is saved as a new version, so nothing is lost.

Plain facts about your work.

Where it runs

Writing and compiling run on our servers in Norway. An AI model provider processes your prompts and documents to generate the text. On the Mac, each request is sealed to our server's own key.

Your files are yours

You own what you write. Export the PDF and the LaTeX source at any time, and delete documents or request account deletion in settings.

You check the claims

CoreTeX shows its sources and every step, and it can still be wrong. Read the draft and check each source before you share it.

Pay once. Use it when you need it.

Two packs of credits. No subscription, and credits never expire. Purchases open after our payment provider's review.

  • Project3,000 creditsNOK 59.90
  • Studio Pack10,000 creditsNOK 149.90

Bring your notes.Leave with a paper.

An invitation beta with 20 seats. Ask for one in the studio.

Questions? Read the FAQ