Skip to content

feat: add revision parameter to Sentence Transformers embedder components#10003

Merged
sjrl merged 5 commits into
deepset-ai:mainfrom
swapniel99:st_revision
Nov 5, 2025
Merged

feat: add revision parameter to Sentence Transformers embedder components#10003
sjrl merged 5 commits into
deepset-ai:mainfrom
swapniel99:st_revision

Conversation

@swapniel99

Copy link
Copy Markdown
Contributor

Related Issues

None

Proposed Changes:

Added a revision parameter to all Sentence Transformers embedder components to allow users to specify a specific model revision/version from the Hugging Face Hub. This parameter is passed through to the underlying Sentence Transformers backend.

How did you test it?

  • Added unit tests for all four embedder components to verify the revision parameter is correctly:
    • Initialized with default value (None)
    • Set when provided explicitly (e.g., "v1.0")
    • Serialized and deserialized in to_dict() and from_dict() methods
  • Updated existing backend initialization tests to include the revision parameter
  • All pre-commit hooks passed successfully

Notes for the reviewer

The revision parameter follows the same pattern as other optional parameters like trust_remote_code and local_files_only. It's passed directly to the Sentence Transformers model initialization, allowing users to pin to specific model versions for reproducibility.

Checklist

  • I have read the contributors guidelines and the code of conduct
  • I have updated the related issue with new insights and changes
  • I added unit tests and updated the docstrings
  • I've used one of the conventional commit types for my PR title: fix:, feat:, build:, chore:, ci:, docs:, style:, refactor:, perf:, test: and added ! in case the PR includes breaking changes.
  • I documented my code
  • I ran pre-commit hooks and fixed any issue

@swapniel99 swapniel99 requested a review from a team as a code owner November 1, 2025 08:58
@swapniel99 swapniel99 requested review from sjrl and removed request for a team November 1, 2025 08:58
@vercel

vercel Bot commented Nov 1, 2025

Copy link
Copy Markdown

@swapniel99 is attempting to deploy a commit to the deepset Team on Vercel.

A member of the Team first needs to authorize it.

@CLAassistant

CLAassistant commented Nov 1, 2025

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@github-actions github-actions Bot added topic:tests type:documentation Improvements on the docs labels Nov 1, 2025
Comment thread haystack/components/embedders/sentence_transformers_document_embedder.py Outdated
Comment thread haystack/components/embedders/sentence_transformers_text_embedder.py Outdated
@sjrl sjrl self-assigned this Nov 3, 2025
@coveralls

coveralls commented Nov 3, 2025

Copy link
Copy Markdown
Collaborator

Pull Request Test Coverage Report for Build 19096477217

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 31 unchanged lines in 6 files lost coverage.
  • Overall coverage increased (+0.006%) to 92.25%

Files with Coverage Reduction New Missed Lines %
components/embedders/sentence_transformers_sparse_document_embedder.py 1 98.41%
components/embedders/sentence_transformers_sparse_text_embedder.py 1 98.08%
components/embedders/sentence_transformers_document_embedder.py 2 97.01%
components/embedders/sentence_transformers_text_embedder.py 2 96.49%
components/agents/agent.py 9 96.48%
utils/base_serialization.py 16 87.6%
Totals Coverage Status
Change from base Build 18976263337: 0.006%
Covered Lines: 13511
Relevant Lines: 14646

💛 - Coveralls

@sjrl

sjrl commented Nov 3, 2025

Copy link
Copy Markdown
Contributor

@swapniel99 could you also add a release note following our guidelines here and fix the failing linting errors. You can reproduce this locally by running hatch run test:lint haystack. Also explained in our contributions guidelines here

@sjrl sjrl 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.

Thanks for the addition!

@sjrl sjrl enabled auto-merge (squash) November 4, 2025 08:49
@swapniel99

Copy link
Copy Markdown
Contributor Author

@swapniel99 could you also add a release note following our guidelines here and fix the failing linting errors. You can reproduce this locally by running hatch run test:lint haystack. Also explained in our contributions guidelines here

I checked but these lines were not edited by me. I don't understand what is supposed to be done here.
Running the lint check is extremely slow on my laptop.

Comment thread haystack/components/embedders/sentence_transformers_document_embedder.py Outdated
@sjrl sjrl merged commit 2ecddff into deepset-ai:main Nov 5, 2025
21 of 22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

topic:tests type:documentation Improvements on the docs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants