Amortized verifier conditioning: calibrated completion probabilities and program synthesis with noisy examples
Abstract
We learn a verifier-conditioned approximation to the completion probability used by the Doob h-transform. The network takes a partial state and a structural or example-based verifier description, and is evaluated against exact enumeration on string and Boolean-program domains. Headline in-distribution runs reach Brier skill 0.952 ± 0.017; separate function-disjoint verification runs reach 0.921 ± 0.042 across three seeds. Experiments compare exact compilation, amortized inference and active identification or abstention. A position-weighted modular family challenges the tested label-based learners while exact algebra solves noiseless cases; a structural screen separates it from five in-prior families with AUC 1.0. Monte Carlo target estimation and warm-start training reduce dependence on exact enumeration. On 45 clean SyGuS string tasks, learned search solves 15.6 ± 1.8 against cvc5’s 41. A hybrid using deductive and learned fallback only on cvc5 null returns improves held-out accuracy by 0.258 and 0.469 at 15% and 30% label noise across 21 tasks, preserving the clean score. Grammar interventions change the gain substantially. Broader benchmarks and fallback ablations are needed to establish generality.
Keywords: constrained generation · Doob h-transform · amortized inference · calibration · statistical query hardness · program synthesis · SyGuS
1Introduction
Many generation problems come with a verifier: a parser that accepts well-formed programs, a checker that tests a candidate against examples, a constraint a string must satisfy. Sampling from a generator conditioned on acceptance is the natural target, and it has an exact mathematical form. For a Markov proposer with kernel p(s' \mid s), conditioning on the terminal event \{V = 1\} is a Doob h-transform [1]:
Here X is the terminal completion and S the current partial state; the transform is defined where h(s)>0. The function h serves two roles. It is the optimal steering signal for valid-by-construction generation, and it is a calibrated probability that the constraint will eventually be satisfied. Constrained-decoding and twisted sequential Monte Carlo methods [2, 3, 4, 5] compute or learn h, or a proxy for it, per constraint, and generally need the constraint to be exposed and tractable.
This paper asks whether h can be amortized across verifiers. Can a single network, given a description of a verifier it has never seen, return calibrated values of h in one forward pass? The evaluation measures numerical probability accuracy against exact h. The experiments measure this capability within explicit verifier families and compare routing methods outside them. External synthesis results include clean-task solve counts and a hybrid evaluation under label noise.
2Method
2.1The operator
We train H_\phi(s, \mathcal{V}) \approx h_V(s), where s is a partial state and \mathcal{V} describes the verifier. The verifier enters in one of two ways: by structure, with an automaton or grammar encoded as tensors, or by behavior, as a support set \{(x_i, V(x_i))\} of labelled examples. The behavior-conditioned form places the operator in the prior-fitted network family [6, 7]: one forward pass over an in-context dataset approximates a posterior quantity. In earlier experiments behavior conditioning generalized across verifiers zero-shot, with Brier skill 0.73, where conditioning on verifier labels failed (0.09).
2.2Calibration as the objective
The operator is graded and trained on calibration. Probability accuracy is evaluated separately from ranking. On partial programs an early network ranked h well (Spearman 0.81) but reached a Brier skill score (BSS) [8] of only 0.52 against exact h. Ranking and calibration come apart, and calibration is the harder target. Two verifier-derived signals train it. The first is regression to exact h where enumeration or dynamic programming provides it. The second is a self-supervised consistency loss from the harmonic recursion,
which holds to 3\times10^{-18} on our substrate and supplies a calibration constraint at every internal state. BSS is computed against exact h, so 1 is perfect and 0 is no better than the base rate.
2.3Substrates
We use two substrates with exact h: an L = 20 string world with automaton verifiers, and R2, a boolean program-synthesis domain-specific language with execution semantics, where exact h is computed by enumeration. For an external test we use the PBE-Strings track of SyGuS-COMP [9].
3The trichotomy
The appropriate conditioning method depends on verifier structure and training support. Table 1 summarizes three regimes with measured boundaries.
| Regime | When | Mechanism | Evidence |
|---|---|---|---|
| Exact compile | V is automaton- or grammar-expressible | Backward dynamic program; training-free and composable | Validity 1.000; AND/OR/NOT exact |
| Bayes-ceiling amortization | V lies in the pretraining prior | Operator tracks the exact Bayes posterior predictive | Median BSS 0.986 vs. ceiling 0.999; ECE 0.011 |
| Active decode or refuse | V is out of prior but identifiable | Identify by active queries, compile, else abstain | Identified in about 7 queries; 0.00 confidently wrong; abstains on 1.00 of out-of-closure verifiers |
3.1Amortization on programs
On R2, three seeds at 60,000 steps and 50,000 training specifications reach in-distribution BSS 0.952 ± 0.017, with all three above 0.90. These headline runs are separate from the function-disjoint verification runs. The latter give disjoint BSS 0.872, 0.944 and 0.947 (mean 0.921 ± 0.042), compared with in-distribution scores 0.861, 0.913 and 0.905 on the same verification checkpoints. Within those paired runs, in-distribution minus disjoint BSS is -0.012, -0.031 and -0.041. The paired comparison supports transfer on this split; the headline means should not be subtracted as if they came from the same runs. One disjoint seed remains below 0.90. Earlier experiments reached BSS 0.61; isotonic recalibration improved BSS by 0.058, a per-specification baseline reached 0.919, and increasing verifier diversity produced scores 0.50, 0.61, 0.72, 0.894 and 0.940.
At inference time, the amortized operator matches or beats a fully trained from-scratch specialist on 5 of 5 learnable families. The cheaper specialist configuration wins on none of those families; total-cost comparisons must include operator pretraining.
3.2Monte Carlo targets for h
A natural objection is that all of this depends on exact h, which is available only when enumeration is feasible. Estimating h from verifier calls alone, by completing a prefix M times at random and averaging acceptances, is unbiased. Its error is pure Monte Carlo noise, with empirical standard deviation equal to \sqrt{p(1-p)/M} to three decimals. At M = 256 calls per target, RMSE is 0.018 with correlation 0.998. Training on such targets reaches 100.4% of the BSS reached with exact targets on identical streams. That run is a warm start from an exact-trained operator; cold-start training from Monte Carlo targets alone is not established. On deep conjunctions of automata, whose product automaton has 11–21 million states, Monte Carlo fine-tuning stays calibrated where it can be checked (BSS 0.964 ± 0.014) and gives a 45-fold sampling advantage over blind sampling where it cannot.
4The boundary
Generalization depends on the verifier family and training prior. The family that marks the boundary is posmod, position-weighted modular sums. Under the tested prior, 60 million draws hit none of 30 target cells. This finite sampling result motivates examination of the prior’s support. Parity-related statistical-query lower bounds [10, 11] motivate this family. Their scope depends on the input distribution, query tolerance and learning model. Four experiments characterize the implemented cases:
- Algebra crosses it. Gaussian elimination over GF(2) recovers the hidden coefficients exactly in 8 of 8 seeds, with held-out accuracy 1.0 after about 48 queries. Linear SGD on the same features stays at chance (0.5015).
- The hard case is dimension times noise. With low-dimensional hidden support, the family is identified at 1.0 even at 45% label noise. The difficult tested case combines noise and high-dimensional hidden support, connecting the experiment to learning parity with noise.
- Structural screening. A structural test with no trained network, combining permutation sensitivity with a local degree-2 statistic, separates
posmodfrom five in-prior families with AUC 1.0. This screen routes the tested boundary family to active identification or abstention. - Dense-supervision experiment. Supervising every position's automaton state still fails (BSS -0.371 against a 0.80 bar after 15,000 steps), and a paired control without the extra supervision gives exactly the same number. A pre-committed freeze on further attempts was triggered.
The router combines a network with a verification-or-abstention gate. A self-check compares predicted h with Monte Carlo estimates from verifier calls. With this check, the tested router records zero confidently wrong answers across three seeds, routes none of 48 posmod verifiers through amortization, and covers 64.8% of in-prior verifiers. Finite observed error counts bound the evidence available for general deployment.
5External results: SyGuS PBE-Strings
Clean-task solve counts. On the PBE-Strings track, a fair single-chain run of the operator-steered synthesizer solves 15.6 ± 1.8 of 45 problems. The enumerative synthesizer Probe [12] solves 14, within a seed's noise. cvc5 [13] solves 41, on a different frontier: the operator solves 2 of cvc5's 4 timeouts, for a union of 43. The single-chain protocol is the comparison reported here; a larger multi-chain portfolio is a different compute budget. Validity-by-construction holds only among completed rollouts. An ablation that scrambles the operator's values attributes about 70% of the gain over an untrained baseline to genuine steering and 30% to search machinery.
Noisy-example performance. Programming-by-example specifications in practice contain mistakes. We build a three-arm hybrid: use cvc5's program if it returns one; otherwise a deductive majority-fit; otherwise operator-steered inference that treats the verifier as a prior. The fallback replaces only cvc5's null returns, and whether cvc5 returned is known at deployment. Under the benchmark convention that a null return scores zero, the hybrid preserves cvc5’s score whenever cvc5 returns a program and can improve on null returns. Its fallback includes both deductive majority-fit and operator inference; their separate contributions require ablation. We score generalization to held-out true labels on all 21 automatically discovered -long instances, without hand-picking, across three seeds (Table 2).
-long, 21 instances, three seeds.| Label noise | cvc5 (default) | Hybrid | Gain |
|---|---|---|---|
| 0% | 0.973 | 0.973 | +0.000 |
| 15% | 0.489 | 0.747 | +0.258 |
| 30% | 0.171 | 0.640 | +0.469 |
The result is unchanged under cvc5's size-minimizing streaming mode, and it replicates on a second string domain (regular expressions; +0.54 and +0.51). cvc5's collapse under noise reflects genuine unsatisfiability. No returned solution was untranslatable (0 of 189).
Sensitivity to grammar structure. Holding cvc5, targets and examples fixed and varying only the grammar, the 30%-noise gain is +0.956 for a grammar without ite and +0.146 with ite and =. This is a 6.5-fold difference from grammar structure alone. Verifier-as-prior inference helps under noise when the grammar's boolean sublanguage cannot cheaply isolate an individual example point. When it can, an exact solver memorizes the noise just as a flexible model would. This experiment identifies point-isolation expressiveness as a candidate predictor. A general predictor of accuracy gains requires a defined grammar class and validation on unseen grammars.
6Limitations
The rigorous calibration results live on two substrates with exact h, the string world and R2, which are not community benchmarks. On truly novel target functions, generalization averages above the 0.90 bar but misses it on one of three seeds. Calibration at non-enumerable depth is shown only as a sampling advantage. Cold-start training from Monte Carlo targets is not established. The external improvement over cvc5 is bounded: it holds in the noisy string programming-by-example regime, on a small battery, and is not a general synthesis result. A comparison showing that frontier LLMs given the same examples produce anti-calibrated h (median BSS -1.55 against the operator's +0.87) is restricted to the toy substrate and is not claimed beyond it.
7Conclusion
A verifier-conditioned network estimates completion probabilities accurately on the tested enumerable domains and transfers to held-out functions. Exact compilation, active identification and abstention extend the routing options. On the small noisy string-synthesis benchmark, a hybrid preserves cvc5’s returned solutions and improves accuracy on null-return cases. Grammar interventions suggest a direction for predicting when the fallback will help.
Data and code availability
Code, pre-registrations and the append-only validation ledger from which every number above is read are in the private project repository. SyGuS-COMP benchmarks are public.
References
- J. L. Doob. Conditional Brownian motion and the boundary limits of harmonic functions. Bulletin de la Société Mathématique de France, 85:431–458, 1957.
- H. Zhang, M. Dang, N. Peng, and G. Van den Broeck. Tractable control for autoregressive language generation. In Proceedings of the 40th International Conference on Machine Learning, PMLR 202:40932–40945, 2023.
- H. Zhang, P.-N. Kung, M. Yoshida, G. Van den Broeck, and N. Peng. Adaptable logical control for large language models. In Advances in Neural Information Processing Systems 37, 2024.
- A. K. Lew, T. Zhi-Xuan, G. Grand, and V. K. Mansinghka. Sequential Monte Carlo steering of large language models using probabilistic programs. arXiv preprint arXiv:2306.03081, 2023.
- S. Zhao, R. Brekelmans, A. Makhzani, and R. Grosse. Probabilistic inference in language models via twisted sequential Monte Carlo. In Proceedings of the 41st International Conference on Machine Learning, 2024.
- S. Müller, N. Hollmann, S. Pineda Arango, J. Grabocka, and F. Hutter. Transformers can do Bayesian inference. In International Conference on Learning Representations, 2022.
- N. Hollmann, S. Müller, K. Eggensperger, and F. Hutter. TabPFN: A transformer that solves small tabular classification problems in a second. In International Conference on Learning Representations, 2023.
- G. W. Brier. Verification of forecasts expressed in terms of probability. Monthly Weather Review, 78(1):1–3, 1950.
- R. Alur, R. Bodik, G. Juniwal, et al. Syntax-guided synthesis. In Formal Methods in Computer-Aided Design (FMCAD), 1–8, 2013.
- M. Kearns. Efficient noise-tolerant learning from statistical queries. Journal of the ACM, 45(6):983–1006, 1998.
- A. Blum, A. Kalai, and H. Wasserman. Noise-tolerant learning, the parity problem, and the statistical query model. Journal of the ACM, 50(4):506–519, 2003.
- S. Barke, H. Peleg, and N. Polikarpova. Just-in-time learning for bottom-up enumerative synthesis. Proceedings of the ACM on Programming Languages, 4(OOPSLA):227, 2020.
- H. Barbosa, C. Barrett, M. Brain, et al. cvc5: A versatile and industrial-strength SMT solver. In Tools and Algorithms for the Construction and Analysis of Systems (TACAS), LNCS 13243:415–442, 2022.