feat(testset): Add ConfBench dataset deployer - #583
Conversation
Adds the ConfBench benchmark dataset as an automatically deployed test
set, extending RealKIE-FCC-Verified with up to 18 noise-augmented
variants per document for confidence calibration and OCR robustness
research.
Changes:
- Add ConfBench deployer Lambda (src/lambda/confbench_deployer/)
- Chunked self-invocation pattern to handle 1,346 files within
Lambda timeout (100 files per chunk)
- Streams PDFs directly from HuggingFace to S3 via multipart upload
- Retry with exponential backoff for transient CDN errors (5xx)
- Failed file report written to S3 at end of deployment
- Add managed config (config_library/managed_config/confbench/)
- Wire confbench into patterns/unified/template.yaml UpdateDefaultConfig
- Add ConfBench CloudFormation resources to template.yaml
- Document ConfBench in docs/test-studio.md
Dataset: https://huggingface.co/datasets/amazon/ConfBench
Source: 75 FCC invoices x up to 18 Augraphy noise variants = 1,346 docs
|
Findings 🔴 1. Blocking — template.yaml:1008 (ConfbenchDeployment): the chained deployment can exceed CloudFormation's 1-hour custom-resource response timeout, failing the stack. CFN's default (and maximum) ServiceTimeout is 3600 s; if no response arrives, the stack operation fails. Because only the final chunk calls cfnresponse.send, the whole 14-chunk chain
So the happy path lands somewhere around 60–90 minutes — straddling the deadline. Any CDN slowness or a couple of retries (each up to 5+10+20 s of time.sleep) pushes it over, and the Two related problems compound it:
Suggested fix: decouple from the CFN wait entirely — send cfnresponse.SUCCESS immediately after chunk 0 is kicked off (the DynamoDB record already carries status, so Test Studio can 🔴 2. Blocking — src/lambda/confbench_deployer/index.py:691-708: the continuation payload grows unboundedly and can exceed Lambda's 256 KB async invoke limit. FailedIdsSoFar accumulates {"id", "error"} for every failure across all 14 chunks and is passed inline in the self-invoke payload, alongside the entire CfnEvent. InvocationType="Event" The design already writes state to S3 (_store_row_data / _load_row_data); failed_ids should ride along there too rather than in the payload. Also note the str(e) in the failed-files 🟡 3. Should fix — ~32.7 GB is added to every single deployment with no opt-out. Measured comparison of the auto-deployed sets: ┌──────────────────────┬──────────┐ That's ~42× the other three combined, landing in a versioned, KMS-encrypted bucket with DataRetentionInDays defaulting to 365. Every customer of the accelerator pays that storage and 🟡 4. Should fix — src/lambda/confbench_deployer/index.py:672-673: document_id may be unbound in the exception handler. except Exception as e: document_id is assigned as the first statement inside the try. If data_dict["id"][idx] itself raises (malformed/short column), the handler raises NameError/UnboundLocalError — masking 🟡 5. Should fix — no CHANGELOG entry. Every prior test-set deployer got one (see CHANGELOG lines 1008, 1382, 1516). CLAUDE.md and the documentation skill require user-facing changes 🟡 6. Should fix — template.yaml:963 + src/lambda/confbench_deployer/index.py:634-637: abort_multipart_upload is not itself guarded. On a transfer error the handler calls abort_multipart_upload before recording last_pdf_error. If the abort call also fails (throttling, transient S3 error), that exception replaces the 🟢 7. Nit — docs/test-studio.md:36 and docs/configuration.md:42 are now stale. Line 36 still says "four benchmark datasets" while the list below it has five entries. 🟢 8. Nit — ruff format would reformat index.py. One block near create_testset_record's default description differs. src/ is in ruff.toml's extend-exclude, so CI won't catch it, but 🟢 9. Nit — datetime.utcnow() (lines 852, 883) is deprecated in Python 3.12. Copied from the existing deployers, so it's consistent — but datetime.now(timezone.utc) is the modern form 🟢 10. Nit — _store_row_data writes full json_response ground truth to S3 (line 447). The docstring says "Only IDs and json_response are needed; page_count and noise_variant are What's good
Recommendation Request changes. The pattern-following is genuinely good — the template block, IAM, and baseline format are all right, and streaming multipart was the correct instinct for large files. But the |
Adds the ConfBench benchmark dataset as an automatically deployed test set, extending RealKIE-FCC-Verified with up to 18 noise-augmented variants per document for confidence calibration and OCR robustness research.
Changes:
Dataset: https://huggingface.co/datasets/amazon/ConfBench
Source: 75 FCC invoices x up to 18 Augraphy noise variants = 1,346 docs
Issue #, if available:
Description of changes:
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.