File size: 11,704 Bytes
874e683
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
96ee226
 
 
 
 
 
 
 
 
874e683
 
 
 
96ee226
874e683
 
 
96ee226
 
0d8f95c
 
 
 
96ee226
 
 
 
 
 
 
 
 
 
 
 
5b6970c
0d8f95c
 
96ee226
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
874e683
96ee226
874e683
96ee226
 
 
874e683
96ee226
874e683
96ee226
874e683
96ee226
 
 
 
 
 
874e683
96ee226
874e683
96ee226
 
874e683
96ee226
874e683
96ee226
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
874e683
 
 
 
 
 
96ee226
 
 
 
874e683
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5b6970c
 
 
 
 
 
 
 
 
 
 
 
 
96ee226
 
 
 
 
 
 
 
 
 
 
 
874e683
 
 
96ee226
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
---

language: en
license: apache-2.0
library_name: transformers
pipeline_tag: text-classification
tags:
  - legal
  - document-ai
  - page-classification
  - modernbert
base_model: answerdotai/ModernBERT-base
---


# clawbert-149


A page classifier for documents filed in California state courts. Intended as a
tool to be used early in a document ingestion process, for prepping filings for
use in a RAG or even attaching to prompts. Pages are classified based on the
OCR'd text — whether Tesseract, VLM OCR, or something in between. Once
classified, they can be sent to other layout/OCR steps designed for extracting
and organizing text, and for tagging the document and its chunks. Per page-type
OCRing is outside of the scope of this tool.

11 page types:

`body · cover_page · subsequent_cover_page · toc · toa · exhibit_cover ·
proof_of_service · verification · judicial_form · transcript · unknown_other`

Exemplars (individual images in [docs/examples/](docs/examples/)):

![one example page per class](docs/page_types.jpg)

## Purpose

