Skip to content

Tune reranker document-length cap for long-document corpora #1234

Description

@phernandez

Finding

The reranker's cost is strongly document-length dependent, measured in two places with the
same default configuration (jinaai/jina-reranker-v1-tiny-en, reranker_candidates=20,
reranker_max_document_chars=0 = unbounded):

  • Short notes (golden ranking corpus, test-int/semantic/test_reranker_latency.py):
    ~90 ms P50 overhead — comfortably interactive.
  • Long conversation chunks (full LoCoMo run, 1,986 queries, basic-memory-benchmarks
    main-rerank-off-long-r1 vs main-rerank-on-long-r1, 2026-08-11): p95 latency rose
    from 420 ms to ~2.1 s — a ~5x p95 regression when documents are long transcript chunks
    and the full ~100-candidate pool is scored.

Quality gain at those settings is real (#951 comment: overall R@5 +5.0pp, single_hop
+9.3pp), so this is about cost, not value.

Proposed work

  1. Sweep reranker_max_document_chars (e.g. 0 / 1000 / 2000 / 4000) on the LoCoMo corpus:
    measure quality (R@5/MRR per category) vs p95 latency per setting. The body-leads
    document construction (build_rerank_document) means a modest cap should keep most of
    the signal — verify that claim with data.
  2. If the sweep supports it, change the default from 0 (unbounded) to the best
    quality-preserving cap, and document the tradeoff in docs/semantic-search.md.
  3. Optionally probe reranker_candidates (20 vs 10) at the chosen cap for the
    latency-sensitive path.

The measurement tooling already exists: the latency benchmark in test-int/semantic/ for
short-note numbers and basic-memory-benchmarks (run-rerank-comparison.sh pattern) for
the long-document corpus.

Acceptance

  • Sweep results recorded (quality vs p95 per cap setting)
  • Default reranker_max_document_chars changed only if quality loss is negligible; the
    decision and numbers documented either way
  • docs/semantic-search.md tuning section updated with the measured guidance

Refs: #1231 (harness + baseline numbers), #951 (quality results), #1143 (feature).

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions