Introduction
While Large Language Models (LLMs) have shown remarkable progress in logical and mathematical reasoning through Reinforcement Learning with Verifiable Rewards (RLVR), they often falter when faced with NP-hard optimization problems. This paper introduces NP-ENGINE, a framework designed to generate verifiable NP-hard problems for training LLMs. The resulting 7B-parameter model, QWEN2.5-7B-NP, not only achieves state-of-the-art performance on complex optimization tasks—surpassing even GPT-4o—but also demonstrates significant out-of-domain generalization to general math, logic, and instruction-following benchmarks.
The Challenge of Optimization Reasoning
Recent breakthroughs in LLM reasoning, such as OpenAI's o1 or DeepSeek-R1, rely heavily on RLVR. This training paradigm uses objective, automatically verifiable answers to provide reward signals. However, most current RLVR applications focus on feasibility—finding any valid answer.
In contrast, many real-world challenges are NP-hard, such as the Traveling Salesman Problem or resource scheduling. For these tasks, simply finding a valid solution is insufficient; the goal is to find the most optimal solution among a vast search space. Existing benchmarks for these problems are often static and lack the tunable difficulty or fine-grained optimal solutions required to provide a continuous reward signal during RL training.
The NP-ENGINE Framework
To bridge this gap, the authors developed NP-ENGINE, a framework encompassing 10 distinct NP-hard tasks across five domains: Graph Clustering, Resource Scheduling, Graph Partitioning, Subset Selection, and Path Planning.
Each task in the engine is supported by a three-part pipeline:
- Controllable Instance Generator: Procedurally creates problems with adjustable difficulty levels.
- Rule-Based Verifier: Automatically validates the model's output against formatting and rule constraints.
- Heuristic Solver: Provides an "approximate optimal" solution to serve as a ground-truth baseline, as finding absolute optima for NP-hard problems is often computationally prohibitive.
Training Methodology: Curriculum and Multi-Stage RL
The researchers fine-tuned Qwen2.5-7B-Instruct using zero-shot RLVR via the Group Relative Policy Optimization (GRPO) algorithm. The reward function was designed to evaluate three criteria: format, feasibility, and optimality (proximity to the heuristic solver's score).
Two key strategies were employed to ensure effective learning:
- Curriculum Learning: The model was initially trained on simple problem instances, with complexity gradually increasing. This prevents sparse rewards and allows the model to bootstrap its reasoning capabilities.
- Multi-Stage RL: Training occurred across all 10 tasks simultaneously in stages, ensuring the model maintained a broad skill set without forgetting or confusing task-specific rules.
Results and Generalization
The performance gains were substantial. On the newly introduced NP-BENCH, QWEN2.5-7B-NP saw its Success Rate (SR) jump from 29.6% (base model) to 93.1%. Its Average Ratio (AR) of optimality increased from 14.6 to 46.6, outperforming GPT-4o (SR: 62.1%, AR: 36.2%).
Beyond optimization, the model showed surprising Out-of-Domain (OOD) Generalization. Despite receiving no specific training in math or logic during the RLVR phase, the model's scores on benchmarks like IFEval and GPQA rose significantly. This suggests that the "deep thinking" required for optimization serves as a gateway to more generalized reasoning capabilities.
Conclusion
NP-ENGINE demonstrates that training LLMs on a diverse set of verifiable, high-complexity optimization problems can significantly enhance both specialized and general reasoning. While currently limited to 10 tasks and a 7B parameter scale, the framework provides a scalable path toward more robust and capable AI systems. Future work will explore larger model sizes and an even broader array of NP-hard challenges.
Summary updated