Add baseline harness: ingest, metrics, ablation arms, external counterpart, audit

- bench/ingest_baseline.py drives the unmodified product IngestionService over
  all 50,789 corpus files in sharded SQLite DBs, then merges them. Thread and
  memory ceilings are set explicitly: ONNX Runtime defaulted to every core
  (95 threads/worker, load 490) and its CPU arena kept freed pages mapped,
  which OOM-killed workers.
- bench/metrics.py: recall@k, MRR, nDCG@10, Wilson lower bound, chance
  baseline. No model, no product import, so the scorer cannot grade itself.
- bench/systems.py + bench/run.py: the five ablation arms over the merged DB,
  latency percentiles, scale curve, and a top-10 equivalence check against the
  live RetrievalService.
- bench/counterpart.py + bench/run_external.py: in-repo Mem0-style flat store
  and Zep-style temporal store as the external reference point.
- bench/audit.py: enforces single-attempt scoring, frozen n, a chance row
  beside every score, and producer != verifier. It already flags the product's
  retry-until-target loop at backend/src/ely_eye/evals.py:2351.
- backend/pyproject.toml: rapidocr-onnxruntime>=1.4.4 was unsatisfiable
  (PyPI maxes at 1.2.3); the successor is the renamed rapidocr package.
This commit is contained in:
ZacharyZhang-NY committed 2026-10-06 14:36:02 -04:00
1 parent 77219c930b
commit fc0698c242
27 files changed
+2589 -24

No files matched your search

+3 -2
View File
@@ -14,6 +14,7 @@ from typing import Any
from pyarrow.parquet import ParquetFile
from pypdf import PdfReader
from pypdf.errors import PyPdfError
from bench.corpus_sources import source_for
from bench.sets_common import (
@@ -44,7 +45,7 @@ def pdf_pages(doc_id: str) -> int | None:
return None
try:
return len(PdfReader(path).pages)
except Exception as exc:
except (OSError, PyPdfError) as exc:
print(f" unreadable pdf {doc_id}: {type(exc).__name__}: {exc}")
return None
@@ -196,7 +197,7 @@ def build() -> tuple[list[dict[str, Any]], list[dict[str, Any]], dict[str, Any]]
def main() -> None:
corpus, queries, report = build()
corpus_count, corpus_sha = write_jsonl(SETS / "corpus" / "pdf.jsonl", corpus)
query_count, query_sha = write_jsonl(SETS / "pdf.jsonl", queries)
_query_count, query_sha = write_jsonl(SETS / "pdf.jsonl", queries)
report |= {"corpus_records": corpus_count, "corpus_sha256": corpus_sha, "queries_sha256": query_sha}
(SETS / "reports" / "pdf.json").parent.mkdir(parents=True, exist_ok=True)
(SETS / "reports" / "pdf.json").write_text(json.dumps(report, indent=1, sort_keys=True))