Skip to content

fix case insensitive lookup for custom text models#645

Open
CODING-DARSH wants to merge 1 commit into
qdrant:mainfrom
CODING-DARSH:fix-custom-model-case-insensitive
Open

fix case insensitive lookup for custom text models#645
CODING-DARSH wants to merge 1 commit into
qdrant:mainfrom
CODING-DARSH:fix-custom-model-case-insensitive

Conversation

@CODING-DARSH

Copy link
Copy Markdown

Checklist

  • Have you followed the guidelines in the Contributing document?
  • Have you checked that there are no existing open PRs for the same issue?
  • Does the change pass tests locally?
  • Have you added a regression test for the fix?

Summary

Custom models can be registered using one casing (e.g. Org/Model) and later instantiated using a different casing (e.g. org/model). TextEmbedding already resolves models case-insensitively, but CustomTextEmbedding later looked up the postprocessing configuration using the original user-provided model name, which could result in a KeyError.

This change uses the canonical resolved model name from self.model_description.model when retrieving the postprocessing configuration.

Changes

  • Fix custom text model postprocessing lookup to use the canonical resolved model name.
  • Add a regression test covering mixed-case registration and instantiation.

Reproduction

Before

  1. Register a custom model as Org/Model.
  2. Instantiate TextEmbedding("org/model").
  3. Construction can fail with KeyError.

After

  1. Register a custom model as Org/Model.
  2. Instantiate TextEmbedding("org/model").
  3. Construction succeeds and uses the correct postprocessing configuration.

Testing

  • Added test_custom_text_model_lookup_is_case_insensitive.
  • Verified with:
poetry run pytest tests/test_custom_models.py -k custom_text_model_lookup_is_case_insensitive -q

@coderabbitai

coderabbitai Bot commented Jun 6, 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

Run ID: 6ade5fc7-7b6f-4aa2-b8b3-213c6c7bd125

📥 Commits

Reviewing files that changed from the base of the PR and between 8a8ea4f and ff91ff6.

📒 Files selected for processing (2)
  • fastembed/text/custom_text_embedding.py
  • tests/test_custom_models.py

📝 Walkthrough

Walkthrough

This PR changes how CustomTextEmbedding retrieves postprocessing configuration during initialization. Instead of using the model_name constructor argument to look up pooling and normalization settings in POSTPROCESSING_MAPPING, the code now uses self.model_description.model. A new test validates that custom models registered with case-variant names correctly preserve their pooling and normalization settings when instantiated via TextEmbedding.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.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
Title check ✅ Passed The title directly and concisely describes the main fix: resolving case-insensitive lookup for custom text models, which aligns with the core change in CustomTextEmbedding.
Description check ✅ Passed The description clearly explains the problem, solution, testing approach, and reproduction steps, all directly related to the changeset.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 and usage tips.

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.

1 participant