Improving Constrained Generation in Language Models via Self-Distilled Twisted Sequential Monte Carlo

Sooyeon Kim, Giung Nam, Juho LeearXiv 2025 · DOI

Introduction

Large Language Models (LLMs) are primarily trained for causal modeling, predicting the next token based on a preceding sequence. However, real-world applications often demand constrained generation, where outputs must satisfy specific non-causal properties, such as adhering to a particular format or avoiding toxic content. A significant challenge in this domain is the "sparse reward" problem: if a base model rarely generates text that meets a constraint, traditional sampling methods like Sequential Monte Carlo (SMC) struggle to find valid sequences.

This paper introduces Self-Distilled Twisted Sequential Monte Carlo (TSMC), a framework designed to navigate these sparse landscapes by iteratively aligning the base model with the desired constraints through self-distillation.

Methodology

The authors build upon Twisted Sequential Monte Carlo, which utilizes a "twist function" (a look-ahead heuristic) to steer the generation process. The core innovation is an iterative loop consisting of two phases:

  1. Self-Distillation: The base language model is fine-tuned on successful samples that satisfy the constraint. This "nudges" the model's natural distribution toward the target, making subsequent steering easier.
  2. Modified Contrastive Twist Learning (CTL): As the base model evolves, the twist function is updated to maintain alignment, ensuring the steering mechanism remains effective for the refined model.

By repeating this process, the base model and the twist function co-evolve, significantly improving the efficiency and quality of the target distribution sampling.

Experimental Results

The researchers evaluated the method using a TinyStories-33M model and a ToxicityModel constraint, aiming to force a wholesome model to generate toxic stories.

Superior Performance Trade-offs

In evaluations comparing toxicity (the constraint) against semantic similarity to the base model, the self-distilled TSMC (at iteration $m=2$) demonstrated superior performance. As seen in the Similarity-Toxicity analysis, the method reaches the favorable upper-left region of the plot, outperforming established alignment techniques such as Direct Preference Optimization (DPO) and GRPO.

Toxicity vs. Similarity trade-off for various alignment methods.

Particle Efficiency

A major bottleneck in SMC methods is the number of "particles" (parallel paths) required for successful generation. Self-distillation drastically reduces this requirement. The $m=2$ iteration achieves higher toxicity with just 20-50 particles than the original $m=0$ model could achieve with 1,000 particles, representing a significant gain in computational efficiency.

Toxicity levels achieved relative to the number of particles used during sampling.

Conclusion

Self-Distilled TSMC effectively bridges the gap between misaligned base models and complex generation constraints. By distilling the model's own successes, the steering task becomes simpler, allowing for the use of lightweight MLP twist functions without sacrificing performance. Future research will focus on scaling this iterative refinement to larger models and more diverse, structurally complex constraints.

Summary updated

BibTeX
@misc{kim2025improving,
  author = {Sooyeon Kim and Giung Nam and Juho Lee},
  title = {{Improving Constrained Generation in Language Models via Self-Distilled Twisted Sequential Monte Carlo}},
  year = {2025},
  eprint = {2507.02315},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2507.02315},
}
Figure