Fill-Mask
Transformers
Safetensors
English
ultrabert
encoder
masked-language-modeling
long-context
custom_code
Instructions to use dmis-lab/UltraBERT-150M with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use dmis-lab/UltraBERT-150M with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("fill-mask", model="dmis-lab/UltraBERT-150M", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForMaskedLM tokenizer = AutoTokenizer.from_pretrained("dmis-lab/UltraBERT-150M", trust_remote_code=True) model = AutoModelForMaskedLM.from_pretrained("dmis-lab/UltraBERT-150M", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Update README.md
Browse files
README.md
CHANGED
|
@@ -153,9 +153,15 @@ UltraBERT is a pre-norm Transformer encoder with RoPE, SwiGLU feed-forward layer
|
|
| 153 |
|
| 154 |
- `model.safetensors` in float32 (the pre-training master weights), with `config.dtype: float32`.
|
| 155 |
- The encoder and the MLM head.
|
| 156 |
-
- The MLM head is the one trained on the 5% masked sequences (the distilled head); the 50% head is not included.
|
| 157 |
- Remote code for `transformers` 5.x with `UltrabertModel`, `UltrabertForMaskedLM`, `UltrabertForSequenceClassification`, `UltrabertForQuestionAnswering` and `UltrabertForTokenClassification`.
|
|
|
|
| 158 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 159 |
|
| 160 |
## ⚙️ Pre-Training
|
| 161 |
|
|
|
|
| 153 |
|
| 154 |
- `model.safetensors` in float32 (the pre-training master weights), with `config.dtype: float32`.
|
| 155 |
- The encoder and the MLM head.
|
|
|
|
| 156 |
- Remote code for `transformers` 5.x with `UltrabertModel`, `UltrabertForMaskedLM`, `UltrabertForSequenceClassification`, `UltrabertForQuestionAnswering` and `UltrabertForTokenClassification`.
|
| 157 |
+
- The MLM head is the one trained on the 5% masked sequences (the distilled head); the 50% head is a separate file, [`head_50%.pth`](./head_50%25.pth). To swap it into `UltrabertForMaskedLM`:
|
| 158 |
|
| 159 |
+
```python
|
| 160 |
+
from huggingface_hub import hf_hub_download
|
| 161 |
+
|
| 162 |
+
head_path = hf_hub_download("dmis-lab/UltraBERT-150M", "head_50%.pth")
|
| 163 |
+
model.load_state_dict(torch.load(head_path), strict=False)
|
| 164 |
+
```
|
| 165 |
|
| 166 |
## ⚙️ Pre-Training
|
| 167 |
|