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_package.py from VibeHash/laya-ledgar: direct link, hf CLI and curl.
- Browser
- Download file 5.79 kB
-
https://huggingface.co/VibeHash/laya-ledgar/resolve/main/code/tests/test_package.py
- Command line
-
hf download hf://VibeHash/laya-ledgar/code/tests/test_package.py
-
curl -L -o test_package.py https://huggingface.co/VibeHash/laya-ledgar/resolve/main/code/tests/test_package.py
5.79 kB
| """The release step must not publish a local path, a blank card slot, or another task's code.""" | |
| from __future__ import annotations | |
| import json | |
| import tempfile | |
| import unittest | |
| from pathlib import Path | |
| from layatasks import package | |
| from layatasks.task import TASKS, load | |
| # The card drafts and NOTICE files live in `cards/` of the working folder. A release carries its card as the model | |
| # repository's README and its NOTICE beside it, not under `code/`, so the tests that need the drafts skip there. | |
| HAS_CARDS = (package.REPO_ROOT / "cards").is_dir() | |
| class LooksLocalTests(unittest.TestCase): | |
| def test_absolute_paths_are_local(self): | |
| for value in ("C:\\Users\\someone\\data.jsonl", "c:/data/x.jsonl", "/home/someone/x", "~/x", "\\\\srv\\share"): | |
| self.assertTrue(package.looks_local(value), value) | |
| def test_hub_ids_and_words_are_not(self): | |
| for value in ("convaiinnovations/laya", "rlcd", "choice:11+", "2026-11-13"): | |
| self.assertFalse(package.looks_local(value), value) | |
| class RepoIdTests(unittest.TestCase): | |
| # Whichever task is present: a release's code folder holds only its own. | |
| def test_accepts_owner_and_name(self): | |
| task = load(TASKS[0]).TASK | |
| repo = "some-one/" + task.release_name | |
| self.assertEqual(package.check_repo_id(repo, task), repo) | |
| def test_refuses_the_placeholder_and_malformed_ids(self): | |
| task = load(TASKS[0]).TASK | |
| name = task.release_name | |
| for value in (package.placeholder(task), name, "a/b/c", "a b/c", "/" + name): | |
| with self.assertRaises(ValueError, msg=value): | |
| package.check_repo_id(value, task) | |
| class SlotTests(unittest.TestCase): | |
| def test_finds_unfilled_slots(self): | |
| self.assertEqual(package.unfilled_slots("right {{n_right}} of {{n}}; done"), ["{{n_right}}", "{{n}}"]) | |
| self.assertEqual(package.unfilled_slots("a dict {'a': 1} and {braces} are fine"), []) | |
| class FillTests(unittest.TestCase): | |
| def test_replaces_every_placeholder(self): | |
| with tempfile.TemporaryDirectory() as tmp: | |
| path = Path(tmp) / "README.md" | |
| path.write_text("load OWNER/laya-x, then OWNER/laya-x", encoding="utf-8") | |
| package.fill_repo(path, "OWNER/laya-x", "someone/laya-x") | |
| self.assertEqual(path.read_text(encoding="utf-8"), "load someone/laya-x, then someone/laya-x") | |
| class ScrubTests(unittest.TestCase): | |
| def test_drops_local_paths_from_the_training_block_only(self): | |
| cfg = {"encoder": "answerdotai/ModernBERT-large", | |
| "training": {"data": "C:\\Users\\someone\\train.jsonl", "epochs_completed": 4, | |
| "base": "convaiinnovations/laya"}} | |
| with tempfile.TemporaryDirectory() as tmp: | |
| path = Path(tmp) / "rl_agent_config.json" | |
| path.write_text(json.dumps(cfg), encoding="utf-8") | |
| package.scrub_config(path) | |
| out = json.loads(path.read_text(encoding="utf-8")) | |
| self.assertEqual(out["training"], {"epochs_completed": 4, "base": "convaiinnovations/laya"}) | |
| self.assertEqual(out["encoder"], "answerdotai/ModernBERT-large") | |
| class LeakTests(unittest.TestCase): | |
| def test_finds_a_home_folder_written_with_either_slash(self): | |
| with tempfile.TemporaryDirectory() as tmp: | |
| folder = Path(tmp) | |
| (folder / "a.json").write_text('{"p": "C:\\\\Users\\\\someone\\\\x"}', encoding="utf-8") | |
| (folder / "b.md").write_text("nothing here", encoding="utf-8") | |
| self.assertEqual(package.local_path_leaks(folder, ["C:\\Users\\someone"]), ["a.json"]) | |
| self.assertEqual(package.local_path_leaks(folder, ["c:/users/someone"]), ["a.json"]) | |
| def test_clean_folder_passes(self): | |
| with tempfile.TemporaryDirectory() as tmp: | |
| (Path(tmp) / "c.json").write_text('{"ok": true}', encoding="utf-8") | |
| self.assertEqual(package.local_path_leaks(Path(tmp), ["C:\\Users\\someone"]), []) | |
| class CodeFolderTests(unittest.TestCase): | |
| def test_ships_the_shared_steps_and_only_its_own_task(self): | |
| for name in TASKS: | |
| task = load(name).TASK | |
| with tempfile.TemporaryDirectory() as tmp: | |
| out = Path(tmp) | |
| package.copy_code(task, out) | |
| shipped = sorted(p.name for p in (out / "code" / "layatasks" / "tasks").iterdir()) | |
| self.assertEqual(shipped, ["__init__.py", "%s.py" % name]) | |
| for module in package.CORE_MODULES: | |
| self.assertTrue((out / "code" / "layatasks" / module).is_file(), module) | |
| self.assertTrue((out / "code" / "tests" / ("test_task_%s.py" % name)).is_file()) | |
| self.assertTrue((out / "code" / "NOTICE").is_file()) | |
| def test_every_core_module_and_test_is_listed(self): | |
| root = package.REPO_ROOT | |
| self.assertEqual(sorted(p.name for p in (root / "layatasks").glob("*.py")), sorted(package.CORE_MODULES)) | |
| on_disk = sorted(p.name for p in (root / "tests").glob("*.py") if not p.name.startswith("test_task_")) | |
| self.assertEqual(on_disk, sorted(package.CORE_TESTS)) | |
| class CardTests(unittest.TestCase): | |
| def test_every_task_has_a_card_and_a_notice_naming_its_placeholder(self): | |
| for name in TASKS: | |
| task = load(name).TASK | |
| card = (package.REPO_ROOT / "cards" / ("%s.md" % name)).read_text(encoding="utf-8") | |
| self.assertIn(package.placeholder(task), card) | |
| self.assertTrue((package.REPO_ROOT / "cards" / ("%s.NOTICE" % name)).is_file()) | |
| if __name__ == "__main__": | |
| unittest.main() | |