RayJackson30 commited on
Commit
96ee226
·
verified ·
1 Parent(s): 874e683

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +322 -40
README.md CHANGED
@@ -13,53 +13,338 @@ base_model: answerdotai/ModernBERT-base
13
 
14
  # clawbert-149
15
 
16
- A page-type classifier for California court filings. The purpose is to route pages of a litigation filing to an OCR tailored to that page type.
17
 
18
- Give it the OCR text of a document with page divisions, it looks at the text per page, with some info about before/after, and picks one of 11 structural types:
 
 
 
 
 
 
 
 
19
 
20
  `body · cover_page · subsequent_cover_page · toc · toa · exhibit_cover ·
21
  proof_of_service · verification · judicial_form · transcript · unknown_other`
22
 
23
- One of each, straight from filed documents (individual images in
24
- [docs/examples/](docs/examples/)):
25
 
26
  ![one example page per class](docs/page_types.jpg)
27
 
28
- ## Not Keyword Matching
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
 
30
- A few examples of trickier pages correctly categorized:
31
 
32
- ![lookalike pages with model predictions](docs/lookalikes.jpg)
 
 
33
 
34
- ## What it's for
35
 
36
- Twofold. I'd rely on it for the first but not the second:
37
 
38
- 1. **Routing pages to the right OCR.** A pleading cover page goes to a model that
39
- analyzes the regions and extracts critical document information; a table of
40
- contents goes to an OCR that recognizes the structure of the headings; a
41
- judicial form can go to a form-trained OCR; and so on. Classify first, route
42
- second.
43
- 2. **Per-page metadata for chunking.** Tell the LLM working with the text "this
44
- is a pleading cover page, it falls on page 1", or "this is a pleading cover
45
- page falling on page 17, after an exhibit cover page" — stuff like that lowers
46
- the risk of AI docket-context mistakes.
47
 
 
48
 
 
 
49
 
50
- I initially built DistilBERT and XGBoost versions of the tool. They worked well for a single OCR type, but broke down when I fed it the same pages OCR'd by multiple engines. The current model is trained on the same 13.6k labeled pages OCR'd by 5 very different OCR engines.
51
 
52
- Claude made me some graphs with benchmarks showing incredible results. Because benchmarks always look to me like garbage, here is my creaky-knee-if-it's-raining estimate: I think it makes the same pick I would make about 95-96% of the time, and then maybe another percent is picks on ambiguous pages, and then 2 or 3 percent of the time it does something stupid.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53
 
54
  ## Specs
55
 
56
  | | |
57
  |---|---|
58
  | Base | ModernBERT-base, 149.6M params, full-page input (1,536 tokens) |
59
- | Trained on | ~13.6k human-labeled pages from 653 CA filings × 5 OCR engines (PP-OCRv5, Tesseract, docTR, Hunyuan VLM, Windows OCR) |
60
- | Splits | document-disjoint (no filing crosses train/test) |
61
- | Held-out test | macro-F1 0.937 · accuracy 0.974 pooled across engines (`eval/modernbert11_metrics.json`) |
62
- | Calibration | ECE ≈ 0.02 on every engine tested — the confidence is usable for triage |
63
  | Weights | this repo (`model.safetensors`, 598 MB) |
64
 
65
  ## Use it
@@ -77,22 +362,19 @@ probs = torch.softmax(model(**enc).logits, -1)[0]
77
  print(model.config.id2label[int(probs.argmax())], float(probs.max()))
