DS-1000, posterior accuracy ŝ & validity rate Z of the no-error constraint

How accurate is ideal constrained generation? For each problem, the rollouts that run without error are exact samples from the validity-constrained posterior; ŝ is the fraction of them that are correct, averaged one-problem-one-vote over the benchmark (0/0 := 0), together with the fraction of problems with no valid rollout and the validity rate Z. 10 models × 6 temperatures, N = 100 rollouts per problem (1 at t = 0), potential DS1000RuntimeNoErrorPotential, Matplotlib excluded (image-graded). This page previously reported the pooled ratio Ŝ = ∑correct/∑valid as its headline (“skyline”); see Definitions for why the macro estimate is the comparable reference and below for the pooled numbers.
* Qwen2.5-Coder 7B, DeepSeek-Coder: externally ingested (# SOLUTION START/END convention).

On this page
  1. Definitions
  2. posterior accuracy ŝ against temperature
  3. ŝ by model and temperature
  4. problems with no valid rollout
  5. posterior vs prior: what conditioning on validity buys
  6. Z, the validity rate (normalizing constant)
  7. pooled Ŝ (secondary)
  8. Qwen3-Coder-30B (BF16) and prompt engineering
  9. by library, choose a model

Definitions

Constraint (validity potential). A sample y is valid iff its code runs to completion under DS1000RuntimeNoErrorPotential — no runtime/syntax error and no timeout:

φ(y) = 1[ y passes DS1000RuntimeNoErrorPotential ] ∈ {0, 1}

An answer that runs but returns the wrong value is still valid — the constraint is “does it run”, not “is it correct”.

Constrained-generation target. Let p0(· | x) be the model’s sampling distribution for problem x at the given temperature. Enforcing the constraint defines the target (posterior) distribution

π(· | x) ∝ p0(· | x) · φ(·)

Rejection sampling realises π exactly: draw from p0, discard invalid samples, keep the valid ones. With N rollouts per problem, the accepted rollouts of problem x are exact draws from π(· | x).

Validity rate (normalizing constant). Estimated by simple Monte Carlo over the rollouts:

Z(x) = 𝔼p0(y|x)[ φ(y) ] = Pr( y valid | x ) ≈ Validx / N

where Validx is the number of valid rollouts of problem x. Z = meanx Z(x) is the benchmark-level validity rate.

Posterior accuracy of a problem. The quantity of interest is how often a sample from the constrained target is correct:

s(x) := Pr( y correct | y valid, x ) = Prπ(·|x)( y correct ) ≈ Correctx / Validx

Single-sample accuracy factorises as Pr(y correct | x) = Z(x) · s(x); averaged over problems it is the pass@1 of the DS-1000 page.

Posterior accuracy over the benchmark (headline). Treating the benchmark as a sample of problems x ~ D, the number we want is the expected posterior accuracy of a new problem,

s̄ := 𝔼x ~ D[ s(x) ] = 𝔼x[ Pr( y correct | y valid, x ) ]

estimated by the macro estimator — one problem, one vote — with the convention 0/0 := 0 for problems none of whose N rollouts is valid:

ŝ = meanx [ Correctx / Validx  if Validx > 0,  else 0 ]

ŝ is a consistent estimate of s̄. Each per-problem ratio is an unbiased estimate of s(x) given at least one valid sample, so at finite N the only bias is the 0/0 := 0 convention, which pulls ŝ down: it treats a problem whose validity rate is small but non-zero as if its posterior accuracy were zero. ŝ therefore tends to under-estimate s̄, by at most the fraction of zero-valid problems, which we report next to every ŝ. (The alternative of simply dropping the zero-valid problems is biased too — it is a ratio of two unbiased estimators and changes the population to “problems this model can make run” — and it hides how many problems the constraint could not touch; we show it only in the tables as ŝ+.)

Why not pool? Earlier versions of this page reported the pooled ratio

Ŝ = (∑x Correctx) / (∑x Validx) = pass@1 / Z

Ŝ is a consistent estimate of a different quantity,

S̄ := 𝔼[ Z(x) s(x) ] / 𝔼[ Z(x) ] = s̄ + Cov(Z, s) / 𝔼[ Z(x) ]

a validity-weighted average: every valid rollout gets one vote, so problems the model already handles well (high Z) dominate, and problems with Z(x) = 0 have no weight at all. Because Z and s are positively correlated on DS-1000 (problems that error more are also wrong more), Ŝ sits above s̄ — not through finite-sample bias but because it estimates the wrong thing. A fine-tuned or approximate sampler is scored by its macro pass@1 (one problem, one vote), so ŝ is the comparable reference. Ŝ is kept below as a secondary number because pass@1 = Z × Ŝ holds exactly on pooled estimates.

Why report this? ŝ is the accuracy of ideal constrained generation: sample exactly from π (enforce validity and nothing else) and ask how often the result is correct. In practice one rarely has exact access to π — sampling it by rejection is expensive — so an inference method approximates it with some π̃ (importance sampling, SMC, fine-tuning, …). To judge that method compare the accuracy of samples from π̃ with ŝ: it says how close the approximation gets to the ideal constrained target. Strictly it is not an upper bound: a biased π̃ can exceed it if its bias favours correct solutions, which is exactly what a fine-tuned sampler that learns more than validity would do. Formerly called the “skyline” on this site.

For each model and temperature (DS-1000, Matplotlib excluded) we report ŝ with a 95% bootstrap CI over problems (2000 resamples), the fraction of problems with no valid rollout, the validity rate Z, and the pooled Ŝ for reference.

posterior accuracy ŝ against temperature

ŝ = meanx Pr(correct | valid, x), 0/0 := 0 — the accuracy ideal constrained generation reaches on a new problem. It falls with temperature as the target π dilutes.

ŝ by model and temperature

Each cell: ŝ, its 95% bootstrap CI, and how many problems had no valid rollout among the N sampled (these enter ŝ as 0). Greedy t=0 has N=1, so its zero-valid count is simply the number of erroring greedy answers. Browse the underlying rollouts in the explorer.

modelt=0.0t=0.2t=0.4t=0.6t=0.7t=0.8t=1.0
Llama-3 8B0.279
[0.249, 0.310]
296/845 zero-valid
0.344
[0.314, 0.372]
62/845 zero-valid
0.342
[0.315, 0.368]
26/845 zero-valid
0.313
[0.289, 0.337]
11/845 zero-valid
–0.266
[0.245, 0.287]
7/844 zero-valid
0.219
[0.199, 0.238]
13/845 zero-valid
Llama-3 8B Instruct0.257
[0.228, 0.288]
295/845 zero-valid
0.326
[0.297, 0.356]
64/845 zero-valid
0.337
[0.311, 0.365]
24/845 zero-valid
0.330
[0.305, 0.356]
11/845 zero-valid
–0.316
[0.292, 0.340]
9/845 zero-valid
0.293
[0.270, 0.315]
9/845 zero-valid
Llama-3.1 8B0.253
[0.225, 0.283]
279/845 zero-valid
0.324
[0.295, 0.352]
63/845 zero-valid
0.320
[0.295, 0.346]
24/845 zero-valid
0.293
[0.270, 0.316]
11/845 zero-valid
–0.255
[0.233, 0.276]
8/845 zero-valid
0.200
[0.182, 0.218]
15/845 zero-valid
Llama-3.1 8B Instruct0.230
[0.202, 0.258]
308/845 zero-valid
0.295
[0.268, 0.324]
65/845 zero-valid
0.312
[0.286, 0.339]
31/845 zero-valid
0.302
[0.279, 0.327]
19/845 zero-valid
–0.281
[0.260, 0.303]
13/845 zero-valid
0.246
[0.226, 0.265]
11/845 zero-valid
Llama-3.2 1B0.022
[0.013, 0.033]
691/845 zero-valid
0.063
[0.049, 0.078]
303/845 zero-valid
0.086
[0.071, 0.102]
127/845 zero-valid
0.081
[0.068, 0.096]
93/845 zero-valid
–0.065
[0.053, 0.077]
83/845 zero-valid
0.042
[0.032, 0.053]
214/845 zero-valid
Llama-3.2 1B Instruct0.043
[0.030, 0.057]
617/845 zero-valid
0.091
[0.074, 0.108]
219/845 zero-valid
0.098
[0.081, 0.114]
99/845 zero-valid
0.098
[0.083, 0.113]
62/845 zero-valid
–0.078
[0.064, 0.091]
57/845 zero-valid
0.070
[0.057, 0.084]
146/845 zero-valid
Qwen2.5-Coder 3B0.289
[0.259, 0.322]
269/845 zero-valid
0.347
[0.319, 0.377]
46/845 zero-valid
0.346
[0.320, 0.372]
16/845 zero-valid
0.310
[0.287, 0.334]
6/845 zero-valid
–0.264
[0.244, 0.284]
3/845 zero-valid
0.222
[0.204, 0.240]
6/845 zero-valid
Qwen2.5-Coder 3B Instruct0.318
[0.288, 0.351]
249/845 zero-valid
0.386
[0.355, 0.419]
59/845 zero-valid
0.390
[0.362, 0.420]
26/845 zero-valid
0.372
[0.346, 0.398]
11/845 zero-valid
–0.342
[0.317, 0.365]
7/845 zero-valid
0.298
[0.277, 0.319]
5/845 zero-valid
Qwen2.5-Coder 7B *0.388
[0.356, 0.421]
202/845 zero-valid
0.443
[0.412, 0.473]
42/845 zero-valid
0.438
[0.411, 0.465]
11/845 zero-valid
0.410
[0.386, 0.436]
7/845 zero-valid
–0.364
[0.342, 0.387]
6/845 zero-valid
0.309
[0.289, 0.329]
4/845 zero-valid
DeepSeek-Coder 6.7B *0.271
[0.241, 0.302]
281/845 zero-valid
0.356
[0.326, 0.386]
67/845 zero-valid
0.363
[0.336, 0.390]
30/845 zero-valid
0.342
[0.318, 0.366]
10/845 zero-valid
–0.300
[0.279, 0.321]
9/845 zero-valid
0.241
[0.223, 0.260]
4/845 zero-valid
Qwen3-Coder 30B FP8 *–––0.480
[0.452, 0.511]
33/845 zero-valid
–––
Qwen3-Coder 30B FP8 raw+card-sampler *––––0.454
[0.425, 0.486]
97/845 zero-valid
––
Qwen3-Coder 30B FP8 card *––––0.290
[0.264, 0.317]
96/845 zero-valid
––
Qwen3-Coder 30B BF16 card *––––0.287
[0.262, 0.313]
97/845 zero-valid
––
Qwen3-Coder 30B BF16 few-shot *––––0.516
[0.485, 0.550]
131/845 zero-valid
––

problems with no valid rollout

Fraction of problems where none of the N rollouts passed the constraint. These are the problems rejection sampling (and any sampler that only re-weights p0) cannot solve at this budget; they contribute 0 to ŝ and bound its downward bias.

posterior vs prior: what conditioning on validity buys

One dot per model at the selected temperature (optionally within one library). The diagonal is P(V) = 1; a dot’s height above it is what enforcing the constraint buys.

Conditioning on validity: the completion runs without a runtime or syntax error (an AssertionError still counts as valid) — the potential DS1000RuntimeNoErrorPotential

x is the prior pass@1: the accuracy as sampled. y is the macro posterior accuracy ŝ = meanx Pr(correct | valid, x) (0/0 := 0): the accuracy of a sampler that draws exactly from the posterior the validity notion above defines, one problem one vote. Height above the diagonal is the gain; error bars are 95% bootstrap CIs (2000 resamples of the problem set) on both axes. Hovering a dot also shows two reference lines: the ray from the origin (its slope is the dot’s ŝ/pass@1 ratio) and the line through (1,1) (slope = the surviving-failure fraction).

Z, the validity rate (normalizing constant)

Z is the proportion of rollouts that obey the constraint (run without error), Z = meanx Z(x) — the potential’s normalizing mass under the sampling distribution. Z collapses toward t=1.0 as more rollouts error out.

pooled Ŝ (secondary)

Ŝ = ∑ correct / ∑ valid = pass@1 / Z, the page’s former headline. It estimates 𝔼[Z s]/𝔼[Z], not 𝔼[s]; the gap to ŝ above is Cov(Z, s)/𝔼[Z] plus the zero-valid problems. Shown for continuity and because it factorises pass@1 exactly.

modelt=0.0t=0.2t=0.4t=0.6t=0.7t=0.8t=1.0
Llama-3 8B0.4300.4160.3970.364–0.3190.288
Llama-3 8B Instruct0.3950.3890.3790.366–0.3510.344
Llama-3.1 8B0.3780.3720.3600.331–0.2960.262
Llama-3.1 8B Instruct0.3610.3640.3550.340–0.3230.314
Llama-3.2 1B0.1230.1070.0940.081–0.0610.045
Llama-3.2 1B Instruct0.1580.1650.1450.127–0.1030.103
Qwen2.5-Coder 3B0.4240.4070.3800.342–0.3000.278
Qwen2.5-Coder 3B Instruct0.4510.4580.4440.419–0.3900.360
Qwen2.5-Coder 7B *0.5100.5030.4780.448–0.4050.371
DeepSeek-Coder 6.7B *0.4060.4110.3990.372–0.3320.280
Qwen3-Coder 30B FP8 *–––0.520–––
Qwen3-Coder 30B FP8 raw+card-sampler *––––0.538––
Qwen3-Coder 30B FP8 card *––––0.305––
Qwen3-Coder 30B BF16 card *––––0.302––
Qwen3-Coder 30B BF16 few-shot *––––0.623––

Qwen3-Coder-30B (BF16) and prompt engineering

Four new columns for Qwen/Qwen3-Coder-30B-A3B-Instruct (MoE, 30.5B total / 3.3B active): the official FP8 release under the raw-completion sweep protocol and under its model-card serving (chat template, t=0.7, top_p 0.8, top_k 20, repetition penalty 1.05), and the unquantized BF16 model under model-card serving with the bare prompt and with a few-shot prompt. 100 samples × 1000 problems each; graded by the standard pipeline (official DS-1000 harness + no-runtime-error potential; chat answers extracted as the last fenced block). Hub: model=qwen3-coder-30b-a3b-*. All numbers below are non-Matplotlib macro.

servingŝ (macro)pass@1pass@100Z#no-valid
FP8 · raw completion (sweep protocol, t=0.6)0.480 [0.452, 0.510]0.3720.7250.71633
FP8 · raw completion, card sampler (t=0.7)0.454 [0.425, 0.484]0.3810.6380.70897
FP8 · model-card chat, bare prompt (t=0.7)0.294 [0.266, 0.323]0.2130.6110.70096
BF16 · model-card chat, bare prompt (t=0.7)0.305 [0.270, 0.347]0.2090.5870.69497
BF16 · model-card chat, few-shot prompt (t=0.7)0.516 [0.484, 0.549]0.4900.5920.787131

FP8 is measurement-free. The FP8 and BF16 bare-prompt cells agree on every metric (ŝ 0.294 vs 0.305; pass@1 0.213 vs 0.209) — the official FP8 quantization does not move DS-1000 results.

Format, not sampling. Model-card serving changes two things at once — the answer format (chat template) and the sampler (t=0.7, top_p 0.8, top_k 20, repetition penalty 1.05). The third row separates them: keeping raw completion and switching only the sampler moves pass@1 by +0.008 (0.372 → 0.381), while switching only the format at that same sampler moves it by -0.167 (0.381 → 0.213). The card cell’s deficit is answer-format, essentially none of it sampling. The card sampler does visibly concentrate, though, at unchanged format: pass@100 0.725 → 0.638 — the same coverage–concentration trade the few-shot prompt shows below, here from truncation (top_p 0.8 ∩ top_k 20) alone.

Raw completion vs model-card serving

The two protocols put the same official problem text in front of the model in different ways, and the model answers in correspondingly different shapes:

Raw completion (the sweep protocol): the problem is fed as plain text to continue — no chat template — and generation stops at </code> / # SOLUTION END. The official prompt already ends inside the solution slot, so the model emits just the missing code, in DS-1000's native format. A typical complete answer:

result = df.iloc[List]

Model-card serving: the same problem is the user message of the chat template, sampled with the card's settings (t=0.7, top_p 0.8, top_k 20, repetition penalty 1.05). The instruct model answers conversationally; the graded answer must then be extracted (last fenced block). A typical answer to the same problem (abridged, real rollout):

Looking at this problem, I need to reorder the DataFrame rows based on a given list of indices. [...]

BEGIN SOLUTION
```python
result = df.iloc[List]
```

Wait, let me re-read the problem more carefully. [...]

Alternative approaches that would also work:

1. Using `np.nditer()`:
```python
...

That output style is where the bare-prompt cells lose their accuracy: the model often gives the right answer first and then helpfully appends alternatives or a self-correction, so a fixed block-picking rule sometimes grades a snippet that runs (valid) but is not the committed answer — deflating P(correct | valid) at identical validity. Z barely differs between the two modes (0.716 vs 0.700); ŝ is where they diverge (0.480 vs 0.294).

The prompt variants screened

Each variant wraps the official problem before the chat template is applied (expert is the exception: raw completion with a header). Verbatim templates — {prompt} stands for the official DS-1000 problem:

codeonly — single-block instruction (chat)
You are completing Python data-science code. The following is a DS-1000 problem: the code after BEGIN SOLUTION must replace the missing part.

{prompt}

Output ONLY the missing completion code in a single ```python block. No explanation, no imports already present in the problem, no surrounding code — exactly what belongs at the BEGIN SOLUTION slot.
fewshot — worked format example + codeonly (chat; the winner)
Example problem:
Problem:
Given a pandas DataFrame df with a column 'x', add a column 'y' equal to twice 'x'.
A:
<code>
import pandas as pd
df = pd.DataFrame({'x': [1, 2]})
</code>
BEGIN SOLUTION
<code>
Example answer:
```python
df['y'] = 2 * df['x']
```

Now the real problem.

You are completing Python data-science code. The following is a DS-1000 problem: the code after BEGIN SOLUTION must replace the missing part.

{prompt}

Output ONLY the missing completion code in a single ```python block. No explanation, no imports already present in the problem, no surrounding code — exactly what belongs at the BEGIN SOLUTION slot.
plan — brief plan, then code (chat; hurts)
{prompt}

First state in at most two sentences what the completion must do, then give the final completion code in a single ```python block.
expert — expert header (raw completion)
# Expert data-science reference solution (correct, minimal, idiomatic)
# Passes all hidden tests.
{prompt}

The few-shot prompt

A screen over four prompt variants (150 stratified problems × 25 samples, FP8) selected a prompt with one worked format example plus an instruction to answer in a single fenced block. The example is synthetic (not a DS-1000 problem, so nothing evaluated leaks into the prompt) and trivial by design — it demonstrates the answer shape, not task knowledge:

Example problem:
Problem:
Given a pandas DataFrame df with a column 'x', add a column 'y' equal to twice 'x'.
A:
<code>
import pandas as pd
df = pd.DataFrame({'x': [1, 2]})
</code>
BEGIN SOLUTION
<code>
Example answer:
```python
df['y'] = 2 * df['x']
```

Now the real problem.

You are completing Python data-science code. The following is a DS-1000 problem: the code after BEGIN SOLUTION must replace the missing part.

<official DS-1000 problem>

Output ONLY the missing completion code in a single ```python block. No explanation, no imports already present in the problem, no surrounding code — exactly what belongs at the BEGIN SOLUTION slot.

Screen results (a plan-then-code variant hurts; the raw-completion 'expert header' variant ties but is not model-card serving):

prompt variantpass@1Zpass@1 (non-MPL)
few-shot example + single-block instruction0.5190.8740.504
raw completion + expert header0.5200.8710.491
single-block instruction only0.5180.8630.489
brief plan, then code0.3890.8260.336
bare model-card prompt (reference)0.2830.731—

How it changes performance

pass@1 more than doubles (0.209 → 0.490, 2.3×) and ŝ rises 0.305 → 0.516. Two mechanisms: (1) extraction — bare chat answers bury the solution among prose, self-corrections and alternative snippets, so any fixed fenced-block heuristic sometimes grades the wrong block (visible as correct>valid disagreements in the bare-prompt cells); the single-block instruction makes extraction unambiguous. (2) commitment — answers shrink to a median ~50 tokens and concentrate on the model's best guess.

The concentration trade-off. pass@100 does not improve (0.587 → 0.592, vs 0.725 under the diverse raw-completion protocol), and the number of problems with no valid sample in 100 grows (33 → 131 of 845): the engineered prompt raises the floor without extending coverage — it nearly pre-collapses the sample distribution onto one answer. Selection-by-validity (best-of-K, rejection sampling) therefore has far less headroom on a well-prompted model (ŝ − pass@1 ≈ +0.03) than on a bare one (≈ +0.10), and the two serving styles bracket the coverage–concentration spectrum the posterior-conditioning story lives on.

By library (BF16)

libraryNumpyPandasPytorchScipySklearnTensorflow
ŝ · bare prompt0.2670.2660.5210.2990.3560.288
Z · bare prompt0.7820.7960.4900.7200.4210.538
ŝ · few-shot prompt0.6050.4590.6050.6190.5170.077
Z · few-shot prompt0.8690.8810.7930.7850.6500.129

Generation: smc_learning/scripts/analysis/gen_ds1000_rollouts.py (sweep-identical official prompts; --chat card serving; --wrap fewshot); scoring: the canonical re-score pipeline (rescore_ds1000_cell.py --postprocess chat) in the DS-1000 environment.yml env.

by library, choose a model

ŝ and Z broken down by library for a single model. Use the selector to switch models; the two plots and the table below update together. Shaded bands are 95% bootstrap CIs (2000 resamples of that library’s problems).

ŝ (macro), zero-valid fraction, Z and pooled Ŝ by library and temperature (selected model):

librarymetrict=0.0t=0.2t=0.4t=0.6t=0.7t=0.8t=1.0
Numpyŝ (macro)0.3640.4030.3800.351–0.3120.273
zero-valid frac.0.2500.0590.0320.023–0.0050.014
Z0.7500.7470.7240.649–0.5280.346
Ŝ (pooled)0.4850.4690.4390.407–0.3680.344
Pandasŝ (macro)0.2100.2350.2390.210–0.1710.127
zero-valid frac.0.3260.0410.0070.000–0.0000.003
Z0.6730.6720.6400.568–0.4530.270
Ŝ (pooled)0.3110.3060.2970.265–0.2240.188
Pytorchŝ (macro)0.2210.3140.3320.349–0.3060.244
zero-valid frac.0.4120.1180.0880.000–0.0000.000
Z0.5880.6140.5830.518–0.4120.227
Ŝ (pooled)0.3750.3850.4070.408–0.3660.329
Scipyŝ (macro)0.2920.3400.3510.336–0.2980.244
zero-valid frac.0.4060.1230.0470.019–0.0280.028
Z0.5940.5720.5540.488–0.3750.214
Ŝ (pooled)0.4920.4750.4520.414–0.3790.354
Sklearnŝ (macro)0.2520.4490.4560.417–0.3320.275
zero-valid frac.0.5650.1220.0430.026–0.0180.043
Z0.4350.4530.4310.376–0.2690.120
Ŝ (pooled)0.5800.5550.5030.446–0.3670.327
Tensorflowŝ (macro)0.4440.5420.5170.424–0.3480.303
zero-valid frac.0.2220.0440.0220.022–0.0220.022
Z0.7780.6960.6650.575–0.4670.280
Ŝ (pooled)0.5710.5200.4990.453–0.3930.362