BoundRL: Efficient Structured Text Segmentation through Reinforced Boundary Generation

Haoyuan Li, Zhengyuan Shen, Sullam Jeoung, Yueyan Chen, Jiayu Li, Qi Zhu, Shuai Wang, Vassilis N. Ioannidis, Huzefa Rangwala · DOI

Abstract

Modern LLM prompts often contain a complex mixture of natural language, code, and structured data like JSON, making precise segmentation a significant challenge. Traditional methods are either computationally expensive due to full-text regeneration or prone to hallucinations. We present BoundRL, a framework that treats segmentation as a boundary generation task. By training models to output only the starting tokens of segments and employing a reinforcement learning strategy with intermediate candidates, BoundRL achieves state-of-the-art performance. Notably, a 1.7B parameter model using BoundRL outperforms frontier models like Claude 4 while reducing inference costs by 90%.

Introduction

The rise of Generative AI has led to increasingly complex structured documents. LLM prompts, for instance, are no longer simple strings but intricate compositions of instructions, few-shot examples, and context data. Segmenting these documents into meaningful parts is crucial for downstream tasks like prompt engineering and safety filtering. However, standard text segmentation techniques fail on non-linear structures like JSON. Direct regeneration of segmented text by LLMs is inefficient, with $O(|d|)$ complexity, and unreliable due to potential hallucinations and text skipping.

The BoundRL Framework

BoundRL introduces a paradigm shift from text regeneration to boundary generation. Instead of outputting the full text of a segment, the model identifies a semantic label and a short sequence of starting tokens for that segment. A deterministic script then reconstructs the full segments by locating these tokens in the original text. This approach reduces the output length from the size of the document $O(|d|)$ to the number of segments $O(n)$.

The BoundRL pipeline: transforming a complex structured document into a segmented output by generating semantic labels and boundary tokens.

Training with Reinforced Boundary Generation

To optimize this process, the authors utilize Reinforcement Learning with Verifiable Rewards (RLVR). Supervised Fine-Tuning (SFT) often struggles with boundary detection because it overly penalizes minor token mismatches that might still successfully locate a boundary. BoundRL uses a dual-objective reward: Reconstruction Fidelity (ensuring the document can be recovered) and Semantic Alignment.

A key innovation is the use of "intermediate candidates." Standard RLVR can suffer from entropy collapse when the gap between the model's random guesses and the ground truth is too large. BoundRL bridges this gap by taking the model's current best guesses and slightly perturbing them (e.g., shifting a boundary or swapping a label) to create learnable stepping stones.

Datasets: The StructSeg Benchmark

The authors introduce StructSeg, a benchmark specifically designed for structured text segmentation. It contains 15.3K annotated LLM prompts:

  • Synthetic Subset: 15,132 prompts generated using Claude 3.5 Sonnet, featuring nested JSON and code.
  • Langchain Subset: 197 real-world prompts from Langchain-hub to test out-of-domain generalization.

Segments are categorized into a taxonomy including Instruction, Example, Context, Question, and Output Format.

Results and Discussion

Evaluation on the StructSeg benchmark demonstrates that BoundRL allows small models to punch far above their weight. A Qwen3-1.7B model achieved an average score of 84.5, significantly surpassing few-shot prompting on Claude-4-Sonnet (68.8). The efficiency gains are equally stark, with a 90% reduction in inference tokens as the model only needs to generate boundary markers rather than the full text.

Performance comparison across different model sizes and boundary prediction strategies. 'SFT w/start' consistently emerges as the most effective configuration.

One of the most surprising insights was that predicting only the starting tokens of a segment is more effective than predicting both start and end tokens. Predicting both imposes a higher learning burden that degrades overall accuracy. Furthermore, the RLVR approach with intermediate candidates yielded a 5-11% absolute improvement in exact match scores on the unseen Langchain prompts compared to standard SFT, proving superior generalization.

Conclusion

BoundRL demonstrates that task framing is as important as model size. By reframing segmentation as a boundary pointing task and using guided reinforcement learning, tiny 1.7B models can outperform frontier LLMs at a fraction of the cost. Future work will explore extending this paradigm to hierarchical document structures and reducing the annotation burden for new domains.

Summary updated

BibTeX
@inproceedings{li2026boundrl,
  author = {Haoyuan Li and Zhengyuan Shen and Sullam Jeoung and Yueyan Chen and Jiayu Li and Qi Zhu and Shuai Wang and Vassilis N. Ioannidis and Huzefa Rangwala},
  title = {{BoundRL: Efficient Structured Text Segmentation through Reinforced Boundary Generation}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2026},
  doi = {10.18653/v1/2026.findings-acl.1733},
}
Figure