1. **Routing pages to the right OCR.** Cover page text would go to a model
   that extracts case metadata; TOC-designated to one that reads heading
   structure; text from a judicial form page to a form-trained OCR. (BUT this tool 
   doesn't do any of this downstream work. It only classifies.)
2. **Metadata for chunking.** A secondary use is tagging extracted text to help
   an LLM when working with documents. E.g., use it to tag pages of an exhibit
   as an exhibit page.

Classifying a page for OCRing and classifying a page for AI-attorney use often
overlap, but not always.

## Trained on a variety of OCR engines

Trained on about 13K pages of human-labelled page images. Each page image was
OCR'd five times, by five different OCR engines. Play around with the tabs
below — the same cover page, five very different transcriptions, one label.
Note that each page is part of a document, and the whole-document mode below
takes previous/subsequent pages into account, which mostly matters for edge
(low-confidence) cases.

<img src="docs/examples/cover_page.jpg" alt="cover page" width="300" align="right">

<details>
<summary><b>PP-OCRv5</b> &nbsp;→&nbsp; <code>cover_page</code> (1.00)</summary>



```text

ORIGINAL

1

JAMES C. HARRISON, State Bar No. 161958

FILED

THOMAS A. WILLIS, State Bar No. 160989

Superior Court Of California,

2

REMCHO, JOHANSEN & PURCELL, LLP

1901 Harrison Street, Suite 1550

Sacramento

3

Oakland, CA 94612

03/05/2018

Phone: (510) 346-6200

mnrubalcaba

4

Fax: (510) 346-6201

Email: twillis@rjp.com

By

., Deputy

5

Casa Number:

Attorneys for Petitioner

34-2018-80002819

6

Chad Mayes

7

8

IN THE SUPERIOR COURT OF THE STATE OF CALIFORNIA

9

COUNTY OF SACRAMENTO

10

(UNLIMITED JURISDICTION)

11

CHAD MAYES,

No.:

12

Petitioner,

Action Filed: March 5, 2018

13

vs.

VERIFIED PETITION FOR WRIT

OF MANDATE

14

ALEX PADILLA, in his official capacity as

Secretary of State of the State of California,

(Proposition 70)

15

Respondent.

ELECTION MATTER - IMMEDIATE

16

ACTION REQUESTED

[Elec. Code, § 13314]

17

DAVID GERALD HILL, in his official capacity

as State Printer of the State of California, and

Writ Hearing:

18

XAVIER BECERRA, in his official capacity as

Attorney General of the State of California,

Date:

19

Time:

Real Parties in Interest.

Dept.:

20

(The Honorable

21

22

23

24

25

26

27

28

1

VERIFIED PETITION FOR WRIT OF MANDATE

```

</details>

<details>

<summary><b>Tesseract</b> &nbsp;→&nbsp; <code>cover_page</code> (1.00)</summary>

```text

ran



oO fe KN DN nN FF WY NY



JAMES C. HARRISON, siate Bar No. 161958

THOMAS A. WILLIS, state Bar No. 160989

REMCHO, JOHANSEN & PURCELL, Lip

1901 Harrison Street, Suite 1550



Oakland, CA 94612



Phone: (510) 346-6200



Fax: (510) 346-6201



Email: twillis@rjp.com



Attorneys for Petitioner



ORIGINAL



FILED



Superior Court Of Californiz,



Sacramento

oz/o5/2018

mrubaicaba



By , Depu



Cage Number:



Chad Mayes 34-201 6-8000281 9g

IN THE SUPERIOR COURT OF THE STATE OF CALIFORNIA

COUNTY OF SACRAMENTO

(UNLIMITED JURISDICTION)

CHAD MAYES, No.: .

Petitioner, Action Filed: March 5, 2018



vs.



ALEX PADILLA, in his official capacity as

Secretary of State of the State of California,



Respondent.



DAVID GERALD HILL, in his official capacity

as State Printer of the State of California, and

XAVIER BECERRA, in his official capacity as

Attomey General of the State of California,



Real Parties in-Interest.



VERIFIED PETITION FOR WRIT

OF MANDATE



(Proposition 70)

ELECTION MATTER - IMMEDIATE



ACTION REQUESTED

[Elec. Code, § 13314]



Writ Hearing:

Date:

Time:

Dept.:

(The Honorable )



VERIFIED PETITION FOR WRIT OF MANDATE

```
</details>
<details>
<summary><b>docTR</b> &nbsp;→&nbsp; <code>cover_page</code> (1.00)</summary>



```text

ORIGINAL

1 JAMES C. HARRISON, State Bar No. 161958

FILED

THOMAS A. WILLIS, State Barl No. 160989

2 REMCHO, JOHANSEN & PURCELL, LLP

Superior Court Of California,

1901 Harrison Street, Suite 1550

Sagramento

3 Oakland, CA 94612

03/05/2018

Phone: (510) 346-6200

4 Fax: (510) 346-6201

mrubalcaba

Email: twillis@rjp.com

By

1 Deputy

5

Case Number:

Attorneys for Petitioner

6 Chad Mayes

34-2018-80002819

7

8

IN THE SUPERIOR COURT OF THE STATE OF CALIFORNIA

9

COUNTY OF SACRAMENTO

10

(UNLIMITED JURISDICTION)

11 CHAD MAYES,

No.:

12

Petitioner,

Action Filed: March 5, 2018

13 Vs.

VERIFIED PETITION FOR WRIT

OF MANDATE

14 ALEX PADILLA, in his official capacity as

Secretary of State of the State of California,

(Proposition 70)

15

Respondent.

ELECTION MATTER - IMMEDIATE

16

ACTION REQUESTED

[Elec. Code, S 13314]

17 DAVID GERALD HILL, in his official capacity

as State Printer of the State of California, and

Writ Hearing:

18 XAVIER BECERRA, in his official capacity as

Attorey General of the State of California,

Date:

19

Time:

Real Parties in Interest.

Dept.:

20

(The Honorable

21

22

23

24

25

26

27

28

1

VERIFIED PETITION FOR WRIT OF MANDATE

```

</details>

<details>

<summary><b>Hunyuan VLM</b> &nbsp;→&nbsp; <code>cover_page</code> (1.00)</summary>

```text

JAMES C. HARRISON, State Bar No. 161958

THOMAS A. WILLIS, State Bar No. 160989

REMCHO, JOHANSEN & PURCELL, LLP

1901 Harrison Street, Suite 1550

Oakland, CA 94612

Phone: (510) 346-6200

Fax: (510) 346-6201

Email: willis@rjp.com

Attorneys for Petitioner Chad Mayes

# ORIGINAL FILED

Superior Court Of California, Sacramento 03/05/2018 mrbalcaba By , Deputy Case Number: 34-2018-80002819

# IN THE SUPERIOR COURT OF THE STATE OF CALIFORNIA COUNTY OF SACRAMENTO (UNLIMITED JURISDICTION)

## CHAD MAYES, Petitioner, vs. ALEX PADILLA, in his official capacity as Secretary of State of the State of California, Respondent.

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.

No.: __________________

Action Filed: March 5, 2018

VERIFIED PETITION FOR WRIT OF MANDATE (Proposition 70)

ELECTION MATTER - IMMEDIATE ACTION REQUESTED [Elec. Code, § 13314]

Writ Hearing: Date: Time: Dept.: (The Honorable _________________)



VERIFIED PETITION FOR WRIT OF MANDATE

```
</details>
<details>
<summary><b>Windows OCR</b> &nbsp;→&nbsp; <code>cover_page</code> (1.00)</summary>



```text

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

```

</details>



<br clear="right">



This model isn't intended to be used by itself. It's an early stage in a

pipeline for ultra-high-quality OCR specific to litigation documents. Examples

of different later treatment:



| page type | later treatment |

|---|---|

| `cover_page` | A VLM that pulls out the parties, filing date, and case number — and retains the artefacts. |
| `transcript` | A reader that untangles the special transcript layout. |
| `exhibit_cover` | These seem to fool VLMs, so send them to dumb OCR. |
| `body` | OCR with better reading order and heading detection — and correlate with the TOC when there is one. |
| `proof_of_service` | Keep images of the signature and the dating. |
| `judicial_form` | A model fine-tuned on the common court forms. |

## Specs

| | |
|---|---|
| Base | ModernBERT-base, 149.6M params, full-page input (1,536 tokens) |
| Trained on | ~13.6k human-labeled pages · 653 CA filings × 5 OCR engines (PP-OCRv5, Tesseract, docTR, Hunyuan VLM, Windows OCR) |
| Splits | document-disjoint — no filing crosses train/test |
| Held-out test | macro-F1 0.937 · accuracy 0.974, pooled across engines (`eval/modernbert11_metrics.json`) |
| Calibration | ECE ≈ 0.02 on every engine tested — confidence usable for triage |
| Weights | this repo (`model.safetensors`, 598 MB) |

## Use it

```python

from transformers import AutoTokenizer, AutoModelForSequenceClassification

import torch



repo = "RayJackson30/clawbert-149"

tok = AutoTokenizer.from_pretrained(repo)

model = AutoModelForSequenceClassification.from_pretrained(repo).eval()



enc = tok(page_text, truncation=True, max_length=1536, return_tensors="pt")

probs = torch.softmax(model(**enc).logits, -1)[0]

print(model.config.id2label[int(probs.argmax())], float(probs.max()))

```

## Whole-document mode

The per-page model classifies one page at a time. The repo also ships a small
context layer (`docxf/`, 1.8M params) that runs over a whole document's page
embeddings — every page attends to every other page — so ambiguous pages get
decided with document context. Pooled test macro-F1 goes 0.937 → 0.949;
`subsequent_cover_page` F1 0.68 → 0.77. Feed it ONE document's pages, in order.

```python

from clawbert149_doc import score_document

labels, probs = score_document([page1_text, page2_text, page3_text])

```

## Know what you're getting

- **Assumes one document.** Won't work on an appendix or combined record —
  document order is a signal.
- **California, probably only.** CA still uses antiquated pleading line numbers
  — annoying for OCR, but a strong classification signal. Unlikely to transfer
  unmodified.
- **More categories coming.** Appellate cover pages, and court-originating
  documents (orders, notifications, minute orders).
- **Text only.** Needs extracted text, divided by page breaks.
- **Extracted PDFs?** I think this works fine on text extracted from native
  PDFs (versus scans) but will verify soon.

## License

Apache-2.0, same as the base model.