Skip to content

Commit 678843e

Browse files
authored
Fix the issue of P-tuning official sample error (#8884)
* Fix the issue of P-tuning official sample error * Create codecov workflow.yml * Delete .github/workflows/workflow.yml
1 parent 6235fcd commit 678843e

File tree

1 file changed

+2
-1
lines changed
  • legacy/examples/few_shot/p-tuning

1 file changed

+2
-1
lines changed

legacy/examples/few_shot/p-tuning/data.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,8 @@ def convert_ids_to_words(example, token_ids):
139139
the length of which should coincide with that of `mask` in prompt.
140140
"""
141141
if "label_ids" in example:
142-
labels = paddle.index_select(token_ids, paddle.to_tensor(example.pop("label_ids")), axis=0).squeeze(0)
142+
label_ids_tensor = paddle.to_tensor([example.pop("label_ids")], dtype='int64')
143+
labels = paddle.index_select(token_ids, label_ids_tensor, axis=0).squeeze(0)
143144
example["labels"] = labels
144145
return example
145146

0 commit comments

Comments
 (0)