jbarrow commited on
Commit
5ab976c
·
verified ·
1 Parent(s): b053813

Upload LOCUS-Substantive weights, tokenizer, and model card

Browse files
Files changed (5) hide show
  1. README.md +74 -0
  2. config.json +85 -0
  3. model.safetensors +3 -0
  4. tokenizer.json +0 -0
  5. tokenizer_config.json +17 -0
README.md ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: answerdotai/ModernBERT-base
3
+ library_name: transformers
4
+ pipeline_tag: text-classification
5
+ tags:
6
+ - text-classification
7
+ - legal
8
+ - locus
9
+ - modernbert
10
+ license: apache-2.0
11
+ datasets:
12
+ - LocalLaws/LOCUS-v1.0
13
+ ---
14
+
15
+ # LocalLaws/LOCUS-Substantive
16
+
17
+ A ModernBERT classifier for the **Substantive (binary)** axis of the LOCUS
18
+ (Local Ordinances Corpus, United States) dataset.
19
+
20
+ Fine-tuned from [answerdotai/ModernBERT-base](https://huggingface.co/answerdotai/ModernBERT-base) on
21
+ [LocalLaws/LOCUS-v1.0](https://huggingface.co/datasets/LocalLaws/LOCUS-v1.0).
22
+
23
+ ## Labels
24
+
25
+ - `not_substantive`
26
+ - `substantive`
27
+
28
+ ## Training
29
+
30
+ | | |
31
+ |---|---|
32
+ | Base model | `answerdotai/ModernBERT-base` |
33
+ | Max length | 1024 |
34
+ | Classifier pooling | `mean` |
35
+ | Train / val / test | 79106 / 10447 / 10447 |
36
+
37
+ ## Evaluation
38
+
39
+ | | |
40
+ |---|---|
41
+ | Metric | binary-F1 |
42
+ | Validation binary-F1 | 0.9402 |
43
+ | Test binary-F1 | 0.9422 |
44
+ | Test accuracy | 0.9328 |
45
+
46
+ ```
47
+ precision recall f1-score support
48
+
49
+ 0 0.9517 0.8898 0.9197 4519
50
+ 1 0.9200 0.9656 0.9422 5928
51
+
52
+ accuracy 0.9328 10447
53
+ macro avg 0.9358 0.9277 0.9310 10447
54
+ weighted avg 0.9337 0.9328 0.9325 10447
55
+
56
+ ```
57
+
58
+ ## Usage
59
+
60
+ ```python
61
+ from transformers import AutoTokenizer, AutoModelForSequenceClassification
62
+ import torch
63
+
64
+ tok = AutoTokenizer.from_pretrained("LocalLaws/LOCUS-Substantive")
65
+ model = AutoModelForSequenceClassification.from_pretrained("LocalLaws/LOCUS-Substantive")
66
+ model.eval()
67
+
68
+ text = "No person shall keep any swine within the city limits."
69
+ enc = tok(text, return_tensors="pt", truncation=True, max_length=1024)
70
+ with torch.no_grad():
71
+ logits = model(**enc).logits
72
+ pred = logits.argmax(-1).item()
73
+ print(model.config.id2label[pred])
74
+ ```
config.json ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "ModernBertForSequenceClassification"
4
+ ],
5
+ "attention_bias": false,
6
+ "attention_dropout": 0.0,
7
+ "bos_token_id": 50281,
8
+ "classifier_activation": "gelu",
9
+ "classifier_bias": false,
10
+ "classifier_dropout": 0.0,
11
+ "classifier_pooling": "mean",
12
+ "cls_token_id": 50281,
13
+ "decoder_bias": true,
14
+ "deterministic_flash_attn": false,
15
+ "dtype": "float32",
16
+ "embedding_dropout": 0.0,
17
+ "eos_token_id": 50282,
18
+ "global_attn_every_n_layers": 3,
19
+ "gradient_checkpointing": false,
20
+ "hidden_activation": "gelu",
21
+ "hidden_size": 768,
22
+ "id2label": {
23
+ "0": "not_substantive",
24
+ "1": "substantive"
25
+ },
26
+ "initializer_cutoff_factor": 2.0,
27
+ "initializer_range": 0.02,
28
+ "intermediate_size": 1152,
29
+ "label2id": {
30
+ "not_substantive": 0,
31
+ "substantive": 1
32
+ },
33
+ "layer_norm_eps": 1e-05,
34
+ "layer_types": [
35
+ "full_attention",
36
+ "sliding_attention",
37
+ "sliding_attention",
38
+ "full_attention",
39
+ "sliding_attention",
40
+ "sliding_attention",
41
+ "full_attention",
42
+ "sliding_attention",
43
+ "sliding_attention",
44
+ "full_attention",
45
+ "sliding_attention",
46
+ "sliding_attention",
47
+ "full_attention",
48
+ "sliding_attention",
49
+ "sliding_attention",
50
+ "full_attention",
51
+ "sliding_attention",
52
+ "sliding_attention",
53
+ "full_attention",
54
+ "sliding_attention",
55
+ "sliding_attention",
56
+ "full_attention"
57
+ ],
58
+ "local_attention": 128,
59
+ "max_position_embeddings": 8192,
60
+ "mlp_bias": false,
61
+ "mlp_dropout": 0.0,
62
+ "model_type": "modernbert",
63
+ "norm_bias": false,
64
+ "norm_eps": 1e-05,
65
+ "num_attention_heads": 12,
66
+ "num_hidden_layers": 22,
67
+ "pad_token_id": 50283,
68
+ "position_embedding_type": "absolute",
69
+ "rope_parameters": {
70
+ "full_attention": {
71
+ "rope_theta": 160000.0,
72
+ "rope_type": "default"
73
+ },
74
+ "sliding_attention": {
75
+ "rope_theta": 10000.0,
76
+ "rope_type": "default"
77
+ }
78
+ },
79
+ "sep_token_id": 50282,
80
+ "sparse_pred_ignore_index": -100,
81
+ "sparse_prediction": false,
82
+ "tie_word_embeddings": true,
83
+ "transformers_version": "5.8.0",
84
+ "vocab_size": 50368
85
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d522aff3e1131199994106459faa514e5294d13fc5fdcb248a530cd24a7ac281
3
+ size 598439784
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "backend": "tokenizers",
3
+ "clean_up_tokenization_spaces": true,
4
+ "cls_token": "[CLS]",
5
+ "is_local": false,
6
+ "local_files_only": false,
7
+ "mask_token": "[MASK]",
8
+ "model_input_names": [
9
+ "input_ids",
10
+ "attention_mask"
11
+ ],
12
+ "model_max_length": 8192,
13
+ "pad_token": "[PAD]",
14
+ "sep_token": "[SEP]",
15
+ "tokenizer_class": "TokenizersBackend",
16
+ "unk_token": "[UNK]"
17
+ }