Skip to content

Commit 7349d16

Browse files
author
d.tarasov
committed
test_chat_template_return_assistant_tokens_mask: force tokenizer padding_side=right
1 parent 10f9b59 commit 7349d16

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

tests/test_tokenization_common.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1265,8 +1265,9 @@ def test_chat_template_return_assistant_tokens_mask(self):
12651265
self.skipTest(reason="No fast tokenizer defined")
12661266

12671267
tokenizer_r = self.rust_tokenizer_class.from_pretrained(pretrained_name)
1268-
if not tokenizer_r.pad_token or tokenizer.pad_token_id < 0:
1269-
self.skipTest(reason="This tokenizer has no padding token set, or pad_token_id < 0")
1268+
self._check_no_pad_token_padding(tokenizer_r, conversations)
1269+
1270+
tokenizer_r.padding_side = "right"
12701271

12711272
# check batched
12721273
output = tokenizer_r.apply_chat_template(
@@ -1358,7 +1359,7 @@ def test_chat_template_return_assistant_tokens_mask(self):
13581359
)
13591360

13601361
self.assertEqual(type(output_pt["assistant_masks"]), torch.Tensor)
1361-
self.assertEqual(output_pt["assistant_masks"].shape, output_pt["attention_mask"].shape)
1362+
self.assertEqual(output_pt["assistant_masks"].shape, output_pt["input_ids"].shape)
13621363

13631364
chat_string = tokenizer_r.apply_chat_template(
13641365
conversations[0], tokenize=False, chat_template=dummy_template

0 commit comments

Comments
 (0)