docs: update model card with verified datasets, I/O specs, and per-stage scores
Browse files
README.md
CHANGED
|
@@ -3,19 +3,53 @@ library_name: pytorch
|
|
| 3 |
tags:
|
| 4 |
- legal-nlp
|
| 5 |
- catala
|
| 6 |
-
- neuro-symbolic
|
| 7 |
-
- continual-learning
|
| 8 |
- statutory-ast
|
|
|
|
|
|
|
| 9 |
license: apache-2.0
|
| 10 |
---
|
| 11 |
|
| 12 |
# MudraForge `law2code` Downstream Parser Stages (Stage 1, 1.5, 2 & 2B)
|
| 13 |
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
|
|
|
| 20 |
|
| 21 |
-
Deterministic
|
|
|
|
|
|
| 3 |
tags:
|
| 4 |
- legal-nlp
|
| 5 |
- catala
|
|
|
|
|
|
|
| 6 |
- statutory-ast
|
| 7 |
+
- continual-learning
|
| 8 |
+
- onnx
|
| 9 |
license: apache-2.0
|
| 10 |
---
|
| 11 |
|
| 12 |
# MudraForge `law2code` Downstream Parser Stages (Stage 1, 1.5, 2 & 2B)
|
| 13 |
|
| 14 |
+
Supervised multi-stage statutory parsing stack for **law2code** ([Live Space](https://huggingface.co/spaces/yamero999/law2code)). These downstream parser models are trained on **annotated statutory ground truth**, separate from the unlabeled MLM encoder pretraining corpora.
|
| 15 |
+
|
| 16 |
+
## Training & Evaluation Data
|
| 17 |
+
- **Annotated Training Corpus:** 250 annotated statutory provisions (`ground_truth_250.json`, 2.33 MB) evaluated under 5-fold cross-validation and full-corpus training.
|
| 18 |
+
- **Unseen OOD Evaluation Set:** 7 unseen US Internal Revenue Code provisions (`sara_gold_eval_20.json`, 951 atomic spans & 137 operand spans).
|
| 19 |
+
|
| 20 |
+
## Per-Stage Architecture, Inputs/Outputs & Internal Scores
|
| 21 |
+
|
| 22 |
+
### 1. Stage 1 — Atomic Non-Operand Parser (`stage1_non_operands`)
|
| 23 |
+
- **Task:** Extracts 9 statutory constant & operator classes (`MONEY`, `RATE`, `DATE`, `DURATION`, `COUNT`, `ACTOR_SCOPE`, `DEFINED_TERM`, `OP`, `XREF`) across 37 BILOU tags.
|
| 24 |
+
- **Inputs:** Tokenized word/char/subword IDs + 36D discourse geometry + clause indices.
|
| 25 |
+
- **Outputs:** `hidden_states` `[1, seq_len, 256]` and `flat_log_probs` `[1, seq_len, 37]`.
|
| 26 |
+
- **Internal Scores:**
|
| 27 |
+
- 5-Fold Blind OOF Exact F1: **91.97%** (Precision: 90.48%, Recall: 93.52%)
|
| 28 |
+
- Full-Corpus Exact F1: **99.17%** (Relaxed F1: 99.36%, Precision: 99.26%, Recall: 99.08%)
|
| 29 |
+
- **Files:** `pytorch/stage1_non_operands_tree_cl_v6_full.pt` (19.4 MB) | `onnx/stage1_non_operands.onnx` (19.10 MB, ORT max diff `3.05e-05`)
|
| 30 |
+
|
| 31 |
+
### 2. Stage 1.5 — Catala Operand Specialist & Entropy Gate (`stage1_5_operands`)
|
| 32 |
+
- **Task:** Extracts algebraic operands & conditions across 4 Catala root branches (`NUMERIC_METRIC`, `CATEGORY_FILTER`, `DOC_POINTER`, `COMPLIANCE_ATTESTATION`) and routes OOD phrases (entropy `H >= 0.50`) to human/CA review via prototype memory (`stage1_5_leaf_prototypes_v2.json`).
|
| 33 |
+
- **Inputs:** Token features + 10-channel coarse Stage 1 conditioning (`s1_coarse`).
|
| 34 |
+
- **Outputs:** `hidden_states` `[1, seq_len, 256]` and `flat_log_probs` `[1, seq_len, 17]`.
|
| 35 |
+
- **Internal Scores:**
|
| 36 |
+
- Blind Fold-1 Untyped F1 (IoU@50): **85.41%** (`NUMERIC_METRIC`: 88.2%, `COMPLIANCE_ATTESTATION`: 76.2%, Router Branch Acc: 94.8%, Catala Leaf Exact: 97.3%)
|
| 37 |
+
- Full-Corpus Exact F1: **98.52%** (Precision: 97.49%, Recall: 99.57%, Catala Leaf Exact: 97.6%)
|
| 38 |
+
- **Files:** `pytorch/stage1_5_operands_catala_tree_v2_full.pt` (26.0 MB) | `onnx/stage1_5_operands.onnx` (22.91 MB, ORT max diff `1.34e-05`)
|
| 39 |
+
|
| 40 |
+
### 3. Stage 2 — Clause Scope Specialist (`stage2_clauses`)
|
| 41 |
+
- **Task:** Factors statutes into executable clause scopes (`COND`, `EXCEPTION`, `RULE_EFFECT`, `INLINE_DEF`) using the 41-tag Stage 1 + Stage 1.5 bridge.
|
| 42 |
+
- **Inputs:** Token features + 41-channel Stage 1/1.5 tag logits (`s1_logits_41`).
|
| 43 |
+
- **Outputs:** Encoder hidden states `h2`, clause representations `ca2`, and boundary anchor logits `s_logits`, `e_logits`.
|
| 44 |
+
- **Internal Scores:**
|
| 45 |
+
- Full-Corpus IoU@50 F1: **97.05%** (Exact F1: 87.73%, Precision: 95.0%, Recall: 99.2%)
|
| 46 |
+
- **Files:** `pytorch/stage2_clauses_v2_full.pt` (18.9 MB) | `onnx/stage2_clauses.onnx` (17.64 MB, ORT max diff `7.63e-06`)
|
| 47 |
|
| 48 |
+
### 4. Stage 2B — Clause Boundary Pointer Refiner (`stage2_refiner`)
|
| 49 |
+
- **Task:** Snaps Stage 2 clause start/end boundaries within a +/-6 token window.
|
| 50 |
+
- **Internal Scores:**
|
| 51 |
+
- Refined Exact F1: **94.93%** (+7.20 Exact F1 over Stage 2 base 87.73%, Overlap F1: 97.05%, 0.0% recall loss)
|
| 52 |
+
- **File:** `pytorch/stage2_refiner_noppo_v2_full.pt` (1.89 MB)
|
| 53 |
|
| 54 |
+
## Deterministic Post-Processing
|
| 55 |
+
Stage 3 (Reflexion Critic & Catala/AST Emitter) runs deterministically over the outputs above with `isAuthorizedToDisburse: false`. Both PyTorch and ONNX outputs support `teach-leaf` prototype memory updates without retraining weights.
|