Nikolay Banar commited on
Commit
271a309
·
1 Parent(s): b9dd296

README.md updated

Browse files
Files changed (1) hide show
  1. README.md +117 -9
README.md CHANGED
@@ -6,21 +6,129 @@ base_model:
6
  - intfloat/multilingual-e5-base
7
  pipeline_tag: sentence-similarity
8
  ---
9
- # Vocabulary Trimmed [intfloat/multilingual-e5-base](https://huggingface.co/intfloat/multilingual-e5-base): `nicolaebanari/me5-base-trimmed-nl-test`
10
  This model is a trimmed version of [intfloat/multilingual-e5-base](https://huggingface.co/intfloat/multilingual-e5-base) by [`vocabtrimmer`](https://github.com/asahi417/lm-vocab-trimmer), a tool for trimming vocabulary of language models to compress the model size.
11
  Following table shows a summary of the trimming process.
12
 
13
- | | intfloat/multilingual-e5-base | nicolaebanari/me5-base-trimmed-nl-test |
14
- |:---------------------------|:--------------------------------|:-----------------------------------------|
15
- | parameter_size_full | 278,043,648 | 124,443,648 |
16
- | parameter_size_embedding | 192,001,536 | 38,401,536 |
17
- | vocab_size | 250,002 | 50,002 |
18
- | compression_rate_full | 100.0 | 44.76 |
19
- | compression_rate_embedding | 100.0 | 20.0 |
20
 
21
 
22
  Following table shows the parameter used to trim vocabulary.
23
 
24
  | language | dataset | dataset_column | dataset_name | dataset_split | target_vocab_size | min_frequency |
25
  |:-----------|:-----------|:-----------------|:---------------|:----------------|--------------------:|----------------:|
26
- | nl | allenai/c4 | text | nl | validation | 50000 | 2 |
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  - intfloat/multilingual-e5-base
7
  pipeline_tag: sentence-similarity
8
  ---
9
+ # E5-base-trm
10
  This model is a trimmed version of [intfloat/multilingual-e5-base](https://huggingface.co/intfloat/multilingual-e5-base) by [`vocabtrimmer`](https://github.com/asahi417/lm-vocab-trimmer), a tool for trimming vocabulary of language models to compress the model size.
11
  Following table shows a summary of the trimming process.
12
 
13
+ | | intfloat/multilingual-e5-base | clips/e5-base-trm |
14
+ |:---------------------------|:------------------------------|:------------------|
15
+ | parameter_size_full | 278,043,648 | 124,443,648 |
16
+ | parameter_size_embedding | 192,001,536 | 38,401,536 |
17
+ | vocab_size | 250,002 | 50,002 |
18
+ | compression_rate_full | 100.0 | 44.76 |
19
+ | compression_rate_embedding | 100.0 | 20.0 |
20
 
21
 
22
  Following table shows the parameter used to trim vocabulary.
23
 
24
  | language | dataset | dataset_column | dataset_name | dataset_split | target_vocab_size | min_frequency |
25
  |:-----------|:-----------|:-----------------|:---------------|:----------------|--------------------:|----------------:|
26
+ | nl | allenai/c4 | text | nl | validation | 50000 | 2 |
27
+
28
+ ## Usage
29
+
30
+ Below is an example to encode queries and passages from the MS-MARCO passage ranking dataset.
31
+
32
+ ```python
33
+ import torch.nn.functional as F
34
+
35
+ from torch import Tensor
36
+ from transformers import AutoTokenizer, AutoModel
37
+
38
+
39
+ def average_pool(last_hidden_states: Tensor,
40
+ attention_mask: Tensor) -> Tensor:
41
+ last_hidden = last_hidden_states.masked_fill(~attention_mask[..., None].bool(), 0.0)
42
+ return last_hidden.sum(dim=1) / attention_mask.sum(dim=1)[..., None]
43
+
44
+
45
+ # Each input text should start with "query: " or "passage: ".
46
+ # For tasks other than retrieval, you can simply use the "query: " prefix.
47
+ input_texts = [
48
+ 'query: hoeveel eiwitten moet een vrouw eten',
49
+ 'query: top definieer',
50
+ "passage: Als algemene richtlijn geldt dat de gemiddelde eiwitbehoefte voor vrouwen van 19 tot 70 jaar volgens de CDC 46 gram per dag bedraagt. Maar, zoals je in deze tabel kunt zien, moet je dit verhogen als je zwanger bent of traint voor een marathon. Bekijk de onderstaande tabel om te zien hoeveel eiwitten je dagelijks zou moeten eten.",
51
+ "passage: Definitie van top voor leerlingen Engels. : 1 het hoogste punt van een berg : de top van een berg. : 2 het hoogste niveau. : 3 een bijeenkomst of reeks bijeenkomsten tussen de leiders van twee of meer regeringen."
52
+ ]
53
+
54
+ tokenizer = AutoTokenizer.from_pretrained('clips/e5-base-trm')
55
+ model = AutoModel.from_pretrained('clips/e5-base-trm')
56
+
57
+ # Tokenize the input texts
58
+ batch_dict = tokenizer(input_texts, max_length=512, padding=True, truncation=True, return_tensors='pt')
59
+
60
+ outputs = model(**batch_dict)
61
+ embeddings = average_pool(outputs.last_hidden_state, batch_dict['attention_mask'])
62
+
63
+ # normalize embeddings
64
+ embeddings = F.normalize(embeddings, p=2, dim=1)
65
+ scores = (embeddings[:2] @ embeddings[2:].T) * 100
66
+ print(scores.tolist())
67
+ ```
68
+
69
+ Below is an example for usage with sentence_transformers.
70
+ ```python
71
+ from sentence_transformers import SentenceTransformer
72
+ model = SentenceTransformer('clips/e5-base-trm')
73
+ input_texts = [
74
+ 'query: hoeveel eiwitten moet een vrouw eten',
75
+ 'query: top definieer',
76
+ "passage: Als algemene richtlijn geldt dat de gemiddelde eiwitbehoefte voor vrouwen van 19 tot 70 jaar volgens de CDC 46 gram per dag bedraagt. Maar, zoals je in deze tabel kunt zien, moet je dit verhogen als je zwanger bent of traint voor een marathon. Bekijk de onderstaande tabel om te zien hoeveel eiwitten je dagelijks zou moeten eten.",
77
+ "passage: Definitie van top voor leerlingen Engels. : 1 het hoogste punt van een berg : de top van een berg. : 2 het hoogste niveau. : 3 een bijeenkomst of reeks bijeenkomsten tussen de leiders van twee of meer regeringen."
78
+ ]
79
+ embeddings = model.encode(input_texts, normalize_embeddings=True)
80
+ ```
81
+ ## Benchmark Evaluation
82
+ Results on MTEB-NL (models introduced in [our paper](https://arxiv.org/abs/2509.12340) and the best model per size category are highlighted in bold):
83
+
84
+ | Model | Prm | Cls | MLCls | PCls | Rrnk | Rtr | Clust | STS | AvgD | AvgT |
85
+ |---------------------------------------|------|----------|----------|----------|----------|----------|----------|----------|----------|----------|
86
+ | **Num. Datasets (→)** | | 12 | 3 | 2 | 1 | 12 | 8 | 2 | 40 | |
87
+ | **Supervised (small, <100M)** | | | | | | | | | | |
88
+ | **e5-small-v2-t2t** | 33M | 53.7 | 38.5 | 74.5 | 85.9 | 45.0 | 24.1 | 74.3 | 46.9 | 56.6 |
89
+ | **e5-small-v2-t2t-nl** | 33M | 55.3 | 40.9 | 74.9 | 86.0 | 49.9 | 28.0 | 74.1 | 49.8 | 58.4 |
90
+ | **e5-small-trm** | 41M | 56.3 | 43.5 | **76.5** | **87.3** | 53.1 | 28.2 | 74.2 | 51.4 | 59.9 |
91
+ | **e5-small-trm-nl** | 41M | **58.2** | **44.7** | 76.0 | 87.1 | **56.0** | **32.2** | **74.6** | **53.8** | **61.3** |
92
+ | **Supervised (base, <305M)** | | | | | | | | | | |
93
+ | granite-embedding-107m-multilingual | 107M | 53.9 | 41.8 | 70.1 | 84.7 | 50.2 | 29.8 | 68.4 | 49.4 | 57.0 |
94
+ | **e5-base-v2-t2t** | 109M | 54.4 | 40.3 | 73.3 | 85.6 | 46.2 | 25.5 | 73.2 | 47.8 | 56.9 |
95
+ | **e5-base-v2-t2t-nl** | 109M | 53.9 | 41.5 | 72.5 | 84.0 | 46.4 | 26.9 | 69.3 | 47.8 | 56.3 |
96
+ | multilingual-e5-small | 118M | 56.3 | 43.5 | 76.5 | 87.1 | 53.1 | 28.2 | 74.2 | 51.4 | 59.8 |
97
+ | paraphrase-multilingual-MiniLM-L12-v2 | 118M | 55.0 | 38.1 | 78.2 | 80.6 | 37.7 | 29.6 | 76.3 | 46.3 | 56.5 |
98
+ | **RobBERT-2023-base-ft** | 124M | 58.1 | 44.6 | 72.7 | 84.7 | 51.6 | 32.9 | 68.5 | 52.0 | 59.0 |
99
+ | **e5-base-trm** | 124M | 58.1 | 44.4 | 76.7 | 88.3 | 55.8 | 28.1 | 74.9 | 52.9 | 60.9 |
100
+ | **e5-base-trm-nl** | 124M | **59.6** | **45.9** | 78.4 | 87.5 | 56.5 | **34.3** | 75.8 | **55.0** | **62.6** |
101
+ | potion-multilingual-128M | 128M | 51.8 | 40.0 | 60.4 | 80.3 | 35.7 | 26.1 | 62.0 | 42.6 | 50.9 |
102
+ | multilingual-e5-base | 278M | 58.2 | 44.4 | 76.7 | **88.4** | 55.8 | 27.7 | 74.9 | 52.8 | 60.9 |
103
+ | granite-embedding-278m-multilingual | 278M | 54.6 | 41.8 | 71.0 | 85.6 | 52.4 | 30.3 | 68.9 | 50.5 | 58.0 |
104
+ | paraphrase-multilingual-mpnet-base-v2 | 278M | 58.1 | 40.5 | **81.9** | 82.3 | 41.4 | 30.8 | 79.3 | 49.2 | 59.2 |
105
+ | Arctic-embed-m-v2.0 | 305M | 54.4 | 42.6 | 66.6 | 86.2 | 51.8 | 26.5 | 64.9 | 49.1 | 56.1 |
106
+ | gte-multilingual-base | 305M | 59.1 | 37.7 | 77.8 | 82.3 | **56.8** | 31.3 | **78.6** | 53.8 | 60.5 |
107
+ | **Supervised (large, >305M)** | | | | | | | | | | |
108
+ | **e5-large-v2-t2t** | 335M | 55.7 | 41.4 | 75.7 | 86.6 | 49.9 | 25.5 | 74.0 | 49.5 | 58.4 |
109
+ | **e5-large-v2-t2t-nl** | 335M | 57.3 | 42.4 | 76.9 | 86.9 | 50.8 | 27.7 | 74.1 | 51.7 | 59.4 |
110
+ | **RobBERT-2023-large-ft** | 355M | 59.3 | 45.2 | 68.7 | 82.3 | 48.3 | 31.6 | 70.6 | 51.0 | 58.0 |
111
+ | **e5-large-trm** | 355M | 60.2 | 45.4 | 80.3 | 90.3 | 59.0 | 28.7 | 78.8 | 55.1 | 63.3 |
112
+ | **e5-large-trm-nl** | 355M | **62.2** | **48.0** | **81.4** | 87.2 | 58.2 | 35.6 | 78.2 | **57.0** | **64.4** |
113
+ | multilingual-e5-large | 560M | 60.2 | 45.4 | 80.3 | **90.3** | 59.1 | 29.5 | 78.8 | 55.3 | 63.4 |
114
+ | Arctic-embed-l-v2.0 | 568M | 59.3 | 45.2 | 74.2 | 88.2 | 59.0 | 29.8 | 71.7 | 54.3 | 61.1 |
115
+ | bge-m3 | 568M | 60.7 | 44.2 | 78.3 | 88.7 | **60.0** | 29.2 | 78.1 | 55.4 | 63.1 |
116
+ | jina-embeddings-v3 | 572M | 61.7 | 38.9 | 76.8 | 78.5 | 59.1 | **38.9** | **84.8** | **57.0** | 62.7 |
117
+
118
+
119
+
120
+ ### Citation Information
121
+
122
+ If you find our paper, benchmark or models helpful, please consider cite as follows:
123
+ ```latex
124
+ @misc{banar2025mtebnle5nlembeddingbenchmark,
125
+ title={MTEB-NL and E5-NL: Embedding Benchmark and Models for Dutch},
126
+ author={Nikolay Banar and Ehsan Lotfi and Jens Van Nooten and Cristina Arhiliuc and Marija Kliocaite and Walter Daelemans},
127
+ year={2025},
128
+ eprint={2509.12340},
129
+ archivePrefix={arXiv},
130
+ primaryClass={cs.CL},
131
+ url={https://arxiv.org/abs/2509.12340},
132
+ }
133
+ ```
134
+ [//]: # (https://arxiv.org/abs/2509.12340)