Open
Conversation
The built-in query expansion model is English-tuned. Given a CJK or other non-English query, it tends to translate the query into English before generating variants. The vector search then runs against English-translated text — and on a non-English corpus, recall drops sharply. `qmd query --no-expand` skips expansion entirely and searches the original query verbatim. Mirrors `--no-rerank`. Also exposed as `expand: false` on the SDK `search()` method. The MCP `query` tool already takes pre-expanded `searches`, so expansion is structurally absent on that path; no MCP changes needed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#454
Summary
Add a
--no-expandflag toqmd querythat skips LLM query expansion and searches the original query verbatim.Motivation
The built-in query expansion model (
qmd-query-expansion-1.7B) is trained primarily on English. Given a non-English query — Chinese, Japanese, Korean — it translates the query into English before generating lex/vec/hyde variants. The vector search downstream then runs against English-translated text, and on a non-English corpus recall drops sharply.A typed-query path (
{ type: 'lex', query: ... }via SDK or MCP) bypasses expansion already, but for the simple ergonomicqmd query "..."CLI path there was no escape hatch. This PR adds one.Changes
qmd query --no-expandskips expansion entirely and searches the original query verbatim. Mirrors--no-rerank.search({ query, expand: false })— analogous to the existingrerank: false.HybridQueryOptions.skipExpansionplumbs through tohybridQuery(). When set,expandQuery()is not called and the lex/vec/hyde fan-out is empty — only the original query runs against BM25 and the vector index.Expansion disabled (--no-expand)line on stderr so users see the flag took effect, instead of the misleading "Expanding query..." line.querytool already takes pre-expandedsearches, so expansion is structurally absent there. No MCP changes needed.Usage
Notes
--no-expandis absent (orexpandis unset /true).--no-expandjust makes the bypass unconditional.--no-rerankfor the lowest-latency CPU path:qmd query "..." --no-expand --no-rerankruns only BM25 + vector + RRF, no LLM calls.