kip-hash v5: masked multi-probe + honest head selection (absolute-win scale-up)
Browse filesSchema 5: 32-bit word unchanged (24 learned bucket bits | 8 isotonic-calibrated score bits); dedup plane retrained on 13 perturbation families with hard-pair emphasis; NEW masked multi-probe candidate generation (masks [1,2], 12,330 probe keys/row) lifts confirmed recall to 0.9769 - TIED with MinHash-64 - at zero post-guard false merges; 16-dim multi-task quality projection + batch-fold-selected ridge verdict head (MAE 17.67 vs the neural-verifier band 17.88, junk AUC 0.668 vs 0.534); 366-412 docs/s single core, 4 B/row, 896 KB int8 artifact, pure-stdlib inference. Deterministic trainer SEED=20261119; distilled from 4,839 teacher-labeled rows (DeepSeek V4.1-Flash-1017 webapp multi-turn, kimi-k3.1-pro via NVIDIA NIM, MiniMax M3.1 Flash fallback) across 44+ languages. MIT license.
Supersedes schema 4 in the same repo. Weights + engine + eval report only - no corpus text ships in the artifact.
- README.md +14 -0
- kip_hash.py +39 -1
|
@@ -88,6 +88,20 @@ post-guard for both**, and kip-hash additionally clears the
|
|
| 88 |
teacher-adjudicated false-merge zone (0 adversarial non-dup pairs
|
| 89 |
merged post-guard, asserted at train time).
|
| 90 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 91 |
**Neural-verifier parity — measured against the honest band, axis by
|
| 92 |
axis.** The eval labels ARE teacher verdicts, so an independent
|
| 93 |
MiniMax M3.1 Flash probe (NVIDIA NIM, same prompt + validators) scored
|
|
|
|
| 88 |
teacher-adjudicated false-merge zone (0 adversarial non-dup pairs
|
| 89 |
merged post-guard, asserted at train time).
|
| 90 |
|
| 91 |
+
**Production validation (real corpus, 12,047 rows)**: the w48 build
|
| 92 |
+
ran kip-hash v5 and MinHash-LSH over the identical post-gate rows —
|
| 93 |
+
kip-hash dropped 2,138 dups in 281s (faster than MinHash's 398s for
|
| 94 |
+
2,163), 2,133 of the drops agree; the 30 MinHash-only merges were
|
| 95 |
+
lexically audited **30/30 below the guard bar (all likely false
|
| 96 |
+
merges)**, while the 5 kip-hash-only drops are dups MinHash missed.
|
| 97 |
+
The wide candidate net (9.46M candidates over the run — template
|
| 98 |
+
families collide under masked keys) is absorbed by a value-identical
|
| 99 |
+
guard fast path: each row's 5-gram set is built once per call and
|
| 100 |
+
intersected at C speed (`len(a & b)`), with a per-row cardinality
|
| 101 |
+
assert falling back to the exact string path on any in-row hash
|
| 102 |
+
collision (regression-tested: 7,043 guard decisions identical, full
|
| 103 |
+
dedup_stream outcomes identical).
|
| 104 |
+
|
| 105 |
**Neural-verifier parity — measured against the honest band, axis by
|
| 106 |
axis.** The eval labels ARE teacher verdicts, so an independent
|
| 107 |
MiniMax M3.1 Flash probe (NVIDIA NIM, same prompt + validators) scored
|
|
@@ -1453,6 +1453,44 @@ class KipHash:
|
|
| 1453 |
# deterministic no matter the worker count.
|
| 1454 |
sigs = self.sign_batch(texts, workers=workers)
|
| 1455 |
lens = [len(t or "") for t in texts]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1456 |
kept, pairs, gray = [], [], []
|
| 1457 |
index = {}
|
| 1458 |
gate_dropped = n_cand = n_conf = guard_rej = junk_dropped = 0
|
|
@@ -1492,7 +1530,7 @@ class KipHash:
|
|
| 1492 |
if not self.confirm(sig["z"], sigs[c]["z"]):
|
| 1493 |
continue
|
| 1494 |
n_conf += 1
|
| 1495 |
-
j =
|
| 1496 |
if j < guard:
|
| 1497 |
guard_rej += 1
|
| 1498 |
continue
|
|
|
|
| 1453 |
# deterministic no matter the worker count.
|
| 1454 |
sigs = self.sign_batch(texts, workers=workers)
|
| 1455 |
lens = [len(t or "") for t in texts]
|
| 1456 |
+
# guard fast path: the 5-gram Jaccard is a pure function of the
|
| 1457 |
+
# row pair, but dense corpora (template families) scan the same
|
| 1458 |
+
# rows against thousands of candidates. Building each row's
|
| 1459 |
+
# gram set ONCE per call and intersecting at C speed is
|
| 1460 |
+
# value-identical: the per-row cardinality check asserts the
|
| 1461 |
+
# 64-bit gram hashes collide no more than the strings already
|
| 1462 |
+
# do (mismatch -> exact string-set fallback for that row).
|
| 1463 |
+
grams_cache = {}
|
| 1464 |
+
|
| 1465 |
+
def _row_grams(j):
|
| 1466 |
+
g = grams_cache.get(j)
|
| 1467 |
+
if g is None:
|
| 1468 |
+
gs = ngrams5(texts[j])
|
| 1469 |
+
n = len(gs)
|
| 1470 |
+
hs = frozenset(
|
| 1471 |
+
int.from_bytes(hashlib.blake2b(
|
| 1472 |
+
s.encode("utf-8"), digest_size=8,
|
| 1473 |
+
person=b"kipj5").digest(), "big")
|
| 1474 |
+
for s in gs)
|
| 1475 |
+
g = (n, hs if len(hs) == n else None)
|
| 1476 |
+
if len(grams_cache) >= 30000:
|
| 1477 |
+
grams_cache.clear()
|
| 1478 |
+
grams_cache[j] = g
|
| 1479 |
+
return g
|
| 1480 |
+
|
| 1481 |
+
def _guard_j(i, c):
|
| 1482 |
+
na, ha = _row_grams(i)
|
| 1483 |
+
nb, hb = _row_grams(c)
|
| 1484 |
+
if ha is not None and hb is not None:
|
| 1485 |
+
inter = len(ha & hb)
|
| 1486 |
+
else: # in-row hash collision: exact path
|
| 1487 |
+
ga = ngrams5(texts[i])
|
| 1488 |
+
gb = ngrams5(texts[c])
|
| 1489 |
+
inter = len(ga & gb)
|
| 1490 |
+
na, nb = len(ga), len(gb)
|
| 1491 |
+
if not inter:
|
| 1492 |
+
return 0.0
|
| 1493 |
+
return inter / (na + nb - inter)
|
| 1494 |
kept, pairs, gray = [], [], []
|
| 1495 |
index = {}
|
| 1496 |
gate_dropped = n_cand = n_conf = guard_rej = junk_dropped = 0
|
|
|
|
| 1530 |
if not self.confirm(sig["z"], sigs[c]["z"]):
|
| 1531 |
continue
|
| 1532 |
n_conf += 1
|
| 1533 |
+
j = _guard_j(i, c)
|
| 1534 |
if j < guard:
|
| 1535 |
guard_rej += 1
|
| 1536 |
continue
|