Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Narsil committed Sep 3, 2021
1 parent 76c4d8b commit c669fc6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/transformers/pipelines/zero_shot_classification.py
Expand Up @@ -88,7 +88,7 @@ def _parse_and_tokenize(
hypothesis_template,
padding=True,
add_special_tokens=True,
truncation=TruncationStrategy.DO_NOT_TRUNCATE,
truncation=TruncationStrategy.ONLY_FIRST,
**kwargs
):
"""
Expand Down
14 changes: 14 additions & 0 deletions tests/test_pipelines_zero_shot.py
Expand Up @@ -105,6 +105,20 @@ def run_entailment_id(self, zero_shot_classifier: Pipeline):
zero_shot_classifier.model.config.label2id = original_label2id
self.assertEqual(original_entailment, zero_shot_classifier.entailment_id)

@require_torch
def test_truncation(self):
zero_shot_classifier = pipeline(
"zero-shot-classification",
model="sshleifer/tiny-distilbert-base-cased-distilled-squad",
framework="pt",
)
# There was a regression in 4.10 for this
# Adding a test so we don't make the mistake again.
# https://github.com/huggingface/transformers/issues/13381#issuecomment-912343499
zero_shot_classifier(
"Who are you voting for in 2020?" * 100, candidate_labels=["politics", "public health", "science"]
)

@require_torch
def test_small_model_pt(self):
zero_shot_classifier = pipeline(
Expand Down

0 comments on commit c669fc6

Please sign in to comment.