78
  ```
79
 
80
- ## Important Limitations
81
-
82
- - **It assumes the PDF is already one document.** It won't work on an appendix or
83
- a combined record — document order is a signal, especially with various
84
- OCRs.
85
- - **California, probably only.** Trained on California pleadings, and California helpfully still uses the antiquated pleading line numbers. It's annoying for OCR, helpful
86
- for classification. I doubt it will work in other states unmodified.
87
- - **More categories are needed and forthcoming:** appellate cover pages, and
88
- court-originating documents (orders, notifications, minute orders). For now
89
- appellate materials land in `unknown_other`.
90
- - Robustness is demonstrated for the five trained engines; I haven't tested it on
91
- other OCR models.
92
- - `subsequent_cover_page` is genuinely ambiguous from one page alone — if you
93
- have whole documents, sequence models on top of these embeddings fix that.
94
- - Text only, which works so far. But also means there's stuff it will never be able to do, like deal with court stamps or signatures.
95
 
96
  ## License
97
 
98
- Apache-2.0, same as the base model.
 
13
 
14
  # clawbert-149
15
 
 
16
 
17
+ A page classifier for documents filed in California state courts. Intended as a
18
+ tool to be used early in a document ingestion process, for prepping filings for
19
+ use in a RAG or even attaching to prompts. Pages are classified based on the
20
+ OCR'd text — whether Tesseract, VLM OCR, or something in between. Once
21
+ classified, they can be sent to other layout/OCR steps designed for extracting
22
+ and organizing text, and for tagging the document and its chunks. Per page-type
23
+ OCRing is outside of the scope of this tool.
24
+
25
+ 11 page types:
26
 
27
  `body · cover_page · subsequent_cover_page · toc · toa · exhibit_cover ·
