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