Turkish embedding: GooAQ-TR 1305k, Siamese encoder, full fine-tuning, distilled from multilingual-e5-large
A fully fine-tuned copy of selmanbaysan/turkish_embedding_model_fine_tuned, trained for Turkish question → answer retrieval on 1,292,329 question–answer pairs of GooAQ-TR, a Turkish machine translation of Google's GooAQ, by distillation from intfloat/multilingual-e5-large: it learned to rank answers as that model ranks them.
| Architecture | Siamese encoder: one fully trained copy of the base model, which encodes questions and answers separately |
| Base model | selmanbaysan/turkish_embedding_model_fine_tuned, all weights trained |
| Trained parameters | all 110,617,344 |
| Embedding | mean of the last hidden states over the non-padding tokens, 768 dimensions |
| Similarity | cosine |
| Input length | 128 tokens |
| Training data | 1,292,329 GooAQ-TR pairs; 13,054 more held out for validation |
| Checkpoint | epoch 2 of 2: the best validation nDCG@10, and the last epoch |
Usage
import torch
from transformers import AutoModel, AutoTokenizer
repo = "sfidan42/turkish-embedding-gooaq-tr-1305k-full-siamese-distill-e5"
tokenizer = AutoTokenizer.from_pretrained(repo)
encoder = AutoModel.from_pretrained(repo).eval()
def embed(model, texts):
batch = tokenizer(texts, padding=True, truncation=True, max_length=128, return_tensors="pt")
with torch.no_grad():
hidden = model(**batch).last_hidden_state
mask = batch["attention_mask"].unsqueeze(-1).to(hidden.dtype)
return torch.nn.functional.normalize((hidden * mask).sum(1) / mask.sum(1), dim=-1)
questions = embed(encoder, ["Kediler neden mırlar?"])
answers = embed(encoder, [
"Kediler çoğunlukla rahat ve mutlu olduklarında mırlar; mırlama stres ya da ağrı anında da duyulabilir.",
"Köpekler, kurtlardan evcilleştirilmiş memelilerdir.",
])
print(questions @ answers.T) # cosine similarities; the first answer should score higher
Inputs longer than 128 tokens are cut, as in training.
Architecture
Siamese encoder. One copy of the base model encodes both questions and answers, each text on its own, so both sides share their weights. All 110,617,344 weights were trained. An embedding is the mean of the last hidden states over the non-padding tokens, and a question and an answer are compared by cosine similarity.
Training data: GooAQ-TR
- Source. GooAQ (Khashabi et al., 2021, "GooAQ: Open Question Answering with Diverse Answer Types"; Apache-2.0): 5,030,530 English questions from Google's autocomplete, each with the answer box Google showed for it.
- English pool. Written snippet answers only (2,703,889); English questions only; no cut-off answers; answers of at least 5 words (2,652,889); then one question per distinct answer, because GooAQ maps many near-identical questions to one snippet, and two of them in one batch would make a correct answer a negative: 1,353,533 pairs.
- Translation with Hy-MT2-30B-A3B (Tencent, Apache-2.0). Each question was translated with its answer as background, using the model's context-aware prompt; when that output looked wrong (template text, an extra line, or more than 1.3 times the length of the question translated alone), the question translated alone was kept. Answers were translated alone. The translator was chosen in two blind reviews (60 items, then 300 questions) against GPT-4.1, MiLMMT-46 12B and HY-MT1.5.
- This model's sample. All 68 translation shards held 1,353,533 pairs. Dropped: 0 with an empty translation, 3 cut off at the token limit, 13,723 whose answer translation was flagged as odd (template text, an extra line, or more than three times the source's length), 0 that repeat a text of the evaluation FAQ sets, and 34,424 whose Turkish question or answer duplicates another pair's. All 1,305,383 remaining pairs were used, in random order (seed 20261010): 1,292,329 for training and 13,054 (1%) for validation. 76,956 of their questions (5.9%) come from the plain translation.
Coverage. All 68 shards of the full run were translated, so the sample is drawn from the whole pool, and its question types are in their pool proportions:
| First word | This sample | Whole pool |
|---|---|---|
| what | 28.0% | 28.1% |
| how | 16.9% | 17.1% |
| are | 15.7% | 15.6% |
| is | 14.3% | 14.1% |
| can | 4.9% | 4.9% |
| do | 3.6% | 3.6% |
| does | 1.3% | 1.3% |
| why | 3.5% | 3.5% |
| who | 1.6% | 1.6% |
| where | 1.3% | 1.3% |
| when | 1.1% | 1.1% |
| which | 0.7% | 0.7% |
| digit | 1.1% | 1.1% |
Training
| Loss | distillation from intfloat/multilingual-e5-large: for each question, the KL divergence from the teacher's softmax over the batch's 128 answers (cosine similarity, temperature 0.01) to this model's (cosine similarity, temperature 0.1). The answers are the 64 questions' own answers and one hard negative per question, drawn at every step from the 30 training answers the teacher finds closest to it. The teacher reads "query:" and "passage:" prefixes; this model reads no prefix |
| Batch | 64 pairs, plus 64 hard negatives |
| Optimizer | AdamW, learning rate 2e-5 at its peak: linear warmup over 20,193 steps (1 epoch), then linear decay to 0 at step 40,386; gradient clipping at 1.0 |
| Epochs | 2 (40,386 steps); the checkpoint on main has the best validation nDCG@10 |
| Precision | bf16 autocast, loss in fp32 |
| Seed | 0 |
| Hardware | NVIDIA RTX PRO 6000 Blackwell Server Edition, 1 h 34 min including the evaluation after every epoch |
Evaluation
GooAQ-TR validation. The 13,054 held-out pairs; each question ranks all 13,054 answers by cosine similarity.
| Model | nDCG@10 | MRR@10 | Recall@10 |
|---|---|---|---|
| This model (epoch 2) | 0.9015 | 0.8820 | 0.9614 |
| Selmanbaysan base, no fine-tuning | 0.8548 | 0.8297 | 0.9322 |
| BAAI/bge-m3 | 0.9142 | 0.8961 | 0.9695 |
| intfloat/multilingual-e5-large | 0.9296 | 0.9140 | 0.9767 |
| OpenAI text-embedding-3-small | 0.8499 | 0.8227 | 0.9342 |
| OpenAI text-embedding-3-large | 0.9414 | 0.9267 | 0.9855 |
Turkish FAQ benchmark. 2,528 questions from the FAQ pages of Turkish institutions (not yet public), each with its own answer, another answer of the same institution and an answer from another domain. The score is the original (Harrell) C-Index: the share of the three answer pairs a model puts in the right order, ties counting one half; chance is 0.5. Differences are this model's (main) minus the other model's, over the same questions, with a bootstrap 95% interval and a sign-flip permutation p, Holm-adjusted across the comparisons.
| Model | C-Index | This model minus it [95% CI] | p (Holm) |
|---|---|---|---|
| This model (epoch 2) | 0.9357 | ||
| Selmanbaysan base, no fine-tuning | 0.9266 | +0.0091 [+0.0045, +0.0138] | < 0.001 |
| BAAI/bge-m3 | 0.9244 | +0.0112 [+0.0055, +0.0167] | < 0.001 |
| intfloat/multilingual-e5-large | 0.9211 | +0.0145 [+0.0088, +0.0200] | < 0.001 |
| OpenAI text-embedding-3-small | 0.9222 | +0.0134 [+0.0079, +0.0193] | < 0.001 |
| OpenAI text-embedding-3-large | 0.9370 | -0.0013 [-0.0065, +0.0040] | 0.662 |
Turkish FAQ retrieval. The same 2,528 questions; each ranks all 2,528 answers of the benchmark by cosine similarity, and nDCG@10 scores the rank of its own answer.
| Model | nDCG@10 |
|---|---|
| This model (epoch 2) | 0.7329 |
| Selmanbaysan base, no fine-tuning | 0.6981 |
| intfloat/multilingual-e5-large | 0.8007 |
| BAAI/bge-m3 | 0.7878 |
| OpenAI text-embedding-3-large | 0.7957 |
| OpenAI text-embedding-3-small | 0.6782 |
| GooAQ-TR LoRA dual encoder, InfoNCE on the same pairs | 0.7204 |
| GooAQ-TR LoRA Siamese encoder, InfoNCE on the same pairs | 0.7213 |
This model and the base model read 128 tokens; the other models read their own maximum length. All models are compared by cosine similarity.
| Epoch | Training loss | nDCG@10 | MRR@10 | Recall@10 | FAQ C-Index |
|---|---|---|---|---|---|
| base | 0.8548 | 0.8297 | 0.9322 | 0.9266 | |
| 1 | 0.3359 | 0.8900 | 0.8697 | 0.9525 | 0.9353 |
2 (main) | 0.2514 | 0.9015 | 0.8820 | 0.9614 | 0.9357 |
The FAQ column only tracks the benchmark; the checkpoint on main was chosen on validation.
Limitations
- The training data is machine-translated. In a blind review of 300 questions, the translation procedure changed the meaning of 9 (GPT-4.1: 7); the fallback threshold was set on the same questions, so the true rate may be slightly higher.
- GooAQ comes from English Google search: 9.6% of the pool is flagged as US-specific (it names US states, dollar prices or the US), and many answers use US units.
- The multilingual-E5 report lists GooAQ, in English, among the teacher's training data, so the teacher may rank GooAQ-TR pairs better than new text.
- Inputs are cut at 128 tokens.
License
Apache-2.0, the license of GooAQ and of Hy-MT2-30B-A3B. The teacher, intfloat/multilingual-e5-large, is MIT-licensed.