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_task_ledgar.py from VibeHash/laya-ledgar: direct link, hf CLI and curl.
- Browser
- Download file 1.25 kB
-
https://huggingface.co/VibeHash/laya-ledgar/resolve/main/code/tests/test_task_ledgar.py
- Command line
-
hf download hf://VibeHash/laya-ledgar/code/tests/test_task_ledgar.py
-
curl -L -o test_task_ledgar.py https://huggingface.co/VibeHash/laya-ledgar/resolve/main/code/tests/test_task_ledgar.py
1.25 kB
| """LEDGAR's option texts, settings and LexGLUE's two numbers on made-up predictions.""" | |
| from __future__ import annotations | |
| import unittest | |
| from layatasks.tasks import ledgar | |
| from layatasks.tasks.ledgar import TASK, extra_scores | |
| class OptionTests(unittest.TestCase): | |
| def test_label_names_in_lower_case(self): | |
| self.assertEqual(ledgar.option_text("Anti-Corruption Laws"), "anti-corruption laws") | |
| self.assertEqual(TASK.question(["Assigns", "Assignments"])["criteria"], ["assigns", "assignments"]) | |
| def test_settings(self): | |
| self.assertEqual((TASK.max_len, TASK.head_max_len, TASK.epochs, TASK.target_error), (768, 512, 4, 0.01)) | |
| self.assertEqual((TASK.loss, TASK.dev_rows), ("soft-ce", 2000)) | |
| class ScoreTests(unittest.TestCase): | |
| def test_micro_and_macro_f1(self): | |
| preds = [{"gold": g, "pred": q} for g, q in | |
| [("notices", "notices"), ("notices", "notices"), ("waivers", "notices"), ("waivers", "waivers")]] | |
| s = extra_scores(preds, None) | |
| self.assertAlmostEqual(s["micro_f1"], 0.75) | |
| # notices: tp 2, fp 1 -> 4/5. waivers: tp 1, fn 1 -> 2/3. | |
| self.assertAlmostEqual(s["macro_f1"], (4 / 5 + 2 / 3) / 2) | |
| if __name__ == "__main__": | |
| unittest.main() | |