Constraint-Aware Training
Organizations: Department of Computer Science and Engineering University of California-San Diego La Jolla, CA
Abstract
When generating programs with language models, constrained decoding can apply program analyses to exclude tokens that violate syntax, scope, or typing rules. However, there is a duplication: standard training already teaches the model to suppress the tokens rejected by these analyses. This duplication leads to the question: if we will perform some analysis to filter a set tokens out during inference anyways, can we avoid teaching the model the said analysis altogether during training, and does this externalization lead to more efficient models? This paper defines a general constraint-aware objective satisfying this externalization desideratum and formalizes the benefits of externalization into three concrete theorems about model size and data efficiency. We show, through a controlled synthetic experiment, that the theorems survive training dynamics: constraint-aware training yields lower prediction loss at a matched parameter count and data compared to ordinary cross-entropy training, motivating training objectives that incorporate the analyses used during generation.
Figures & tables
Appendix figures & tables5 assets
Supplementary material from the paper’s appendix.
Appendix
| Depth | Seed | ( ) | ( ) | CE range | |
|---|---|---|---|---|---|
| 2 | 0 | 3.008 | 1.639 | 1.1036 | 4 |
| 2 | 1 | 2.382 | 1.536 | 1.1006 | 3 |
| 4 | 0 | 3.283 | 1.972 | 0.8318 | 5 |
| 4 | 1 | 2.451 | 2.236 | 0.8552 | 5 |
| 8 | 0 | 3.178 | 1.706 | 0.4764 | 8 |
| 8 | 1 | 2.450 | 1.494 | 0.5861 | 7 |
| Pairs (M) | CE | |||
|---|---|---|---|---|
| 2.4 | 0.017490 | 0.045766 | ||
| 7.2 | 0.017969 | 0.029436 | ||
| 24 | 0.015902 | 0.023875 | ||
| 36 | 0.015219 | 0.022487 |
| Pairs (M) | Objective | Peak LR | Readout decay | Masked excess | CE total |
|---|---|---|---|---|---|
| 2.4 | CA | 0.010 | 0 | – | |
| 2.4 | CE | 0.003 | 0.1 | 0.049277 | |
| 36 | CA | 0.001 | 0 | – | |
| 36 | CE | 0.003 | 0.1 | 0.027421 |
| Cell | Objective | Masked excess ( nats) | ( nats) |
|---|---|---|---|
| A | CA | 0.0664 | |
| A | CE | 6.5800 | |
| B | CA | 0.0414 | |
| B | CE | 4.4032 | |
| C | CA | 0.0410 | |
| C | CE | 5.3315 |
Constrained Generative Modeling
Constrained generative modeling develops methods that produce samples satisfying structural, physical, semantic, or user-defined requirements.
See all 187 papers