Can Large Language Models Handle Numeric Constraints? A Comprehensive Study and Solutions
摘要
Large Language Models (LLMs) perform well in reasoning and generation but often fail to meet explicit numerical constraints, such as fixed word counts or token lengths. This limitation affects tasks like summarization and structured generation but remains underexplored. In this work, we present a systematic study on numerically constrained generation with LLMs, aiming to assess their ability to process and follow quantitative requirements. We introduce a bilingual benchmark in English and Chinese to assess LLMs’ ability to follow seven common types of numerical constraints, from simple to logically complex cases. Evaluation on six LLMs shows that performance drops as constraints become stricter, especially when targeting larger values or specific numerical categories (e.g., 13, non powers of two), revealing controllability gaps. To address this, we explore three strategies: (1) prompt engineering, (2) stepwise generation, and (3) fine-tuning with chain-of-thought data. We release our benchmark and code to support future work on controllable text generation ( https://github.com/hanchen2816/NCGBench ).