arXiv:2606.27538cs.CLcs.AI2026-06

让Transformer提前带上下文,生成更快、长文本更稳。

The Context-Ready Transformer

  • 用修正网络让每个词在进入块前就带上上下文信息
  • 单层模型比6层标准Transformer快2.6倍,且精度相当
  • 适合需要长上下文和高速推理的场景

我们提出一种新型循环神经网络架构——上下文就绪Transformer,基于D层Transformer块构建。在从左到右生成时,修正网络将前一位置的块输出(即过去上下文的缓存摘要)与当前词嵌入结合,使词以已上下文化的形式进入块。序列化推理下,该修正链使其成为递归神经网络。训练时,将修正过程展开K次,每步并行处理所有位置。预训练Transformer可通过添加零初始化的修正前馈网络并微调转化为上下文就绪模型。在宽度、深度、块大小及两个数据集上进行评估,所有对比均针对标准Transformer及其变体和消融实验。当D=5时,性能优于12层Transformer,且在A100上生成速度提升1.7倍;K=10时,单层模型(D=1)胜过6层Transformer,推理速度提升2.6倍,序列推理与并行K=10仅差0.01困惑度。该架构在宽表示和长上下文中优势最明显。在指针追踪任务中,使用BPTT训练的D=1模型成功解决全部10个组合层级,而标准Transformer表现出阶梯式深度依赖。

原文摘要 · Abstract (English)

We introduce the context-ready transformer, a new recurrent neural network architecture built from a D-layer transformer block that pre-contextualizes each token before it enters the block. During left-to-right generation, a correction network combines the previous position's block output -- a cached summary of past context -- with the current token embedding, so the tokenenters the block already contextualized rather than as a raw embedding. At sequential inference, the correction chain makes the architecture a recurrent neural network. For training, we unroll the correction process K times over the full sequence, processing all positions in parallel at each step. A pretrained transformer can also be converted to a context-ready model by adding a zero-initialized correction FFN and fine-tuning. We evaluate across widths, depths, block sizes, and two datasets, with all comparisons against standard transformers, variants, and ablations. A D=5 model beats a 12-layer transformer while generating 1.7x faster on an A100. With K=10, a single-layermodel (D=1) beats a 6-layer transformer with a 2.6x inference speedup, and sequential inference matches parallel K=10 to within 0.01 PPL. The architecture benefits most from wide representations and long contexts. On a pointer-chasing task, D=1 trained with BPTT solves all 10 composition levels, while standard transformers exhibit staircase-like depth dependence.

Transformer长文本推理加速上下文建模

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。