OpenJudgment-4B-Preview / code /test_v4_intent.py
xtristan's picture
Publish recent human-supervised judgment dataset; no training
d360720 verified
Raw
History Blame Contribute Delete
1.68 kB
import unittest
from v4_intent import CANDIDATES, adapt
class IntentAdapterTest(unittest.TestCase):
def row(self, label=CANDIDATES[0], split="train"):
return {"content": "Дякую за допомогу!", "final_category": label,
"split": split, "id": 1, "rating": 5, "source": "original"}
def test_exact_taxonomy_and_no_label_leak(self):
for index, label in enumerate(CANDIDATES):
task = adapt(self.row(label))[0]
self.assertEqual(task["target"], [float(i == index) for i in range(5)])
self.assertEqual(task["state"], "Дякую за допомогу!")
def test_eval_partitions_never_become_train(self):
for split in ("test", "challenge"):
row = self.row(split=split)
task = adapt(row)[0]
self.assertEqual(task["source_split"], split)
self.assertEqual(task["split"], split)
self.assertTrue(task["metadata"]["evaluation_only"])
with self.assertRaises(ValueError):
adapt(row, expected_split="train")
def test_bad_split_and_label_fail_closed(self):
for split in (None, "validation", ""):
with self.assertRaises(ValueError):
adapt(self.row(split=split))
with self.assertRaises(ValueError):
adapt(self.row(label="positive"))
def test_groups_ignore_labels_and_split(self):
a = self.row()
b = self.row(CANDIDATES[1], "test")
b["content"] = " ДЯКУЮ за допомогу!\n"
self.assertEqual(adapt(a)[0]["group_key"], adapt(b)[0]["group_key"])
if __name__ == "__main__":
unittest.main()