mjbommar commited on
Commit
baa443c
·
verified ·
1 Parent(s): aafe39c

Upload OGBert-110M sentence model

Browse files
1_Pooling/config.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "word_embedding_dimension": 768,
3
+ "pooling_mode_cls_token": false,
4
+ "pooling_mode_mean_tokens": true,
5
+ "pooling_mode_max_tokens": false,
6
+ "pooling_mode_mean_sqrt_len_tokens": false,
7
+ "pooling_mode_weightedmean_tokens": false,
8
+ "pooling_mode_lasttoken": false,
9
+ "include_prompt": true
10
+ }
README.md ADDED
@@ -0,0 +1,169 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - en
4
+ license: apache-2.0
5
+ library_name: sentence-transformers
6
+ tags:
7
+ - sentence-transformers
8
+ - feature-extraction
9
+ - sentence-similarity
10
+ - transformers
11
+ - modernbert
12
+ - embeddings
13
+ pipeline_tag: sentence-similarity
14
+ datasets:
15
+ - mjbommar/ogbert-v1-mlm
16
+ model-index:
17
+ - name: ogbert-110m-sentence
18
+ results:
19
+ - task:
20
+ type: clustering
21
+ dataset:
22
+ name: Custom Domain Clustering
23
+ type: custom
24
+ metrics:
25
+ - type: adjusted_rand_index
26
+ value: 0.941
27
+ - task:
28
+ type: retrieval
29
+ dataset:
30
+ name: Custom Domain Retrieval
31
+ type: custom
32
+ metrics:
33
+ - type: mrr
34
+ value: 0.959
35
+ ---
36
+
37
+ # OGBert-110M-Sentence
38
+
39
+ A 110M parameter ModernBERT-based sentence embedding model for glossary and domain-specific text.
40
+
41
+ **Related models:**
42
+ - [mjbommar/ogbert-110m-base](https://huggingface.co/mjbommar/ogbert-110m-base) - Base MLM model for fill-mask tasks
43
+
44
+ ## Model Details
45
+
46
+ | Property | Value |
47
+ |----------|-------|
48
+ | Architecture | ModernBERT + Mean Pooling + L2 Normalize |
49
+ | Parameters | 110M |
50
+ | Hidden size | 768 |
51
+ | Layers | 12 |
52
+ | Attention heads | 12 |
53
+ | Vocab size | 32,768 |
54
+ | Max sequence | 1,024 tokens |
55
+ | Embedding dim | 768 (L2 normalized) |
56
+
57
+ ## Training
58
+
59
+ - **Pretraining**: Masked Language Modeling on domain-specific glossary corpus
60
+ - **Dataset**: [mjbommar/ogbert-v1-mlm](https://huggingface.co/datasets/mjbommar/ogbert-v1-mlm) - derived from [OpenGloss](https://arxiv.org/abs/2511.18622), a synthetic encyclopedic dictionary with 537K senses across 150K lexemes
61
+ - **Checkpoint**: Step 8K (selected for optimal downstream performance)
62
+ - **Key finding**: L2 normalization of embeddings is critical for clustering/retrieval performance
63
+
64
+ ## Performance
65
+
66
+ ### Document Clustering (ARI)
67
+
68
+ Evaluated on 80 domain-specific documents across 10 categories using KMeans clustering.
69
+
70
+ | Model | Params | ARI | Cluster Acc |
71
+ |-------|--------|-----|-------------|
72
+ | **OGBert-110M-Sentence** | **110M** | **0.941** | **0.975** |
73
+ | BERT-base | 110M | 0.896 | 0.950 |
74
+ | RoBERTa-base | 125M | 0.941 | 0.975 |
75
+ | MiniLM-L6-v2 | 22M | 0.833 | 0.925 |
76
+
77
+ OGBert-110M-Sentence matches RoBERTa-base on clustering and **beats MiniLM by 13%**.
78
+
79
+ ### Document Retrieval (MRR)
80
+
81
+ Mean Reciprocal Rank for same-category document retrieval.
82
+
83
+ | Model | Params | Sample MRR |
84
+ |-------|--------|------------|
85
+ | **OGBert-110M-Sentence** | **110M** | **0.959** |
86
+ | BERT-base | 110M | 0.994 |
87
+ | RoBERTa-base | 125M | 0.989 |
88
+ | MiniLM-L6-v2 | 22M | 0.958 |
89
+
90
+ ### Word Similarity (SimLex-999)
91
+
92
+ Spearman correlation between model cosine similarities and human judgments.
93
+
94
+ | Model | Params | SimLex-999 (ρ) |
95
+ |-------|--------|----------------|
96
+ | **OGBert-110M-Sentence** | **110M** | **0.345** |
97
+ | BERT-base | 110M | 0.070 |
98
+ | RoBERTa-base | 125M | -0.061 |
99
+
100
+ OGBert-110M-Sentence achieves **5x better** word similarity than BERT-base.
101
+
102
+ ### Summary vs Baselines
103
+
104
+ At the same size as BERT-base, OGBert-110M-Sentence achieves:
105
+ - **5x better** word similarity (SimLex)
106
+ - **Matches** RoBERTa on clustering (ARI)
107
+ - **13% better** clustering than MiniLM
108
+
109
+ ## Usage
110
+
111
+ ### Sentence-Transformers (Recommended)
112
+
113
+ ```python
114
+ from sentence_transformers import SentenceTransformer
115
+
116
+ model = SentenceTransformer('mjbommar/ogbert-110m-sentence')
117
+ embeddings = model.encode(['your text here']) # L2 normalized by default
118
+ ```
119
+
120
+ **Example - Domain Similarity:**
121
+ ```python
122
+ sentences = [
123
+ 'The financial audit revealed discrepancies in the quarterly report.',
124
+ 'An accounting review found errors in the fiscal statement.',
125
+ 'The patient was diagnosed with acute respiratory infection.',
126
+ ]
127
+ embeddings = model.encode(sentences)
128
+ ```
129
+
130
+ The model correctly identifies higher similarity within the same domain.
131
+
132
+ ### Direct Transformers Usage
133
+
134
+ ```python
135
+ from transformers import AutoModel, AutoTokenizer
136
+ import torch.nn.functional as F
137
+
138
+ tokenizer = AutoTokenizer.from_pretrained('mjbommar/ogbert-110m-sentence')
139
+ model = AutoModel.from_pretrained('mjbommar/ogbert-110m-sentence')
140
+
141
+ inputs = tokenizer('your text here', return_tensors='pt', padding=True, truncation=True)
142
+ outputs = model(**inputs)
143
+
144
+ # Mean pooling + L2 normalize (critical for performance)
145
+ mask = inputs['attention_mask'].unsqueeze(-1)
146
+ pooled = (outputs.last_hidden_state * mask).sum(1) / mask.sum(1)
147
+ embeddings = F.normalize(pooled, p=2, dim=1)
148
+ ```
149
+
150
+ ### For Fill-Mask Tasks
151
+
152
+ Use [mjbommar/ogbert-110m-base](https://huggingface.co/mjbommar/ogbert-110m-base) instead.
153
+
154
+ ## Citation
155
+
156
+ If you use this model, please cite the OpenGloss dataset:
157
+
158
+ ```bibtex
159
+ @article{bommarito2025opengloss,
160
+ title={OpenGloss: A Synthetic Encyclopedic Dictionary and Semantic Knowledge Graph},
161
+ author={Bommarito II, Michael J.},
162
+ journal={arXiv preprint arXiv:2511.18622},
163
+ year={2025}
164
+ }
165
+ ```
166
+
167
+ ## License
168
+
169
+ Apache 2.0
config.json ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "mjbommar/ogbert-110m-sentence",
3
+ "architectures": [
4
+ "ModernBertModel"
5
+ ],
6
+ "attention_bias": false,
7
+ "attention_dropout": 0.0,
8
+ "bos_token_id": 50281,
9
+ "classifier_activation": "gelu",
10
+ "classifier_bias": false,
11
+ "classifier_dropout": 0.0,
12
+ "classifier_pooling": "cls",
13
+ "cls_token_id": 50281,
14
+ "decoder_bias": true,
15
+ "deterministic_flash_attn": false,
16
+ "dtype": "float32",
17
+ "embedding_dropout": 0.0,
18
+ "eos_token_id": 50282,
19
+ "global_attn_every_n_layers": 3,
20
+ "hidden_act": "gelu",
21
+ "hidden_activation": "gelu",
22
+ "hidden_size": 768,
23
+ "initializer_cutoff_factor": 2.0,
24
+ "initializer_range": 0.02,
25
+ "intermediate_size": 3072,
26
+ "layer_norm_eps": 1e-05,
27
+ "layer_types": [
28
+ "full_attention",
29
+ "sliding_attention",
30
+ "sliding_attention",
31
+ "full_attention",
32
+ "sliding_attention",
33
+ "sliding_attention",
34
+ "full_attention",
35
+ "sliding_attention",
36
+ "sliding_attention",
37
+ "full_attention",
38
+ "sliding_attention",
39
+ "sliding_attention"
40
+ ],
41
+ "local_attention": 128,
42
+ "max_position_embeddings": 1024,
43
+ "mlp_bias": false,
44
+ "mlp_dropout": 0.0,
45
+ "model_type": "modernbert",
46
+ "norm_bias": false,
47
+ "norm_eps": 1e-05,
48
+ "num_attention_heads": 12,
49
+ "num_hidden_layers": 12,
50
+ "pad_token_id": 2,
51
+ "repad_logits_with_grad": false,
52
+ "rope_parameters": {
53
+ "full_attention": {
54
+ "rope_theta": 160000.0,
55
+ "rope_type": "default"
56
+ },
57
+ "sliding_attention": {
58
+ "rope_theta": 10000.0,
59
+ "rope_type": "default"
60
+ }
61
+ },
62
+ "sep_token_id": 50282,
63
+ "sparse_pred_ignore_index": -100,
64
+ "sparse_prediction": false,
65
+ "torch_dtype": "float32",
66
+ "transformers_version": "4.47.0",
67
+ "vocab_size": 32768
68
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1820508556341b6e8a9f5bb17f174cd1bbc3ff3847d33e4fee547bae42714d7c
3
+ size 556226256
modules.json ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "idx": 0,
4
+ "name": "0",
5
+ "path": "",
6
+ "type": "sentence_transformers.models.Transformer"
7
+ },
8
+ {
9
+ "idx": 1,
10
+ "name": "1",
11
+ "path": "1_Pooling",
12
+ "type": "sentence_transformers.models.Pooling"
13
+ },
14
+ {
15
+ "idx": 2,
16
+ "name": "2",
17
+ "path": "2_Normalize",
18
+ "type": "sentence_transformers.models.Normalize"
19
+ }
20
+ ]
special_tokens_map.json ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": "<|start|>",
3
+ "cls_token": "<|cls|>",
4
+ "eos_token": "<|end|>",
5
+ "mask_token": "<|mask|>",
6
+ "pad_token": "<|pad|>",
7
+ "sep_token": "<|sep|>",
8
+ "unk_token": "<|unk|>"
9
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "additional_special_tokens": null,
3
+ "backend": "tokenizers",
4
+ "bos_token": "<|start|>",
5
+ "clean_up_tokenization_spaces": false,
6
+ "cls_token": "<|cls|>",
7
+ "eos_token": "<|end|>",
8
+ "extra_special_tokens": [],
9
+ "is_local": false,
10
+ "mask_token": "<|mask|>",
11
+ "model_max_length": 1024,
12
+ "model_type": "modernbert",
13
+ "pad_token": "<|pad|>",
14
+ "sep_token": "<|sep|>",
15
+ "tokenizer_class": "TokenizersBackend",
16
+ "unk_token": "<|unk|>",
17
+ "vocab_size": 32767
18
+ }