Text Classification
Laya
Safetensors
English
ledgar
lexglue
legal
contracts
calibrated
selective-prediction
Eval Results (legacy)
Instructions to use VibeHash/laya-ledgar with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Laya
How to use VibeHash/laya-ledgar with Laya:
# No code snippets available yet for this library. # To use this model, check the repository files and the library's documentation. # Want to help? PRs adding snippets are welcome at: # https://github.com/huggingface/huggingface.js
- Notebooks
- Google Colab
- Kaggle
Download code/tests/test_train.py from VibeHash/laya-ledgar: direct link, hf CLI and curl.
- Browser
- Download file 2.46 kB
-
https://huggingface.co/VibeHash/laya-ledgar/resolve/main/code/tests/test_train.py
- Command line
-
hf download hf://VibeHash/laya-ledgar/code/tests/test_train.py
-
curl -L -o test_train.py https://huggingface.co/VibeHash/laya-ledgar/resolve/main/code/tests/test_train.py
2.46 kB
| """The training settings handed to Laya: the task's changes, and nothing else moved.""" | |
| from __future__ import annotations | |
| import importlib.util | |
| import unittest | |
| from layatasks import train | |
| from layatasks.task import TASKS, load | |
| class ConfigTests(unittest.TestCase): | |
| def test_task_settings_reach_laya_and_the_rest_stay_default(self): | |
| from laya.train import TrainConfig | |
| default = TrainConfig() | |
| for name in TASKS: | |
| task = load(name).TASK | |
| cfg = train.config(task, seed=3) | |
| self.assertEqual((cfg.seed, cfg.epochs, cfg.max_len, cfg.head_max_len, cfg.target_error, cfg.loss), | |
| (3, task.epochs, task.max_len, task.head_max_len, task.target_error, task.loss)) | |
| self.assertEqual((cfg.micro_batch, cfg.grad_accum), (default.micro_batch, default.grad_accum)) | |
| for field in ("encoder_lr", "head_lr", "calib_max", "calib_seed", "shuffle_options"): | |
| self.assertEqual(getattr(cfg, field), getattr(default, field), field) | |
| def test_smaller_micro_batches_keep_the_step_at_64_rows(self): | |
| task = load(TASKS[0]).TASK | |
| cfg = train.config(task, seed=0, micro_batch=4) | |
| self.assertEqual((cfg.micro_batch, cfg.grad_accum), (4, 16)) | |
| with self.assertRaises(ValueError): | |
| train.config(task, seed=0, micro_batch=6) | |
| class DevSplitTests(unittest.TestCase): | |
| def rows(self): | |
| # Every third text repeats, as contract boilerplate does. | |
| return [{"state": "provision %d" % (i // 3 if i % 3 == 0 else i), "n": i} for i in range(300)] | |
| def test_dev_texts_are_new_to_training(self): | |
| rows = self.rows() | |
| kept, dev = train.split_dev(rows, 40) | |
| self.assertEqual(len(dev), 40) | |
| dev_texts = {r["state"] for r in dev} | |
| self.assertFalse(dev_texts & {r["state"] for r in kept}) | |
| self.assertEqual(len({r["n"] for r in kept} & {r["n"] for r in dev}), 0) | |
| dropped = len(rows) - len(kept) - len(dev) | |
| self.assertEqual(dropped, sum(1 for r in rows if r["state"] in dev_texts) - len(dev)) | |
| def test_same_rows_every_time(self): | |
| a, b = train.split_dev(self.rows(), 40), train.split_dev(self.rows(), 40) | |
| self.assertEqual(a, b) | |
| self.assertNotEqual(train.split_dev(self.rows(), 40, seed=1)[1], a[1]) | |
| if __name__ == "__main__": | |
| unittest.main() | |