Skip to content

Discussion: where would a post-fusion rerank hook for semantic-gap queries be welcome? #322

Description

@Qiiks

Summary

A question before any code: the multi-lane search (exact/lexical/semantic/anchored + evidence tiers + kind priors) is already well-engineered, and I'm not proposing to replace any of it. Is there interest in an optional, calibrated rerank stage above the fusion, aimed specifically at semantic-gap queries — and if so, where would it belong architecturally?

The gap I measured

AFT's kind priors and RRF fusion are uniform across definition kinds (semantic_kind_multiplier gives every Function/Class/Struct 1.08 under NaturalLanguage strength, mod.rs:4423), so when a query's wording shares no tokens with the right answer's name, the fused order falls back to raw cosine order. Two failure surfaces I hit in practice:

  • Intent-vs-mention traps: processRefund (returns money) vs cancelPurchase (merely mentions refund in its docstring) — cosine ranks them by embedding similarity, not by which one does the thing the query asks.
  • Paraphrased intent: "where is money returned when a purchase is called off?" shares zero tokens with processRefund.

A small live probe (7-candidate shortlists, hosted decision model scoring each candidate's relevance with typed probability judgments): 4/4 top-1 vs raw cosine 1/4 on paraphrase queries, and clean intent separation (0.930 vs 0.050 for "actually returns money"). Caveat, stated plainly: this was measured against a raw-cosine shortlist, not against AFT's real fused output — the local semantic engine was unavailable during testing. I'm presenting the mechanism, not claiming AFT's fusion underperforms.

What the hook would look like

  • Placement: after freeze_non_exact_scores produces the fused list — a post-fusion stage that may reorder (or annotate) the top-N, never add/remove candidates. Exact-tier results stay score-free per R16 and are never touched.
  • Opt-in + fail-open: off by default; if the external judge errors or times out (~1s budget), the fused order passes through untouched. Zero added latency when disabled.
  • No new failure mode on the hot path: the judge call would be async/bounded, and results carry an annotation when reranked so provenance stays honest (source/rank_score fields already exist for exactly this kind of metadata).
  • Config: something like search.rerank: "off" (default) with the judge provider configurable.

Honest counter-case (why this might be a "no")

  • The fused system already handles the common cases via exact/lexical lanes; semantic-gap queries may be rare enough not to justify the dependency.
  • An external scoring endpoint is a new vendor dependency AFT (local-first, fast, deterministic) may not want at all.
  • A local cross-encoder could do this dependency-free, at the cost of shipping/benchmarking a model.

Why I'm asking rather than PRing

I've had good experiences contributing here (#267, #300) — both landed as discussions first. This one touches the search scoring path, which is clearly carefully tuned (pinned plan table, R16 score-free exact tier, cap protection), so I'd rather hear where (or whether) the maintainers think a rerank hook fits before writing any of it.

Happy to share the full probe methodology and numbers, or to prototype behind the default-off flag if there's interest.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions