hydrag-benchmark 0.5.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. hydrag_benchmark-0.5.0/.gitignore +28 -0
  2. hydrag_benchmark-0.5.0/CHANGELOG.md +63 -0
  3. hydrag_benchmark-0.5.0/LICENSE +190 -0
  4. hydrag_benchmark-0.5.0/PKG-INFO +219 -0
  5. hydrag_benchmark-0.5.0/README.md +182 -0
  6. hydrag_benchmark-0.5.0/pyproject.toml +89 -0
  7. hydrag_benchmark-0.5.0/src/hydrag_benchmark/__init__.py +3 -0
  8. hydrag_benchmark-0.5.0/src/hydrag_benchmark/augmentation_cache.py +15 -0
  9. hydrag_benchmark-0.5.0/src/hydrag_benchmark/beir_loader.py +154 -0
  10. hydrag_benchmark-0.5.0/src/hydrag_benchmark/beir_runner.py +317 -0
  11. hydrag_benchmark-0.5.0/src/hydrag_benchmark/cli.py +297 -0
  12. hydrag_benchmark-0.5.0/src/hydrag_benchmark/doc2query.py +19 -0
  13. hydrag_benchmark-0.5.0/src/hydrag_benchmark/embedding.py +162 -0
  14. hydrag_benchmark-0.5.0/src/hydrag_benchmark/harness.py +201 -0
  15. hydrag_benchmark-0.5.0/src/hydrag_benchmark/heads/__init__.py +20 -0
  16. hydrag_benchmark-0.5.0/src/hydrag_benchmark/heads/base.py +51 -0
  17. hydrag_benchmark-0.5.0/src/hydrag_benchmark/heads/head_a.py +313 -0
  18. hydrag_benchmark-0.5.0/src/hydrag_benchmark/heads/head_b.py +230 -0
  19. hydrag_benchmark-0.5.0/src/hydrag_benchmark/heads/head_c.py +83 -0
  20. hydrag_benchmark-0.5.0/src/hydrag_benchmark/heads/head_d.py +93 -0
  21. hydrag_benchmark-0.5.0/src/hydrag_benchmark/heads/head_e.py +113 -0
  22. hydrag_benchmark-0.5.0/src/hydrag_benchmark/metrics.py +78 -0
  23. hydrag_benchmark-0.5.0/src/hydrag_benchmark/py.typed +1 -0
  24. hydrag_benchmark-0.5.0/src/hydrag_benchmark/quality_filter.py +97 -0
  25. hydrag_benchmark-0.5.0/src/hydrag_benchmark/runner.py +515 -0
  26. hydrag_benchmark-0.5.0/src/hydrag_benchmark/suite.py +62 -0
  27. hydrag_benchmark-0.5.0/suites/cpython-stdlib.yaml +194 -0
  28. hydrag_benchmark-0.5.0/suites/k8s-kep.yaml +192 -0
  29. hydrag_benchmark-0.5.0/suites/synthetic-smoke.yaml +50 -0
  30. hydrag_benchmark-0.5.0/tests/__init__.py +0 -0
  31. hydrag_benchmark-0.5.0/tests/test_beir.py +256 -0
  32. hydrag_benchmark-0.5.0/tests/test_cli.py +206 -0
  33. hydrag_benchmark-0.5.0/tests/test_doc2query.py +196 -0
  34. hydrag_benchmark-0.5.0/tests/test_harness.py +274 -0
  35. hydrag_benchmark-0.5.0/tests/test_head_a.py +207 -0
  36. hydrag_benchmark-0.5.0/tests/test_head_b.py +247 -0
  37. hydrag_benchmark-0.5.0/tests/test_metrics.py +90 -0
  38. hydrag_benchmark-0.5.0/tests/test_prefill.py +177 -0
  39. hydrag_benchmark-0.5.0/tests/test_quality_filter.py +108 -0
  40. hydrag_benchmark-0.5.0/tests/test_strategy.py +230 -0
  41. hydrag_benchmark-0.5.0/tests/test_suite.py +64 -0