28
  proof_of_service · verification · judicial_form · transcript · unknown_other`
29
 
30
+ Exemplars (individual images in [docs/examples/](docs/examples/)):
 
31
 
32
  ![one example page per class](docs/page_types.jpg)
33
 
34
+ ## Purpose
35
+
36
+ 1. **Routing pages to the right OCR.** A cover page goes to a model that
37
+ extracts case metadata; a table of contents to one that reads heading
38
+ structure; a judicial form to a form-trained OCR. This tool doesn't do any of
39
+ this downstream work. It only classifies.
40
+ 2. **Metadata for chunking.** A secondary use is tagging extracted text to help
41
+ an LLM when working with documents. E.g., use it to tag pages of an exhibit
42
+ as an exhibit page.
43
+
44
+ Classifying a page for OCRing and classifying a page for AI-attorney use often
45
+ overlap, but not always.
46
+
47
+ ## Trained on a variety of OCR engines
48
+
49
+ Trained on about 13K pages of human-labelled page images. Each page image was
50
+ OCR'd five times, by five different OCR engines. Play around with the tabs
51
+ below — the same cover page, five very different transcriptions, one label.
52
+ Note that each page is part of a document, and the process takes into account
53
+ previous/subsequent classifications.
54
+
55
+ <img src="docs/examples/cover_page.jpg" alt="cover page" width="300" align="right">
56
+
57
+ <details>
58
+ <summary><b>PP-OCRv5</b> &nbsp;→&nbsp; <code>cover_page</code> (1.00)</summary>
59
+
60
+ ```text
61
+ ORIGINAL
62
+ 1
63
+ JAMES C. HARRISON, State Bar No. 161958
64
+ FILED
65
+ THOMAS A. WILLIS, State Bar No. 160989
66
+ Superior Court Of California,
67
+ 2
68
+ REMCHO, JOHANSEN & PURCELL, LLP
69
+ 1901 Harrison Street, Suite 1550
70
+ Sacramento
71
+ 3
72
+ Oakland, CA 94612
73
+ 03/05/2018
74
+ Phone: (510) 346-6200
75
+ mnrubalcaba
76
+ 4
77
+ Fax: (510) 346-6201
78
+ Email: twillis@rjp.com
79
+ By
80
+ ., Deputy
81
+ 5
82
+ Casa Number:
83
+ Attorneys for Petitioner
84
+ 34-2018-80002819
85
+ 6
86
+ Chad Mayes
87
+ 7
88
+ 8
89
+ IN THE SUPERIOR COURT OF THE STATE OF CALIFORNIA
90
+ 9
91
+ COUNTY OF SACRAMENTO
92
+ 10
93
+ (UNLIMITED JURISDICTION)
94
+ 11
95
+ CHAD MAYES,
96
+ No.:
97
+ 12
98
+ Petitioner,
99
+ Action Filed: March 5, 2018
100
+ 13
101
+ vs.
102
+ VERIFIED PETITION FOR WRIT
103
+ OF MANDATE
104
+ 14
105
+ ALEX PADILLA, in his official capacity as
106
+ Secretary of State of the State of California,
107
+ (Proposition 70)
108
+ 15
109
+ Respondent.
110
+ ELECTION MATTER - IMMEDIATE
111
+ 16
112
+ ACTION REQUESTED
113
+ [Elec. Code, § 13314]
114
+ 17
115
+ DAVID GERALD HILL, in his official capacity
116
+ as State Printer of the State of California, and
117
+ Writ Hearing:
118
+ 18
119
+ XAVIER BECERRA, in his official capacity as
120
+ Attorney General of the State of California,
121
+ Date:
122
+ 19
123
+ Time:
124
+ Real Parties in Interest.
125
+ Dept.:
126
+ 20
127
+ (The Honorable
128
+ 21
129
+ 22
130
+ 23
131
+ 24
132
+ 25
133
+ 26
134
+ 27
135
+ 28
136
+ 1
137
+ VERIFIED PETITION FOR WRIT OF MANDATE
138
+ ```
139
+ </details>
140
+ <details>
141
+ <summary><b>Tesseract</b> &nbsp;→&nbsp; <code>cover_page</code> (1.00)</summary>
142
+
143
+ ```text
144
+ ran
145
+
146
+ oO fe KN DN nN FF WY NY
147
+
148
+ JAMES C. HARRISON, siate Bar No. 161958
149
+ THOMAS A. WILLIS, state Bar No. 160989
150
+ REMCHO, JOHANSEN & PURCELL, Lip
151
+ 1901 Harrison Street, Suite 1550
152
+
153
+ Oakland, CA 94612
154
+
155
+ Phone: (510) 346-6200
156
+
157
+ Fax: (510) 346-6201
158
+
159
+ Email: twillis@rjp.com
160
+
161
+ Attorneys for Petitioner
162
+
163
+ ORIGINAL
164
+
165
+ FILED
166
 
167
+ Superior Court Of Californiz,
168
 
169
+ Sacramento
170
+ oz/o5/2018
171
+ mrubaicaba
172
 
173
+ By , Depu
174
 
175
+ Cage Number:
176
 
177
+ Chad Mayes 34-201 6-8000281 9g
178
+ IN THE SUPERIOR COURT OF THE STATE OF CALIFORNIA
179
+ COUNTY OF SACRAMENTO
180
+ (UNLIMITED JURISDICTION)
181
+ CHAD MAYES, No.: .
182
+ Petitioner, Action Filed: March 5, 2018
 
 
 
183
 
184
+ vs.
185
 
186
+ ALEX PADILLA, in his official capacity as
187
+ Secretary of State of the State of California,
188
 
189
+ Respondent.
190
 
191
+ DAVID GERALD HILL, in his official capacity
192
+ as State Printer of the State of California, and
193
+ XAVIER BECERRA, in his official capacity as
194
+ Attomey General of the State of California,
195
+
196
+ Real Parties in-Interest.
197
+
198
+ VERIFIED PETITION FOR WRIT
199
+ OF MANDATE
200
+
201
+ (Proposition 70)
202
+ ELECTION MATTER - IMMEDIATE
203
+
204
+ ACTION REQUESTED
205
+ [Elec. Code, § 13314]
206
+
207
+ Writ Hearing:
208
+ Date:
209
+ Time:
210
+ Dept.:
211
+ (The Honorable )
212
+
213
+ VERIFIED PETITION FOR WRIT OF MANDATE
214
+ ```
215
+ </details>
216
+ <details>
217
+ <summary><b>docTR</b> &nbsp;→&nbsp; <code>cover_page</code> (1.00)</summary>
218
+
219
+ ```text
220
+ ORIGINAL
221
+ 1 JAMES C. HARRISON, State Bar No. 161958
222
+ FILED
223
+ THOMAS A. WILLIS, State Barl No. 160989
224
+ 2 REMCHO, JOHANSEN & PURCELL, LLP
225
+ Superior Court Of California,
226
+ 1901 Harrison Street, Suite 1550
227
+ Sagramento
228
+ 3 Oakland, CA 94612
229
+ 03/05/2018
230
+ Phone: (510) 346-6200
231
+ 4 Fax: (510) 346-6201
232
+ mrubalcaba
233
+ Email: twillis@rjp.com
234
+ By
235
+ 1 Deputy
236
+ 5
237
+ Case Number:
238
+ Attorneys for Petitioner
239
+ 6 Chad Mayes
240
+ 34-2018-80002819
241
+ 7
242
+ 8
243
+ IN THE SUPERIOR COURT OF THE STATE OF CALIFORNIA
244
+ 9
245
+ COUNTY OF SACRAMENTO
246
+ 10
247
+ (UNLIMITED JURISDICTION)
248
+ 11 CHAD MAYES,
249
+ No.:
250
+ 12
251
+ Petitioner,
252
+ Action Filed: March 5, 2018
253
+ 13 Vs.
254
+ VERIFIED PETITION FOR WRIT
255
+ OF MANDATE
256
+ 14 ALEX PADILLA, in his official capacity as
257
+ Secretary of State of the State of California,
258
+ (Proposition 70)
259
+ 15
260
+ Respondent.
261
+ ELECTION MATTER - IMMEDIATE
262
+ 16
263
+ ACTION REQUESTED
264
+ [Elec. Code, S 13314]
265
+ 17 DAVID GERALD HILL, in his official capacity
266
+ as State Printer of the State of California, and
267
+ Writ Hearing:
268
+ 18 XAVIER BECERRA, in his official capacity as
269
+ Attorey General of the State of California,
270
+ Date:
271
+ 19
272
+ Time:
273
+ Real Parties in Interest.
274
+ Dept.:
275
+ 20
276
+ (The Honorable
277
+ 21
278
+ 22
279
+ 23
280
+ 24
281
+ 25
282
+ 26
283
+ 27
284
+ 28
285
+ 1
286
+ VERIFIED PETITION FOR WRIT OF MANDATE
287
+ ```
288
+ </details>
289
+ <details>
290
+ <summary><b>Hunyuan VLM</b> &nbsp;→&nbsp; <code>cover_page</code> (1.00)</summary>
291
+
292
+ ```text
293
+ JAMES C. HARRISON, State Bar No. 161958
294
+ THOMAS A. WILLIS, State Bar No. 160989
295
+ REMCHO, JOHANSEN & PURCELL, LLP
296
+ 1901 Harrison Street, Suite 1550
297
+ Oakland, CA 94612
298
+ Phone: (510) 346-6200
299
+ Fax: (510) 346-6201
300
+ Email: willis@rjp.com
301
+ Attorneys for Petitioner Chad Mayes
302
+ # ORIGINAL FILED
303
+ Superior Court Of California, Sacramento 03/05/2018 mrbalcaba By , Deputy Case Number: 34-2018-80002819
304
+ # IN THE SUPERIOR COURT OF THE STATE OF CALIFORNIA COUNTY OF SACRAMENTO (UNLIMITED JURISDICTION)
305
+ ## CHAD MAYES, Petitioner, vs. ALEX PADILLA, in his official capacity as Secretary of State of the State of California, Respondent.
306
+ DAVID GERALD HILL, in his official capacity as State Printer of the State of California, and XAVIER BECERRA, in his official capacity as Attorney General of the State of California, Real Parties in Interest.
307
+ No.: __________________
308
+ Action Filed: March 5, 2018
309
+ VERIFIED PETITION FOR WRIT OF MANDATE (Proposition 70)
310
+ ELECTION MATTER - IMMEDIATE ACTION REQUESTED [Elec. Code, § 13314]
311
+ Writ Hearing: Date: Time: Dept.: (The Honorable _________________)
312
+
313
+ VERIFIED PETITION FOR WRIT OF MANDATE
314
+ ```
315
+ </details>
316
+ <details>
317
+ <summary><b>Windows OCR</b> &nbsp;→&nbsp; <code>cover_page</code> (1.00)</summary>
318
+
319
+ ```text
320
+ 1 2 3 4 5 6 7 8 9 10 11 12 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 JAMES C. HARRISON, State Bar No. 161958 THOMAS A. WILLIS, 160989 REMCHO, JOHANSEN & PURCELL, LLP 1901 Harrison S&eet, Suite 1550 Oakland, CA 94612 Phone: (510) 346-6200 Fax: (510) 346-6201 Email: twillis@rjp.com Attomeys for Petitioner Chad Mayes ORIGINAL FILED Superior Court Of Californi Sacramento 0310512018 mrubalcaba , Depu Case Number: 34-2018-80002819 IN THE SUPERIOR COURT OF THE STATE OF CALIFORNIA COUNTY OF SACRAMENTO (UNLIMITED JURISDICTION) CHAD MAYES, Petitioner, ALEX PADILLA, in his official capacity as Secretary of State of the State of California, Respondent. DAVID GERALD HILL, in his officialeapacity as State Printer of the State of California, and XAVIER BECERRA, in his offcial capacity as Attomey General of the State of Califomia, Real Parties in Interest. Action Filed: March 5, 2018 VERIFIED PETITION FOR WRIT OF MANDATE (Proposition 70) ELECTION MATTER - IMMEDIATE ACTION REQUESTED [Elec. code, 133141 Writ Hearing: Date: Time: (The Honorable 1 VERIFIED PETITION FOR WRIT OF MANDATE
321
+ ```
322
+ </details>
323
+
324
+ <br clear="right">
325
+
326
+ This model isn't intended to be used by itself. It's an early stage in a
327
+ pipeline for ultra-high-quality OCR specific to litigation documents. Examples
328
+ of different later treatment:
329
+
330
+ | page type | later treatment |
331
+ |---|---|
332
+ | `cover_page` | A VLM that pulls out the parties, filing date, and case number — and retains the artefacts. |
333
+ | `transcript` | A reader that untangles the special transcript layout. |
334
+ | `exhibit_cover` | These seem to fool VLMs, so send them to dumb OCR. |
335
+ | `body` | OCR with better reading order and heading detection — and correlate with the TOC when there is one. |
336
+ | `proof_of_service` | Keep images of the signature and the dating. |
337
+ | `judicial_form` | A model fine-tuned on the common court forms. |
338
 
339
  ## Specs
340
 
341
  | | |
342
  |---|---|
343
  | Base | ModernBERT-base, 149.6M params, full-page input (1,536 tokens) |
344
+ | Trained on | ~13.6k human-labeled pages · 653 CA filings × 5 OCR engines (PP-OCRv5, Tesseract, docTR, Hunyuan VLM, Windows OCR) |
345
+ | Splits | document-disjoint no filing crosses train/test |
346
+ | Held-out test | macro-F1 0.937 · accuracy 0.974, pooled across engines (`eval/modernbert11_metrics.json`) |
347
+ | Calibration | ECE ≈ 0.02 on every engine tested — confidence usable for triage |
348
  | Weights | this repo (`model.safetensors`, 598 MB) |
349
 
350
  ## Use it
 
362
  print(model.config.id2label[int(probs.argmax())], float(probs.max()))
363
  ```
364
 
365
+ ## Know what you're getting
366
+
367
+ - **Assumes one document.** Won't work on an appendix or combined record —
368
+ document order is a signal.
369
+ - **California, probably only.** CA still uses antiquated pleading line numbers
370
+ annoying for OCR, but a strong classification signal. Unlikely to transfer
371
+ unmodified.
372
+ - **More categories coming.** Appellate cover pages, and court-originating
373
+ documents (orders, notifications, minute orders).
374
+ - **Text only.** Needs extracted text, divided by page breaks.
375
+ - **Extracted PDFs?** I think this works fine on text extracted from native
376
+ PDFs (versus scans) but will verify soon.
 
 
 
377
 
378
  ## License
379
 
380
+ Apache-2.0, same as the base model.