Skip to content

Commit

Permalink
[Bug Fix] fix qa pipeline tensor to numpy (#31585)
Browse files Browse the repository at this point in the history
* fix qa pipeline

* fix tensor to numpy
  • Loading branch information
jiqing-feng authored Jul 11, 2024
1 parent c1e139c commit aec1ca3
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/transformers/pipelines/question_answering.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def select_starts_ends(
max_answer_len (`int`): Maximum size of the answer to extract from the model's output.
"""
# Ensure padded tokens & question tokens cannot belong to the set of candidate answers.
undesired_tokens = np.abs(np.array(p_mask) - 1)
undesired_tokens = np.abs(p_mask.numpy() - 1)

if attention_mask is not None:
undesired_tokens = undesired_tokens & attention_mask
Expand Down

0 comments on commit aec1ca3

Please sign in to comment.