Skip to content

fix: preserve dotted identifiers in BM25 retrieval - #2336

Merged
pancacake merged 3 commits into
HKUDS:devfrom
remote-controlled-man:codex/prflow-771d3b45fccc
Nov 5, 2026
Merged

pancacake merged 3 commits into
HKUDS:devfrom
remote-controlled-man:codex/prflow-771d3b45fccc

Conversation

@remote-controlled-man

Copy link
Copy Markdown
Contributor

Description

BM25's default tokenizer loses dotted exercise/section identifiers and single-character terms. Use one shared token pattern for corpus and queries across regular, scoped, and legacy page retrieval, including the direct bm25s fallback. Identifiers such as 2.6.8 remain intact even next to Chinese text; existing English stopword filtering still applies.

Record the pattern with persisted BM25 sidecars and restore it when loading. Rebuild older or incompatible caches from stored documents without new embeddings. A bounded cache reuses rebuilds for a loaded index/result count, and loading an updated index invalidates that reuse.

Related Issues

Module(s) Affected

  • services
  • tests
  • docs

Validation

On macOS arm64 with standalone CPython 3.12.14 and Redis 7.4:

  • python -m pytest -q tests deeptutor/learning/tests: 12,257 passed, 43 skipped, 31 subtests passed.
  • python -m pytest tests/services/rag -q: 980 passed, 1 skipped.
  • pre-commit run --all-files --show-diff-on-failure: all hooks passed.
  • Whole-repository Ruff check/format, import-linter, architecture and repository/workspace hygiene checks passed.
  • uv pip check: all 281 installed packages compatible.

The BM25 regressions use synthetic documents and mock embeddings. The upstream Python/OS CI matrix remains to run.

Checklist

  • This PR targets dev
  • I have read and followed the contribution guidelines.
  • My code follows the project's coding standards.
  • I have run pre-commit run --all-files and fixed any issues.
  • I have added relevant tests for my changes.
  • I have updated the documentation.
  • My changes do not introduce any known new security vulnerabilities.

Copilot AI balanced review requested due to automatic review settings November 2, 2026 03:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@pancacake
pancacake merged commit 8602605 into HKUDS:dev Nov 5, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants