hgissbkh commited on
Commit
5303e1d
·
verified ·
1 Parent(s): fede021

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +38 -18
README.md CHANGED
@@ -4,30 +4,34 @@ library_name: transformers
4
  license: apache-2.0
5
  ---
6
 
7
- # Encoder Model from "Should We Still Pretrain Encoders with Masked Language Modeling?"
8
 
9
- This repository contains an encoder model, part of the research presented in the paper **"[Should We Still Pretrain Encoders with Masked Language Modeling?](https://huggingface.co/papers/2507.00994)"**.
10
-
11
- This paper investigates the effectiveness of Masked Language Modeling (MLM) versus Causal Language Modeling (CLM) for pretraining text encoders to achieve high-quality text representations. It demonstrates that while MLM generally yields better performance, CLM-trained models are more data-efficient. The research further proposes a biphasic training strategy that sequentially applies CLM and then MLM, achieving optimal performance under a fixed computational budget.
12
 
13
  * **Paper:** [Should We Still Pretrain Encoders with Masked Language Modeling?](https://huggingface.co/papers/2507.00994)
14
- * **Project Page:** [https://hf.co/MLMvsCLM](https://hf.co/MLMvsCLM)
15
- * **Code:** [https://github.com/Nicolas-BZRD/EuroBERT](https://github.com/Nicolas-BZRD/EuroBERT)
16
-
17
- ## Model Description
18
-
19
- This model is an encoder designed to produce robust text representations for a wide range of natural language processing tasks. It is trained as part of an extensive study on encoder pretraining objectives, focusing on the trade-offs and benefits of MLM and CLM, and the effectiveness of a biphasic training approach. The model architecture is an `SLModel` as identified in the `config.json`.
 
 
 
 
 
 
 
 
 
 
 
 
 
20
 
21
  ## Usage
22
 
23
- You can use this model for feature extraction with the Hugging Face `transformers` library. Since this model might use a custom architecture (`SLModel`), you may need to install the associated `EuroBERT` package and use `trust_remote_code=True` when loading the model.
24
-
25
- First, install the `EuroBERT` package:
26
- ```bash
27
- pip install git+https://github.com/Nicolas-BZRD/EuroBERT.git
28
- ```
29
-
30
- Then, you can load and use the model as follows:
31
 
32
  ```python
33
  from transformers import AutoTokenizer, AutoModel
@@ -62,4 +66,20 @@ sum_embeddings = torch.sum(last_hidden_state * input_mask_expanded, 1)
62
  sum_mask = torch.clamp(input_mask_expanded.sum(1), min=1e-9)
63
  mean_pooled_embedding = sum_embeddings / sum_mask
64
  print(f"Shape of mean pooled embedding: {mean_pooled_embedding.shape}")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
  ```
 
4
  license: apache-2.0
5
  ---
6
 
7
+ # Overview
8
 
9
+ This repository contains an encoder model, part of the research presented in the paper *Should We Still Pretrain Encoders with Masked Language Modeling?* (Gisserot-Boukhlef, et al.).
 
 
10
 
11
  * **Paper:** [Should We Still Pretrain Encoders with Masked Language Modeling?](https://huggingface.co/papers/2507.00994)
12
+ * **Blog post:** [Link](https://huggingface.co/blog/Nicolas-BZRD/encoders-should-not-be-only-pre-trained-with-mlm)
13
+ * **Project page:** [https://hf.co/MLMvsCLM](https://hf.co/MLMvsCLM)
14
+
15
+ ## Model Naming
16
+
17
+ Model identifiers follow a consistent format that encodes key training details:
18
+
19
+ * **Single-stage models**:
20
+ `[model size]-[objective]-[number of steps]`.
21
+ Example: `610m-clm-42k` denotes a 610M-parameter model trained with CLM for 42,000 steps.
22
+ * **Two-stage models**:
23
+ `[model size]-[objective #1]-[steps #1]-[objective #2]-[total steps]`.
24
+ Example: `610m-clm-10k-mlm40-42k` indicates a 610M model trained first with CLM for 10k steps, then continued with MLM (40% masking ratio) for 32k more steps, totaling 42k steps.
25
+ * **Continued pretraining from decayed checkpoints**:
26
+ These use the dec prefix on the first training stage.
27
+ Example: `610m-clm-dec42k-mlm40-64k refers` to a 610M model pretrained with CLM for 42k steps (with weight decay), then further trained with MLM (40% masking) for 22k additional steps, totaling 64k.
28
+ * **Intermediate checkpoints**:
29
+ To refer to a specific training step before the final checkpoint, append the step number at the end.
30
+ Example: `610m-mlm40-42k-1000` corresponds to step 1,000 during the MLM training phase of a 610M model trained for 42k steps.
31
 
32
  ## Usage
33
 
34
+ You can use this model for feature extraction with the Hugging Face `transformers` library.
 
 
 
 
 
 
 
35
 
36
  ```python
37
  from transformers import AutoTokenizer, AutoModel
 
66
  sum_mask = torch.clamp(input_mask_expanded.sum(1), min=1e-9)
67
  mean_pooled_embedding = sum_embeddings / sum_mask
68
  print(f"Shape of mean pooled embedding: {mean_pooled_embedding.shape}")
69
+ ```
70
+
71
+ ## Citation
72
+
73
+ If you found this model useful, please consider citing our paper:
74
+
75
+ ```bibtex
76
+ @misc{gisserotboukhlef2025pretrainencodersmaskedlanguage,
77
+ title={Should We Still Pretrain Encoders with Masked Language Modeling?},
78
+ author={Hippolyte Gisserot-Boukhlef and Nicolas Boizard and Manuel Faysse and Duarte M. Alves and Emmanuel Malherbe and André F. T. Martins and Céline Hudelot and Pierre Colombo},
79
+ year={2025},
80
+ eprint={2507.00994},
81
+ archivePrefix={arXiv},
82
+ primaryClass={cs.CL},
83
+ url={https://arxiv.org/abs/2507.00994},
84
+ }
85
  ```