Ver Fonte

Merge pull request #370 from mvanhorn/osc/231-no-rerank-cli-flag

feat(cli): add --no-rerank flag to skip reranking in qmd query
Tobias Lütke há 2 meses atrás
pai
commit
2b8f329d7e
1 ficheiros alterados com 6 adições e 0 exclusões
  1. 6 0
      src/cli/qmd.ts

+ 6 - 0
src/cli/qmd.ts

@@ -1745,6 +1745,7 @@ type OutputOptions = {
   context?: string;      // Optional context for query expansion
   candidateLimit?: number;  // Max candidates to rerank (default: 40)
   intent?: string;       // Domain intent for disambiguation
+  skipRerank?: boolean;  // Skip LLM reranking, use RRF scores only
 };
 
 // Highlight query terms in text (skip short words < 3 chars)
@@ -2227,6 +2228,7 @@ async function querySearch(query: string, opts: OutputOptions, _embedModel: stri
         limit: opts.all ? 500 : (opts.limit || 10),
         minScore: opts.minScore || 0,
         candidateLimit: opts.candidateLimit,
+        skipRerank: opts.skipRerank,
         explain: !!opts.explain,
         intent,
         hooks: {
@@ -2253,6 +2255,7 @@ async function querySearch(query: string, opts: OutputOptions, _embedModel: stri
         limit: opts.all ? 500 : (opts.limit || 10),
         minScore: opts.minScore || 0,
         candidateLimit: opts.candidateLimit,
+        skipRerank: opts.skipRerank,
         explain: !!opts.explain,
         intent,
         hooks: {
@@ -2367,6 +2370,7 @@ function parseCLI() {
       "line-numbers": { type: "boolean" },  // add line numbers to output
       // Query options
       "candidate-limit": { type: "string", short: "C" },
+      "no-rerank": { type: "boolean", default: false },
       intent: { type: "string" },
       // MCP HTTP transport options
       http: { type: "boolean" },
@@ -2406,6 +2410,7 @@ function parseCLI() {
     collection: values.collection as string[] | undefined,
     lineNumbers: !!values["line-numbers"],
     candidateLimit: values["candidate-limit"] ? parseInt(String(values["candidate-limit"]), 10) : undefined,
+    skipRerank: !!values["no-rerank"],
     explain: !!values.explain,
     intent: values.intent as string | undefined,
   };
@@ -2624,6 +2629,7 @@ function showHelp(): void {
   console.log("  --min-score <num>          - Minimum similarity score");
   console.log("  --full                     - Output full document instead of snippet");
   console.log("  -C, --candidate-limit <n>  - Max candidates to rerank (default 40, lower = faster)");
+  console.log("  --no-rerank                - Skip LLM reranking (use RRF scores only, much faster on CPU)");
   console.log("  --line-numbers             - Include line numbers in output");
   console.log("  --explain                  - Include retrieval score traces (query --json/CLI)");
   console.log("  --files | --json | --csv | --md | --xml  - Output format");