Manuscript Offprint

arXiv:2610.12545

AutoIndexer: Flexible-Order Decoding by Training Causal Models on Chains of Edits

Shu Ishida, Aliasghar Khani, Tianyu Zhang, The Cong Luong, James Seale Smith, Adam Gaier

Abstract

Autoregressive decoding is less suited to non-causally ordered data, e.g., cross-references or future dependencies, since their outputs cannot be revised post hoc, unlike iterative human reasoning. Diffusion LLMs partially mitigate this limitation but still cannot flexibly insert or remove arbitrary numbers of tokens from a pre-generated context. We design AutoIndexer as a generative model with a novel training and decoding mechanism that simulates a Chain of Edits, allowing the model to flexibly modify its prior outputs in hindsight via token insertions, substitutions, and deletions. The model learns to predict marker tokens for opening and closing edits, simultaneously moving a cursor to positions in the existing token sequence, analogous to a text editor. Training sequences are obtained by perturbing ground-truth labels with inverse chained edit operations, and the model learns to edit by undoing those inverses. The perturbation training allows AutoIndexer to be robust to erroneous context and adaptable to editing tasks such as code correction. We demonstrate that our method exhibits post-generation context-editing capabilities that most autoregressive and diffusion models lack without compromising performance on standard LLM benchmarks. The code is available at https://github.com/AutodeskAILab/autoindexer.

Figure

Figure 1: Overview of the AutoIndexer method. Analogous to using a text editor, AutoIndexer can edit its prior outputs by predicting edit-start/-end cursor positions. The positional encodings of the tokens are modified after each edit and efficiently computed by our specialized attention kernel.

40th Conference on Neural Information Processing Systems (NeurIPS 2026). Workshop: BeNTo: Beyond Next-Token Prediction – Diffusion & Flow Models for Next-Generation Decoding.

1 Introduction

Generative sequential models such as Large Language Models (LLMs) [1–5] have typically been trained autoregressively, due to the ease of formulating a generative task as a next-token prediction problem, and parallelizing the learning of its conditional probability distribution.

Autoregressive modeling is most effective when the order in which the data is presented is aligned with the direction of causality. However, not all tasks align well with autoregressive generation. For example, LLMs struggle to generate a large document with self-consistent reference sections, chapters, and word count for blocks of text. These references and numbers should be determined after the majority of the text has been generated, but because of the autoregressive constraint, the model may have to choose a section number arbitrarily and then later have to force the word count or numbers of sections to fit the requirement. A related challenge is the difficulty of modifying or improving generated outputs. A useful ability for a generative model would be to insert, edit, or delete text with ease, as one would do with a text editor. This would also allow for a more hierarchical generation, where the model can first output an outline of the solution as some form of high-level blueprint, summary, or bullet points, and then edit and refine the details to obtain the final solution.

This motivates a decoding mechanism that is more flexible and allows amendments in hindsight. A recent surge in work on discrete diffusion [6–8] attempts to address this shortcoming as an iterative token demasking and correction task. However, there are several limitations to this approach. First, most diffusion architectures generate a fixed-length output, which is not effective for applications such as chat systems, where model generations are of arbitrary length. Second, discrete diffusion regenerates the entire text using a bi-directional encoder, which cannot reuse previous computations with KV caching, making inference less efficient. Third, even though the token-correction mechanism could allow modifications to previously generated output, having a fixed position for each token prevents insertion or deletion of arbitrary numbers of tokens. Block diffusion [9] combines autoregressive generation with block-wise discrete diffusion, alleviating the first two issues. However, such approaches are still constrained by the absolute positions at which tokens were generated.

We postulate that the limiting factor in existing work is that they do not distinguish between the generated positions and the display positions of tokens when they apply positional encoding. By decoupling these two positions, the model can generate tokens in a flexible order that is then parsed and reordered into the display order. In this work, we propose a novel training paradigm, which applies a set of inverse edit operations to the target sequence, and train the model to undo the inverse edit operations, effectively making the model learn to edit and refine the context that it generated. This is analogous to diffusion training, in which the model is trained to undo a noising operation.

The uniqueness of our method is that the model reassigns a new set of positional encodings to tokens in the context according to the display order during and after each edit, as opposed to the generated order. The model can perform operations such as insertion, editing, and deletion to manipulate existing outputs in a similar way to how we write documents using a text editor. Once tokens are substituted or deleted, they are also masked out so that the model only sees the tokens currently in context in the display order during further generation. Therefore, the underlying model is still autoregressive in its generation order, retaining its benefits such as KV-caching and early stopping of generation via an End-of-Sequence token [EOS], but can be non-autoregressive in the display order.

We name the method AutoIndexer because it learns to propose the positions in the context for editing. AutoIndexer has a marker head to determine the timing of the edit, and a cursor head that predicts the edit cursor positions, in addition to the vocabulary token head. This is in contrast to Fill-in-the-Middle (FIM) [10], where the section to be edited is given, both during training and at inference.

RAW <h4 className="col-12 col-md-12 my-3 mx-auto contact-t <<...>> question or are you a hairstylist looking to join us?</h4>... [EDIT 61,61] itles">Do you have a [RETURN] ... PARSED <h4 className="col-12 col-md-12 my-3 mx-auto contact-titles">Do you have a question or are you a hairstylist looking to join us?</h4>

Figure 2: Example of a successful edit by AutoIndexer. It opens an edit at position [61, 61), inserts the missing text, and returns to continue generation. «<...>> is where the omission of the prompt took place (omission location is not disclosed to the model). More examples in Appendix A.7.2.

Table 1: Comparison between decoding strategies of transformers.

AutoregressiveDiscrete DiffusionChain of Edits (Ours)
Generation order of tokensAutoregressiveNon-autoregressiveAutoregressive
Display order of tokensFixed-orderFixed-orderDecoupled (flexible)
Prediction targetNext tokenToken demaskingUndo perturbation
KV-cachingExactApproximateExact
Amendable contextNoLimitedYes

Our contributions are the following: (a) Active Context Refinement: a model that can modify its output in any order without length constraints, by making it decide when and where an edit is required and move a cursor to any position in the sequence, unlike Fill-in-the-Middle [10] where the edit span is given externally; (b) Perturbation training: a self-supervised learning paradigm to teach the model to edit by perturbing each ground-truth sequence with randomly sampled inverse edit operations, and training the model to autoregressively undo this perturbation, analogous to a diffusion objective but over discrete edit inverses rather than noise; (c) Fused Kernel with Chain-of-Edits RoPE: an attention kernel that computes the relative positional encodings using RoPE [11] but for multiple edits in one forward pass for training efficiency, informing the model of the updated token positions after each edit operation; and (d) Sequence Parser: a parser that converts the model's generation with multiple edit operations back to display order.

References (48)