Retrieval Evaluation and Benchmarks =================================== The repository includes a small deterministic benchmark harness that compares BM25 lexical retrieval, vector retrieval, and reciprocal-rank-fusion hybrid retrieval. It reports Precision@K, Recall@K, MRR, and nDCG@K, with per-query rankings and a SHA-256 fingerprint of the input dataset. Run the bundled smoke-test dataset from the repository root: .. code-block:: bash python -m benchmarks.run_retrieval_benchmark --k 5 --output benchmark-results.json The bundled corpus is synthetic and intentionally small. It validates the benchmark pipeline; its scores must not be treated as evidence of production retrieval quality or compared with published benchmarks. For meaningful evaluation, create a JSON dataset with a ``documents`` array containing unique ``id``, ``source`` and ``content`` fields, and a ``queries`` array containing unique ``id``, ``text`` and a ``relevant`` mapping from relevant document IDs to non-negative graded relevance values. See ``benchmarks/data/sample_retrieval.json`` for the schema. The Python API accepts any implementation of ``EmbeddingBackend`` so teams can run the same judged dataset against local or hosted embedding models: .. code-block:: python from benchmarks.retrieval_benchmark import run_benchmark_file from automated_document_parser import HashingEmbedder report = run_benchmark_file( "my-domain-evaluation.json", embedder=HashingEmbedder(dimensions=384), k=5, ) For production evaluations, use representative and permission-cleared corpora, multiple query intents, human-reviewed relevance judgements, and separate train/tuning and held-out test queries. Record the embedding model, model version, preprocessing/chunking settings, retrieval parameters, dataset fingerprint, and relevance-judgement version alongside every result. Evaluate retrieval quality and operational factors such as latency, cost, throughput, index build time, and update behavior separately. Do not select a model based on the bundled sample dataset. End-to-end ingestion and queue benchmark ---------------------------------------- The pipeline benchmark measures synthetic text-document parsing, schema extraction, classification, chunking, hashing embeddings, indexing, retrieval, SQLite queue enqueue/claim throughput and Python-traced peak memory. It records Python/platform/workload metadata and p50/p95/p99 latency percentiles. Run it from the repository root: .. code-block:: bash python -m benchmarks.run_pipeline_benchmark \ --documents 100 --document-chars 4096 --queue-concurrency 4 \ --output pipeline-benchmark.json The input corpus is generated locally and contains no private documents. The queue test uses one SQLite store instance with bounded thread concurrency; it does not imply multi-host or multi-process scalability. The benchmark does not measure OCR or hosted model latency. Compare reports only when hardware, Python, workload and configuration are comparable. Timings are observational and are not enforced as brittle wall-clock thresholds in normal CI. Recorded local synthetic baseline --------------------------------- A reference run is stored at ``benchmarks/results/local-baseline.json``. It was collected on an 8-core arm64 Mac with 8 GiB RAM, Python 3.14.6, using 30 synthetic 2 KiB invoices, a 128-dimensional local hashing embedder and queue concurrency of four. This is a reproducibility example, not a service-level objective or a cross-machine performance claim. .. list-table:: Observed local baseline :header-rows: 1 * - Measurement - Result * - Ingestion throughput - 190.6 documents/second * - Ingestion latency p50 / p95 / p99 - 5.032 / 5.342 / 10.525 ms * - Retrieval latency p50 / p95 / p99 - 3.966 / 4.170 / 9.209 ms * - Queue enqueue / claim throughput - 3,529 / 6,813 jobs/second * - Python-traced peak memory - 771,878 bytes In this particular small synthetic run, schema extraction and embed/store were the largest measured median stages (about 1.1 ms each), followed by parsing (about 0.84 ms). The practical recommendation is to preserve stage-level measurements and repeat the same workload before optimizing; the current data does not justify architectural changes or larger worker counts. OCR, hosted embeddings, large PDFs, disk contention and multi-process/multi-host queue behavior are not represented. Document intelligence quality evaluation ---------------------------------------- Run the offline synthetic evaluation corpus: .. code-block:: bash python -m benchmarks.run_document_evaluation \ --output document-evaluation.json The versioned corpus at ``benchmarks/data/document_intelligence_v1.json`` is original synthetic text licensed CC0-1.0. Reports include dataset SHA-256, provenance, per-document diagnostics, character error rate, classification accuracy, exact normalized entity precision/recall/F1, and schema-field exact accuracy. The evaluator runs locally without paid APIs and does not modify the existing retrieval evaluation harness. Only include documents with known ground truth in the scored denominator. Unlabelled fields must be omitted from ``expected_fields`` rather than counted as misses. Before using results to choose a production model, expand the corpus with permission-cleared, human-reviewed examples and document each source's license and annotation process. OCR/table-specific metrics require a separate corpus with page/table ground truth.