Xenova HF staff commited on
Commit
54f78a5
·
verified ·
1 Parent(s): 267e43c

Update README.md

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