Skip to content

Commit

Permalink
Added support for bfloat16 to zero-shot classification pipeline (hugg…
Browse files Browse the repository at this point in the history
…ingface#33554)

* Added support for bfloat16 to zero-shot classification pipeline

* Ensure support for TF.

Co-authored-by: Matt <Rocketknight1@users.noreply.github.com>

* Remove dependency on `torch`.

Co-authored-by: Matt <Rocketknight1@users.noreply.github.com>

---------

Co-authored-by: Matt <Rocketknight1@users.noreply.github.com>
  • Loading branch information
2 people authored and BernardZach committed Dec 5, 2024
1 parent 392da56 commit 9b4d0e0
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/transformers/pipelines/zero_shot_classification.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,10 @@ def _forward(self, inputs):
def postprocess(self, model_outputs, multi_label=False):
candidate_labels = [outputs["candidate_label"] for outputs in model_outputs]
sequences = [outputs["sequence"] for outputs in model_outputs]
logits = np.concatenate([output["logits"].numpy() for output in model_outputs])
if self.framework == "pt":
logits = np.concatenate([output["logits"].float().numpy() for output in model_outputs])
else:
logits = np.concatenate([output["logits"].numpy() for output in model_outputs])
N = logits.shape[0]
n = len(candidate_labels)
num_sequences = N // n
Expand Down

0 comments on commit 9b4d0e0

Please sign in to comment.