Skip to content

fix: skip the bm25 mock model_file in the offline cache probe - #676

Open
codechrl wants to merge 3 commits into
qdrant:mainfrom
codechrl:fix/bm25-offline-cache-probe
Open

fix: skip the bm25 mock model_file in the offline cache probe#676
codechrl wants to merge 3 commits into
qdrant:mainfrom
codechrl:fix/bm25-offline-cache-probe

Conversation

@codechrl

Copy link
Copy Markdown

Summary

For the Qdrant/bm25 sparse model, a fully-cached install still triggers a live Hugging Face Hub fetch instead of resolving offline. This makes Bm25 unusable with HF_HUB_OFFLINE=1 / local_files_only=True and adds an avoidable network round-trip on every load even when all files are already on disk.

Fixes #675.

The bug

Qdrant/bm25 is a mock model with no real ONNX weight file; it declares a placeholder model_file of "mock.file", and its real required assets are the per-language stop-word lists in additional_files. The offline cache probe in ModelManagement.download_model required the model_file to exist on disk, but "mock.file" is never downloaded, so the check always failed and a fully-cached bm25 fell through to the live network fetch.

The fix

Add a MOCK_MODEL_FILE constant on ModelManagement and filter it out of the required-files set before the existence check. For any real model, model_file is a genuine weight file that is not the mock placeholder, so it stays required and behavior is unchanged.

Tests

A regression test seeds the cache with only the real additional_files, monkeypatches the Hub download, and asserts the resolved path is the cached snapshot and the network branch was never reached. Placed in tests/test_common.py to avoid colliding with open PR #642, which adds a new tests/test_model_management.py.

Caveat

Verified against the real download_model control flow with a faked Hub call, not a live end-to-end download.

Qdrant/bm25 uses model_file="mock.file", a placeholder that never exists on
disk, so download_model's offline short-circuit always failed and a fully
cached bm25 fell through to a live Hub fetch. Filter the mock file out of the
required-files check; real models still require their weight file.
@coderabbitai

coderabbitai Bot commented Aug 14, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: e5de8d10-e08c-4d7a-8e88-c8d1524cbaee

📥 Commits

Reviewing files that changed from the base of the PR and between 26653f8 and 959222b.

📒 Files selected for processing (1)
  • tests/test_common.py

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

The change adds ModelManagement.MOCK_MODEL_FILE for models without physical ONNX weights. Hugging Face cache validation ignores this placeholder while continuing to require real files. Tests cover right- and left-padding pooling and offline BM25 cache resolution without network access.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 95922

This change lets fully cached BM25 models resolve locally without an unnecessary Hugging Face fetch, improving offline use and load behavior; no actionable merge-blocking risk remains beyond normal checks and review.

Possibly related issues

Suggested reviewers: joein

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description check ✅ Passed The description clearly explains the BM25 offline cache bug, the placeholder-file fix, and the regression test.
Title check ✅ Passed The title clearly and concisely identifies the fix for skipping the BM25 mock model file during offline cache probing.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Resolves the tests/test_common.py conflict introduced by the qwen test
additions (qdrant#678, qdrant#680). Both sides are kept: the last-token-pooling tests
from main and the bm25 offline-cache-probe test from this branch. The fix
itself (fastembed/common/model_management.py) was untouched by the merge.
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.

Qdrant/bm25 refetches from the Hub when fully cached (offline probe ignores the mock model_file)

1 participant