Teaching Metric Distance to Discrete Autoregressive Language Models

Jiwan Chung, Saejin Kim, Yongrae Jo, Jaewoo Park, Dongjun Min, Youngjae Yu

TL;DR

Discrete autoregressive language models are increasingly applied to non-textual tasks like robotics, computer vision, and mathematics, but standard cross-entropy training treats all incorrect token predictions as equally wrong. This paper introduces DIST²Loss (DIScreTized DISTance Loss), a distance-aware objective that replaces rigid one-hot targets with smooth, reward-weighted distributions based on predefined token distances. This simple, plug-and-play loss function acts as a stable, closed-form alternative to reinforcement learning, significantly boosting data efficiency and performance across diverse multimodal tasks.

What Problem Does This Paper Address?

Large Language Models (LLMs) are no longer just for text; they are widely adapted to predict bounding boxes in vision, joint angles in robotics, and quantized embeddings in image generation. However, these models are traditionally trained using standard cross-entropy loss against "one-hot" target distributions.

This categorical formulation introduces a major flaw when dealing with metrically structured data: it ignores numerical proximity. For instance, if a robot arm needs to rotate 108 degrees, predicting 109 degrees is penalized just as harshly as predicting 0 degrees. The model completely ignores the intrinsic geometry of the token space. While Reinforcement Learning (RL) can teach models these nuances via distance-based rewards, RL is notoriously unstable, computationally expensive, and requires extensive sampling and rollouts.

Figure 1: Tasks beyond language frequently involve outputs with inherent metric structure, such as quantities or coordinates, highlighting domains where distance modeling could be beneficial.

Methods

The authors propose DIScreTized DISTance Loss (DIST²Loss) to inject metric priors directly into the target distribution.

Instead of forcing the model to match a single correct token, DIST²Loss constructs a soft target distribution over the vocabulary using a discretized exponential family distribution:

$$p_d(v|x, t) = \frac{\exp\left(-\frac{d(v,x,t)}{\tau}\right)}{\sum_{v'\in V_d} \exp\left(-\frac{d(v',x,t)}{\tau}\right)}$$

where $d$ is a task-specific distance metric (such as Euclidean distance for coordinates or cosine distance for high-dimensional embeddings) and $\tau$ is a temperature hyperparameter controlling the distribution's smoothness. The final training objective simply adds this distance-based regularization to the standard cross-entropy loss ($\mathcal{L} = \mathcal{L}_{CE} + \alpha \mathcal{L}_{dist}$).

Conceptually, the authors demonstrate that DIST²Loss is the closed-form solution to entropy-regularized policy optimization. By treating token distances as negative rewards, the optimal policy can be computed analytically in a single forward pass, completely bypassing the need for unstable RL sampling, rollouts, or value networks.

Overview of the DIST²Loss training pipeline.

Datasets

The authors evaluate their method across five distinct domains using established benchmarks:

  1. Toy Regression: A synthetic meta-linear regression task designed to test structural generalization.
  2. Visual Grounding: Combined training sets of RefCOCO, RefCOCO+, and RefCOCOg for bounding box coordinate prediction.
  3. Robotic Manipulation: VIMABench, evaluating robot arm manipulation across various data scales (1K, 10K, 100K samples).
  4. Generative Reward Modeling: The HelpSteer2 dataset for predicting human preference scores, evaluated on RewardBench and MT-Bench.
  5. Image Generation: ImageNet (256×256) using vector-quantized (VQ) tokens from the LlamaGen pipeline.

Key Insights and Ideas

  • RL Benefits Without the RL Pain: Framing distance-aware supervision as a solved RL problem is highly elegant. It provides the alignment benefits of reinforcement learning with known rewards while remaining as stable and fast as standard supervised fine-tuning (SFT).
  • Geometry Dictates Semantics: In high-dimensional spaces like VQ codebooks for image generation, token distance directly correlates with semantic similarity. As shown in the paper's token-replacement experiments, replacing a token with a "close" neighbor preserves image structure, while a "distant" token destroys it. DIST²Loss successfully exploits this intrinsic geometry during training.
  • Potent in Data-Scarce Regimes: The metric prior acts as a powerful regularizer. It is especially effective when training data is limited (e.g., small robotics datasets) because it guides the model away from making catastrophically large errors early in training.
Visualizing how token distance affects image semantics in VQ codebooks.

Key Results

  • Visual Grounding: Fine-tuning a Phi3V model with DIST²Loss achieved performance on par with state-of-the-art models that underwent large-scale pretraining on detection datasets. Hard-case analysis showed that even when predictions were technically incorrect (IoU < 0.5), DIST²Loss outputs remained geometrically much closer to the ground truth than standard SFT.
  • Robotic Manipulation: On VIMABench, DIST²Loss significantly boosted success rates, particularly in the data-scarce 1K sample setting, where L1 protocol accuracy jumped from 49.6% (SFT) to 53.9%.
  • Reward Modeling: Applying DIST²Loss to a Llama-3.1-8B backbone improved RewardBench classification accuracy from 75.3% (SFT) to 85.3%, showing massive gains in the challenging "Chat Hard" and "Safety" domains.
  • Image Generation: On ImageNet, it consistently outperformed the standard SFT baseline, lowering the Frechet Inception Distance (FID) and improving the Inception Score (IS) across both 111M and 343M parameter model variants.

Limitations and Future Work

  • The Credit Assignment Problem: For multi-token sequences (like multi-digit numbers), a global error does not naturally break down into independent token-level contributions. While the authors propose practical workarounds like Place Value Weighting (weighting higher digits more heavily), explicit credit assignment mechanisms for complex multi-token structures remain an open challenge.
  • Extension to Non-Metric Structures: Currently, the loss requires a well-defined metric space. The authors note that extending this framework to non-metric structures, such as hierarchical or relational outputs, is a promising direction for future research.

Summary updated

Abstract

Large language models (LLMs) operate as autoregressive predictors over discrete token vocabularies, a formulation that has enabled their adaptation far beyond natural language to vision, robotics, and multimodal reasoning. However, training against one-hot targets disregards metric relationships between tokens and limits effectiveness on tasks where distance is meaningful, such as numerical values, spatial coordinates, or quantized embeddings. We introduce DIST2Loss, a distance-aware objective for discrete autoregressive models that replaces one-hot targets with reward-weighted distributions derived from predefined token distances. DIST2Loss can be interpreted as the closed-form solution to entropy-regularized policy optimization with known per-token rewards, retaining the core mechanism of reinforcement learning while avoiding sampling, rollouts, and instability. Our experiments show that DIST2Loss improves data efficiency and downstream performance across diverse domains. It yields tighter bounding boxes in visual grounding, accelerates robotic manipulation by improving action learning, enhances reward modeling for LLM alignment, and strengthens vector-quantized image generation. These results demonstrate that distance-aware supervision offers a simple and general alternative to one-hot supervision for discrete autoregressive models.
BibTeX
@inproceedings{chung2026teaching,
  author = {Jiwan Chung and Saejin Kim and Yongrae Jo and Jaewoo Park and Dongjun Min and Youngjae Yu},
  title = {{Teaching Metric Distance to Discrete Autoregressive Language Models}},
  booktitle = {International Conference on Learning Representations},
  year = {2026},
  url = {https://openreview.net/forum?id=s0zLtkY7iu},
}
Figure