@@ -0,0 +1,28 @@
1
+ dist/
2
+ build/
3
+ .ruff_cache/
4
+ *.egg-info/
5
+ *.egg
6
+ .eggs/
7
+ *.so
8
+ *.onnx
9
+ .env
10
+ .venv/
11
+ *.whl
12
+ __pycache__/
13
+ *.pyc
14
+ .mypy_cache/
15
+ .pytest_cache/
16
+ # Local benchmark results
17
+ beir-results/
18
+ # Dev scripts
19
+ run_beir_save.py
20
+ *.whl
21
+ __pycache__/
22
+ *.pyc
23
+ .mypy_cache/
24
+ .pytest_cache/
25
+ # Scratch dev scripts
26
+ test_pool.py
27
+ test_profile.py
28
+ test_profile4.py
@@ -0,0 +1,63 @@
1
+ # Changelog
2
+
3
+ All notable changes to `hydrag-benchmark` will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [0.5.0] - 2026-03-18
9
+
10
+ ### Changed
11
+
12
+ - **Doc2Query & AugmentationCache re-exported from hydrag-core** (T-746): `doc2query.py` and `augmentation_cache.py` are now thin re-export wrappers; canonical implementation lives in `hydrag.doc2query` (hydrag-core v1.2.0+). All existing imports remain backward-compatible.
13
+ - Package version bumped to `0.5.0`.
14
+
15
+ ## [0.4.0] - 2026-03-18
16
+
17
+ ### Changed
18
+
19
+ - Minor version bump for hydrag-core v1.2.0 compatibility.
20
+
21
+ ## [0.3.0] - 2026-03-15
22
+
23
+ ### Added
24
+
25
+ - `prefill` CLI command for Phase 1a Doc2Query cache population.
26
+ - `multihead` CLI command for A/B/C configuration harness execution.
27
+ - GPU optional extra (`hydrag-benchmark[gpu]`) for transformers-based embedding path.
28
+ - New benchmark suites: `k8s-kep.yaml` and `cpython-stdlib.yaml`.
29
+
30
+ ### Changed
31
+
32
+ - Package version bumped to `0.3.0`.
33
+ - README updated for complete CLI argument, config, and artifact-path parity.
34
+
35
+ ## [0.2.0] - 2026-03-15
36
+
37
+ ### Added
38
+
39
+ - Strategy-aware dispatch: `similarity`, `hybrid`, `crag`, `hydrag` each route
40
+ through appropriate hydrag-core retrieval heads.
41
+ - `_ChromaDBAdapter` implementing `VectorStoreAdapter` protocol for hydrag-core
42
+ integration.
43
+ - `SUPPORTED_STRATEGIES` and `_STRATEGY_HEADS` constants in `runner.py`.
44
+ - 13 new strategy dispatch tests (`test_strategy.py`).
45
+ - CI job with pytest + smoke benchmark + recall gate (`recall_at_k >= 0.5`).
46
+
47
+ ### Changed
48
+
49
+ - `_search_fn` replaced with strategy-aware dispatch (was direct ChromaDB query).
50
+
51
+ ## [0.1.0] - 2026-03-14
52
+
53
+ ### Added
54
+
55
+ - Initial release.
56
+ - `hydrag-bench` CLI with `run` and `list-suites` subcommands.
57
+ - Benchmark suite YAML format with versioned schema.
58
+ - Frozen v0.1 metrics: `recall_at_1`, `recall_at_k`, `mrr`, `chunk_overlap`,
59
+ `latency_ms` (avg, p50, p95, p99).
60
+ - Versioned JSON output schema (`schema_version: "0.1"`).
61
+ - Synthetic smoke-test suite (`suites/synthetic-smoke.yaml`).
62
+ - PEP 561 `py.typed` marker for type-checked consumers.
63
+ - 30 unit tests covering runner, metrics, CLI, and suite parsing.
@@ -0,0 +1,190 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to the Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by the Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding any notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided alongside the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ Copyright 2026 Studio Playbook Contributors
179
+
180
+ Licensed under the Apache License, Version 2.0 (the "License");
181
+ you may not use this file except in compliance with the License.
182
+ You may obtain a copy of the License at
183
+
184
+ http://www.apache.org/licenses/LICENSE-2.0
185
+
186
+ Unless required by applicable law or agreed to in writing, software
187
+ distributed under the License is distributed on an "AS IS" BASIS,
188
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
189
+ See the License for the specific language governing permissions and
190
+ limitations under the License.
@@ -0,0 +1,219 @@
1
+ Metadata-Version: 2.4
2
+ Name: hydrag-benchmark
3
+ Version: 0.5.0
4
+ Summary: Local-only RAG benchmarking CLI — measures recall, MRR, chunk overlap, latency, and BEIR IR metrics
5
+ Project-URL: Homepage, https://github.com/studio-playbook/hydrag-benchmark
6
+ Project-URL: Documentation, https://github.com/studio-playbook/hydrag-benchmark#readme
7
+ Project-URL: Repository, https://github.com/studio-playbook/hydrag-benchmark
8
+ Project-URL: Changelog, https://github.com/studio-playbook/hydrag-benchmark/blob/main/CHANGELOG.md
9
+ Project-URL: Issues, https://github.com/studio-playbook/hydrag-benchmark/issues
10
+ Author: Studio Playbook Contributors
11
+ License-Expression: Apache-2.0
12
+ License-File: LICENSE
13
+ Keywords: benchmark,hydrag,mrr,rag,recall,retrieval
14
+ Classifier: Development Status :: 4 - Beta
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: Intended Audience :: Science/Research
17
+ Classifier: License :: OSI Approved :: Apache Software License
18
+ Classifier: Operating System :: OS Independent
19
+ Classifier: Programming Language :: Python :: 3
20
+ Classifier: Programming Language :: Python :: 3.10
21
+ Classifier: Programming Language :: Python :: 3.11
22
+ Classifier: Programming Language :: Python :: 3.12
23
+ Classifier: Programming Language :: Python :: 3.13
24
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
25
+ Classifier: Typing :: Typed
26
+ Requires-Python: >=3.10
27
+ Requires-Dist: hydrag-core[chromadb]
28
+ Requires-Dist: pyyaml>=6.0
29
+ Provides-Extra: dev
30
+ Requires-Dist: mypy>=1.10; extra == 'dev'
31
+ Requires-Dist: pytest>=8.0; extra == 'dev'
32
+ Requires-Dist: ruff>=0.4; extra == 'dev'
33
+ Provides-Extra: gpu
34
+ Requires-Dist: torch>=2.0; extra == 'gpu'
35
+ Requires-Dist: transformers>=4.40; extra == 'gpu'
36
+ Description-Content-Type: text/markdown
37
+
38
+ # hydrag-benchmark
39
+
40
+ Local-only RAG benchmarking CLI for retrieval quality and latency analysis.
41
+
42
+ ## Installation
43
+
44
+ ```bash
45
+ pip install hydrag-benchmark
46
+ ```
47
+
48
+ Optional GPU path for multi-head dense embeddings:
49
+
50
+ ```bash
51
+ pip install "hydrag-benchmark[gpu]"
52
+ ```
53
+
54
+ ## Included Suites
55
+
56
+ - `suites/synthetic-smoke.yaml`
57
+ - `suites/k8s-kep.yaml`
58
+ - `suites/cpython-stdlib.yaml`
59
+
60
+ ## Quickstart
61
+
62
+ ```bash
63
+ # List shipped suites
64
+ hydrag-bench list-suites --suite-dir ./suites
65
+
66
+ # Run classic strategy benchmark
67
+ hydrag-bench run suites/synthetic-smoke.yaml \
68
+ --strategy hydrag \
69
+ --corpus-dir ./my-codebase/src \
70
+ --output-dir ./results
71
+
72
+ # Inspect output
73
+ python -m json.tool ./results/synthetic-smoke_hydrag.json
74
+ ```
75
+
76
+ ## Commands
77
+
78
+ ```bash
79
+ hydrag-bench --help
80
+ hydrag-bench --version
81
+
82
+ # 1) Classic single-strategy benchmark
83
+ hydrag-bench run <suite.yaml> --strategy <similarity|hybrid|crag|hydrag> --corpus-dir <path> [options]
84
+
85
+ # 2) List suites
86
+ hydrag-bench list-suites --suite-dir <path>
87
+
88
+ # 3) Prefill Doc2Query cache (Phase 1a)
89
+ hydrag-bench prefill --corpus-dir <path> [options]
90
+
91
+ # 4) Multi-head harness benchmark (Heads A/B/C)
92
+ hydrag-bench multihead <suite.yaml> --corpus-dir <path> [options]
93
+ ```
94
+
95
+ ### `run` Arguments
96
+
97
+ | Flag | Required | Default | Description |
98
+ |------|----------|---------|-------------|
99
+ | `suite` | yes | - | Path to benchmark suite YAML |
100
+ | `--strategy` | yes | - | One of `similarity`, `hybrid`, `crag`, `hydrag` |
101
+ | `--corpus-dir` | yes | - | Root directory of files to index |
102
+ | `--output-dir` | no | stdout | Directory to write `<suite>_<strategy>.json` |
103
+ | `--suite-dir` | no | - | Base dir for resolving relative `suite` path |
104
+ | `--n-results` | no | `5` | Top-k retrieval depth |
105
+ | `--seed` | no | `42` | Seed override |
106
+ | `--embedding-model` | no | `Alibaba-NLP/gte-Qwen2-7B-instruct` | Embedding model label passed to runner |
107
+ | `--db-path` | no | temp dir | ChromaDB persistence path |
108
+
109
+ ### `list-suites` Arguments
110
+
111
+ | Flag | Required | Default | Description |
112
+ |------|----------|---------|-------------|
113
+ | `--suite-dir` | yes | - | Directory containing `.yaml` / `.yml` suites |
114
+
115
+ ### `prefill` Arguments
116
+
117
+ | Flag | Required | Default | Description |
118
+ |------|----------|---------|-------------|
119
+ | `--corpus-dir` | yes | - | Root directory to chunk and process |
120
+ | `--doc2query-model` | no | `qwen3:4b` | Doc2Query model name |
121
+ | `--doc2query-api-url` | no | `http://localhost:11434` | Doc2Query API base URL |
122
+ | `--doc2query-timeout-s` | no | `30.0` | Request timeout seconds |
123
+ | `--doc2query-max-retries` | no | `2` | Retry attempts after first failure |
124
+ | `--doc2query-n-questions` | no | `3` | Synthetic questions per chunk |
125
+ | `--cache-dir` | no | in-memory only | Directory containing `augmentation_cache.json` |
126
+
127
+ ### `multihead` Arguments
128
+
129
+ | Flag | Required | Default | Description |
130
+ |------|----------|---------|-------------|
131
+ | `suite` | yes | - | Path to benchmark suite YAML |
132
+ | `--corpus-dir` | yes | - | Root directory of files to index |
133
+ | `--output-dir` | no | stdout | Directory to write `<suite>_multihead.json` and sidecar |
134
+ | `--suite-dir` | no | - | Base dir for resolving relative `suite` path |
135
+ | `--n-results` | no | `5` | Top-k retrieval depth |
136
+ | `--seed` | no | `42` | Seed override |
137
+ | `--use-gpu` | no | `false` | Use transformers embedder (requires `[gpu]`) |
138
+ | `--doc2query-model` | no | `qwen3:4b` | Doc2Query model name |
139
+ | `--doc2query-api-url` | no | `http://localhost:11434` | Doc2Query API base URL |
140
+ | `--doc2query-timeout-s` | no | `30.0` | Request timeout seconds |
141
+ | `--doc2query-max-retries` | no | `2` | Retry attempts after first failure |
142
+ | `--doc2query-n-questions` | no | `3` | Synthetic questions per chunk |
143
+ | `--embedding-model` | no | `Alibaba-NLP/gte-Qwen2-7B-instruct` | Dense embedding model name |
144
+ | `--alpha` | no | `0.5` | Head C rerank interpolation weight |
145
+ | `--cache-dir` | no | none | Directory for `augmentation_cache.json` persistence |
146
+
147
+ ## Config Variables and Runtime Inputs
148
+
149
+ - `hydrag-benchmark` does not read `HYDRAG_BENCHMARK_*` environment variables.
150
+ - Operator-facing runtime configuration is via CLI flags and suite YAML fields.
151
+ - Suite-level fields consumed by code:
152
+ - top-level: `name`, `version`, `seed`, `description`, `cases`
153
+ - `environment`: `strategy`, `n_results`
154
+
155
+ ## File Paths and Artifacts
156
+
157
+ | Path / Pattern | Producer | Meaning |
158
+ |----------------|----------|---------|
159
+ | `<output-dir>/<suite>_<strategy>.json` | `run` | Single-strategy result JSON (`schema_version: 0.1`) |
160
+ | `<output-dir>/<suite>_multihead.json` | `multihead` | Multi-head comparison matrix (`schema_version: 0.2`) |
161
+ | `<output-dir>/questions_sidecar.json` | `multihead` | Head B generated questions sidecar |
162
+ | `<cache-dir>/augmentation_cache.json` | `prefill` / `multihead` | 3-state Doc2Query cache shared across phases |
163
+ | `<db-path>` | `run` | ChromaDB persistent store location |
164
+
165
+ ## Output Schemas
166
+
167
+ - `run` emits schema `0.1` with per-case and aggregate metrics.
168
+ - `multihead` emits schema `0.2` with 5 config groups:
169
+ - `A-only`
170
+ - `B-only`
171
+ - `C-only`
172
+ - `A+B`
173
+ - `A+B+C`
174
+
175
+ ## Frozen 0.1 Metrics
176
+
177
+ | Metric | Description |
178
+ |--------|-------------|
179
+ | `recall_at_1` | 1.0 when top result includes a relevant phrase |
180
+ | `recall_at_k` | Fraction of relevant phrases found in top-k |
181
+ | `mrr` | Mean Reciprocal Rank of first relevant result |
182
+ | `chunk_overlap` | Token overlap between retrieved chunks and relevant phrases |
183
+ | `latency_ms.avg` | Mean latency in milliseconds |
184
+ | `latency_ms.p50` | 50th percentile latency |
185
+ | `latency_ms.p95` | 95th percentile latency |
186
+ | `latency_ms.p99` | 99th percentile latency |
187
+
188
+ ## Suite YAML Format
189
+
190
+ ```yaml
191
+ name: my-benchmark
192
+ version: "1.0"
193
+ seed: 42
194
+ description: Description of the benchmark suite.
195
+
196
+ environment:
197
+ strategy: hydrag
198
+ n_results: 5
199
+
200
+ cases:
201
+ - id: case-001
202
+ query: "search query text"
203
+ relevant_phrases:
204
+ - "expected phrase in results"
205
+ - "another expected phrase"
206
+ tags: [optional, tags]
207
+ ```
208
+
209
+ ## Development
210
+
211
+ ```bash
212
+ cd packages/hydrag-benchmark
213
+ pip install -e ".[dev]"
214
+ python -m pytest tests/ -v
215
+ ```
216
+
217
+ ## License
218
+
219
+ Apache-2.0
@@ -0,0 +1,182 @@
1
+ # hydrag-benchmark
2
+
3
+ Local-only RAG benchmarking CLI for retrieval quality and latency analysis.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pip install hydrag-benchmark
9
+ ```
10
+
11
+ Optional GPU path for multi-head dense embeddings:
12
+
13
+ ```bash
14
+ pip install "hydrag-benchmark[gpu]"
15
+ ```
16
+
17
+ ## Included Suites
18
+
19
+ - `suites/synthetic-smoke.yaml`
20
+ - `suites/k8s-kep.yaml`
21
+ - `suites/cpython-stdlib.yaml`
22
+
23
+ ## Quickstart
24
+
25
+ ```bash
26
+ # List shipped suites
27
+ hydrag-bench list-suites --suite-dir ./suites
28
+
29
+ # Run classic strategy benchmark
30
+ hydrag-bench run suites/synthetic-smoke.yaml \
31
+ --strategy hydrag \
32
+ --corpus-dir ./my-codebase/src \
33
+ --output-dir ./results
34
+
35
+ # Inspect output
36
+ python -m json.tool ./results/synthetic-smoke_hydrag.json
37
+ ```
38
+
39
+ ## Commands
40
+
41
+ ```bash
42
+ hydrag-bench --help
43
+ hydrag-bench --version
44
+
45
+ # 1) Classic single-strategy benchmark
46
+ hydrag-bench run <suite.yaml> --strategy <similarity|hybrid|crag|hydrag> --corpus-dir <path> [options]
47
+
48
+ # 2) List suites
49
+ hydrag-bench list-suites --suite-dir <path>
50
+
51
+ # 3) Prefill Doc2Query cache (Phase 1a)
52
+ hydrag-bench prefill --corpus-dir <path> [options]
53
+
54
+ # 4) Multi-head harness benchmark (Heads A/B/C)
55
+ hydrag-bench multihead <suite.yaml> --corpus-dir <path> [options]
56
+ ```
57
+
58
+ ### `run` Arguments
59
+
60
+ | Flag | Required | Default | Description |
61
+ |------|----------|---------|-------------|
62
+ | `suite` | yes | - | Path to benchmark suite YAML |
63
+ | `--strategy` | yes | - | One of `similarity`, `hybrid`, `crag`, `hydrag` |
64
+ | `--corpus-dir` | yes | - | Root directory of files to index |
65
+ | `--output-dir` | no | stdout | Directory to write `<suite>_<strategy>.json` |
66
+ | `--suite-dir` | no | - | Base dir for resolving relative `suite` path |
67
+ | `--n-results` | no | `5` | Top-k retrieval depth |
68
+ | `--seed` | no | `42` | Seed override |
69
+ | `--embedding-model` | no | `Alibaba-NLP/gte-Qwen2-7B-instruct` | Embedding model label passed to runner |
70
+ | `--db-path` | no | temp dir | ChromaDB persistence path |
71
+
72
+ ### `list-suites` Arguments
73
+
74
+ | Flag | Required | Default | Description |
75
+ |------|----------|---------|-------------|
76
+ | `--suite-dir` | yes | - | Directory containing `.yaml` / `.yml` suites |
77
+
78
+ ### `prefill` Arguments
79
+
80
+ | Flag | Required | Default | Description |
81
+ |------|----------|---------|-------------|
82
+ | `--corpus-dir` | yes | - | Root directory to chunk and process |
83
+ | `--doc2query-model` | no | `qwen3:4b` | Doc2Query model name |
84
+ | `--doc2query-api-url` | no | `http://localhost:11434` | Doc2Query API base URL |
85
+ | `--doc2query-timeout-s` | no | `30.0` | Request timeout seconds |
86
+ | `--doc2query-max-retries` | no | `2` | Retry attempts after first failure |
87
+ | `--doc2query-n-questions` | no | `3` | Synthetic questions per chunk |
88
+ | `--cache-dir` | no | in-memory only | Directory containing `augmentation_cache.json` |
89
+
90
+ ### `multihead` Arguments
91
+
92
+ | Flag | Required | Default | Description |
93
+ |------|----------|---------|-------------|
94
+ | `suite` | yes | - | Path to benchmark suite YAML |
95
+ | `--corpus-dir` | yes | - | Root directory of files to index |
96
+ | `--output-dir` | no | stdout | Directory to write `<suite>_multihead.json` and sidecar |
97
+ | `--suite-dir` | no | - | Base dir for resolving relative `suite` path |
98
+ | `--n-results` | no | `5` | Top-k retrieval depth |
99
+ | `--seed` | no | `42` | Seed override |
100
+ | `--use-gpu` | no | `false` | Use transformers embedder (requires `[gpu]`) |
101
+ | `--doc2query-model` | no | `qwen3:4b` | Doc2Query model name |
102
+ | `--doc2query-api-url` | no | `http://localhost:11434` | Doc2Query API base URL |
103
+ | `--doc2query-timeout-s` | no | `30.0` | Request timeout seconds |
104
+ | `--doc2query-max-retries` | no | `2` | Retry attempts after first failure |
105
+ | `--doc2query-n-questions` | no | `3` | Synthetic questions per chunk |
106
+ | `--embedding-model` | no | `Alibaba-NLP/gte-Qwen2-7B-instruct` | Dense embedding model name |
107
+ | `--alpha` | no | `0.5` | Head C rerank interpolation weight |
108
+ | `--cache-dir` | no | none | Directory for `augmentation_cache.json` persistence |
109
+
110
+ ## Config Variables and Runtime Inputs
111
+
112
+ - `hydrag-benchmark` does not read `HYDRAG_BENCHMARK_*` environment variables.
113
+ - Operator-facing runtime configuration is via CLI flags and suite YAML fields.
114
+ - Suite-level fields consumed by code:
115
+ - top-level: `name`, `version`, `seed`, `description`, `cases`
116
+ - `environment`: `strategy`, `n_results`
117
+
118
+ ## File Paths and Artifacts
119
+
120
+ | Path / Pattern | Producer | Meaning |
121
+ |----------------|----------|---------|
122
+ | `<output-dir>/<suite>_<strategy>.json` | `run` | Single-strategy result JSON (`schema_version: 0.1`) |
123
+ | `<output-dir>/<suite>_multihead.json` | `multihead` | Multi-head comparison matrix (`schema_version: 0.2`) |
124
+ | `<output-dir>/questions_sidecar.json` | `multihead` | Head B generated questions sidecar |
125
+ | `<cache-dir>/augmentation_cache.json` | `prefill` / `multihead` | 3-state Doc2Query cache shared across phases |
126
+ | `<db-path>` | `run` | ChromaDB persistent store location |
127
+
128
+ ## Output Schemas
129
+
130
+ - `run` emits schema `0.1` with per-case and aggregate metrics.
131
+ - `multihead` emits schema `0.2` with 5 config groups:
132
+ - `A-only`
133
+ - `B-only`
134
+ - `C-only`
135
+ - `A+B`
136
+ - `A+B+C`
137
+
138
+ ## Frozen 0.1 Metrics
139
+
140
+ | Metric | Description |
141
+ |--------|-------------|
142
+ | `recall_at_1` | 1.0 when top result includes a relevant phrase |
143
+ | `recall_at_k` | Fraction of relevant phrases found in top-k |
144
+ | `mrr` | Mean Reciprocal Rank of first relevant result |
145
+ | `chunk_overlap` | Token overlap between retrieved chunks and relevant phrases |
146
+ | `latency_ms.avg` | Mean latency in milliseconds |
147
+ | `latency_ms.p50` | 50th percentile latency |
148
+ | `latency_ms.p95` | 95th percentile latency |
149
+ | `latency_ms.p99` | 99th percentile latency |
150
+
151
+ ## Suite YAML Format
152
+
153
+ ```yaml
154
+ name: my-benchmark
155
+ version: "1.0"
156
+ seed: 42
157
+ description: Description of the benchmark suite.
158
+
159
+ environment:
160
+ strategy: hydrag
161
+ n_results: 5
162
+
163
+ cases:
164
+ - id: case-001
165
+ query: "search query text"
166
+ relevant_phrases:
167
+ - "expected phrase in results"
168
+ - "another expected phrase"
169
+ tags: [optional, tags]
170
+ ```
171
+
172
+ ## Development
173
+
174
+ ```bash
175
+ cd packages/hydrag-benchmark
176
+ pip install -e ".[dev]"
177
+ python -m pytest tests/ -v
178
+ ```
179
+
180
+ ## License
181
+
182
+ Apache-2.0