lucasorrentino commited on
Commit
856bce1
·
unverified ·
1 Parent(s): 2bfbf15

Upload folder using huggingface_hub

Browse files
.gitattributes CHANGED
@@ -33,4 +33,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
36
  *.json filter=lfs diff=lfs merge=lfs -text
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ ContractNer/performance_heatmap.png filter=lfs diff=lfs merge=lfs -text
37
  *.json filter=lfs diff=lfs merge=lfs -text
ContractNer/.gitattributes ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tar filter=lfs diff=lfs merge=lfs -text
29
+ *.tflite filter=lfs diff=lfs merge=lfs -text
30
+ *.tgz filter=lfs diff=lfs merge=lfs -text
31
+ *.wasm filter=lfs diff=lfs merge=lfs -text
32
+ *.xz filter=lfs diff=lfs merge=lfs -text
33
+ *.zip filter=lfs diff=lfs merge=lfs -text
34
+ *.zst filter=lfs diff=lfs merge=lfs -text
35
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
ContractNer/README.md ADDED
@@ -0,0 +1,186 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - en
4
+ - multilingual
5
+ library_name: gliner
6
+ pipeline_tag: token-classification
7
+ tags:
8
+ - gliner
9
+ - named-entity-recognition
10
+ - information-extraction
11
+ - legal
12
+ - contracts
13
+ - multilingual
14
+ - nlp
15
+ dataset:
16
+ - contractner
17
+ base_model: urchade/gliner_multi-v2.1
18
+ license: apache-2.0
19
+ widget:
20
+ - text: "This AGREEMENT is made effective as of January 1, 2026 by and between Agile Lab S.r.l., a company organized under the laws of Italy, and John Doe, serving as Chief Executive Officer. The Executive shall receive an annual base salary of $225,000.00."
21
+ example_title: "Contract Parties & Salary"
22
+ ---
23
+
24
+ # GLiNER ContractNER Multi - Fine-Grained Legal Entity Extraction
25
+
26
+ **Model Name:** `gliner-contractner-multi-v2.1` (Agile Lab Fine-tune)
27
+ **Base Architecture:** GLiNER Multi v2.1 (Backbone: `microsoft/mdeberta-v3-base`)
28
+
29
+ ## Model Description
30
+
31
+ **GLiNER ContractNER Multi** is a multilingual span-based Named Entity Recognition (NER) model fine-tuned by **Agile Lab** on the **ContractNER** dataset. It is designed to extract fine-grained entities from legal contracts with high precision.
32
+
33
+ Built on the **GLiNER Multi v2.1** architecture, this model achieves **80%+ F1 score** on contract-specific entity extraction, significantly outperforming general-purpose LLMs and domain-specific legal models in our benchmarks.
34
+
35
+ ### Key Highlights
36
+ * **Contract-Specialized:** Fine-tuned on **3,240+ annotated contract chunks** from SEC EDGAR filings.
37
+ * **Granular Extraction:** Capable of identifying 18 specific entity types including parties, dates, financial terms (salaries, shares), and regulatory references.
38
+ * **Open-Vocabulary NER:** Supports promptable entity extraction—you can provide custom label names at inference time without retraining.
39
+ * **Multilingual Capability:** Inherits multilingual behavior from GLiNER Multi v2.1 and mDeBERTa-v3-base, though optimized primarily for English contracts (performance may degrade on low-resource languages).
40
+ * **Production-Ready:** A recommended threshold of **0.8–0.9** balances high precision with acceptable recall, minimizing costly false positives in legal review workflows.
41
+
42
+ ---
43
+
44
+ ## 🚀 How to Use
45
+
46
+ To use this model, you need to install the `gliner` library.
47
+
48
+ ### Installation
49
+ ```bash
50
+ pip install gliner
51
+ ```
52
+
53
+ ### Inference Code
54
+ ```python
55
+ from gliner import GLiNER
56
+
57
+ # Load the model (replace 'AgileLab/your-model-repo' with your actual HF repo ID)
58
+ model = GLiNER.from_pretrained("AgileLab/gliner-contractner-multi-v2.1")
59
+
60
+ # Example contract text
61
+ text = """
62
+ This EMPLOYMENT AGREEMENT is made effective as of January 1, 2026,
63
+ by and between Tech Solutions Inc. ("Company") and Jane Doe ("Executive").
64
+ The Executive shall serve as Chief Technology Officer.
65
+ The Company agrees to pay the Executive an annual base salary of $250,000.00.
66
+ """
67
+
68
+ # Define the entities you want to extract (Open Vocabulary)
69
+ labels = [
70
+ "Parties", "EffectiveDate", "Role", "Salary", "TerminationDate"
71
+ ]
72
+
73
+ # Predict
74
+ entities = model.predict_entities(text, labels, threshold=0.5)
75
+
76
+ # Print results
77
+ for entity in entities:
78
+ print(f"{entity['text']} => {entity['label']} (Score: {entity['score']:.2f})")
79
+ ```
80
+
81
+ ---
82
+
83
+ ## 📊 Evaluation & Benchmarks
84
+
85
+ In our comprehensive evaluation on the validation set, this model achieved an overall **F1 score of 80.0%**, demonstrating a strong balance between precision and recall.
86
+
87
+ ### Performance vs. Other Models
88
+ * **GLiNER ContractNER (This Model):** **80.0% F1**
89
+ * **General Purpose LLMs (Qwen, Gemma):** < 35% F1
90
+ * **Standalone DeBERTa Models:** 46% – 78% F1
91
+ * **Legal-Specific Models (LegalBERT, ContractBERT):** < 10% F1
92
+
93
+ *This model is best-in-class for contract entity extraction when utilizing the GLiNER span+query architecture.*
94
+
95
+ ### Detailed Metrics by Entity (Validation Split)
96
+
97
+ | Entity | Precision | Recall | F1 Score | Support |
98
+ | :--- | :--- | :--- | :--- | :--- |
99
+ | **Act** | 81.16 | 74.67 | 77.78 | 75 |
100
+ | **Address** | 68.00 | 77.27 | 72.34 | 22 |
101
+ | **Court** | 80.00 | 80.00 | 80.00 | 20 |
102
+ | **EffectiveDate** | 62.50 | 96.15 | 75.76 | 26 |
103
+ | **PII_Ref** | 77.27 | 100.00 | **87.18** | 17 |
104
+ | **Parties** | 70.13 | 85.71 | 77.14 | 63 |
105
+ | **Percentage** | 59.46 | 91.67 | 72.13 | 24 |
106
+ | **Price** | 42.50 | 94.44 | 58.62 | 18 |
107
+ | **Principal** | 36.25 | 90.62 | 51.79 | 32 |
108
+ | **Ratio** | 29.79 | 73.68 | 42.42 | 19 |
109
+ | **Regulation** | 66.67 | 88.37 | 76.00 | 43 |
110
+ | **RenewalTerm** | 42.86 | 75.00 | 54.55 | 12 |
111
+ | **Rent** | 30.00 | 75.00 | 42.86 | 8 |
112
+ | **Role** | 90.32 | 80.00 | **84.85** | 35 |
113
+ | **Salary** | 42.86 | 100.00 | 60.00 | 18 |
114
+ | **Shares** | 40.48 | 89.47 | 55.74 | 19 |
115
+ | **TerminationDate**| 23.64 | 72.22 | 35.62 | 18 |
116
+ | **Title** | 70.11 | 73.49 | 71.76 | 83 |
117
+
118
+ ---
119
+
120
+ ## Supported Entity Schema
121
+
122
+ The model was trained on the **ContractNER** schema. While you can use custom labels, performance is best with categories semantically similar to:
123
+
124
+ ### Document Metadata
125
+ * **EffectiveDate**: Contract start date (e.g., "January 1, 2026").
126
+ * **TerminationDate**: Contract end or expiration date.
127
+ * **RenewalTerm**: Renewal periods or conditions.
128
+ * **Title**: Official document title.
129
+
130
+ ### Actors & Roles
131
+ * **Parties**: Legal entities entering the agreement (companies, individuals).
132
+ * **Role**: Professional titles and positions (e.g., "Chief Executive Officer").
133
+
134
+ ### Contact Information
135
+ * **Address**: Physical addresses.
136
+ * **PII_Ref**: Personal identifiable information references (phone, email, fax).
137
+
138
+ ### Financial Values
139
+ * **Salary**: Compensation amounts (always with currency symbol, e.g., "$225,000.00").
140
+ * **Price**: Goods/services prices.
141
+ * **Principal**: Loan principal amounts.
142
+ * **Shares**: Stock or equity quantities.
143
+ * **Percentage**: Percentage values (e.g., "50%").
144
+ * **Ratio**: Financial ratios.
145
+ * **Rent**: Lease or rental amounts.
146
+
147
+ ### Legal and Regulatory
148
+ * **Court**: Judicial bodies and tribunals (e.g., "State of Texas").
149
+ * **Act**: Legislative acts and laws.
150
+ * **Regulation**: Regulatory references (e.g., "Rule 10b5-1").
151
+
152
+ ---
153
+
154
+ ## Training Details
155
+
156
+ ### Data Source & Preprocessing
157
+ * **Dataset:** ContractNER corpus (Adibhatla et al., 2023) — Real contracts from SEC EDGAR (U.S. Securities and Exchange Commission filings).
158
+ * **Original Size:** ~5,000+ annotated contract segments.
159
+ * **Consolidated Dataset:** ~3,240 chunks after stratified reduction and class consolidation.
160
+ * **Adjustments:**
161
+ * Removed `RevolvingCredit` class (too rare and ambiguous).
162
+ * Rebalanced dataset to ensure minimum representation per class.
163
+ * **Split:** 80% training / 20% validation (random split).
164
+ * **Methodology:** Human-in-the-loop iterative labeling.
165
+
166
+ ### Architecture & Configuration
167
+ * **Base Model:** GLiNER Multi v2.1 (209M parameters).
168
+ * **Encoder Backbone:** `microsoft/mdeberta-v3-base` (86M backbone + 190M embedding parameters).
169
+ * **Architecture Type:** Span-based NER with entity-query matching.
170
+ * **Hardware:** NVIDIA L4 GPU.
171
+ * **Training Time:** ~30 minutes per fine-tuning run.
172
+
173
+ ---
174
+
175
+ ## Visualizations
176
+
177
+ ### Loss Curves
178
+ ![Training Loss](train_loss.png)
179
+
180
+ ### Model Comparison
181
+ ![Model Comparison](model_comparison.png)
182
+
183
+ ---
184
+
185
+ ## License
186
+ Apache 2.0
ContractNer/added_tokens.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:030e747c4ca7992a3ac794c6fda9919352c88ae722e85178217cd083b450078d
3
+ size 86
ContractNer/gliner_config.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fd3a79f99223d828e3ac90c3a8f015c343e61b6ded3e86f6271f9030384dc3cb
3
+ size 3533
ContractNer/model.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ee7e571fd83185659c62645946d03e5b2e8b090a15ebc495f03874750c7e3917
3
+ size 268435456
ContractNer/performance_heatmap.png ADDED

Git LFS Details

  • SHA256: 9bcb1f0c7dd2fd9f64e74470a8facfc3beca4cc81ed7df219804ecc951509c39
  • Pointer size: 131 Bytes
  • Size of remote file: 332 kB
ContractNer/pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2175a73b2be700594661330dbaecb0a2a842aa4ef06e5863a2338d68cc2a0403
3
+ size 1155879495