File size: 2,752 Bytes
cfd10de
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1049e37
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
---

pipeline_tag: sentence-similarity
language: es
license: mit
tags:
- trimmed
library_name: sentence-transformers
base_model: intfloat/multilingual-e5-large
base_model_relation: quantized
datasets:
- lbourdois/fineweb-2-trimming
---


# multilingual-e5-large-spa-32768
This model is a **39.73% smaller** version of [intfloat/multilingual-e5-large](https://huggingface.co/intfloat/multilingual-e5-large) optimized for **Spanish** language via vocabulary size reduction using the [trimming](https://huggingface.co/blog/lbourdois/introduction-to-trimming) method.  
This trimmed model should perform similarly to the original model with only 32,768 tokens and a much smaller memory footprint. However, it may not perform well for other languages as tokens not commonly used in the selected languages were removed from the vocabulary.

## Model Statistics
| Metric | Original | Trimmed | Reduction |
|--------|----------|---------|-----------|
| **Vocabulary size** | 250,037 tokens | 32,768 tokens | **86.89%** |
| **Model size** | 559,890,432 params | 337,442,816 params | **39.73%** |

![image](https://raw.githubusercontent.com/lbourdois/blog/refs/heads/master/assets/images/Trimming/me5-large-32768.png)

## Mining Dataset Statistics
- **Number of texts used for mining**: 200,000 texts  
- **Dataset**: [lbourdois/fineweb-2-trimming](https://huggingface.co/datasets/lbourdois/fineweb-2-trimming)

## Usage
```python

from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub

model = SentenceTransformer("alphaedge-ai/multilingual-e5-large-spa-32768")

# Run inference with queries and documents

query = "My query in Spanish"

documents = [

    "Chunk in Spanish",

    "Chunk in Spanish",

    "Chunk in Spanish",

]

query_embeddings = model.encode_query(query)

document_embeddings = model.encode_document(documents)

print(query_embeddings.shape, document_embeddings.shape)

# Compute similarities to determine a ranking

similarities = model.similarity(query_embeddings, document_embeddings)

print(similarities)

```

## Citations

#### Multilingual E5
```

@article{wang2024multilingual,

  title={Multilingual E5 Text Embeddings: A Technical Report},

  author={Wang, Liang and Yang, Nan and Huang, Xiaolong and Yang, Linjun and Majumder, Rangan and Wei, Furu},

  journal={arXiv preprint arXiv:2402.05672},

  year={2024}

}

```

#### Trimming blog post
```

@misc{hf_blogpost_trimming,

      title={Introduction to Trimming}, 

      author={Loïck BOURDOIS and Tom AARSEN and Bram VANROY and Christopher AKIKI and Woojun JUNG and Manuel ROMERO and Prithiv SAKTHI},

      year={2026},

      url={https://huggingface.co/blog/lbourdois/introduction-to-trimming}, 

}

```