Update README.md
Browse files
README.md
CHANGED
@@ -11,6 +11,30 @@ tags: []
|
|
11 |
|
12 |
## Model Details
|
13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
### Model Description
|
15 |
|
16 |
<!-- Provide a longer summary of what this model is. -->
|
|
|
11 |
|
12 |
## Model Details
|
13 |
|
14 |
+
### Code to create models
|
15 |
+
```python
|
16 |
+
from transformers import ModernBertConfig, ModernBertForSequenceClassification, AutoTokenizer
|
17 |
+
|
18 |
+
model_id = "answerdotai/ModernBERT-base"
|
19 |
+
config = ModernBertConfig.from_pretrained(
|
20 |
+
model_id,
|
21 |
+
hidden_size=32,
|
22 |
+
intermediate_size=64,
|
23 |
+
num_hidden_layers=4,
|
24 |
+
num_attention_heads=2,
|
25 |
+
global_attn_every_n_layers=3,
|
26 |
+
)
|
27 |
+
|
28 |
+
# Create model and randomize all weights
|
29 |
+
model = ModernBertForSequenceClassification(config)
|
30 |
+
|
31 |
+
torch.manual_seed(0) # Set for reproducibility
|
32 |
+
for name, param in model.named_parameters():
|
33 |
+
param.data = torch.randn_like(param)
|
34 |
+
|
35 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
36 |
+
```
|
37 |
+
|
38 |
### Model Description
|
39 |
|
40 |
<!-- Provide a longer summary of what this model is. -->
|