XLM: A Python package for non-autoregressive language models

Dhruvesh Patel, Durga Prasad Maram, Sai Sreenivas Chintha, Benjamin Rozonoyer, Andrew McCallum · DOI

Abstract

Non-autoregressive language models (NARLMs) offer promising alternatives to standard autoregressive models, particularly for tasks requiring fast inference or complex planning. However, the lack of standardized tooling has led to a fragmented research landscape with incompatible codebases. We introduce XLM, a modular Python framework built on PyTorch Lightning and Hydra, designed to unify the implementation and evaluation of diverse NARLM architectures. By decoupling model logic from execution harnesses, XLM enables reproducible research and fair benchmarking across diffusion, insertion, and masked language models.

Introduction

In contemporary natural language processing, Autoregressive Language Models (ARLMs) serve as the dominant paradigm, supported by mature libraries like Hugging Face transformers. While ARLMs excel at sequential prediction, there is growing interest in Non-Autoregressive Language Models (NARLMs) that generate text through parallel refinement, arbitrary insertion, or iterative editing. These models potentially offer faster inference and superior performance on structured tasks like path-finding.

Despite their potential, NARLM research suffers from a "wild west" of bespoke implementations. Each new paper often introduces a hard-coded codebase where data loading, loss functions, and prediction logic are tightly coupled, making "apples-to-apples" comparisons nearly impossible. XLM addresses this by providing a unified, modular architecture that allows researchers to share and compare components without rewriting boilerplate code.

Framework Design and Methods

The XLM library, xlm-core, is built upon three primary pillars: PyTorch for core deep learning, PyTorch Lightning for structured training workflows, and Hydra for hierarchical configuration management. The framework adheres to several key design principles to ensure flexibility and maintainability:

  • Composition over Inheritance: Rather than complex class hierarchies, XLM utilizes a "Harness" that plugs in specific Model, LossFunction, and Predictor components. This allows users to swap loss functions or model heads via configuration files without modifying Python source code.
  • Maximal Independence: Each model implementation is isolated within its own directory, preventing cross-model dependencies and "spaghetti code."
  • Scaffolding Workflow: To lower the barrier to entry, the library includes an xlm-scaffold command that automatically generates the necessary directory structure and template files for new experiments.
The XLM framework architecture, highlighting the separation between the DataModule, the execution Harness, and the configuration-driven Trainer.

By leveraging Hydra's ability to instantiate Python classes directly from YAML files, XLM moves the complexity of model setup out of the scripts and into readable, versionable configurations. This approach ensures that experiments are both highly flexible and easily reproducible.

Evaluation and Datasets

To demonstrate the utility of the framework, we evaluated several state-of-the-art NARLMs across synthetic and natural language benchmarks:

  1. Star Graphs (StarEasy, StarMedium, StarHard): Synthetic path-finding tasks designed to test a model's ability to maintain global structure and plan sequences.
  2. LM1B (One Billion Word Benchmark): A standard large-scale news corpus used for general unconditional language modeling.
  3. OpenWebText: Used for evaluating the performance of smaller-scale language models.

Key Results

The XLM framework successfully reproduced results for several prominent architectures, including Masked Diffusion (MDLM), Masked Language Models (MLM), and Insertion Language Models (ILM). Implementations within XLM matched original reported results within a 2% margin, validating the framework's robustness.

Comparison of Negative Log-Likelihood (NLL) and Entropy across different NARLM architectures (MDLM, ILM) and standard ARLM on a unified benchmark.

In planning-intensive tasks like the "Hard" Star Graph benchmark, the Insertion Language Model (ILM) significantly outperformed standard ARLMs, achieving 97.5% sequence accuracy compared to the ARLM's 25.2%. Furthermore, XLM enabled the first direct comparison of metrics like negative log-likelihood and entropy across these disparate architectures on identical datasets, a task that previously required significant engineering effort.

Limitations and Future Work

Currently, XLM is optimized for research on relatively small-scale non-autoregressive models. Scaling these techniques to multi-billion parameter models remains an open challenge for the field. Future development of the library will focus on:

  • Expanding Modalities: Adding support for non-textual sequences, such as molecule generation.
  • Advanced Architectures: Integrating newer methods like "Edit Flows."
  • Performance Optimization: Utilizing FlexAttention (introduced in PyTorch 2.5) to accelerate the irregular attention patterns common in NARLM generation.

By standardizing the non-standard, XLM provides a foundation for the next generation of language modeling research.

Summary updated

BibTeX
@inproceedings{patel2026xlm,
  author = {Dhruvesh Patel and Durga Prasad Maram and Sai Sreenivas Chintha and Benjamin Rozonoyer and Andrew McCallum},
  title = {{XLM: A Python package for non-autoregressive language models}},
  booktitle = {EACL (System Demonstrations)},
  year = {2026},
  doi = {10.18653/v1/2026.eacl-demo.31},
}
Figure