tomaarsen HF Staff commited on
Commit
346bb64
·
verified ·
1 Parent(s): 777570d

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +47 -0
README.md CHANGED
@@ -11,6 +11,53 @@ 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
+
16
+ ```python
17
+ import torch
18
+
19
+ from transformers import (
20
+ AutoTokenizer,
21
+ EuroBertConfig,
22
+ EuroBertForMaskedLM,
23
+ EuroBertForSequenceClassification,
24
+ EuroBertForTokenClassification,
25
+ EuroBertModel,
26
+ )
27
+
28
+
29
+ classes = [
30
+ EuroBertForTokenClassification,
31
+ EuroBertModel,
32
+ EuroBertForMaskedLM,
33
+ EuroBertForSequenceClassification,
34
+ ]
35
+
36
+ for klass in classes:
37
+ model_id = "EuroBERT/EuroBERT-210m"
38
+ config = EuroBertConfig.from_pretrained(
39
+ model_id,
40
+ hidden_size=32,
41
+ intermediate_size=64,
42
+ num_hidden_layers=4,
43
+ num_attention_heads=2,
44
+ num_key_value_heads=2,
45
+ )
46
+ del config.auto_map # Avoid custom code loading
47
+
48
+ # Create model and randomize all weights
49
+ model = klass(config)
50
+
51
+ torch.manual_seed(0) # Set for reproducibility
52
+ for name, param in model.named_parameters():
53
+ param.data = torch.randn_like(param)
54
+
55
+ tokenizer = AutoTokenizer.from_pretrained(model_id, config=config)
56
+
57
+ model.push_to_hub(f"tiny-random-{klass.__name__}")
58
+ tokenizer.push_to_hub(f"tiny-random-{klass.__name__}")
59
+ ```
60
+
61
  ### Model Description
62
 
63
  <!-- Provide a longer summary of what this model is. -->