Sentence Similarity
sentence-transformers
Safetensors
Turkish
xlm-roberta
feature-extraction
embeddings
turkish
türkçe
e5
retrieval
semantic-search
mteb
tr-mteb
Eval Results (legacy)
text-embeddings-inference
Instructions to use thealper2/intfloat-multilingual-e5-base-tr-nli with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use thealper2/intfloat-multilingual-e5-base-tr-nli with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("thealper2/intfloat-multilingual-e5-base-tr-nli") sentences = [ "The weather is lovely today.", "It's so sunny outside!", "He drove to the stadium." ] embeddings = model.encode(sentences) similarities = model.similarity(embeddings, embeddings) print(similarities.shape) # [3, 3] - Notebooks
- Google Colab
- Kaggle
Upload folder using huggingface_hub
Browse files- .gitattributes +1 -0
- 1_Pooling/config.json +10 -0
- README.md +399 -0
- config.json +30 -0
- config_sentence_transformers.json +14 -0
- model.safetensors +3 -0
- modules.json +20 -0
- sentence_bert_config.json +4 -0
- tokenizer.json +3 -0
- tokenizer_config.json +15 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
tokenizer.json filter=lfs diff=lfs merge=lfs -text
|
1_Pooling/config.json
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"word_embedding_dimension": 768,
|
| 3 |
+
"pooling_mode_cls_token": false,
|
| 4 |
+
"pooling_mode_mean_tokens": true,
|
| 5 |
+
"pooling_mode_max_tokens": false,
|
| 6 |
+
"pooling_mode_mean_sqrt_len_tokens": false,
|
| 7 |
+
"pooling_mode_weightedmean_tokens": false,
|
| 8 |
+
"pooling_mode_lasttoken": false,
|
| 9 |
+
"include_prompt": true
|
| 10 |
+
}
|
README.md
ADDED
|
@@ -0,0 +1,399 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language:
|
| 3 |
+
- tr
|
| 4 |
+
license: cc-by-sa-4.0
|
| 5 |
+
library_name: sentence-transformers
|
| 6 |
+
pipeline_tag: sentence-similarity
|
| 7 |
+
tags:
|
| 8 |
+
- sentence-transformers
|
| 9 |
+
- sentence-similarity
|
| 10 |
+
- feature-extraction
|
| 11 |
+
- embeddings
|
| 12 |
+
- turkish
|
| 13 |
+
- türkçe
|
| 14 |
+
- e5
|
| 15 |
+
- retrieval
|
| 16 |
+
- semantic-search
|
| 17 |
+
- mteb
|
| 18 |
+
- tr-mteb
|
| 19 |
+
base_model: intfloat/multilingual-e5-base
|
| 20 |
+
datasets:
|
| 21 |
+
- mertcobanov/all-nli-triplets-turkish
|
| 22 |
+
- emrecan/stsb-mt-turkish
|
| 23 |
+
metrics:
|
| 24 |
+
- spearmanr
|
| 25 |
+
- ndcg
|
| 26 |
+
- accuracy
|
| 27 |
+
- v_measure
|
| 28 |
+
model-index:
|
| 29 |
+
- name: e5-tr-nli
|
| 30 |
+
results:
|
| 31 |
+
- task:
|
| 32 |
+
type: semantic-textual-similarity
|
| 33 |
+
name: Semantic Textual Similarity
|
| 34 |
+
dataset:
|
| 35 |
+
name: STSb-TR (test)
|
| 36 |
+
type: trmteb/stsb-tr
|
| 37 |
+
metrics:
|
| 38 |
+
- type: spearman_cosine
|
| 39 |
+
value: 0.7907
|
| 40 |
+
- task:
|
| 41 |
+
type: retrieval
|
| 42 |
+
name: Retrieval
|
| 43 |
+
dataset:
|
| 44 |
+
name: TQuad
|
| 45 |
+
type: trmteb/tquad
|
| 46 |
+
metrics:
|
| 47 |
+
- type: ndcg_at_10
|
| 48 |
+
value: 0.8222
|
| 49 |
+
- task:
|
| 50 |
+
type: retrieval
|
| 51 |
+
name: Retrieval
|
| 52 |
+
dataset:
|
| 53 |
+
name: Quora-TR
|
| 54 |
+
type: trmteb/quora-tr
|
| 55 |
+
metrics:
|
| 56 |
+
- type: ndcg_at_10
|
| 57 |
+
value: 0.7323
|
| 58 |
+
- task:
|
| 59 |
+
type: retrieval
|
| 60 |
+
name: Retrieval
|
| 61 |
+
dataset:
|
| 62 |
+
name: MS MARCO-TR
|
| 63 |
+
type: trmteb/msmarco-tr
|
| 64 |
+
metrics:
|
| 65 |
+
- type: ndcg_at_10
|
| 66 |
+
value: 0.2734
|
| 67 |
+
- task:
|
| 68 |
+
type: classification
|
| 69 |
+
name: Classification
|
| 70 |
+
dataset:
|
| 71 |
+
name: News-Cat
|
| 72 |
+
type: trmteb/news-cat
|
| 73 |
+
metrics:
|
| 74 |
+
- type: accuracy
|
| 75 |
+
value: 0.9600
|
| 76 |
+
---
|
| 77 |
+
|
| 78 |
+
# e5-tr-nli — Turkish Sentence Embedding Model (Bi-Encoder)
|
| 79 |
+
|
| 80 |
+
A **Turkish sentence-embedding (bi-encoder) model** for **retrieval and semantic
|
| 81 |
+
search**, fine-tuned from [`intfloat/multilingual-e5-base`](https://huggingface.co/intfloat/multilingual-e5-base)
|
| 82 |
+
with contrastive learning (`MultipleNegativesRankingLoss`) on Turkish NLI triplets.
|
| 83 |
+
|
| 84 |
+
> This is **NOT a reranker (cross-encoder)**. It maps a single sentence to a dense
|
| 85 |
+
> vector; relevance is computed as the cosine similarity between two independently
|
| 86 |
+
> produced vectors — suitable for approximate nearest-neighbour search, RAG
|
| 87 |
+
> retrieval, clustering, deduplication and semantic similarity.
|
| 88 |
+
|
| 89 |
+
- **Embedding dimension:** 768
|
| 90 |
+
- **Max sequence length:** 256 tokens (trained); backbone supports 512
|
| 91 |
+
- **Pooling:** mean pooling
|
| 92 |
+
- **Similarity function:** cosine
|
| 93 |
+
- **Parameters:** ~278M (XLM-RoBERTa-base backbone)
|
| 94 |
+
- **Prefix convention:** e5-style `query:` / `passage:` (see [Usage](#usage) — **required**)
|
| 95 |
+
|
| 96 |
+
---
|
| 97 |
+
|
| 98 |
+
## Table of Contents
|
| 99 |
+
1. [Intended Use](#intended-use)
|
| 100 |
+
2. [Usage](#usage)
|
| 101 |
+
3. [Training Data](#training-data)
|
| 102 |
+
4. [Training Procedure](#training-procedure)
|
| 103 |
+
5. [Evaluation](#evaluation)
|
| 104 |
+
6. [TR-MTEB Results](#tr-mteb-results-full)
|
| 105 |
+
7. [Limitations & Biases](#limitations--biases)
|
| 106 |
+
8. [Compute & Environmental Impact](#compute--environmental-impact)
|
| 107 |
+
9. [Licensing](#licensing)
|
| 108 |
+
10. [Citation](#citation)
|
| 109 |
+
11. [Reproduction](#reproduction)
|
| 110 |
+
|
| 111 |
+
---
|
| 112 |
+
|
| 113 |
+
## Intended Use
|
| 114 |
+
|
| 115 |
+
**In scope**
|
| 116 |
+
- Turkish semantic search / passage retrieval (dense retrieval, RAG)
|
| 117 |
+
- Semantic textual similarity, paraphrase & duplicate detection
|
| 118 |
+
- Clustering and topic grouping of Turkish text
|
| 119 |
+
- Feature extraction for downstream Turkish NLP classifiers
|
| 120 |
+
|
| 121 |
+
**Out of scope**
|
| 122 |
+
- Re-ranking with query–document cross-attention (use a cross-encoder instead)
|
| 123 |
+
- Long-document embedding beyond 256 tokens without chunking
|
| 124 |
+
- High-stakes decisions (legal, medical, hiring) without human oversight
|
| 125 |
+
- Non-Turkish text (backbone is multilingual, but this model is tuned for Turkish)
|
| 126 |
+
|
| 127 |
+
---
|
| 128 |
+
|
| 129 |
+
## Usage
|
| 130 |
+
|
| 131 |
+
### ⚠️ e5 prefixes are mandatory
|
| 132 |
+
The model was trained with the e5 asymmetric prefixes and **must** be used with them,
|
| 133 |
+
consistently at training / evaluation / inference:
|
| 134 |
+
|
| 135 |
+
| Role | Prefix |
|
| 136 |
+
|------|--------|
|
| 137 |
+
| Query / anchor / any symmetric-task sentence (STS, classification, clustering) | `query: ` |
|
| 138 |
+
| Passage / document / positive & negative candidates | `passage: ` |
|
| 139 |
+
|
| 140 |
+
Omitting the prefixes degrades quality noticeably.
|
| 141 |
+
|
| 142 |
+
### With `sentence-transformers`
|
| 143 |
+
```python
|
| 144 |
+
from sentence_transformers import SentenceTransformer
|
| 145 |
+
from sentence_transformers.util import cos_sim
|
| 146 |
+
|
| 147 |
+
model = SentenceTransformer("thealper2/multilingual-e5-base-tr-nli")
|
| 148 |
+
|
| 149 |
+
# Asymmetric retrieval: query vs. candidate passages
|
| 150 |
+
query = "query: Türkiye'nin başkenti neresidir?"
|
| 151 |
+
passages = [
|
| 152 |
+
"passage: Ankara, Türkiye'nin başkentidir.",
|
| 153 |
+
"passage: İstanbul Türkiye'nin en kalabalık şehridir.",
|
| 154 |
+
"passage: Muz tropikal bir meyvedir.",
|
| 155 |
+
]
|
| 156 |
+
q = model.encode(query, normalize_embeddings=True)
|
| 157 |
+
p = model.encode(passages, normalize_embeddings=True)
|
| 158 |
+
print(cos_sim(q, p)) # highest score -> the Ankara passage
|
| 159 |
+
```
|
| 160 |
+
|
| 161 |
+
### Semantic similarity (symmetric — use `query:` on both sides)
|
| 162 |
+
```python
|
| 163 |
+
a = model.encode("query: Bugün hava çok güzel.", normalize_embeddings=True)
|
| 164 |
+
b = model.encode("query: Hava bugün oldukça güzel.", normalize_embeddings=True)
|
| 165 |
+
print(float(cos_sim(a, b))) # ~0.9
|
| 166 |
+
```
|
| 167 |
+
|
| 168 |
+
### With 🤗 Transformers (mean pooling)
|
| 169 |
+
```python
|
| 170 |
+
import torch, torch.nn.functional as F
|
| 171 |
+
from transformers import AutoTokenizer, AutoModel
|
| 172 |
+
|
| 173 |
+
tok = AutoTokenizer.from_pretrained("thealper2/multilingual-e5-base-tr-nli")
|
| 174 |
+
mdl = AutoModel.from_pretrained("thealper2/multilingual-e5-base-tr-nli")
|
| 175 |
+
|
| 176 |
+
def encode(texts):
|
| 177 |
+
batch = tok(texts, padding=True, truncation=True, max_length=256, return_tensors="pt")
|
| 178 |
+
with torch.no_grad():
|
| 179 |
+
out = mdl(**batch)
|
| 180 |
+
mask = batch["attention_mask"].unsqueeze(-1).float()
|
| 181 |
+
emb = (out.last_hidden_state * mask).sum(1) / mask.sum(1) # mean pooling
|
| 182 |
+
return F.normalize(emb, p=2, dim=1)
|
| 183 |
+
|
| 184 |
+
emb = encode(["query: örnek cümle", "passage: örnek pasaj"])
|
| 185 |
+
```
|
| 186 |
+
|
| 187 |
+
---
|
| 188 |
+
|
| 189 |
+
## Training Data
|
| 190 |
+
|
| 191 |
+
- **Source:** [`mertcobanov/all-nli-triplets-turkish`](https://huggingface.co/datasets/mertcobanov/all-nli-triplets-turkish)
|
| 192 |
+
— a machine-translated Turkish version of the AllNLI (SNLI + MultiNLI) triplet set.
|
| 193 |
+
- **Format:** `(anchor, positive, negative)` triplets, where the `negative` acts as a
|
| 194 |
+
**hard negative** for the contrastive objective.
|
| 195 |
+
- **Column handling:** **Only the Turkish columns** (`anchor_translated`,
|
| 196 |
+
`positive_translated`, `negative_translated`) were used and renamed to
|
| 197 |
+
`anchor` / `positive` / `negative`. **All English columns were discarded.**
|
| 198 |
+
- **Cleaning:** rows with `None` / empty / whitespace-only fields were filtered out.
|
| 199 |
+
- **Resulting sizes (after filtering):**
|
| 200 |
+
|
| 201 |
+
| Split | Triplets |
|
| 202 |
+
|-------|---------:|
|
| 203 |
+
| train | **277,167** |
|
| 204 |
+
| dev | 6,584 |
|
| 205 |
+
| test | 6,609 |
|
| 206 |
+
|
| 207 |
+
---
|
| 208 |
+
|
| 209 |
+
## Training Procedure
|
| 210 |
+
|
| 211 |
+
### Objective
|
| 212 |
+
- **Loss:** `CachedMultipleNegativesRankingLoss` (MNRL with in-batch + hard negatives;
|
| 213 |
+
the cached variant is used to simulate a large effective batch on limited VRAM).
|
| 214 |
+
- **Batch sampler:** `NO_DUPLICATES` (required for MNRL to avoid trivial in-batch collisions).
|
| 215 |
+
- **In-batch negatives:** every other positive/negative in the batch serves as a negative
|
| 216 |
+
for a given anchor, so larger batches yield a stronger contrastive signal.
|
| 217 |
+
|
| 218 |
+
### Hyperparameter search
|
| 219 |
+
An **Optuna** search (TPE sampler) was run **before** the final training:
|
| 220 |
+
|
| 221 |
+
| Setting | Value |
|
| 222 |
+
|--------|-------|
|
| 223 |
+
| Trials | 10 |
|
| 224 |
+
| Subset | 40,000 random training triplets |
|
| 225 |
+
| Steps / trial | 600 |
|
| 226 |
+
| Search space | `lr ∈ {1e-5, 2e-5, 3e-5}`, `batch ∈ {32, 64, 128}`, `warmup_ratio ∈ {0.0, 0.1}` |
|
| 227 |
+
| Selection metric | `stsb-tr` **dev** `spearman_cosine` |
|
| 228 |
+
| **Best config** | **lr = 2e-5, batch = 32, warmup_ratio = 0.1** (dev spearman = **0.8285**) |
|
| 229 |
+
|
| 230 |
+
### Final training
|
| 231 |
+
|
| 232 |
+
| Setting | Value |
|
| 233 |
+
|--------|-------|
|
| 234 |
+
| Base model | `intfloat/multilingual-e5-base` |
|
| 235 |
+
| Epochs | 1 |
|
| 236 |
+
| Learning rate | 2e-5 |
|
| 237 |
+
| Batch size | 32 (cached MNRL) |
|
| 238 |
+
| Warmup ratio | 0.1 |
|
| 239 |
+
| Max sequence length | 256 |
|
| 240 |
+
| Precision | bf16 |
|
| 241 |
+
| Seed | 42 |
|
| 242 |
+
| Eval strategy | steps, monitoring `eval_stsb-tr-dev_spearman_cosine` |
|
| 243 |
+
| Checkpoint selection | `load_best_model_at_end=True` (best dev spearman) |
|
| 244 |
+
|
| 245 |
+
### Frameworks & hardware
|
| 246 |
+
- `sentence-transformers` 5.2.2, `transformers` 5.0.0, `torch` 2.11.0+cu128,
|
| 247 |
+
`datasets` 4.4.1, Python 3.12
|
| 248 |
+
- 1× NVIDIA GeForce RTX 5050 Laptop GPU (8 GB), CUDA 12.8
|
| 249 |
+
|
| 250 |
+
---
|
| 251 |
+
|
| 252 |
+
## Evaluation
|
| 253 |
+
|
| 254 |
+
### Baseline (base model) vs. Final (this model)
|
| 255 |
+
Measured on the dataset's own test triplets (`TripletEvaluator`, cosine accuracy) and
|
| 256 |
+
on the external Turkish STS set [`emrecan/stsb-mt-turkish`](https://huggingface.co/datasets/emrecan/stsb-mt-turkish)
|
| 257 |
+
(`EmbeddingSimilarityEvaluator`, Spearman; scores normalised 0–5 → 0–1):
|
| 258 |
+
|
| 259 |
+
| Metric | Baseline (e5-base) | Final | Δ |
|
| 260 |
+
|--------|:---:|:---:|:---:|
|
| 261 |
+
| stsb-tr **dev** spearman_cosine | 0.8092 | **0.8312** | +0.0220 |
|
| 262 |
+
| stsb-tr **test** spearman_cosine | 0.7761 | **0.7814** | +0.0053 |
|
| 263 |
+
| nli-tr **test** cosine_accuracy | 0.8968 | **0.9260** | +0.0292 |
|
| 264 |
+
|
| 265 |
+
### Methodology notes for TR-MTEB
|
| 266 |
+
- Datasets pulled **directly from HuggingFace** (`trmteb/*`); metrics computed with a
|
| 267 |
+
standalone script (no `mteb` package dependency), following standard MTEB protocols:
|
| 268 |
+
- **STS** → Spearman of cosine vs. gold; **Retrieval** → nDCG@10 / Recall@10 / MAP@10
|
| 269 |
+
via exact cosine search; **Classification** → logistic regression on frozen
|
| 270 |
+
embeddings (accuracy + macro-F1); **PairClassification** → average precision of cosine;
|
| 271 |
+
**Clustering** → V-measure (MiniBatchKMeans, k = #labels); **BitextMining** → top-1
|
| 272 |
+
nearest-neighbour accuracy.
|
| 273 |
+
- e5 prefixes applied throughout (`query:` for queries/symmetric sides, `passage:` for corpus).
|
| 274 |
+
- Retrieval search runs on-GPU in fp16.
|
| 275 |
+
- `75haber`, `thy_sa`, `irony-tr` have **no train split** in the `trmteb` org, so a seeded
|
| 276 |
+
**70/30 stratified self-split** was used for those classification tasks (marked `note` in
|
| 277 |
+
`trmteb_results.json`). All other classification sets use their official train/test.
|
| 278 |
+
|
| 279 |
+
### Category summary (macro averages)
|
| 280 |
+
|
| 281 |
+
| Task type | # datasets | Avg. main metric |
|
| 282 |
+
|-----------|:---:|:---:|
|
| 283 |
+
| STS (spearman_cosine) | 1 | **0.791** |
|
| 284 |
+
| BitextMining (accuracy) | 1 | **0.975** |
|
| 285 |
+
| Classification (accuracy) | 6 | **0.817** |
|
| 286 |
+
| PairClassification (AP) | 3 | **0.573** |
|
| 287 |
+
| Clustering (v-measure) | 2 | **0.487** |
|
| 288 |
+
| Retrieval (nDCG@10) | 10 | **0.407** |
|
| 289 |
+
| **Overall (mean of category means)** | 23 | **0.675** |
|
| 290 |
+
|
| 291 |
+
---
|
| 292 |
+
|
| 293 |
+
## TR-MTEB Results (full)
|
| 294 |
+
|
| 295 |
+
Evaluated on the [TR-MTEB](https://huggingface.co/trmteb) datasets
|
| 296 |
+
(Baysan & Güngör, *TR-MTEB*, Findings of EMNLP 2025).
|
| 297 |
+
|
| 298 |
+
| Task type | Dataset | Main metric | Value |
|
| 299 |
+
|---|---|---|---:|
|
| 300 |
+
| STS | stsb-tr | spearman_cosine | 0.7907 |
|
| 301 |
+
| BitextMining | wmt16_en_tr | accuracy | 0.9753 |
|
| 302 |
+
| Classification | news-cat | accuracy | 0.9600 |
|
| 303 |
+
| Classification | 75haber ᵃ | accuracy | 0.8696 |
|
| 304 |
+
| Classification | ts_timeline_news_category | accuracy | 0.7250 |
|
| 305 |
+
| Classification | thy_sa ᵃ | accuracy | 0.8386 |
|
| 306 |
+
| Classification | offenseval | accuracy | 0.8427 |
|
| 307 |
+
| Classification | irony-tr ᵃ | accuracy | 0.6667 |
|
| 308 |
+
| PairClassification | snli_tr | ap_cosine | 0.5280 |
|
| 309 |
+
| PairClassification | multinli_tr | ap_cosine | 0.6324 |
|
| 310 |
+
| PairClassification | xnli_tr | ap_cosine | 0.5591 |
|
| 311 |
+
| Clustering | ts_abstract_corpus | v_measure | 0.5762 |
|
| 312 |
+
| Clustering | 630koseyazisi | v_measure | 0.3978 |
|
| 313 |
+
| Retrieval | tquad | ndcg@10 | 0.8222 |
|
| 314 |
+
| Retrieval | quora-tr | ndcg@10 | 0.7323 |
|
| 315 |
+
| Retrieval | squad-tr | ndcg@10 | 0.6584 |
|
| 316 |
+
| Retrieval | scifact-tr | ndcg@10 | 0.5309 |
|
| 317 |
+
| Retrieval | cqadupstack-gaming-tr | ndcg@10 | 0.3584 |
|
| 318 |
+
| Retrieval | msmarco-tr | ndcg@10 | 0.2734 |
|
| 319 |
+
| Retrieval | arguana-tr | ndcg@10 | 0.2583 |
|
| 320 |
+
| Retrieval | nfcorpus-tr | ndcg@10 | 0.2272 |
|
| 321 |
+
| Retrieval | fiqa-tr | ndcg@10 | 0.1237 |
|
| 322 |
+
| Retrieval | scidocs-tr | ndcg@10 | 0.0887 |
|
| 323 |
+
|
| 324 |
+
ᵃ *Train-less set — evaluated via a seeded 70/30 stratified self-split (not the official
|
| 325 |
+
protocol; treat as indicative).*
|
| 326 |
+
|
| 327 |
+
Retrieval also reports Recall@10 and MAP@10 in `trmteb_results.json`.
|
| 328 |
+
|
| 329 |
+
---
|
| 330 |
+
|
| 331 |
+
## Limitations & Biases
|
| 332 |
+
- **Translated training data.** The NLI triplets are machine-translated; translation
|
| 333 |
+
artefacts and noise are inherited, which can cap fine-grained semantic precision.
|
| 334 |
+
- **Short-text bias.** Trained on NLI-style short sentences at 256 tokens; long-document
|
| 335 |
+
retrieval requires chunking and may underperform (see the lower `fiqa`/`scidocs` scores).
|
| 336 |
+
- **Prefix sensitivity.** Using the model without `query:`/`passage:` prefixes degrades results.
|
| 337 |
+
- **Domain gaps.** Scientific/financial retrieval (scidocs, fiqa) is weak; the model is
|
| 338 |
+
strongest on general-domain QA-style retrieval (tquad, squad-tr, quora-tr).
|
| 339 |
+
- **Societal bias.** The backbone and NLI data may encode social biases; validate before
|
| 340 |
+
deployment in sensitive settings.
|
| 341 |
+
- **Single epoch.** Trained for 1 epoch; longer schedules or larger effective batches may
|
| 342 |
+
improve retrieval further.
|
| 343 |
+
|
| 344 |
+
## Compute & Environmental Impact
|
| 345 |
+
- Single consumer laptop GPU (RTX 5050, 8 GB). Full pipeline (Optuna sweep + 1-epoch
|
| 346 |
+
training on 277k triplets + evaluation) ran in a few GPU-hours. No multi-GPU/cluster
|
| 347 |
+
training was used.
|
| 348 |
+
|
| 349 |
+
## Licensing
|
| 350 |
+
- **Backbone** `intfloat/multilingual-e5-base`: MIT.
|
| 351 |
+
- **Training data** derives from **AllNLI** (SNLI is **CC BY-SA 4.0**; MultiNLI has mixed
|
| 352 |
+
source licenses), translated to Turkish. Because the most restrictive component is
|
| 353 |
+
CC BY-SA 4.0, this model card is released under **CC BY-SA 4.0**; verify that this suits
|
| 354 |
+
your use case and comply with the ShareAlike terms.
|
| 355 |
+
- **Evaluation datasets** belong to their respective authors (see the `trmteb` org and
|
| 356 |
+
`emrecan/stsb-mt-turkish`).
|
| 357 |
+
|
| 358 |
+
## Citation
|
| 359 |
+
|
| 360 |
+
This model:
|
| 361 |
+
```bibtex
|
| 362 |
+
@misc{e5-tr-nli,
|
| 363 |
+
title = {e5-tr-nli: A Turkish Sentence Embedding Model},
|
| 364 |
+
note = {Fine-tuned from intfloat/multilingual-e5-base on Turkish NLI triplets},
|
| 365 |
+
year = {2026}
|
| 366 |
+
}
|
| 367 |
+
```
|
| 368 |
+
|
| 369 |
+
TR-MTEB benchmark:
|
| 370 |
+
```bibtex
|
| 371 |
+
@inproceedings{baysan-gungor-2025-trmteb,
|
| 372 |
+
title = {{TR-MTEB}: A Comprehensive Benchmark and Embedding Model Suite for {T}urkish Sentence Representations},
|
| 373 |
+
author = {Baysan, Mehmet Selman and G{\"u}ng{\"o}r, Tunga},
|
| 374 |
+
booktitle = {Findings of the Association for Computational Linguistics: EMNLP 2025},
|
| 375 |
+
year = {2025}
|
| 376 |
+
}
|
| 377 |
+
```
|
| 378 |
+
|
| 379 |
+
Base model (E5):
|
| 380 |
+
```bibtex
|
| 381 |
+
@article{wang2024multilingual,
|
| 382 |
+
title = {Multilingual E5 Text Embeddings: A Technical Report},
|
| 383 |
+
author = {Wang, Liang and Yang, Nan and Huang, Xiaolong and Yang, Linjun and Majumder, Rangan and Wei, Furu},
|
| 384 |
+
journal = {arXiv preprint arXiv:2402.05672},
|
| 385 |
+
year = {2024}
|
| 386 |
+
}
|
| 387 |
+
```
|
| 388 |
+
|
| 389 |
+
## Reproduction
|
| 390 |
+
The full pipeline (data prep, Optuna sweep, training, and TR-MTEB evaluation) is scripted:
|
| 391 |
+
- `train_embedding_tr.py` — `--mode sweep | train | eval | mteb`
|
| 392 |
+
- `eval_trmteb_hf.py` — TR-MTEB evaluation straight from HuggingFace `trmteb/*` datasets
|
| 393 |
+
- `config.py`, `Makefile`, `requirements.txt`
|
| 394 |
+
|
| 395 |
+
To publish (disabled by default — no secrets are used):
|
| 396 |
+
```python
|
| 397 |
+
from sentence_transformers import SentenceTransformer
|
| 398 |
+
SentenceTransformer("models/e5-tr-nli-final").push_to_hub("thealper2/multilingual-e5-base-tr-nli")
|
| 399 |
+
```
|
config.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"add_cross_attention": false,
|
| 3 |
+
"architectures": [
|
| 4 |
+
"XLMRobertaModel"
|
| 5 |
+
],
|
| 6 |
+
"attention_probs_dropout_prob": 0.1,
|
| 7 |
+
"bos_token_id": 0,
|
| 8 |
+
"classifier_dropout": null,
|
| 9 |
+
"dtype": "float32",
|
| 10 |
+
"eos_token_id": 2,
|
| 11 |
+
"hidden_act": "gelu",
|
| 12 |
+
"hidden_dropout_prob": 0.1,
|
| 13 |
+
"hidden_size": 768,
|
| 14 |
+
"initializer_range": 0.02,
|
| 15 |
+
"intermediate_size": 3072,
|
| 16 |
+
"is_decoder": false,
|
| 17 |
+
"layer_norm_eps": 1e-05,
|
| 18 |
+
"max_position_embeddings": 514,
|
| 19 |
+
"model_type": "xlm-roberta",
|
| 20 |
+
"num_attention_heads": 12,
|
| 21 |
+
"num_hidden_layers": 12,
|
| 22 |
+
"output_past": true,
|
| 23 |
+
"pad_token_id": 1,
|
| 24 |
+
"position_embedding_type": "absolute",
|
| 25 |
+
"tie_word_embeddings": true,
|
| 26 |
+
"transformers_version": "5.0.0",
|
| 27 |
+
"type_vocab_size": 1,
|
| 28 |
+
"use_cache": true,
|
| 29 |
+
"vocab_size": 250002
|
| 30 |
+
}
|
config_sentence_transformers.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"model_type": "SentenceTransformer",
|
| 3 |
+
"__version__": {
|
| 4 |
+
"sentence_transformers": "5.2.2",
|
| 5 |
+
"transformers": "5.0.0",
|
| 6 |
+
"pytorch": "2.11.0+cu128"
|
| 7 |
+
},
|
| 8 |
+
"prompts": {
|
| 9 |
+
"query": "",
|
| 10 |
+
"document": ""
|
| 11 |
+
},
|
| 12 |
+
"default_prompt_name": null,
|
| 13 |
+
"similarity_fn_name": "cosine"
|
| 14 |
+
}
|
model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a489f44be96bffc5c29ce6431c2ed6ed77ff5b2e9bc2aee0d4333bcf635e1818
|
| 3 |
+
size 1112197064
|
modules.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[
|
| 2 |
+
{
|
| 3 |
+
"idx": 0,
|
| 4 |
+
"name": "0",
|
| 5 |
+
"path": "",
|
| 6 |
+
"type": "sentence_transformers.models.Transformer"
|
| 7 |
+
},
|
| 8 |
+
{
|
| 9 |
+
"idx": 1,
|
| 10 |
+
"name": "1",
|
| 11 |
+
"path": "1_Pooling",
|
| 12 |
+
"type": "sentence_transformers.models.Pooling"
|
| 13 |
+
},
|
| 14 |
+
{
|
| 15 |
+
"idx": 2,
|
| 16 |
+
"name": "2",
|
| 17 |
+
"path": "2_Normalize",
|
| 18 |
+
"type": "sentence_transformers.models.Normalize"
|
| 19 |
+
}
|
| 20 |
+
]
|
sentence_bert_config.json
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"max_seq_length": 256,
|
| 3 |
+
"do_lower_case": false
|
| 4 |
+
}
|
tokenizer.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:0c16d8a2bff758ba6e009849c31b8ffc8ba92bfc907e0bcee96a09f1818fe2da
|
| 3 |
+
size 16766387
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"add_prefix_space": true,
|
| 3 |
+
"backend": "tokenizers",
|
| 4 |
+
"bos_token": "<s>",
|
| 5 |
+
"clean_up_tokenization_spaces": true,
|
| 6 |
+
"cls_token": "<s>",
|
| 7 |
+
"eos_token": "</s>",
|
| 8 |
+
"is_local": false,
|
| 9 |
+
"mask_token": "<mask>",
|
| 10 |
+
"model_max_length": 512,
|
| 11 |
+
"pad_token": "<pad>",
|
| 12 |
+
"sep_token": "</s>",
|
| 13 |
+
"tokenizer_class": "XLMRobertaTokenizer",
|
| 14 |
+
"unk_token": "<unk>"
|
| 15 |
+
}
|