📝 Description
Build a comprehensive Python benchmark module using pytest-benchmark to evaluate and empirically compare Pipeline A (Canonical Incident Schema) vs Pipeline B (Template-Driven Extraction). This will measure extraction accuracy, consistency, hallucination rates, latency, cost, and scalability across both pipelines.
💡 Rationale
Following discussion #611, we agreed that the best way to settle the debate between Pipeline A and Pipeline B is through empirical evidence rather than assumptions. To make this decision objectively, we need robust benchmarking infrastructure that measures:
- Extraction Accuracy: Field-level precision against ground truth
- Consistency: Cross-form consistency (Pipeline A) and cross-template field consistency (Pipeline B)
- Hallucination Rate: Detection of fabricated values in critical fields (injury type, cause, property damage)
- Performance: End-to-end latency, LLM call counts, and token costs
- Scalability: Performance degradation when generating 1, 10, and 100 forms from the same narrative
🛠️ Proposed Solution
Implement a structured benchmark framework with pytest-benchmark integration:
benchmark/
├── README.md
├── conftest.py
├── run.py
│
├── datasets/
│ ├── narratives/ # Synthetic + anonymized incident reports
│ ├── templates/ # Real-world forms (NFIRS, MA, CAL FIRE, NY)
│ └── ground_truth/ # Expected extraction results
│
├── pipelines/
│ ├── base.py # Abstract pipeline interface
│ ├── pipeline_a.py # Canonical Incident Schema wrapper
│ └── pipeline_b.py # Template-Driven Extraction wrapper
│
├── evaluators/
│ ├── accuracy.py # Field-level accuracy (LLM-as-judge)
│ ├── consistency.py # Cross-form/cross-template consistency
│ ├── hallucination.py # False positive field detection
│ └── aggregate.py # Combined metrics reporting
│
├── tests/
│ ├── test_pipeline_a_benchmark.py
│ ├── test_pipeline_b_benchmark.py
│ └── test_extraction_metrics.py
│
├── reports/
│ ├── raw/ # Benchmark run outputs
│ ├── summaries/ # CSV/JSON comparison reports
│ └── figures/ # Visualization artifacts
│
├── config/
│ └── benchmark.yaml # Configuration for metrics, dataset size
│
└── utils/
├── io.py # File/data I/O helpers
├── metrics.py # Shared metric calculations
└── logging.py # Structured benchmark logging
Implementation approach:
✅ Acceptance Criteria
📌 Additional Context
- Related discussion: Designing a Benchmark Module to Evaluate Pipeline Improvements #611 "Designing a Benchmark Module to Evaluate Pipeline Improvements"
- Inspired by collaborative feedback from @chetanr25, @abhishek-8081, @vharkins1
- Ground truth should support confidence scores per field for accuracy vs confidence analysis
- Consider LLM-as-a-judge for nuanced partial value matching (e.g., "Floor 3" ≈ "3rd floor")
- Recommend CLI for development testing + CI protection of main branch
- Initial benchmark dataset should combine fully synthetic narratives with anonymized real-world fire reports
📝 Description
Build a comprehensive Python benchmark module using pytest-benchmark to evaluate and empirically compare Pipeline A (Canonical Incident Schema) vs Pipeline B (Template-Driven Extraction). This will measure extraction accuracy, consistency, hallucination rates, latency, cost, and scalability across both pipelines.
💡 Rationale
Following discussion #611, we agreed that the best way to settle the debate between Pipeline A and Pipeline B is through empirical evidence rather than assumptions. To make this decision objectively, we need robust benchmarking infrastructure that measures:
🛠️ Proposed Solution
Implement a structured benchmark framework with pytest-benchmark integration:
Implementation approach:
python run.py --pipeline a --output reports/) + GitHub Actions integration✅ Acceptance Criteria
python benchmark/run.py --pipeline a --dataset 10 --output reports/benchmark/README.mdwith dataset schema and metric definitions📌 Additional Context