LSRIF: Logic-Structured Reinforcement Learning for Instruction Following

Qingyu Ren, Qianyu He, Jingwen Chang, Jie Zeng, Jiaqing Liang, Yanghua Xiao, Han Xia, Zeye Sun, Fei Yu · DOI

Abstract

Instruction-following is critical for large language models, but real-world instructions often contain logical structures such as sequential dependencies and conditional branching. Existing methods typically construct datasets with parallel constraints and optimize average rewards, ignoring logical dependencies and yielding noisy signals. We propose a logic-structured training framework LSRIF that explicitly models instruction logic. We first construct a dataset LSRInstruct with constraint structures such as parallel, sequential, and conditional types, and then design structure-aware rewarding method LSRIF including average aggregation for parallel structures, failure-penalty propagation for sequential structures, and selective rewards for conditional branches. Experiments show LSRIF brings significant improvements in instruction-following (in-domain and out-of-domain) and general reasoning. Analysis reveals that learning with explicit logic structures brings parameter updates in attention layers and sharpens token-level attention to constraints and logical operators.

The Challenge of Logical Instructions

Most current instruction-following research treats user prompts as a "flat" list of independent constraints. For example, if a prompt asks for a summary in 50 words and no commas, models are typically rewarded based on the average success of those two parallel tasks. However, real-world instructions are rarely that simple. They often involve complex logical dependencies that current Reinforcement Learning (RL) methods struggle to capture.

Decomposing a complex instruction into its constituent constraints and logical operators.

As illustrated above, a single complex instruction can be decomposed into specific constraints (e.g., length limits, formatting) and the logical connectors that bind them (e.g., "First," "Then," "If/Else"). When models are trained using simple average rewards, a failure in an early step of a sequence makes the reward for subsequent steps "noisy" or irrelevant, leading to a breakdown in logical execution.

The LSRIF Framework

To address these limitations, we propose the LSRIF framework, which explicitly models instruction logic through two main pillars: structured data and structure-aware rewards.

LSRINSTRUCT Dataset

We constructed a training set of approximately 38,000 instructions, seeded from sources like Infinity-Instruct and Open Assistant. Unlike standard datasets, LSRINSTRUCT explicitly tags each prompt with its logical structure: Parallel (And), Sequential (First-Then), and Conditional (If-Else).

Structure-Aware Reward Modeling (LSRM)

Instead of simple averaging, we designed reward functions that mirror logical execution pathways:

The LSRIF reward modeling strategies: Average Aggregation, Penalty Propagation, and Branch Selection.
  • Average Aggregation: Used for parallel tasks where constraints are independent.
  • Penalty Propagation: For sequential dependencies, if an early step fails, a "decay coefficient" ($\gamma$) penalizes the rewards of all subsequent steps. This forces the model to prioritize getting the foundational steps right.
  • Branch Selection: For conditional logic, the reward is calculated only for the branch the model was intended to follow, effectively ignoring irrelevant branches and reducing signal noise.

Experimental Results

The performance boosts provided by LSRIF were substantial across various model sizes, ranging from 1.5B to 14B parameters. On the IFEval benchmark, the Qwen2.5-1.5B-Instruct model saw a massive +25.2 point increase. Notably, a Qwen3-8B model trained with LSRIF reached a score of 90.2, outperforming GPT-4o (84.8) on this specific benchmark.

Beyond instruction following, the framework significantly improved general reasoning. On the Enigmata benchmark (a suite of 36 logical and mathematical tasks), a Distill-Qwen-7B model improved its arithmetic score from 3.7 to 14.3—nearly a fourfold improvement. This suggests that instruction following and logical reasoning are deeply linked; teaching a model to follow structured instructions inherently improves its ability to process logic.

Interpretability and Analysis

Our analysis revealed that LSRIF training primarily updates the attention layers (specifically Query and Key projections) rather than the MLP layers. Post-training, models exhibited "sharper" token-level attention, learning to pay significantly more attention to logical connectors (like "if," "else," and "finally") and specific constraint keywords (like "bullet" or "lowercase").

Furthermore, the models demonstrated strong generalization capabilities, showing improved performance on "nested" structures (logic within logic) that were not present in the initial training data. This indicates that the models are learning the underlying principles of logical execution rather than just memorizing patterns.

Conclusion

LSRIF demonstrates that explicitly modeling the logical structure of instructions is a powerful lever for improving LLM performance. By moving away from "flat" reward signals and toward structure-aware reinforcement learning, we can develop models that are not only better at following complex human instructions but also more capable at general logical reasoning.

Summary updated

BibTeX
@misc{ren2026lsrif,
  author = {Qingyu Ren and Qianyu He and Jingwen Chang and Jie Zeng and Jiaqing Liang and Yanghua Xiao and Han Xia and Zeye Sun and Fei Yu},
  title = {{LSRIF: Logic-Structured Reinforcement Learning for Instruction Following}},
  year = {2026},
  eprint = {2601.06431},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2601.06431},
}
Figure