Sentence Similarity
sentence-transformers
Safetensors
Turkish
bert
feature-extraction
retrieval
turkish
finance
banking
rag
federated-rag
text-embeddings-inference
Instructions to use Toxotes/mosaic-embed with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use Toxotes/mosaic-embed with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("Toxotes/mosaic-embed") 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
Model card
Browse files
README.md
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language:
|
| 3 |
+
- tr
|
| 4 |
+
license: mit
|
| 5 |
+
library_name: sentence-transformers
|
| 6 |
+
base_model: intfloat/multilingual-e5-small
|
| 7 |
+
pipeline_tag: sentence-similarity
|
| 8 |
+
tags:
|
| 9 |
+
- sentence-transformers
|
| 10 |
+
- feature-extraction
|
| 11 |
+
- sentence-similarity
|
| 12 |
+
- retrieval
|
| 13 |
+
- turkish
|
| 14 |
+
- finance
|
| 15 |
+
- banking
|
| 16 |
+
- rag
|
| 17 |
+
- federated-rag
|
| 18 |
+
---
|
| 19 |
+
|
| 20 |
+
# MOSAIC TurkEmbed
|
| 21 |
+
|
| 22 |
+
MOSAIC TurkEmbed is a Turkish financial-domain retrieval embedding model. It is
|
| 23 |
+
[intfloat/multilingual-e5-small](https://huggingface.co/intfloat/multilingual-e5-small) fine-tuned on query-to-passage
|
| 24 |
+
pairs built from Turkish banking and finance documents. It is the retriever developed for
|
| 25 |
+
[MOSAIC](https://github.com/tahatoy/mosaic-federated-rag), a privacy-preserving federated retrieval-augmented
|
| 26 |
+
generation (RAG) architecture for Turkish banking branches.
|
| 27 |
+
|
| 28 |
+
This model supersedes
|
| 29 |
+
[Toxotes/mosaic-turkembed-finetuned](https://huggingface.co/Toxotes/mosaic-turkembed-finetuned). That earlier model was
|
| 30 |
+
trained on instruction-response pairs and retrieved source passages worse than its base model; this version is trained
|
| 31 |
+
on query-to-source-passage pairs and outperforms the base model on the MOSAIC cross-branch retrieval benchmark.
|
| 32 |
+
|
| 33 |
+
## Usage
|
| 34 |
+
|
| 35 |
+
The model follows the e5 convention: prefix queries with `query: ` and passages with `passage: `.
|
| 36 |
+
|
| 37 |
+
```python
|
| 38 |
+
from sentence_transformers import SentenceTransformer
|
| 39 |
+
|
| 40 |
+
model = SentenceTransformer("Toxotes/mosaic-turkembed")
|
| 41 |
+
queries = ["query: Bankanın konut kredisi aylık faiz oranı ne kadar?"]
|
| 42 |
+
passages = ["passage: Banka, konut kredilerinde uyguladığı aylık faiz oranını düşürdüğünü açıkladı."]
|
| 43 |
+
q = model.encode(queries, normalize_embeddings=True)
|
| 44 |
+
p = model.encode(passages, normalize_embeddings=True)
|
| 45 |
+
print(q @ p.T)
|
| 46 |
+
```
|
| 47 |
+
|
| 48 |
+
## Training
|
| 49 |
+
|
| 50 |
+
| Setting | Value |
|
| 51 |
+
|---------|-------|
|
| 52 |
+
| Base model | intfloat/multilingual-e5-small (384 dimensions) |
|
| 53 |
+
| Training pairs | 6,629 query-passage pairs from 6,482 chunks; 731 queries from 720 further chunks held out for model selection |
|
| 54 |
+
| Queries | natural questions written by Qwen3-8B for each chunk, plus cloze queries built from sentences that contain a single figure |
|
| 55 |
+
| Negatives | in-batch negatives and one mined hard negative per query (rank 3-30 under the base model, near-duplicates of the positive removed) |
|
| 56 |
+
| Loss | MultipleNegativesRankingLoss, no duplicate passages within a batch |
|
| 57 |
+
| Hyperparameters | batch size 64, learning rate 2e-5, maximum sequence length 256, mixed precision |
|
| 58 |
+
| Epochs | 6 trained, epoch 4 selected on the held-out development queries |
|
| 59 |
+
|
| 60 |
+
Passages are 600-character chunks with a 120-character overlap from Turkish financial texts (company disclosures,
|
| 61 |
+
regulatory and central bank documents, banking question-answer material). Every chunk that contains the source sentence
|
| 62 |
+
of any evaluation question was removed before training, so the evaluation questions never share a passage with the
|
| 63 |
+
training data. The generated questions were filtered: they must end with a question mark and must not copy a word
|
| 64 |
+
sequence of six or more words from the passage.
|
| 65 |
+
|
| 66 |
+
## Evaluation
|
| 67 |
+
|
| 68 |
+
MOSAIC cross-branch retrieval benchmark: 22,192 passages from two bank branches; 600 cloze questions about a figure in a
|
| 69 |
+
passage held by the other branch, and 419 paraphrased versions of these questions. MRR@10 in the federated setting, in
|
| 70 |
+
which each branch returns its top 10 passages and headquarters merges them. 95% confidence intervals from a paired
|
| 71 |
+
bootstrap against the base model.
|
| 72 |
+
|
| 73 |
+
| Model | Cloze questions | Paraphrased questions |
|
| 74 |
+
|-------|-----------------|-----------------------|
|
| 75 |
+
| multilingual-e5-small (base) | 0.887 | 0.796 |
|
| 76 |
+
| mosaic-turkembed-finetuned (previous release) | 0.829 | 0.730 |
|
| 77 |
+
| **MOSAIC TurkEmbed (this model)** | **0.931** | **0.803** |
|
| 78 |
+
| multilingual-e5-small + cross-encoder re-ranking | 0.838 | 0.844 |
|
| 79 |
+
| **MOSAIC TurkEmbed + cross-encoder re-ranking** | **0.868** | **0.848** |
|
| 80 |
+
|
| 81 |
+
Difference from the base model: +0.044 MRR@10 on cloze questions (95% CI [0.027, 0.061]) and +0.007 on paraphrased
|
| 82 |
+
questions (95% CI [-0.015, 0.028]). Hit@10 on cloze questions rises from 0.950 to 0.983. The re-ranker is
|
| 83 |
+
`cross-encoder/mmarco-mMiniLMv2-L12-H384-v1` applied to the top 20 candidates.
|
| 84 |
+
|
| 85 |
+
## Limitations
|
| 86 |
+
|
| 87 |
+
- The gain is clear for questions that ask for a specific figure or statement in a passage; on freely paraphrased
|
| 88 |
+
questions the model is on par with the base model.
|
| 89 |
+
- Training queries were generated by a language model without manual checking.
|
| 90 |
+
- The model was trained and evaluated on one institution's document collection; performance on other Turkish financial
|
| 91 |
+
corpora was not measured.
|
| 92 |
+
|
| 93 |
+
## Citation
|
| 94 |
+
|
| 95 |
+
```bibtex
|
| 96 |
+
@software{toy_mosaic_2026,
|
| 97 |
+
author = {Toy, Mehmet Taha and S{\"u}zen, Ahmet Ali},
|
| 98 |
+
title = {{MOSAIC}: A Privacy-Preserving Federated Retrieval-Augmented Generation Architecture for Turkish Banking},
|
| 99 |
+
year = {2026},
|
| 100 |
+
url = {https://github.com/tahatoy/mosaic-federated-rag}
|
| 101 |
+
}
|
| 102 |
+
```
|