mirror of
https://github.com/wassname/AntiPaSTO.git
synced 2026-09-24 13:00:41 +08:00
Co-Authored-By: PI[openai-codex] <288921227+claudypoo@users.noreply.github.com>
23 lines
637 B
Python
23 lines
637 B
Python
import torch
|
|
|
|
from antipasto.eval import append_choice_newline
|
|
|
|
|
|
class NewlineTokenizer:
|
|
def __call__(self, text, add_special_tokens):
|
|
assert text == "\n"
|
|
assert not add_special_tokens
|
|
return {"input_ids": [107]}
|
|
|
|
|
|
def test_append_choice_newline_appends_before_scoring():
|
|
input_ids = torch.tensor([[1, 2], [3, 4]])
|
|
attention_mask = torch.tensor([[1, 1], [1, 0]])
|
|
|
|
input_ids, attention_mask = append_choice_newline(
|
|
input_ids, NewlineTokenizer(), attention_mask
|
|
)
|
|
|
|
assert input_ids.tolist() == [[1, 2, 107], [3, 4, 107]]
|
|
assert attention_mask.tolist() == [[1, 1, 1], [1, 0, 1]]
|