Skip to content

chore: Check that we are compatible with transformers v5 #10587

Open
sjrl wants to merge 14 commits intomainfrom
support-transformers-v5
Open

chore: Check that we are compatible with transformers v5 #10587
sjrl wants to merge 14 commits intomainfrom
support-transformers-v5

Conversation

@sjrl
Copy link
Contributor

@sjrl sjrl commented Feb 13, 2026

Related Issues

Proposed Changes:

  • Updated failing unit tests due to a mock needing to be updated
  • hf_device_map is not always present anymore. Seems to only be set when mixed device loading is actually configured. Updated code to check if hf_device_map is present and if not then we fall back to using the regular device attribute.
  • text2text-generation no longer exists as a valid HF pipeline anymore. It seems we should always use text-generation.
    • Updated defaults in HuggingFaceLocalGenerator to match changes made in the Chat variant. Needed to make some sort of change since the default task was text2text-generation which fails when using transformers v5.
    • Yes text2text-generation was removed as a valid HF Pipeline in this PR Delete Text2TextPipeline, SummarizationPipeline and TranslationPipeline huggingface/transformers#43256 even though it still exists in the code base. Just not as straightforward to use anymore so I'll list it as a deprecated option in our components if users are using transformers v5+

How did you test it?

Notes for the reviewer

All of these changes are compatible with both transformers v4 and v5 (v4 tested locally). Not straightforward to test for both versions in our CI.

Checklist

  • I have read the contributors guidelines and the code of conduct.
  • I have updated the related issue with new insights and changes.
  • I have 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 have documented my code.
  • I have added a release note file, following the contributors guidelines.
  • I have run pre-commit hooks and fixed any issue.

@vercel
Copy link

vercel bot commented Feb 13, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
haystack-docs Ignored Ignored Preview Feb 16, 2026 2:37pm

Request Review

@coveralls
Copy link
Collaborator

coveralls commented Feb 13, 2026

Pull Request Test Coverage Report for Build 22065664803

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.
  • 45 unchanged lines in 5 files lost coverage.
  • Overall coverage decreased (-0.002%) to 92.64%

Files with Coverage Reduction New Missed Lines %
components/rankers/transformers_similarity.py 5 90.83%
utils/hf.py 5 87.44%
components/generators/chat/hugging_face_api.py 7 96.65%
components/readers/extractive.py 8 95.65%
components/generators/chat/hugging_face_local.py 20 85.29%
Totals Coverage Status
Change from base Build 22059650324: -0.002%
Covered Lines: 15218
Relevant Lines: 16427

💛 - Coveralls

@github-actions github-actions bot added the type:documentation Improvements on the docs label Feb 13, 2026
@sjrl sjrl marked this pull request as ready for review February 16, 2026 10:03
@sjrl sjrl requested a review from a team as a code owner February 16, 2026 10:03
@sjrl sjrl requested review from julian-risch and removed request for a team February 16, 2026 10:03
Copy link
Member

@julian-risch julian-risch left a comment

Choose a reason for hiding this comment

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

Looks quite good to me already! My main change request is to mention that the default model has been changed from "google/flan-t5-base" to "Qwen/Qwen3-0.6B". Other than that just two small questions and a simplification with walrus operator.

huggingface_pipeline_kwargs["model"], token=huggingface_pipeline_kwargs["token"]
).pipeline_tag # type: ignore[assignment] # we'll check below if task is in supported tasks

if task not in PIPELINE_SUPPORTED_TASKS:
Copy link
Member

Choose a reason for hiding this comment

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

We could add a check here for task == "text2text-generation" and trigger a DeprecationWarning. However, as the deprecation comes directly from huggingface transformers, it's not strictly necessary. Still could be helpful for Haystack users.

Copy link
Member

Choose a reason for hiding this comment

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

Same for HuggingFaceLocalGenerator

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We'd also need to check for the transformers version technically since it's only deprecated for v5+. So I'm not entirely sure if it's worth the effort.

Copy link
Member

Choose a reason for hiding this comment

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

fair point

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll look into to see if there is an easy way to make this check


self._model_name_or_path = model_name_or_path
self.tokenizer: AutoTokenizer | None = None
self.tokenizer: TokenizersBackend | SentencePieceBackend | None = None
Copy link
Member

Choose a reason for hiding this comment

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

Will instances of AutoTokenizer still work as expected or is there a breaking change that we should mention in the release notes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm this is just a type change so nothing should break, but it's possible imports of these types would fail if they weren't present before. I'll double check locally.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right the imports aren't present so I think I'll go with ignoring the type issues from mypy so we can support both versions

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated to make type Any so mypy is satisfied and works in both major versions of transformers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support Transformers v5

3 participants