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_fit.py from VibeHash/laya-ledgar: direct link, hf CLI and curl.
- Browser
- Download file 1.67 kB
-
https://huggingface.co/VibeHash/laya-ledgar/resolve/main/code/tests/test_fit.py
- Command line
-
hf download hf://VibeHash/laya-ledgar/code/tests/test_fit.py
-
curl -L -o test_fit.py https://huggingface.co/VibeHash/laya-ledgar/resolve/main/code/tests/test_fit.py
1.67 kB
| """The time estimate's replay of Laya's batching, checked by hand and against Laya's own split.""" | |
| from __future__ import annotations | |
| import importlib.util | |
| import random | |
| import unittest | |
| from layatasks import fit | |
| class PaddedTokenTests(unittest.TestCase): | |
| def test_pads_each_micro_batch_to_its_longest_row(self): | |
| # Of ten rows Laya holds back int(10 * 0.1) = 1 for calibration and trains on nine. | |
| lengths = [5] * 9 + [50] | |
| keep = [lengths[i] for i in fit.train_rows(len(lengths))] | |
| self.assertEqual(len(keep), 9) | |
| order = list(keep) | |
| random.Random(0).shuffle(order) | |
| expected = sum(max(order[s:s + 4]) * len(order[s:s + 4]) for s in range(0, len(order), 4)) | |
| self.assertEqual(fit.padded_tokens(lengths, epochs=1, micro_batch=4), expected) | |
| def test_equal_rows_need_no_padding(self): | |
| self.assertEqual(fit.padded_tokens([7] * 100, epochs=3), 7 * 90 * 3) | |
| class SplitTests(unittest.TestCase): | |
| def test_hold_out_matches_laya(self): | |
| from laya.train import split_calibration | |
| for n in (10, 999, 5000): | |
| items = list(range(n)) | |
| train, _calib = split_calibration(items, fit.CALIB_MAX, fit.CALIB_FRAC, fit.CALIB_SEED) | |
| self.assertEqual(fit.train_rows(n), train) | |
| class DescribeTests(unittest.TestCase): | |
| def test_counts_rows_longer_than_the_room(self): | |
| d = fit.describe([1, 2, 3, 10, 20], room=5) | |
| self.assertEqual((d["truncated"], d["truncated_share"], d["state_tokens"]["max"]), (2, 0.4, 20)) | |
| if __name__ == "__main__": | |
| unittest.main() | |