Compact Constraint Encoding for LLM Code Generation: An Empirical Study of Token Economics and Constraint Compliance

๐Ÿ“… 2026-04-08
๐Ÿ“ˆ Citations: 0
โœจ Influential: 0
๐Ÿ“„ PDF

career value

159K/year
๐Ÿค– AI Summary
This work addresses the inefficiency of large language models in code generation, where lengthy natural language constraint prompts incur high token costs without consistently improving constraint adherence. The authors propose replacing conventional prompts with compact, structured constraint headers and conduct the first systematic, multi-model, multi-task study to disentangle the effects of token reduction from constraint compliance. Through multi-round controlled experiments, rule-based scoring, model self-evaluation, and Cliffโ€™s ฮด effect size analysis, they demonstrate that reducing constraint-related tokens by 71%โ€”and overall prompt length by 25โ€“30%โ€”does not significantly degrade adherence performance. Crucially, compliance is found to depend primarily on constraint type and task domain rather than prompt format, underscoring the importance of deliberate structured constraint design.

Technology Category

Application Category

๐Ÿ“ Abstract
LLMs used for code generation are typically guided by engineering constraints--technology choices, dependency restrictions, and architectural patterns--expressed in verbose natural language. We investigate whether compact, structured constraint headers can reduce prompt token consumption without degrading constraint compliance. Across six experimental rounds spanning 11 models, 16 benchmark tasks, and over 830 LLM invocations, we find that compact headers reduce constraint-portion tokens by approximately 71% and full-prompt tokens by 25--30%, replicated across three independent rounds. However, we detect no statistically significant differences in constraint satisfaction rate (CSR) across three encoding forms or four propagation modes; observed effect sizes are negligible (Cliff's $ฮด$ < 0.01, 95% CI spanning $\pm$2.6 percentage points). This null pattern holds across two models from different capability tiers. A supplementary experiment with four non-CSS tasks provides additional cross-domain support for the encoding null result. The largest observed sources of compliance variance are constraint type ($ฮ”$ = 9 percentage points between normal and counter-intuitive constraints) and task domain: counter-intuitive constraints opposing model defaults fail at 10--100%, while conventional constraints achieve 99%+ compliance regardless of encoding. Model self-assessments systematically overestimate compliance relative to rule-based scoring, revealing a gap between constraint understanding and execution. Under the tested conditions, the primary benefit of compact constraint encoding is token reduction rather than compliance improvement, and engineering effort toward compliance is better directed at constraint design than prompt formatting.
Problem

Research questions and friction points this paper is trying to address.

constraint encoding
code generation
large language models
token efficiency
constraint compliance
Innovation

Methods, ideas, or system contributions that make the work stand out.

compact constraint encoding
token efficiency
constraint compliance
LLM code generation
prompt engineering