Skip to content

fix(transformers): respect zero stride override in TransformersExtractiveReader - #4177

Open
muthukkumaranb wants to merge 3 commits into
deepset-ai:mainfrom
muthukkumaranb:muthukkumaranb-patch-1
Open

muthukkumaranb wants to merge 3 commits into
deepset-ai:mainfrom
muthukkumaranb:muthukkumaranb-patch-1

Conversation

@muthukkumaranb

Copy link
Copy Markdown
Contributor

Related Issues

Proposed Changes:

TransformersExtractiveReader.run() resolved the stride override with stride or self.stride, so an explicit stride=0 (no overlap between split sequences) was silently replaced by the init value. It now falls back only when stride is None.

This follows up on #4159, which fixed the same pattern for score_threshold and overlap_threshold in the same method and noted that stride=0 was left out to keep that change small.

How did you test it?

  • Added test_run_respects_zero_stride_override: sets the init stride to 64, calls run(..., stride=0) and asserts _preprocess receives stride=0. It fails on main (assert 64 == 0) and passes with the fix.
  • pytest -m "not integration" tests/test_extractive_reader.py: 39 passed.
  • ruff check and ruff format --check pass.

Notes for the reviewer

One-line change. The remaining or fallbacks in run() (top_k, max_seq_length, max_batch_size, answers_per_seq) are left unchanged since 0 is not a meaningful value for them.

Checklist

@muthukkumaranb
muthukkumaranb requested a review from a team as a code owner October 30, 2026 17:11
@muthukkumaranb
muthukkumaranb requested review from julian-risch and removed request for a team October 30, 2026 17:11
@github-actions

Copy link
Copy Markdown
Contributor

Heads-up for maintainers

This PR is from a fork and touches integrations whose integration tests require API keys.
Those tests are skipped in CI because fork PRs don't have access to repo secrets for security reasons.

Affected integrations:

  • transformers

Please run the integration tests locally (hatch run test:integration inside each folder) before approving.

@github-actions

Copy link
Copy Markdown
Contributor

Coverage report (transformers)

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  integrations/transformers/src/haystack_integrations/components/readers/transformers
  extractive_reader.py
Project Total  

This report was generated by python-coverage-comment-action

This branch has not been deployed

No deployments
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.

TransformersExtractiveReader.run() ignores a zero stride override

1 participant