feat: biometric-engine benchmark harness + accuracy protocol - #152
Merged
Conversation
…hmark harness Synthetic-cohort generator (seeded, 512-d embeddings), FAR/FRR/EER via full ROC sweep, perf_counter latency percentiles, anti-spoofing decision summary. Thresholds are read from the engine source/env at run time — no hardcoded duplicates. No network, no dataset downloads, no model weights loaded.
18 tests: cohort determinism (same seed -> identical cohort), unit-norm and intra<inter variance invariants, hand-computed FAR/FRR/EER/AUC on toy confusion sets, threshold sourcing from engine config (env override wins), report schema validation, CLI smoke. Plus the committed report.json snapshot from a real run (seed 20260114).
Protocol description, cohort variance parameters, thresholds, results table from a real executed run, explicit LIMITATIONS (decision-layer only; iBeta PAD L1/L2 = accredited-lab roadmap, not claimed), and the exact CI job YAML to apply once a workflow-scoped token is available.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
WP7: a benchmark harness + published accuracy protocol for
services/biometric-engine, as a partial answer to the Onfido/Entrust maturity gap.services/biometric-engine/benchmarks/run_benchmarks.py— deterministic, fully offline decision-layer benchmark:numpy.default_rng(seed), default20260114): N=200 identities (configurable) × K=10 samples of L2-normalised 512-d embeddings. Inter-class centres uniform on the unit sphere (impostor cosine ~ N(0, 1/512), std ≈ 0.044); intra-class additive Gaussian noise withσ_intra = sqrt((1/target − 1)/dim)derived from--target-genuine-cosine(default 0.65). Genuine pairs = all within-identity pairs (9,000); impostor pairs = equal-count cross-identity sample.LIVENESS_THRESHOLD/MATCH_THRESHOLD/ANTISPOOFING_THRESHOLDare parsed frommain.py(or the same env vars the engine reads) — no hardcoded duplicates; provenance is recorded in the report. FAR/FRR at the operating point, full ROC sweep, EER (interpolated crossing), trapezoidal AUC.perf_counter(18,000 timed calls).ANTISPOOFING_THRESHOLDrule (classifier weights deliberately NOT loaded offline — labelled as such).benchmarks/report.json(seed, params, thresholds+provenance, metrics, latency, environment; labelSYNTHETIC-COHORT) + markdown summary on stdout.main.pyis importable it uses the engine's own_cosine_similarity; otherwise byte-identical local math is used and the report records which ran.services/biometric-engine/test_benchmarks.py— 18 tests: generator determinism (same seed → bit-identical cohort), unit-norm + intra<inter variance invariants, hand-computed FAR/FRR/EER/AUC on toy confusion sets, threshold sourcing (env override wins; parsed default equals the literal inmain.py), report schema validation, CLI smoke.docs/biometric-benchmarks.md— protocol, parameters, thresholds, real-run results table, LIMITATIONS, and the exact CI job YAML (see deviation below).services/biometric-engine/benchmarks/report.json— committed snapshot of a real run.Why
Vendor-maturity gap (Onfido/Entrust): we had no reproducible, honest measurement of the biometric decision layer. This provides deterministic validation of the threshold/similarity logic and a published protocol — without inflating accuracy claims.
How tested (real output)
(Existing suite still green:
python -m unittest test_main→Ran 21 tests ... OK.)Real benchmark run (
python benchmarks/run_benchmarks.py, seed 20260114, 200×10, 9,000 genuine / 9,000 impostor pairs, thresholds read from engine: MATCH=0.40, LIVENESS=0.72, ANTISPOOF=0.60):Zero errors are expected — the synthetic cohort is well separated by construction. These numbers validate the decision layer (threshold logic, ROC/EER math, env config path, similarity speed); they say nothing about real-world accuracy and are labelled SYNTHETIC-COHORT everywhere.
Limitations
Closes-gap
Partial close of the Onfido/Entrust maturity gap: reproducible decision-layer validation + published protocol now exist. Remaining gap (real-dataset FAR/FRR, demographic breakdown, iBeta PAD L1/L2) is external/accredited-lab roadmap, documented in
docs/biometric-benchmarks.md.Deviation
The
biometric-benchmarksCI job (non-blocking,continue-on-error: true, uploadsreport.jsonartifact) was written and YAML-validated but could not be pushed: the automation token lacks theworkflowscope required to modify.github/workflows/(HTTP 403insufficient scopes). The exact, ready-to-apply job block and run command are documented indocs/biometric-benchmarks.md→ "CI wiring". Everything else is in this branch.