querygym 0.2.0__tar.gz → 0.3.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.
- querygym-0.3.0/MANIFEST.in +38 -0
- {querygym-0.2.0/querygym.egg-info → querygym-0.3.0}/PKG-INFO +41 -17
- {querygym-0.2.0 → querygym-0.3.0}/README.md +33 -16
- {querygym-0.2.0 → querygym-0.3.0}/docs/about/changelog.md +16 -1
- {querygym-0.2.0 → querygym-0.3.0}/docs/api/core.md +10 -0
- {querygym-0.2.0 → querygym-0.3.0}/docs/getting-started/quickstart.md +1 -2
- {querygym-0.2.0 → querygym-0.3.0}/docs/index.md +1 -1
- querygym-0.3.0/docs/user-guide/cli.md +41 -0
- {querygym-0.2.0 → querygym-0.3.0}/docs/user-guide/methods-reference.md +74 -1
- {querygym-0.2.0 → querygym-0.3.0}/docs/user-guide/reformulation.md +1 -1
- querygym-0.3.0/docs/user-guide/reproducibility.md +82 -0
- {querygym-0.2.0 → querygym-0.3.0}/examples/querygym_pyserini/pipeline.py +64 -16
- {querygym-0.2.0 → querygym-0.3.0}/examples/querygym_pyserini/reformulate_queries.py +2 -2
- querygym-0.3.0/examples/querygym_pyserini/run_summary.py +111 -0
- {querygym-0.2.0 → querygym-0.3.0}/pyproject.toml +15 -2
- {querygym-0.2.0 → querygym-0.3.0}/querygym/__init__.py +3 -1
- {querygym-0.2.0 → querygym-0.3.0}/querygym/cli.py +74 -29
- {querygym-0.2.0 → querygym-0.3.0}/querygym/config/defaults.yaml +10 -1
- {querygym-0.2.0 → querygym-0.3.0}/querygym/core/base.py +21 -0
- {querygym-0.2.0 → querygym-0.3.0}/querygym/core/runner.py +1 -0
- querygym-0.3.0/querygym/core/utils.py +48 -0
- {querygym-0.2.0 → querygym-0.3.0}/querygym/loaders/__init__.py +2 -2
- querygym-0.3.0/querygym/loaders/bright.py +97 -0
- {querygym-0.2.0 → querygym-0.3.0}/querygym/methods/__init__.py +1 -0
- {querygym-0.2.0 → querygym-0.3.0}/querygym/methods/query2e.py +320 -8
- querygym-0.3.0/querygym/methods/reformer.py +213 -0
- {querygym-0.2.0 → querygym-0.3.0}/querygym/prompt_bank.yaml +48 -0
- {querygym-0.2.0 → querygym-0.3.0/querygym.egg-info}/PKG-INFO +41 -17
- {querygym-0.2.0 → querygym-0.3.0}/querygym.egg-info/SOURCES.txt +6 -0
- {querygym-0.2.0 → querygym-0.3.0}/querygym.egg-info/requires.txt +9 -0
- querygym-0.3.0/tests/test_cli_config.py +77 -0
- querygym-0.3.0/tests/test_methods_query2e.py +211 -0
- querygym-0.2.0/MANIFEST.in +0 -27
- querygym-0.2.0/docs/user-guide/cli.md +0 -6
- querygym-0.2.0/querygym/core/utils.py +0 -24
- {querygym-0.2.0 → querygym-0.3.0}/LICENSE +0 -0
- {querygym-0.2.0 → querygym-0.3.0}/docs/about/license.md +0 -0
- {querygym-0.2.0 → querygym-0.3.0}/docs/api/adapters.md +0 -0
- {querygym-0.2.0 → querygym-0.3.0}/docs/api/loaders.md +0 -0
- {querygym-0.2.0 → querygym-0.3.0}/docs/api/methods.md +0 -0
- {querygym-0.2.0 → querygym-0.3.0}/docs/development/contributing.md +0 -0
- {querygym-0.2.0 → querygym-0.3.0}/docs/development/guide.md +0 -0
- {querygym-0.2.0 → querygym-0.3.0}/docs/getting-started/installation.md +0 -0
- {querygym-0.2.0 → querygym-0.3.0}/docs/user-guide/datasets.md +0 -0
- {querygym-0.2.0 → querygym-0.3.0}/docs/user-guide/docker.md +0 -0
- {querygym-0.2.0 → querygym-0.3.0}/docs/user-guide/prompts.md +0 -0
- {querygym-0.2.0 → querygym-0.3.0}/docs/user-guide/searcher.md +0 -0
- {querygym-0.2.0 → querygym-0.3.0}/examples/docker/quickstart.ipynb +0 -0
- {querygym-0.2.0 → querygym-0.3.0}/examples/querygym_pyserini/evaluate.py +0 -0
- {querygym-0.2.0 → querygym-0.3.0}/examples/querygym_pyserini/retrieve.py +0 -0
- {querygym-0.2.0 → querygym-0.3.0}/examples/querygym_pyserini/utils.py +0 -0
- {querygym-0.2.0 → querygym-0.3.0}/examples/snippets/01_load_from_file.py +0 -0
- {querygym-0.2.0 → querygym-0.3.0}/examples/snippets/02_load_with_loaders.py +0 -0
- {querygym-0.2.0 → querygym-0.3.0}/examples/snippets/03_query_reformulation.py +0 -0
- {querygym-0.2.0 → querygym-0.3.0}/examples/snippets/04_context_reformulation.py +0 -0
- {querygym-0.2.0 → querygym-0.3.0}/examples/snippets/05_using_adapters.py +0 -0
- {querygym-0.2.0 → querygym-0.3.0}/examples/snippets/tiny_queries.tsv +0 -0
- {querygym-0.2.0 → querygym-0.3.0}/querygym/__main__.py +0 -0
- {querygym-0.2.0 → querygym-0.3.0}/querygym/adapters/__init__.py +0 -0
- {querygym-0.2.0 → querygym-0.3.0}/querygym/adapters/pyserini_adapter.py +0 -0
- {querygym-0.2.0 → querygym-0.3.0}/querygym/adapters/pyterrier_adapter.py +0 -0
- {querygym-0.2.0 → querygym-0.3.0}/querygym/core/llm.py +0 -0
- {querygym-0.2.0 → querygym-0.3.0}/querygym/core/prompts.py +0 -0
- {querygym-0.2.0 → querygym-0.3.0}/querygym/core/registry.py +0 -0
- {querygym-0.2.0 → querygym-0.3.0}/querygym/core/searcher.py +0 -0
- {querygym-0.2.0 → querygym-0.3.0}/querygym/core/searcher_wrappers.py +0 -0
- {querygym-0.2.0 → querygym-0.3.0}/querygym/data/dataloader.py +0 -0
- {querygym-0.2.0 → querygym-0.3.0}/querygym/loaders/beir.py +0 -0
- {querygym-0.2.0 → querygym-0.3.0}/querygym/loaders/msmarco.py +0 -0
- {querygym-0.2.0 → querygym-0.3.0}/querygym/methods/csqe.py +0 -0
- {querygym-0.2.0 → querygym-0.3.0}/querygym/methods/genqr.py +0 -0
- {querygym-0.2.0 → querygym-0.3.0}/querygym/methods/genqr_ensemble.py +0 -0
- {querygym-0.2.0 → querygym-0.3.0}/querygym/methods/lamer.py +0 -0
- {querygym-0.2.0 → querygym-0.3.0}/querygym/methods/mugi.py +0 -0
- {querygym-0.2.0 → querygym-0.3.0}/querygym/methods/qa_expand.py +0 -0
- {querygym-0.2.0 → querygym-0.3.0}/querygym/methods/query2doc.py +0 -0
- {querygym-0.2.0 → querygym-0.3.0}/querygym/methods/thinkqe.py +0 -0
- {querygym-0.2.0 → querygym-0.3.0}/querygym.egg-info/dependency_links.txt +0 -0
- {querygym-0.2.0 → querygym-0.3.0}/querygym.egg-info/entry_points.txt +0 -0
- {querygym-0.2.0 → querygym-0.3.0}/querygym.egg-info/top_level.txt +0 -0
- {querygym-0.2.0 → querygym-0.3.0}/setup.cfg +0 -0
- {querygym-0.2.0 → querygym-0.3.0}/tests/test_cli_script_gen.py +0 -0
- {querygym-0.2.0 → querygym-0.3.0}/tests/test_dataloader.py +0 -0
- {querygym-0.2.0 → querygym-0.3.0}/tests/test_methods_genqr.py +0 -0
- {querygym-0.2.0 → querygym-0.3.0}/tests/test_methods_thinkqe.py +0 -0
- {querygym-0.2.0 → querygym-0.3.0}/tests/test_prompts.py +0 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Include package data files
|
|
2
|
+
include querygym/prompt_bank.yaml
|
|
3
|
+
include querygym/config/*.yaml
|
|
4
|
+
|
|
5
|
+
# Include documentation
|
|
6
|
+
include README.md
|
|
7
|
+
include LICENSE
|
|
8
|
+
include CONTRIBUTING.md
|
|
9
|
+
include Structure.md
|
|
10
|
+
|
|
11
|
+
# Include examples
|
|
12
|
+
recursive-include examples *.py *.tsv *.ipynb
|
|
13
|
+
|
|
14
|
+
# Include docs
|
|
15
|
+
recursive-include docs *.md
|
|
16
|
+
|
|
17
|
+
# Exclude reproducibility umbrella and (preemptive) future web/ from sdist.
|
|
18
|
+
# These are repo-only artifacts; nothing in them belongs in the PyPI source dist.
|
|
19
|
+
prune reproducibility
|
|
20
|
+
prune web
|
|
21
|
+
|
|
22
|
+
# Belt-and-suspenders: explicit exclude for workspace files that would never
|
|
23
|
+
# match a default include rule but shouldn't sneak in via a future MANIFEST sweep.
|
|
24
|
+
exclude package.json pnpm-workspace.yaml pnpm-lock.yaml package-lock.json yarn.lock
|
|
25
|
+
global-exclude node_modules
|
|
26
|
+
global-exclude .astro
|
|
27
|
+
|
|
28
|
+
# Exclude development and build artifacts
|
|
29
|
+
global-exclude __pycache__
|
|
30
|
+
global-exclude *.py[co]
|
|
31
|
+
global-exclude .DS_Store
|
|
32
|
+
global-exclude *.egg-info
|
|
33
|
+
global-exclude *.so
|
|
34
|
+
global-exclude .pytest_cache
|
|
35
|
+
global-exclude htmlcov
|
|
36
|
+
global-exclude .coverage
|
|
37
|
+
global-exclude .mypy_cache
|
|
38
|
+
global-exclude .ruff_cache
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: querygym
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0
|
|
4
4
|
Summary: LLM-based Query Reformulation Toolkit
|
|
5
5
|
Author-email: Radin Hamidi Rad <radin.h@gmail.com>, Amin Bigdeli <aminbigdeli97@gmail.com>, Mert Incesu <mert.incesu03@gmail.com>, Negar Arabzadeh <ngr.arabzadeh@gmail.com>
|
|
6
6
|
License: Apache-2.0
|
|
@@ -29,6 +29,8 @@ Provides-Extra: hf
|
|
|
29
29
|
Requires-Dist: datasets>=2.20.0; extra == "hf"
|
|
30
30
|
Provides-Extra: beir
|
|
31
31
|
Requires-Dist: beir>=2.0.0; extra == "beir"
|
|
32
|
+
Provides-Extra: bright
|
|
33
|
+
Requires-Dist: datasets>=2.20.0; extra == "bright"
|
|
32
34
|
Provides-Extra: pyserini
|
|
33
35
|
Requires-Dist: pyserini>=0.22.0; extra == "pyserini"
|
|
34
36
|
Provides-Extra: dev
|
|
@@ -41,10 +43,15 @@ Requires-Dist: mypy>=1.5.0; extra == "dev"
|
|
|
41
43
|
Requires-Dist: mkdocs>=1.5.0; extra == "dev"
|
|
42
44
|
Requires-Dist: mkdocs-material>=9.0.0; extra == "dev"
|
|
43
45
|
Requires-Dist: mkdocstrings[python]>=0.23.0; extra == "dev"
|
|
46
|
+
Provides-Extra: repro
|
|
47
|
+
Requires-Dist: pandas>=2.0.0; extra == "repro"
|
|
48
|
+
Requires-Dist: jsonschema>=4.20.0; extra == "repro"
|
|
44
49
|
Provides-Extra: all
|
|
45
50
|
Requires-Dist: datasets>=2.20.0; extra == "all"
|
|
46
51
|
Requires-Dist: beir>=2.0.0; extra == "all"
|
|
47
52
|
Requires-Dist: pyserini>=0.22.0; extra == "all"
|
|
53
|
+
Requires-Dist: pandas>=2.0.0; extra == "all"
|
|
54
|
+
Requires-Dist: jsonschema>=4.20.0; extra == "all"
|
|
48
55
|
Dynamic: license-file
|
|
49
56
|
|
|
50
57
|
[](https://deepwiki.com/ls3-lab/QueryGym)
|
|
@@ -64,8 +71,9 @@ Dynamic: license-file
|
|
|
64
71
|
</p>
|
|
65
72
|
|
|
66
73
|
<p align="center">
|
|
67
|
-
<a href="https://querygym.
|
|
68
|
-
<a href="https://
|
|
74
|
+
<a href="https://querygym.com">🌐 Website</a> •
|
|
75
|
+
<a href="https://leaderboard.querygym.com">📊 Leaderboard</a> •
|
|
76
|
+
<a href="https://querygym.readthedocs.io/">📚 Docs</a> •
|
|
69
77
|
<a href="https://pypi.org/project/querygym/">📦 PyPI</a> •
|
|
70
78
|
<a href="https://arxiv.org/abs/2511.15996">📄 Paper</a>
|
|
71
79
|
</p>
|
|
@@ -76,7 +84,7 @@ Dynamic: license-file
|
|
|
76
84
|
|
|
77
85
|
- Single **Prompt Bank** (YAML) with metadata
|
|
78
86
|
- **Simple DataLoader**: Dependency-free file loading for queries, qrels, and contexts
|
|
79
|
-
- **Format Loaders**: Optional BEIR
|
|
87
|
+
- **Format Loaders**: Optional BEIR, MS MARCO, and BRIGHT format loaders in `querygym.loaders`
|
|
80
88
|
- **OpenAI-compatible** LLM client (works with any OpenAI API–compatible endpoint)
|
|
81
89
|
- **Pyserini** optional: either pass contexts (JSONL) or pass a retriever instance to build contexts
|
|
82
90
|
- Export-only: emits reformulated queries; optionally generates a **bash** script for Pyserini + `trec_eval`
|
|
@@ -92,10 +100,11 @@ QueryGym implements the following query reformulation methods:
|
|
|
92
100
|
| **Query2Doc** | Generates pseudo-documents from LLM knowledge | [Wang et al., 2023](https://arxiv.org/abs/2303.07678) |
|
|
93
101
|
| **QA Expand** | Question-answer based expansion with sub-questions | [Seo et al., 2025](https://arxiv.org/abs/2502.08557) |
|
|
94
102
|
| **MuGI** | Multi-granularity information expansion with adaptive concatenation | [Zhang et al., 2024](https://arxiv.org/abs/2401.06311) |
|
|
95
|
-
| **LameR** | Context-based passage synthesis using retrieved documents | [
|
|
96
|
-
| **CSQE** | Context-based sentence-level query expansion (KEQE + CSQE) | [
|
|
97
|
-
| **ThinkQE** | Multi-round reasoning-based query expansion with corpus feedback | [
|
|
103
|
+
| **LameR** | Context-based passage synthesis using retrieved documents | [Shen et al., 2023](https://arxiv.org/abs/2304.14233) |
|
|
104
|
+
| **CSQE** | Context-based sentence-level query expansion (KEQE + CSQE) | [Lei et al., 2024](https://arxiv.org/abs/2402.18031) |
|
|
105
|
+
| **ThinkQE** | Multi-round reasoning-based query expansion with corpus feedback | [Lei et al., 2025](https://arxiv.org/abs/2506.09260) |
|
|
98
106
|
| **Query2E** | Query to entity/keyword expansion | [Jagerman et al., 2023](https://arxiv.org/abs/2305.03653)|
|
|
107
|
+
| **ReFormeR** | Pattern-based, document-conditioned reformulation via learned transformation rules | [Bigdeli et al., 2026](https://arxiv.org/abs/2604.01417) |
|
|
99
108
|
|
|
100
109
|
For detailed usage and parameters, see the [Methods Reference](https://querygym.readthedocs.io/en/latest/user-guide/methods-reference/).
|
|
101
110
|
|
|
@@ -154,8 +163,7 @@ export OPENAI_API_KEY=sk-...
|
|
|
154
163
|
# Run a method (e.g., genqr_ensemble)
|
|
155
164
|
querygym run --method genqr_ensemble \
|
|
156
165
|
--queries-tsv queries.tsv \
|
|
157
|
-
--output-tsv reformulated.tsv
|
|
158
|
-
--cfg-path querygym/config/defaults.yaml
|
|
166
|
+
--output-tsv reformulated.tsv
|
|
159
167
|
```
|
|
160
168
|
|
|
161
169
|
### Loading Datasets
|
|
@@ -182,6 +190,20 @@ queries = qg.loaders.msmarco.load_queries("queries.tsv")
|
|
|
182
190
|
qrels = qg.loaders.msmarco.load_qrels("qrels.tsv")
|
|
183
191
|
```
|
|
184
192
|
|
|
193
|
+
**BRIGHT:**
|
|
194
|
+
```python
|
|
195
|
+
import querygym as qg
|
|
196
|
+
from datasets import load_dataset
|
|
197
|
+
|
|
198
|
+
examples = load_dataset("xlangai/BRIGHT", "examples")["biology"]
|
|
199
|
+
documents = load_dataset("xlangai/BRIGHT", "documents")["biology"]
|
|
200
|
+
|
|
201
|
+
queries = qg.loaders.bright.load_queries(examples)
|
|
202
|
+
reasoning_queries = qg.loaders.bright.load_reasoning_queries(examples)
|
|
203
|
+
qrels = qg.loaders.bright.load_qrels(examples)
|
|
204
|
+
corpus = qg.loaders.bright.load_corpus(documents)
|
|
205
|
+
```
|
|
206
|
+
|
|
185
207
|
## Examples
|
|
186
208
|
|
|
187
209
|
See the [examples](examples/) directory for:
|
|
@@ -220,13 +242,15 @@ This project is licensed under the Apache License 2.0 - see the [LICENSE](LICENS
|
|
|
220
242
|
If you use QueryGym in your research, please cite:
|
|
221
243
|
|
|
222
244
|
```bibtex
|
|
223
|
-
@
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
245
|
+
@inproceedings{10.1145/3774905.3793135,
|
|
246
|
+
author = {Bigdeli, Amin and Hamidi Rad, Radin and Incesu, Mert and Arabzadeh, Negar and Clarke, Charles and Bagheri, Ebrahim},
|
|
247
|
+
title = {QueryGym: A Toolkit for Reproducible LLM-Based Query Reformulation},
|
|
248
|
+
booktitle = {Companion Proceedings of the ACM Web Conference 2026},
|
|
249
|
+
series = {WWW Companion '26},
|
|
250
|
+
year = {2026},
|
|
251
|
+
pages = {196--199},
|
|
252
|
+
publisher = {Association for Computing Machinery},
|
|
253
|
+
doi = {10.1145/3774905.3793135},
|
|
254
|
+
url = {https://doi.org/10.1145/3774905.3793135}
|
|
231
255
|
}
|
|
232
256
|
```
|
|
@@ -15,8 +15,9 @@
|
|
|
15
15
|
</p>
|
|
16
16
|
|
|
17
17
|
<p align="center">
|
|
18
|
-
<a href="https://querygym.
|
|
19
|
-
<a href="https://
|
|
18
|
+
<a href="https://querygym.com">🌐 Website</a> •
|
|
19
|
+
<a href="https://leaderboard.querygym.com">📊 Leaderboard</a> •
|
|
20
|
+
<a href="https://querygym.readthedocs.io/">📚 Docs</a> •
|
|
20
21
|
<a href="https://pypi.org/project/querygym/">📦 PyPI</a> •
|
|
21
22
|
<a href="https://arxiv.org/abs/2511.15996">📄 Paper</a>
|
|
22
23
|
</p>
|
|
@@ -27,7 +28,7 @@
|
|
|
27
28
|
|
|
28
29
|
- Single **Prompt Bank** (YAML) with metadata
|
|
29
30
|
- **Simple DataLoader**: Dependency-free file loading for queries, qrels, and contexts
|
|
30
|
-
- **Format Loaders**: Optional BEIR
|
|
31
|
+
- **Format Loaders**: Optional BEIR, MS MARCO, and BRIGHT format loaders in `querygym.loaders`
|
|
31
32
|
- **OpenAI-compatible** LLM client (works with any OpenAI API–compatible endpoint)
|
|
32
33
|
- **Pyserini** optional: either pass contexts (JSONL) or pass a retriever instance to build contexts
|
|
33
34
|
- Export-only: emits reformulated queries; optionally generates a **bash** script for Pyserini + `trec_eval`
|
|
@@ -43,10 +44,11 @@ QueryGym implements the following query reformulation methods:
|
|
|
43
44
|
| **Query2Doc** | Generates pseudo-documents from LLM knowledge | [Wang et al., 2023](https://arxiv.org/abs/2303.07678) |
|
|
44
45
|
| **QA Expand** | Question-answer based expansion with sub-questions | [Seo et al., 2025](https://arxiv.org/abs/2502.08557) |
|
|
45
46
|
| **MuGI** | Multi-granularity information expansion with adaptive concatenation | [Zhang et al., 2024](https://arxiv.org/abs/2401.06311) |
|
|
46
|
-
| **LameR** | Context-based passage synthesis using retrieved documents | [
|
|
47
|
-
| **CSQE** | Context-based sentence-level query expansion (KEQE + CSQE) | [
|
|
48
|
-
| **ThinkQE** | Multi-round reasoning-based query expansion with corpus feedback | [
|
|
47
|
+
| **LameR** | Context-based passage synthesis using retrieved documents | [Shen et al., 2023](https://arxiv.org/abs/2304.14233) |
|
|
48
|
+
| **CSQE** | Context-based sentence-level query expansion (KEQE + CSQE) | [Lei et al., 2024](https://arxiv.org/abs/2402.18031) |
|
|
49
|
+
| **ThinkQE** | Multi-round reasoning-based query expansion with corpus feedback | [Lei et al., 2025](https://arxiv.org/abs/2506.09260) |
|
|
49
50
|
| **Query2E** | Query to entity/keyword expansion | [Jagerman et al., 2023](https://arxiv.org/abs/2305.03653)|
|
|
51
|
+
| **ReFormeR** | Pattern-based, document-conditioned reformulation via learned transformation rules | [Bigdeli et al., 2026](https://arxiv.org/abs/2604.01417) |
|
|
50
52
|
|
|
51
53
|
For detailed usage and parameters, see the [Methods Reference](https://querygym.readthedocs.io/en/latest/user-guide/methods-reference/).
|
|
52
54
|
|
|
@@ -105,8 +107,7 @@ export OPENAI_API_KEY=sk-...
|
|
|
105
107
|
# Run a method (e.g., genqr_ensemble)
|
|
106
108
|
querygym run --method genqr_ensemble \
|
|
107
109
|
--queries-tsv queries.tsv \
|
|
108
|
-
--output-tsv reformulated.tsv
|
|
109
|
-
--cfg-path querygym/config/defaults.yaml
|
|
110
|
+
--output-tsv reformulated.tsv
|
|
110
111
|
```
|
|
111
112
|
|
|
112
113
|
### Loading Datasets
|
|
@@ -133,6 +134,20 @@ queries = qg.loaders.msmarco.load_queries("queries.tsv")
|
|
|
133
134
|
qrels = qg.loaders.msmarco.load_qrels("qrels.tsv")
|
|
134
135
|
```
|
|
135
136
|
|
|
137
|
+
**BRIGHT:**
|
|
138
|
+
```python
|
|
139
|
+
import querygym as qg
|
|
140
|
+
from datasets import load_dataset
|
|
141
|
+
|
|
142
|
+
examples = load_dataset("xlangai/BRIGHT", "examples")["biology"]
|
|
143
|
+
documents = load_dataset("xlangai/BRIGHT", "documents")["biology"]
|
|
144
|
+
|
|
145
|
+
queries = qg.loaders.bright.load_queries(examples)
|
|
146
|
+
reasoning_queries = qg.loaders.bright.load_reasoning_queries(examples)
|
|
147
|
+
qrels = qg.loaders.bright.load_qrels(examples)
|
|
148
|
+
corpus = qg.loaders.bright.load_corpus(documents)
|
|
149
|
+
```
|
|
150
|
+
|
|
136
151
|
## Examples
|
|
137
152
|
|
|
138
153
|
See the [examples](examples/) directory for:
|
|
@@ -171,13 +186,15 @@ This project is licensed under the Apache License 2.0 - see the [LICENSE](LICENS
|
|
|
171
186
|
If you use QueryGym in your research, please cite:
|
|
172
187
|
|
|
173
188
|
```bibtex
|
|
174
|
-
@
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
189
|
+
@inproceedings{10.1145/3774905.3793135,
|
|
190
|
+
author = {Bigdeli, Amin and Hamidi Rad, Radin and Incesu, Mert and Arabzadeh, Negar and Clarke, Charles and Bagheri, Ebrahim},
|
|
191
|
+
title = {QueryGym: A Toolkit for Reproducible LLM-Based Query Reformulation},
|
|
192
|
+
booktitle = {Companion Proceedings of the ACM Web Conference 2026},
|
|
193
|
+
series = {WWW Companion '26},
|
|
194
|
+
year = {2026},
|
|
195
|
+
pages = {196--199},
|
|
196
|
+
publisher = {Association for Computing Machinery},
|
|
197
|
+
doi = {10.1145/3774905.3793135},
|
|
198
|
+
url = {https://doi.org/10.1145/3774905.3793135}
|
|
182
199
|
}
|
|
183
200
|
```
|
|
@@ -5,6 +5,20 @@ All notable changes to querygym will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [0.3.0] - 2026-10-04
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- `BaseReformulator.effective_params()`: method parameters that identify a run's configuration
|
|
12
|
+
- `querygym.core.utils.strip_think_trace()` helper for removing `<think>` reasoning traces
|
|
13
|
+
- `--clean-output/--no-clean-output` CLI flag
|
|
14
|
+
|
|
15
|
+
### Changed
|
|
16
|
+
- Query2E removes chat-model framing (`<think>` traces, introductory/closing sentences, markdown headings, category labels, term descriptions) from the LLM output before keyword parsing ([#42](https://github.com/ls3-lab/QueryGym/issues/42)). Controlled by the new `clean_output` parameter (default `True`); `clean_output=False` parses the raw output as before. Query2E method version 2.0
|
|
17
|
+
- Query2E runs record `clean_output: true` in their method parameters when output cleanup is enabled
|
|
18
|
+
- `querygym run` applies the per-method blocks in `querygym/config/defaults.yaml` (GenQR, GenQR Ensemble, Query2E, QA-Expand, MuGI, ReFormeR). Previously every method ran with the top-level `temperature: 1.0` / `max_tokens: 1024`; CLI output changes for GenQR, GenQR Ensemble, Query2E, QA-Expand and ReFormeR. Query2E runs few-shot by default (`mode: fs`); pass `--mode zs` for zero-shot
|
|
19
|
+
- `--cfg-path` is merged over the bundled defaults instead of replacing them, so a config file only needs the settings it changes
|
|
20
|
+
- Bundled default `seed` is 42, the same as the Python API and `MethodConfig` default
|
|
21
|
+
|
|
8
22
|
## [0.2.0] - 2026-04-12
|
|
9
23
|
|
|
10
24
|
### Added
|
|
@@ -114,7 +128,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
114
128
|
- Export to TSV/JSONL formats
|
|
115
129
|
- Script generation for Pyserini + trec_eval
|
|
116
130
|
|
|
117
|
-
[Unreleased]: https://github.com/ls3-lab/QueryGym/compare/v0.
|
|
131
|
+
[Unreleased]: https://github.com/ls3-lab/QueryGym/compare/v0.3.0...HEAD
|
|
132
|
+
[0.3.0]: https://github.com/ls3-lab/QueryGym/compare/v0.2.0...v0.3.0
|
|
118
133
|
[0.2.0]: https://github.com/ls3-lab/QueryGym/compare/v0.1.6...v0.2.0
|
|
119
134
|
[0.1.6]: https://github.com/ls3-lab/QueryGym/compare/v0.1.5...v0.1.6
|
|
120
135
|
[0.1.5]: https://github.com/ls3-lab/QueryGym/compare/v0.1.4...v0.1.5
|
|
@@ -108,6 +108,16 @@ for r in results:
|
|
|
108
108
|
print(f"{r.qid}: {r.reformulated}")
|
|
109
109
|
```
|
|
110
110
|
|
|
111
|
+
#### effective_params
|
|
112
|
+
|
|
113
|
+
```python
|
|
114
|
+
params = reformulator.effective_params()
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Method parameters that identify a run's configuration: the JSON-serializable subset of the configured params (runtime objects such as a searcher are dropped). Methods override it to record a parameter whose default changed, e.g. Query2E adds `clean_output: true` when output cleanup is enabled.
|
|
118
|
+
|
|
119
|
+
**Returns:** `Dict[str, Any]`
|
|
120
|
+
|
|
111
121
|
#### concatenate_result
|
|
112
122
|
|
|
113
123
|
```python
|
|
@@ -107,8 +107,7 @@ querygym also provides a command-line interface:
|
|
|
107
107
|
querygym run \
|
|
108
108
|
--method genqr_ensemble \
|
|
109
109
|
--queries-tsv queries.tsv \
|
|
110
|
-
--output-tsv reformulated.tsv
|
|
111
|
-
--cfg-path querygym/config/defaults.yaml
|
|
110
|
+
--output-tsv reformulated.tsv
|
|
112
111
|
```
|
|
113
112
|
|
|
114
113
|
See [CLI Usage](../user-guide/cli.md) for more details.
|
|
@@ -89,7 +89,7 @@ pip install querygym[dev]
|
|
|
89
89
|
- [CLI Usage](user-guide/cli.md)
|
|
90
90
|
- [API Reference](api/core.md)
|
|
91
91
|
|
|
92
|
-
> 📊 **Looking for benchmarks?** Visit the [Leaderboard](https://
|
|
92
|
+
> 📊 **Looking for benchmarks?** Visit the [Leaderboard](https://leaderboard.querygym.com).
|
|
93
93
|
|
|
94
94
|
## Citation
|
|
95
95
|
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# CLI
|
|
2
|
+
|
|
3
|
+
- `run` — produce reformulated TSV. For Query2E, `--no-clean-output` parses the raw LLM output instead of removing chat-model framing first.
|
|
4
|
+
- `data-to-tsv` — convert any backend to `qid<TAB>query`.
|
|
5
|
+
- `prompts-list` / `prompts-show` — inspect prompt bank.
|
|
6
|
+
- `script-gen` — create a Pyserini + trec_eval bash script.
|
|
7
|
+
|
|
8
|
+
## Configuration
|
|
9
|
+
|
|
10
|
+
`querygym run` uses the bundled defaults (`querygym/config/defaults.yaml`). They contain top-level `llm` and `params` settings plus a block per method with that method's defaults:
|
|
11
|
+
|
|
12
|
+
```yaml
|
|
13
|
+
query2e:
|
|
14
|
+
llm:
|
|
15
|
+
temperature: 0.7
|
|
16
|
+
max_tokens: 256
|
|
17
|
+
params:
|
|
18
|
+
mode: "fs"
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Pass `--cfg-path` to override them with your own YAML file. Settings are resolved in this order (highest first):
|
|
22
|
+
|
|
23
|
+
1. CLI flags (`--mode`, `--num-examples`, ...)
|
|
24
|
+
2. The method's block in your config file
|
|
25
|
+
3. Top-level `llm` / `params` in your config file
|
|
26
|
+
4. The method's block in the bundled defaults
|
|
27
|
+
5. Top-level `llm` in the bundled defaults
|
|
28
|
+
|
|
29
|
+
Top-level `params` of the bundled defaults (index and retrieval settings) only apply when no `--cfg-path` is given. `seed` and `retries` come from your config file when given (default `42` / `2`).
|
|
30
|
+
|
|
31
|
+
A config file only needs the settings you want to change:
|
|
32
|
+
|
|
33
|
+
```yaml
|
|
34
|
+
llm:
|
|
35
|
+
model: "qwen2.5:7b"
|
|
36
|
+
base_url: "http://localhost:11434/v1"
|
|
37
|
+
api_key: "ollama"
|
|
38
|
+
query2e:
|
|
39
|
+
params:
|
|
40
|
+
max_keywords: 10
|
|
41
|
+
```
|
|
@@ -16,6 +16,7 @@ Complete reference guide for all query reformulation methods in QueryGym, includ
|
|
|
16
16
|
- [Query2E](#query2e)
|
|
17
17
|
- [CSQE](#csqe)
|
|
18
18
|
- [ThinkQE](#thinkqe)
|
|
19
|
+
- [ReFormeR](#reformer)
|
|
19
20
|
|
|
20
21
|
---
|
|
21
22
|
|
|
@@ -444,6 +445,7 @@ result = reformulator.reformulate(qg.QueryItem("q1", "machine learning"))
|
|
|
444
445
|
| `mode` | str | `"zs"` | Mode: `"zs"`/`"zeroshot"` (zero-shot) or `"fs"`/`"fewshot"` (few-shot) |
|
|
445
446
|
| `num_examples` | int | `4` | Number of few-shot examples (only for `mode="fs"`) |
|
|
446
447
|
| `max_keywords` | int | `20` | Maximum number of keywords to extract |
|
|
448
|
+
| `clean_output` | bool | `True` | Remove chat-model framing from the LLM output before keyword parsing: `<think>` traces, introductory/closing sentences, markdown headings, category labels and term descriptions. `False` parses the raw output |
|
|
447
449
|
| `dataset_type` | str | `None` | Dataset type for few-shot: `"msmarco"`, `"beir"`, or `"generic"` |
|
|
448
450
|
| `collection_path` | str | `None` | Path to collection file (for MS MARCO/generic) |
|
|
449
451
|
| `train_queries_path` | str | `None` | Path to training queries file |
|
|
@@ -490,7 +492,7 @@ result = reformulator.reformulate(qg.QueryItem("q1", "deep learning"))
|
|
|
490
492
|
#### Output Format
|
|
491
493
|
|
|
492
494
|
- **Concatenation:** `(query × 5) + keywords`
|
|
493
|
-
- **Metadata:** Includes `mode`, `keywords` list, `prompt_id`, `num_examples` (for few-shot)
|
|
495
|
+
- **Metadata:** Includes `mode`, `keywords` list, `prompt_id`, `num_examples` (for few-shot). With `clean_output`, also `clean_output` and, when applicable, `unclosed_think` (reasoning trace not closed), `truncated_at_query` (model continued with another few-shot example), `cleanup_fallback` (raw keyword list used) or `cleanup_empty` (no keywords found)
|
|
494
496
|
|
|
495
497
|
---
|
|
496
498
|
|
|
@@ -663,6 +665,77 @@ result = reformulator.reformulate_batch([qg.QueryItem("q1", "quantum computing")
|
|
|
663
665
|
|
|
664
666
|
---
|
|
665
667
|
|
|
668
|
+
### ReFormeR
|
|
669
|
+
|
|
670
|
+
**Method Name:** `"reformer"`
|
|
671
|
+
**Requires Context:** Yes
|
|
672
|
+
**Description:** Pattern-based, document-conditioned query reformulation. For each query, two LLM calls are made: first to select the best-fitting reformulation pattern from a pre-learned library (guided by top retrieved documents), then to apply that pattern's transformation rule to produce the final reformulated query. The output replaces the original query entirely.
|
|
673
|
+
|
|
674
|
+
#### Parameters
|
|
675
|
+
|
|
676
|
+
| Parameter | Type | Default | Description |
|
|
677
|
+
|-----------|------|---------|-------------|
|
|
678
|
+
| `retrieval_k` | int | 10 | Number of documents to retrieve per query |
|
|
679
|
+
| `context_docs` | int | 3 | Number of top retrieved documents fed to pattern selection (step 1) |
|
|
680
|
+
| `patterns_path` | str | None | Path to a custom patterns JSON file; if omitted, the built-in 10-pattern library is used |
|
|
681
|
+
| `threads` | int | 16 | Number of threads for batch retrieval |
|
|
682
|
+
|
|
683
|
+
#### LLM Configuration
|
|
684
|
+
|
|
685
|
+
| Parameter | Default | Description |
|
|
686
|
+
|-----------|---------|-------------|
|
|
687
|
+
| `temperature` | 0.1 | Sampling temperature for both LLM calls |
|
|
688
|
+
| `max_tokens` | 500 | Maximum tokens per generation |
|
|
689
|
+
|
|
690
|
+
#### Usage Example
|
|
691
|
+
|
|
692
|
+
```python
|
|
693
|
+
import querygym as qg
|
|
694
|
+
|
|
695
|
+
reformulator = qg.create_reformulator(
|
|
696
|
+
"reformer",
|
|
697
|
+
model="gpt-4.1",
|
|
698
|
+
params={
|
|
699
|
+
"searcher_type": "pyserini",
|
|
700
|
+
"searcher_kwargs": {"index": "msmarco-v1-passage"},
|
|
701
|
+
"retrieval_k": 10,
|
|
702
|
+
"context_docs": 3,
|
|
703
|
+
},
|
|
704
|
+
llm_config={"temperature": 0.1, "max_tokens": 500},
|
|
705
|
+
)
|
|
706
|
+
|
|
707
|
+
result = reformulator.reformulate(qg.QueryItem("q1", "what causes diabetes"))
|
|
708
|
+
print(result.reformulated)
|
|
709
|
+
print(result.metadata["selected_pattern"]) # e.g. "Semantic Clarification"
|
|
710
|
+
```
|
|
711
|
+
|
|
712
|
+
#### Custom Patterns
|
|
713
|
+
|
|
714
|
+
To use your own extracted patterns, pass a path to a JSON file with the same structure as the built-in library:
|
|
715
|
+
|
|
716
|
+
```python
|
|
717
|
+
reformulator = qg.create_reformulator(
|
|
718
|
+
"reformer",
|
|
719
|
+
model="gpt-4.1",
|
|
720
|
+
params={
|
|
721
|
+
"patterns_path": "/path/to/my_patterns.json",
|
|
722
|
+
"searcher_type": "pyserini",
|
|
723
|
+
"searcher_kwargs": {"index": "msmarco-v1-passage"},
|
|
724
|
+
},
|
|
725
|
+
)
|
|
726
|
+
```
|
|
727
|
+
|
|
728
|
+
Each pattern in the JSON must have: `pattern_name`, `description`, `transformation_rule`, and `examples` (list of `[original, reformulated]` pairs).
|
|
729
|
+
|
|
730
|
+
#### How It Works
|
|
731
|
+
|
|
732
|
+
1. **Pattern selection** (`reformer.pattern_selection.v1`): The LLM receives the query, the top `context_docs` retrieved documents, and the full pattern library as JSON. It returns the single best-fitting pattern as JSON.
|
|
733
|
+
2. **Pattern application** (`reformer.pattern_application.v1`): The LLM receives the query, the selected pattern's `transformation_rule`, and its `examples`. It returns only the reformulated query string.
|
|
734
|
+
|
|
735
|
+
If the pattern selection response cannot be parsed as valid JSON, the method falls back to the first pattern in the library and records `"pattern_fallback": true` in the result metadata.
|
|
736
|
+
|
|
737
|
+
---
|
|
738
|
+
|
|
666
739
|
## See Also
|
|
667
740
|
|
|
668
741
|
- [API Reference](../api/methods.md) - Technical API documentation
|
|
@@ -75,7 +75,7 @@ results = reformulator.reformulate_batch(queries, contexts=contexts)
|
|
|
75
75
|
|
|
76
76
|
### Query2E
|
|
77
77
|
|
|
78
|
-
Query to
|
|
78
|
+
Query to keyword expansion. Chat-model framing (introductory sentences, markdown, `<think>` traces) is removed from the LLM output before keyword parsing; pass `clean_output=False` to parse the raw output.
|
|
79
79
|
|
|
80
80
|
```python
|
|
81
81
|
reformulator = qg.create_reformulator("query2e", model="gpt-4")
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# Reproducibility & Leaderboard Submissions
|
|
2
|
+
|
|
3
|
+
QueryGym ships with a reproducibility pipeline that powers `leaderboard.querygym.com` and the SIGIR 2026 reproducibility paper. This page explains how to submit a result.
|
|
4
|
+
|
|
5
|
+
The full schema lives at `reproducibility/schema.md` (human-readable) and `reproducibility/schema.json` (machine-readable). All submitted JSONs are validated against it three times: at emit time, at submit time, and at aggregate time in CI.
|
|
6
|
+
|
|
7
|
+
## Trusted contributor flow
|
|
8
|
+
|
|
9
|
+
If you have commit access:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
# 1. Run the example pipeline.
|
|
13
|
+
python examples/querygym_pyserini/pipeline.py \
|
|
14
|
+
--dataset msmarco-v1-passage.trecdl2019 \
|
|
15
|
+
--method query2e \
|
|
16
|
+
--model gpt-4.1-mini \
|
|
17
|
+
--output-dir outputs/dl19_query2e_zs
|
|
18
|
+
|
|
19
|
+
# 2. Copy the output into the canonical layout.
|
|
20
|
+
python -m reproducibility.scripts.submit_run --from-dir outputs/dl19_query2e_zs
|
|
21
|
+
|
|
22
|
+
# 3. Regenerate the aggregate CSV + manifest.
|
|
23
|
+
make repro-aggregate
|
|
24
|
+
|
|
25
|
+
# 4. Commit and open a PR.
|
|
26
|
+
git add reproducibility/data/
|
|
27
|
+
git commit -m "add query2e/gpt-4.1-mini result on dl19-passage"
|
|
28
|
+
git push
|
|
29
|
+
gh pr create
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
CI runs the schema/validator tests and `aggregate_runs.py --check`. If everything is green, the leaderboard rebuilds on merge.
|
|
33
|
+
|
|
34
|
+
### Common failure modes
|
|
35
|
+
|
|
36
|
+
| Symptom | Cause | Fix |
|
|
37
|
+
|---|---|---|
|
|
38
|
+
| `aggregator --check failed: results.csv is out of date` | You forgot step 3. | Run `make repro-aggregate`, commit the diff. |
|
|
39
|
+
| `dataset_id 'foo' not in dataset_registry.yaml` | Typo or new dataset not registered. | Add the dataset to `dataset_registry.yaml` first, then re-submit. |
|
|
40
|
+
| `method_id 'foo' not in registered methods` | Method not registered or name typo'd. | Register via `@register_method("foo")` in `querygym/methods/`. |
|
|
41
|
+
| `params_hash mismatch` | The JSON was hand-edited. | Don't hand-edit run JSONs — re-run the emitter or use `submit_run` instead. |
|
|
42
|
+
| `metric(s) ['bleu'] not in eval_metrics for dataset 'X'` | Unsupported metric for that dataset. | Either drop the metric or add it to the dataset's `output.eval_metrics` in the registry. |
|
|
43
|
+
|
|
44
|
+
## External (fork) contributor flow
|
|
45
|
+
|
|
46
|
+
If you don't have commit access:
|
|
47
|
+
|
|
48
|
+
1. Fork `ls3-lab/QueryGym` on GitHub and clone your fork.
|
|
49
|
+
2. Run steps 1–3 from the trusted flow above.
|
|
50
|
+
3. Push to your fork and open a PR against `ls3-lab/QueryGym:main`.
|
|
51
|
+
|
|
52
|
+
CI runs the same schema/validator/aggregator checks against your PR — no LLM keys or Pyserini are needed for these checks, so fork PRs get fast feedback.
|
|
53
|
+
|
|
54
|
+
A maintainer will additionally **re-verify your numbers locally** before merging:
|
|
55
|
+
|
|
56
|
+
- **Cheap pre-check (~30s):** the maintainer runs `pytrec_eval` against your submitted `run.txt` using the dataset's qrels and confirms the reported metrics match.
|
|
57
|
+
- **Full re-run (only if needed):** if the cheap check is suspicious, the maintainer runs the example pipeline with your `config` block as inputs and compares reformulated queries + run file.
|
|
58
|
+
|
|
59
|
+
This is why every submission must include `run.txt` and `reformulated_queries.tsv` alongside the JSON — they make verification cheap.
|
|
60
|
+
|
|
61
|
+
## Verifying a published number (paper readers)
|
|
62
|
+
|
|
63
|
+
Each leaderboard row links to the canonical files at a paper-release tag. To verify independently:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
git clone --depth=1 --branch=paper-sigir2026 https://github.com/ls3-lab/QueryGym.git
|
|
67
|
+
cd QueryGym
|
|
68
|
+
|
|
69
|
+
# Pick a run.
|
|
70
|
+
RUN_DIR=reproducibility/data/runs/msmarco-v1-passage.trecdl2019/query2e/gpt-4.1-mini
|
|
71
|
+
|
|
72
|
+
# Re-run trec_eval against the public qrels (Pyserini ships them).
|
|
73
|
+
python -m pyserini.eval.trec_eval -m ndcg_cut.10 dl19-passage "${RUN_DIR}"/*.run.txt
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
The number from `pyserini.eval.trec_eval` should match `metrics.ndcg_cut_10` in the corresponding JSON.
|
|
77
|
+
|
|
78
|
+
## External tools (dashboard, third parties)
|
|
79
|
+
|
|
80
|
+
The contract is `reproducibility/schema.json` — a Draft 2020-12 JSON Schema document. Any tool that emits a conformant JSON can submit (subject to the trusted vs. fork flows above). You don't need to import any Python from QueryGym; just read the schema file and validate locally with whatever JSON Schema library your stack provides (`Ajv` for JS, `jsonschema` for Python, `everit-org/json-schema` for Java).
|
|
81
|
+
|
|
82
|
+
`schema_version` is `"const": 1` today. Bumping it to 2 will be a breaking change announced ahead of time.
|