Download docs/NULL-MODEL.md from SaluteFaceOpensource/synthidbio-sequence-pilots: direct link, hf CLI and curl.
- Browser
- Download file 7.2 kB
-
https://huggingface.co/datasets/SaluteFaceOpensource/synthidbio-sequence-pilots/resolve/main/docs/NULL-MODEL.md
- Command line
-
hf download hf://datasets/SaluteFaceOpensource/synthidbio-sequence-pilots/docs/NULL-MODEL.md
-
curl -L -o NULL-MODEL.md https://huggingface.co/datasets/SaluteFaceOpensource/synthidbio-sequence-pilots/resolve/main/docs/NULL-MODEL.md
A closed-form null model for SynthID Bio sequence scores
This is the main original contribution of the package. It is elementary, but it is exact where it claims to be, and it addresses the specific problem the pilot left open.
The problem
The pilot calibrated detection thresholds empirically: take a cohort of unwatermarked sequences, score them, take the 95th percentile, use that as the threshold. Two such thresholds produced held-out negative flag rates of 12.5% and 4.7%.
A correctly calibrated 95th-percentile threshold should flag about 5% of held-out negatives. Getting 12.5% from one and 4.7% from another means at least one is badly misplaced, and from the flag rates alone you cannot tell which.
Empirical calibration conflates two sources of variation:
- Cohort sampling noise. A 95th percentile estimated from a few dozen sequences has a wide confidence interval.
- Per-sequence score variance. Two sequences of different lengths have genuinely different null distributions, so no single constant is the right threshold for both.
The second source does not need to be estimated at all. It has a closed form.
Derivation
A score is the mean of binary g-values over all (window, key) pairs:
score = (1 / (W*K)) * SUM over w=1..W, k=1..K of b[w,k]
with W = length - 3 windows and K = 25 keys.
Each bit is a deterministic function of the triple (initialisation vector, 4-residue context, key). Under the null hypothesis of no watermark, the bits behave as unbiased coin flips — with one structural exception:
Identical 4-residue contexts produce identical bits.
This follows directly from the construction: the bit depends on the context
only through its hash, so two windows with the same 4 residues contribute the
same bit for every key. A repeated 4-mer is not an independent draw.
test_scorer.py asserts this property directly rather than assuming it.
Group the windows by distinct context. Let there be D distinct contexts with
multiplicities m_1 ... m_D, where SUM_i m_i = W. Then
score = (1 / (W*K)) * SUM over i=1..D of m_i * SUM over k=1..K of b[i,k]
Treating the b[i,k] as independent unbiased bits across distinct contexts
and keys, each with variance 1/4:
Var(score) = (1 / (W^2 * K^2)) * SUM_i m_i^2 * K * (1/4)
= (1/4) * SUM_i m_i^2 / (W^2 * K)
Define the repeat inflation factor
R = SUM_i m_i^2 / W
which gives the compact form
E[score] = 0.5
SE = 0.5 * sqrt(R / (W*K))
and an effective independent bit count of W*K/R.
Behaviour of R
| sequence | W | distinct | R | effective bits |
|---|---|---|---|---|
| all residues distinct 4-mers | W | W | 1.0 | W·25 |
ACDE tiled to 120 aa |
117 | 4 | 29.26 | 100 |
| poly-A, 50 aa | 47 | 1 | 47.0 | 25 |
The two extremes are the sanity checks, and both are in the test suite:
R = 1exactly when every context is distinct, recovering the naive0.5/sqrt(W*K).R = Wfor a homopolymer, where all windows share one context, leaving exactlyK = 25independent bits no matter how long the sequence is.
The identity SE = SE_naive * sqrt(R) is
asserted at all three values of R.
So the naive standard error is correct only for repeat-free sequences, and is too small — anticonservative, producing too many false flags — for anything with repeated 4-mers. Low-complexity regions, linkers and repeat proteins are where this bites.
Per-sequence thresholds
Replace a single shared constant with a per-sequence threshold:
threshold = 0.5 + z_alpha * 0.5 * sqrt(R / (W*K))
For the two backbones in this package, at the 95th percentile:
| backbone | W | R | SE | p95 threshold |
|---|---|---|---|---|
| 5L33 | 103 | 1.000 | 0.009853 | 0.516207 |
| 6MRR | 65 | 1.000 | 0.012403 | 0.520402 |
These differ by 0.004, about 0.3 of a standard error. A single constant applied to both is mis-calibrated for at least one of them, and the direction of the error depends on sequence length. That is a concrete, length-driven mechanism that would produce exactly the kind of flag-rate spread the pilot saw — though see the caveat below about attribution.
A threshold computed this way needs no cohort, so it removes source (1) of the variation entirely and makes source (2) explicit per sequence.
What this sample shows
Running python analysis/null_model.py over the bundled sequences:
- All 10 sequences lie within ±2.1 SE of 0.5.
- Largest deviation:
6MRR-baseline-2at z = +2.06, two-sided p = 0.039 uncorrected. Across 10 comparisons that is not significant (Bonferroni-adjusted p ≈ 0.39). - 2 of 10 exceed their own one-sided p95 threshold where ~0.5 would be expected. At n = 10 the binomial probability of ≥2 is about 0.09, so this is unremarkable, but it is the kind of thing worth rechecking on the full cohort.
- Both are 6MRR baselines, so if anything is there it is backbone-specific rather than general. With n = 5 per backbone, chance is the leading explanation.
Independently, data/reference_verification.json records that a batch of all
810 released sequences spans 0.4697 to 0.5262 — a tight band around 0.5.
All of this is consistent with public-key scores carrying no detection signal, which is what the construction predicts when the real keys are secret.
Assumptions and caveats
Stated plainly, because they bound what the model is good for:
- The repeat correction is exact. Identical contexts yield identical bits by construction, and the test suite verifies it. No approximation.
- Across-context independence is an approximation. The model treats distinct contexts as independent draws. The hash is a fixed LCG-and-shift construction, not a random oracle, so distinct contexts could carry residual correlation. A null threshold is exactly the place an unbiased-bit assumption belongs, but it is an assumption and it has not been tested here. Testing it properly needs the full released cohort — see NOT-INCLUDED.md.
- Normal approximation. The p95/p99 thresholds use normal quantiles. With
1625–2575 bits that is reasonable, but the score is a lattice variable
(
k/(W*K)), so for smallWor largeRan exact or simulated null is preferable. For a homopolymer there are only 26 attainable values. - Null only. This model says nothing about the distribution under a real watermark with real keys. It cannot give you a detection rate, a power calculation or a ROC curve. It only tells you where the null sits.
- It does not explain the 12.5%/4.7% result on its own. Length-driven mis-calibration is a plausible contributing mechanism, and it is testable, but the cohorts that produced those numbers are not in this package, so attributing the spread to this cause specifically would be unsupported.
Reproducing the tables above
python scorer/test_scorer.py # 56 checks, incl. every R bound above
python analysis/null_model.py # the per-sequence table
Both are dependency-free and run in under a second.