QueryGym
QueryGym
Open-source toolkit for reproducible LLM-based query reformulation.

Reproducible query reformulation, powered by LLMs.

QueryGym is a toolkit for benchmarking and reproducing LLM-based query rewriting methods across IR datasets. Open prompt bank, pluggable searchers, frozen schemas, citable runs.

Live reformulation preview
USER QUERY
what causes diabetes?
querygym.create_reformulator("genqr_ensemble")
REFORMULATED
what causes diabetes?
what causes diabetes type 1 type 2 insulin resistance pancreas autoimmune glucose metabolism risk factors genetic predisposition lifestyle obesity

What you get

QueryGym pairs a small, opinionated library with a contract-driven reproducibility pipeline. The toolkit and the leaderboard share the same data shape.

The ecosystem

QueryGym is split into three surfaces. They share the same data contract, so a run from the toolkit or a third-party submitter lands in the same leaderboard.

Try it in 30 seconds

Reformulate a query against any OpenAI-compatible endpoint. Pyserini and BEIR are optional extras.

pip
pip install querygym
python
import querygym as qg

reformulator = qg.create_reformulator("genqr_ensemble", model="gpt-4.1-mini")
result = reformulator.reformulate(qg.QueryItem("q1", "what causes diabetes?"))
print(result.reformulated)

Supported methods

Nine reformulation methods, each with a registered prompt, a paper reference, and a reproducibility entry on the leaderboard.

  • GenQR

    genqr

    Generic LLM-driven keyword expansion.

  • GenQR Ensemble

    genqr_ensemble

    10 instruction variants for diverse keyword expansion.

  • Query2Doc

    query2doc

    Generates pseudo-documents from LLM knowledge.

  • QA Expand

    qa_expand

    Question-answer expansion with sub-questions.

  • MuGI

    mugi

    Multi-granularity expansion with adaptive concatenation.

  • LameR

    lamer

    Context-based passage synthesis from retrieved docs.

  • CSQE

    csqe

    Sentence-level context expansion (KEQE + CSQE).

  • ThinkQE

    thinkqe

    Multi-round reasoning with corpus feedback.

  • Query2E

    query2e

    Query-to-entity / keyword expansion.