Update README.md
Browse files
README.md
CHANGED
|
@@ -1,39 +1,48 @@
|
|
| 1 |
---
|
| 2 |
tags:
|
| 3 |
-
- sentence-transformers
|
| 4 |
-
- sentence-similarity
|
| 5 |
-
- feature-extraction
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
pipeline_tag: sentence-similarity
|
| 7 |
library_name: sentence-transformers
|
|
|
|
| 8 |
---
|
| 9 |
|
| 10 |
-
|
| 11 |
|
| 12 |
-
|
| 13 |
|
| 14 |
-
|
| 15 |
|
| 16 |
-
|
| 17 |
-
-
|
| 18 |
-
|
| 19 |
-
-
|
| 20 |
-
- **Output Dimensionality:** 768 dimensions
|
| 21 |
-
- **Similarity Function:** Cosine Similarity
|
| 22 |
-
<!-- - **Training Dataset:** Unknown -->
|
| 23 |
-
<!-- - **Language:** Unknown -->
|
| 24 |
-
<!-- - **License:** Unknown -->
|
| 25 |
|
| 26 |
-
|
| 27 |
|
| 28 |
-
|
| 29 |
-
- **Repository:** [Sentence Transformers on GitHub](https://github.com/UKPLab/sentence-transformers)
|
| 30 |
-
- **Hugging Face:** [Sentence Transformers on Hugging Face](https://huggingface.co/models?library=sentence-transformers)
|
| 31 |
|
| 32 |
-
|
|
|
|
|
|
|
| 33 |
|
| 34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
SentenceTransformer(
|
| 36 |
-
(0): Transformer({'max_seq_length': 2048, 'do_lower_case': False}) with Transformer model: Gemma3TextModel
|
| 37 |
(1): Pooling({'word_embedding_dimension': 768, 'pooling_mode_cls_token': False, 'pooling_mode_mean_tokens': True, 'pooling_mode_max_tokens': False, 'pooling_mode_mean_sqrt_len_tokens': False, 'pooling_mode_weightedmean_tokens': False, 'pooling_mode_lasttoken': False, 'include_prompt': True})
|
| 38 |
(2): Dense({'in_features': 768, 'out_features': 3072, 'bias': False, 'activation_function': 'torch.nn.modules.linear.Identity'})
|
| 39 |
(3): Dense({'in_features': 3072, 'out_features': 768, 'bias': False, 'activation_function': 'torch.nn.modules.linear.Identity'})
|
|
@@ -41,103 +50,357 @@ SentenceTransformer(
|
|
| 41 |
)
|
| 42 |
```
|
| 43 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
## Usage
|
| 45 |
|
| 46 |
-
###
|
| 47 |
|
| 48 |
-
|
| 49 |
|
| 50 |
```bash
|
| 51 |
pip install -U sentence-transformers
|
| 52 |
```
|
| 53 |
|
| 54 |
-
|
|
|
|
| 55 |
```python
|
| 56 |
from sentence_transformers import SentenceTransformer
|
| 57 |
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
# Run inference
|
| 61 |
sentences = [
|
| 62 |
-
|
| 63 |
-
"
|
| 64 |
-
|
| 65 |
]
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
#
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
```
|
| 75 |
|
| 76 |
-
|
| 77 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 78 |
|
| 79 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
|
| 81 |
-
|
| 82 |
-
|
| 83 |
|
| 84 |
-
|
| 85 |
-
|
|
|
|
| 86 |
|
| 87 |
-
|
| 88 |
|
| 89 |
-
|
| 90 |
|
| 91 |
-
|
| 92 |
-
-->
|
| 93 |
|
| 94 |
-
|
| 95 |
-
### Out-of-Scope Use
|
| 96 |
|
| 97 |
-
|
| 98 |
-
-->
|
| 99 |
|
| 100 |
-
|
| 101 |
-
## Bias, Risks and Limitations
|
| 102 |
|
| 103 |
-
|
| 104 |
-
-->
|
| 105 |
|
| 106 |
-
|
| 107 |
-
### Recommendations
|
| 108 |
|
| 109 |
-
|
| 110 |
-
-
|
|
|
|
|
|
|
| 111 |
|
| 112 |
-
##
|
| 113 |
|
| 114 |
-
|
| 115 |
-
-
|
| 116 |
-
|
| 117 |
-
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 122 |
|
| 123 |
## Citation
|
| 124 |
|
| 125 |
-
|
| 126 |
|
| 127 |
-
|
| 128 |
-
## Glossary
|
| 129 |
|
| 130 |
-
|
| 131 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 132 |
|
| 133 |
-
|
| 134 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 135 |
|
| 136 |
-
|
| 137 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 138 |
|
| 139 |
-
|
| 140 |
-
## Model Card Contact
|
| 141 |
|
| 142 |
-
|
| 143 |
-
-->
|
|
|
|
| 1 |
---
|
| 2 |
tags:
|
| 3 |
+
- sentence-transformers
|
| 4 |
+
- sentence-similarity
|
| 5 |
+
- feature-extraction
|
| 6 |
+
- text-embeddings
|
| 7 |
+
- turkish
|
| 8 |
+
- tr
|
| 9 |
+
- distillation
|
| 10 |
+
- gemma
|
| 11 |
pipeline_tag: sentence-similarity
|
| 12 |
library_name: sentence-transformers
|
| 13 |
+
license: mit
|
| 14 |
---
|
| 15 |
|
| 16 |
+

|
| 17 |
|
| 18 |
+
# embeddingmagibu-152m
|
| 19 |
|
| 20 |
+
Bu model, **Türkçe odaklı uzun bağlam (2048 token)** sentence embedding üretmek için eğitilmiş bir **SentenceTransformer** modelidir. 768 boyutlu normalize vektör uzayına projeksiyon yapar ve özellikle:
|
| 21 |
|
| 22 |
+
- Semantik benzerlik (STS)
|
| 23 |
+
- Semantik arama / retrieval
|
| 24 |
+
- Kümeleme
|
| 25 |
+
- Sınıflandırma (embedding tabanlı)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
+
gibi görevlerde kullanılabilir.
|
| 28 |
|
| 29 |
+
Model, sıfırdan rastgele başlatılmak yerine iki aşamalı bir yaklaşımla geliştirilmiştir:
|
|
|
|
|
|
|
| 30 |
|
| 31 |
+
1. **Tokenizer yeniden eğitimi** (Türkçe için 2^16 vocab BPE)
|
| 32 |
+
2. **Transformer klonlama** (teacher model ağırlıklarını kopyala + yeni vocab için embedding tablosunu hesapla)
|
| 33 |
+
3. **Embedding distillation** (teacher embedding’lerini önceden hesapla, student’ı kısa sürede yaklaştır)
|
| 34 |
|
| 35 |
+
Bu sayede, büyük modellerle yarışan kaliteyi hedeflerken **parametre sayısı** yaklaşık **152M** seviyesinde yakalamıştır.
|
| 36 |
+
|
| 37 |
+
---
|
| 38 |
+
|
| 39 |
+
# Model Mimarisi
|
| 40 |
+
|
| 41 |
+
Bu model SentenceTransformers formatında aşağıdaki boru hattını kullanır:
|
| 42 |
+
|
| 43 |
+
```text
|
| 44 |
SentenceTransformer(
|
| 45 |
+
(0): Transformer({'max_seq_length': 2048, 'do_lower_case': False}) with Transformer model: Gemma3TextModel
|
| 46 |
(1): Pooling({'word_embedding_dimension': 768, 'pooling_mode_cls_token': False, 'pooling_mode_mean_tokens': True, 'pooling_mode_max_tokens': False, 'pooling_mode_mean_sqrt_len_tokens': False, 'pooling_mode_weightedmean_tokens': False, 'pooling_mode_lasttoken': False, 'include_prompt': True})
|
| 47 |
(2): Dense({'in_features': 768, 'out_features': 3072, 'bias': False, 'activation_function': 'torch.nn.modules.linear.Identity'})
|
| 48 |
(3): Dense({'in_features': 3072, 'out_features': 768, 'bias': False, 'activation_function': 'torch.nn.modules.linear.Identity'})
|
|
|
|
| 50 |
)
|
| 51 |
```
|
| 52 |
|
| 53 |
+
---
|
| 54 |
+
|
| 55 |
+
## Eğitim Süreci ve Oluşturulma Detayları
|
| 56 |
+
|
| 57 |
+
Bu bölüm, modelin “nasıl üretildiğini” mümkün olduğunca tekrarlanabilir ve teknik şekilde anlatır.
|
| 58 |
+
|
| 59 |
+
### 1) Tokenizer: 2^16 vocab BPE (SentencePiece)
|
| 60 |
+
|
| 61 |
+
- **Tokenizer türü:** BPE
|
| 62 |
+
- **Vocab:** $2^{16} = 65{,}536$ token
|
| 63 |
+
- **Eğitim kütüphanesi:** SentencePiece
|
| 64 |
+
- **Tokenizer eğitim verisi:** [ytu-ce-cosmos/Cosmos-Turkish-Corpus-v1.0](https://huggingface.co/datasets/ytu-ce-cosmos/Cosmos-Turkish-Corpus-v1.0)
|
| 65 |
+
- Dataset kartına göre: Türkçe pretrain korpusu, ~15B token; geniş kaynak yelpazesi; URL bazlı deduplikasyon uygulanmış.
|
| 66 |
+
- Lisans: CC-BY-4.0
|
| 67 |
+
|
| 68 |
+
Amaç: Türkçe metinler için daha uygun alt-parça dağılımı elde ederek **vocab’ı küçültmek** ve **embedding tablosu parametrelerini** düşürmek.
|
| 69 |
+
|
| 70 |
+
### 2) Model Klonlama: `transformer-cloner`
|
| 71 |
+
|
| 72 |
+
Sıfırdan model başlatmak yerine, teacher modelin (EmbeddingGemma) ağırlıklarını mümkün olduğunca **koruyarak** yeni tokenizer’a adapte edebilmek için `transformer-cloner` adlı bir Python kütüphanesi kullanılmıştır:
|
| 73 |
+
|
| 74 |
+
- PyPI: [transformer-cloner](https://pypi.org/project/transformer-cloner/)
|
| 75 |
+
- GitHub: [malibayram/transformer-cloner](https://github.com/malibayram/transformer-cloner)
|
| 76 |
+
|
| 77 |
+
#### Temel fikir
|
| 78 |
+
|
| 79 |
+
Teacher modeldeki transformer katmanları (attention/MLP/LayerNorm vb.) olduğu gibi korunur; asıl sorun, tokenizer değiştiğinde **token embedding tablosunun** (vocab_size × hidden_size) uyumsuz hale gelmesidir.
|
| 80 |
+
|
| 81 |
+
`transformer-cloner`, yeni tokenizer’daki her token için teacher tokenizer tarafında bir **token-id eşlemesi** oluşturur:
|
| 82 |
+
|
| 83 |
+
- `build_token_id_map()` yeni vocab’daki her `target_token_id` için teacher tarafında bir veya birden çok `source_token_id` döner: `{target_id: [source_ids...]}`
|
| 84 |
+
- Ardından `clone()` aşamasında embedding’ler **hesaplanarak** aktarılır.
|
| 85 |
+
|
| 86 |
+
#### Embedding aktarım stratejisi
|
| 87 |
+
|
| 88 |
+
Yeni token birden fazla teacher token’a parçalanıyorsa, teacher embedding’leri birleştirilir. `transformer-cloner` bu birleşimi `EmbeddingStrategy` ile tanımlar (MEAN, WEIGHTED, FIRST, LAST, vb.).
|
| 89 |
+
|
| 90 |
+
Bu projede kullanılan yaklaşım:
|
| 91 |
+
|
| 92 |
+
- Yeni token embedding’i, eşleşen teacher token embedding’lerinin ortalaması gibi bir stratejiyle (pratikte MEAN/WEIGHTED) hesaplanır.
|
| 93 |
+
|
| 94 |
+
Bu sayede:
|
| 95 |
+
|
| 96 |
+
- Student model **rastgele init** yerine teacher’dan türetilmiş embeddinglerle başlar.
|
| 97 |
+
- Vocab küçüldüğü için embedding tablosu ve toplam parametre sayısı ciddi azalır.
|
| 98 |
+
|
| 99 |
+
### 3) Teacher embedding’lerini önceden hesaplama: `distil-trainer` (dataset üretimi)
|
| 100 |
+
|
| 101 |
+
Teacher model distillation sırasında her adımda çalıştırılmasın diye, teacher embedding’leri önceden hesaplanıp bir Hugging Face dataset’i olarak kaydedilmiştir.
|
| 102 |
+
|
| 103 |
+
- PyPI: [distil-trainer](https://pypi.org/project/distil-trainer/)
|
| 104 |
+
- GitHub: [malibayram/distil-trainer](https://github.com/malibayram/distil-trainer)
|
| 105 |
+
|
| 106 |
+
Bu aşamada `TeacherEmbeddingsGenerator` kullanılır:
|
| 107 |
+
|
| 108 |
+
- Kod: [src/distil_trainer/data/embeddings_generator.py](https://github.com/malibayram/distil-trainer/blob/main/src/distil_trainer/data/embeddings_generator.py)
|
| 109 |
+
|
| 110 |
+
Generator şu çıktıları üretebilir:
|
| 111 |
+
|
| 112 |
+
- `teacher_embedding_final`: SentenceTransformer pipeline’ının final embedding’i (Normalize dahil encode çıktısı)
|
| 113 |
+
- `teacher_embedding_pre_dense`: Dense katmanlarından önceki embedding (Dense varsa)
|
| 114 |
+
|
| 115 |
+
Bu projede teacher embedding’leri **300,000 örnek** üzerinde hesaplanıp şu dataset’e yazılmıştır:
|
| 116 |
+
|
| 117 |
+
- [alibayram/cosmos-corpus-0-05-with-embeddings](https://huggingface.co/datasets/alibayram/cosmos-corpus-0-05-with-embeddings)
|
| 118 |
+
- Satır sayısı: 300,000
|
| 119 |
+
- Kolonlar pratikte: `text`, `teacher_embedding_final` ve Dense varsa `teacher_embedding_pre_dense`
|
| 120 |
+
|
| 121 |
+
> Not: Dataset preview’ında embedding kolonlarının float dizileri olduğu görülür.
|
| 122 |
+
|
| 123 |
+
### 4) Embedding Distillation eğitimi (A100 80GB, ~4 saat)
|
| 124 |
+
|
| 125 |
+
Student model, teacher’ın embedding uzayına yaklaşacak şekilde eğitilmiştir.
|
| 126 |
+
|
| 127 |
+
Bu eğitimde kullanılan ana bileşen:
|
| 128 |
+
|
| 129 |
+
- `EmbeddingDistillationTrainer` ve `EmbeddingTrainerConfig`
|
| 130 |
+
- Örnek script referansı: [distil-trainer/train.py](https://github.com/malibayram/distil-trainer/blob/main/train.py)
|
| 131 |
+
|
| 132 |
+
Bu projenin raporlanan ayarları (özet):
|
| 133 |
+
|
| 134 |
+
- **target_type:** `final` (teacher final embedding’i hedefleniyor)
|
| 135 |
+
- **loss:** cosine
|
| 136 |
+
- **num_epochs:** 1
|
| 137 |
+
- **batch_size:** 256
|
| 138 |
+
- **learning_rate:** 5e-5
|
| 139 |
+
- **warmup_ratio:** 0.01
|
| 140 |
+
- **weight_decay:** 0.01
|
| 141 |
+
- **max_grad_norm:** 1.0
|
| 142 |
+
- **precision:** bf16
|
| 143 |
+
- **gradient_checkpointing:** açık
|
| 144 |
+
- **torch.compile:** açık
|
| 145 |
+
- **checkpointing:** her 100 adımda kaydet
|
| 146 |
+
|
| 147 |
+
Eğitim donanımı:
|
| 148 |
+
|
| 149 |
+
- **GPU:** NVIDIA A100 80GB (kiralık)
|
| 150 |
+
- **Süre:** ~4 saat
|
| 151 |
+
|
| 152 |
+
Deney takibi:
|
| 153 |
+
|
| 154 |
+
- Weights & Biases run: https://api.wandb.ai/links/alibayram-ytu/srxzzhof
|
| 155 |
+
|
| 156 |
+
---
|
| 157 |
+
|
| 158 |
+
## Evaluation
|
| 159 |
+
|
| 160 |
+
Bu bölümde iki seviyede sonuç raporlanmıştır:
|
| 161 |
+
|
| 162 |
+
1. Eğitim sırasında periyodik kontrol: STSbTR üzerinde karşılaştırma
|
| 163 |
+
2. Eğitim sonunda: TR-MTEB (Türkçe MTEB) benchmark
|
| 164 |
+
|
| 165 |
+
### 1) STSbTR (figenfikri/stsb_tr) karşılaştırması
|
| 166 |
+
|
| 167 |
+
Her 100 adım checkpoint alındıktan sonra, [figenfikri/stsb_tr](https://huggingface.co/datasets/figenfikri/stsb_tr) üzerinde Pearson/Spearman korelasyonları takip edilmiştir.
|
| 168 |
+
|
| 169 |
+
Örnek bir kayıt (timestamp: 2026-01-02):
|
| 170 |
+
|
| 171 |
+
| Model | Pearson | Spearman |
|
| 172 |
+
| ----------------------------------------------------------- | ------: | -------: |
|
| 173 |
+
| intfloat/multilingual-e5-large-instruct | 0.8275 | 0.8129 |
|
| 174 |
+
| trmteb/turkish-embedding-model-fine-tuned | 0.8215 | 0.8061 |
|
| 175 |
+
| ytu-ce-cosmos/turkish-e5-large | 0.8090 | 0.7906 |
|
| 176 |
+
| sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2 | 0.7884 | 0.7659 |
|
| 177 |
+
| **embeddingmagibu-152m (bu model)** | 0.7512 | 0.7305 |
|
| 178 |
+
| google/embeddinggemma-300m (teacher) | 0.7391 | 0.7194 |
|
| 179 |
+
|
| 180 |
+
Bu gözlem, distillation ilerledikçe student modelin teacher’ı geçebildiğini ve güçlü Türkçe embedding modellerine yaklaştığını göstermektedir.
|
| 181 |
+
|
| 182 |
+
### 2) TR-MTEB (MTEB-TR) benchmark
|
| 183 |
+
|
| 184 |
+
TR-MTEB, Türkçe embedding modellerini çok görevli bir ölçekte değerlendiren bir benchmark’tır:
|
| 185 |
+
|
| 186 |
+
- Referans repo: [selmanbaysan/mteb_tr](https://github.com/selmanbaysan/mteb_tr)
|
| 187 |
+
- Bu projede ayrıca fork + arayüz ile bir Space yayınlanmıştır: https://huggingface.co/spaces/alibayram/mteb-turkish
|
| 188 |
+
|
| 189 |
+
#### EmbeddingGemma’nın kullandığı 15 görev ortalaması (rapor)
|
| 190 |
+
|
| 191 |
+
| Model | Ortalama |
|
| 192 |
+
| ----------------------------------------------- | --------: |
|
| 193 |
+
| intfloat/multilingual-e5-large-instruct | 72.77 |
|
| 194 |
+
| intfloat/multilingual-e5-large | 72.28 |
|
| 195 |
+
| ytu-ce-cosmos/turkish-e5-large | 72.22 |
|
| 196 |
+
| google/embeddinggemma-300m | 70.97 |
|
| 197 |
+
| selmanbaysan/turkish embedding model fine tuned | 70.47 |
|
| 198 |
+
| **embeddingmagibu-152m (bu model)** | **69.68** |
|
| 199 |
+
|
| 200 |
+
#### TR-MTEB 24 görev (tam) ortalaması (rapor)
|
| 201 |
+
|
| 202 |
+
| Model | Ortalama |
|
| 203 |
+
| ----------------------------------------------- | --------: |
|
| 204 |
+
| intfloat/multilingual-e5-large | 65.59 |
|
| 205 |
+
| ytu-ce-cosmos/turkish-e5-large | 64.84 |
|
| 206 |
+
| intfloat/multilingual-e5-large-instruct | 64.72 |
|
| 207 |
+
| alibaba-NLP/gte-multilingual-base | 63.25 |
|
| 208 |
+
| intfloat/multilingual-e5-base | 63.00 |
|
| 209 |
+
| **embeddingmagibu-152m (bu model)** | **62.57** |
|
| 210 |
+
| selmanbaysan/turkish embedding model fine tuned | 62.17 |
|
| 211 |
+
|
| 212 |
+
> Yorum: Bu model, bazı görevlerde çok daha büyük / çok daha pahalı şekilde eğitilmiş modellere yaklaşırken, daha küçük boyut + 2048 bağlam uzunluğu ile pratik bir denge hedefler.
|
| 213 |
+
|
| 214 |
+
---
|
| 215 |
+
|
| 216 |
## Usage
|
| 217 |
|
| 218 |
+
### Sentence Transformers
|
| 219 |
|
| 220 |
+
Kurulum:
|
| 221 |
|
| 222 |
```bash
|
| 223 |
pip install -U sentence-transformers
|
| 224 |
```
|
| 225 |
|
| 226 |
+
Basit kullanım:
|
| 227 |
+
|
| 228 |
```python
|
| 229 |
from sentence_transformers import SentenceTransformer
|
| 230 |
|
| 231 |
+
model = SentenceTransformer("alibayram/embeddingmagibu-152m", trust_remote_code=True)
|
| 232 |
+
|
|
|
|
| 233 |
sentences = [
|
| 234 |
+
"Bugün hava çok güzel.",
|
| 235 |
+
"Dışarısı güneşli.",
|
| 236 |
+
"Stadyuma arabayla gitti.",
|
| 237 |
]
|
| 238 |
+
|
| 239 |
+
embeddings = model.encode(sentences, normalize_embeddings=True)
|
| 240 |
+
print(embeddings.shape) # (3, 768)
|
| 241 |
+
```
|
| 242 |
+
|
| 243 |
+
Benzerlik hesaplama:
|
| 244 |
+
|
| 245 |
+
```python
|
| 246 |
+
import numpy as np
|
| 247 |
+
|
| 248 |
+
sim = embeddings @ embeddings.T # normalize edilmişse cosine == dot
|
| 249 |
+
print(sim)
|
| 250 |
```
|
| 251 |
|
| 252 |
+
### Query/Document modunda (prompt’lu) kullanım
|
| 253 |
+
|
| 254 |
+
EmbeddingGemma ailesi, query/document ayrımı için prompt formatlarını destekler. Bu modelin Pooling konfigürasyonunda `include_prompt=True` olduğu için SentenceTransformers tarafında `encode_query` / `encode_document` kullanımına uygundur.
|
| 255 |
+
|
| 256 |
+
```python
|
| 257 |
+
from sentence_transformers import SentenceTransformer
|
| 258 |
+
|
| 259 |
+
model = SentenceTransformer("alibayram/embeddingmagibu-152m", trust_remote_code=True)
|
| 260 |
|
| 261 |
+
query = "Mars neden kırmızı gezegen olarak bilinir?"
|
| 262 |
+
docs = [
|
| 263 |
+
"Mars, yüzeyindeki demir oksit nedeniyle kırmızı görünür.",
|
| 264 |
+
"Venüs atmosferi çok yoğundur.",
|
| 265 |
+
]
|
| 266 |
|
| 267 |
+
q = model.encode_query(query)
|
| 268 |
+
d = model.encode_document(docs)
|
| 269 |
|
| 270 |
+
scores = model.similarity(q, d)
|
| 271 |
+
print(scores)
|
| 272 |
+
```
|
| 273 |
|
| 274 |
+
### Precision notu
|
| 275 |
|
| 276 |
+
EmbeddingGemma aktivasyonları `float16` ile sorun yaşayabilir; mümkünse `bfloat16` veya `float32` tercih edin.
|
| 277 |
|
| 278 |
+
---
|
|
|
|
| 279 |
|
| 280 |
+
## Export (GGUF / Ollama)
|
|
|
|
| 281 |
|
| 282 |
+
Model, küçük boyutu ve uzun bağlam desteği nedeniyle bf16 formatında GGUF’a dönüştürülüp Ollama üzerinden paylaşılacak şekilde paketlenmiştir.
|
|
|
|
| 283 |
|
| 284 |
+
[Ollama Hub sayfası](https://ollama.com/alibayram/embeddingmagibu-152m)
|
|
|
|
| 285 |
|
| 286 |
+
---
|
|
|
|
| 287 |
|
| 288 |
+
## Kullanım Alanları
|
|
|
|
| 289 |
|
| 290 |
+
- Türkçe semantik arama / RAG indeksleme
|
| 291 |
+
- Türkçe STS / duplicate detection
|
| 292 |
+
- Kümeleme / topic discovery
|
| 293 |
+
- Embedding tabanlı sınıflandırma
|
| 294 |
|
| 295 |
+
## Kapsam Dışı Kullanım
|
| 296 |
|
| 297 |
+
- Bu model bir “chat / instruction-following” LLM olarak hedeflenmemiştir.
|
| 298 |
+
- Güvenlik-kritik kararları tek başına otomatik vermek için tasarlanmamıştır.
|
| 299 |
+
|
| 300 |
+
---
|
| 301 |
+
|
| 302 |
+
## Yanlılıklar ve Sınırlamalar
|
| 303 |
+
|
| 304 |
+
- **Veri kaynaklı önyargılar:** Web verileri kaçınılmaz olarak sosyal/kültürel önyargılar içerebilir.
|
| 305 |
+
- **Alan genellemesi:** Türkçe dış�� dillerde performans düşebilir.
|
| 306 |
+
- **Uzun metinler:** 2048 token’a kadar destek olsa bile çok uzun içeriklerde en iyi sonuç için chunking + pooling stratejileri gerekebilir.
|
| 307 |
+
|
| 308 |
+
---
|
| 309 |
+
|
| 310 |
+
## Model Üretim Hattı
|
| 311 |
+
|
| 312 |
+
Bu çalışmanın üretim hattı:
|
| 313 |
+
|
| 314 |
+
1. Cosmos Türkçe korpustan SentencePiece BPE tokenizer eğit
|
| 315 |
+
2. Teacher EmbeddingGemma’dan `transformer-cloner` ile yeni vocab’e embedding map et ve modeli klonla
|
| 316 |
+
3. `distil-trainer` ile teacher embedding’lerini dataset’e yaz (`teacher_embedding_final`, `teacher_embedding_pre_dense`)
|
| 317 |
+
4. Student’ı bu dataset üzerinden cosine loss ile distill et
|
| 318 |
+
5. STSbTR ve TR-MTEB ile değerlendir
|
| 319 |
+
|
| 320 |
+
---
|
| 321 |
|
| 322 |
## Citation
|
| 323 |
|
| 324 |
+
Eğer bu modeli veya eğitim hattını akademik çalışmada kullanırsanız, aşağıdaki referansları kullanmanız önerilir.
|
| 325 |
|
| 326 |
+
### Bu model
|
|
|
|
| 327 |
|
| 328 |
+
```bibtex
|
| 329 |
+
@misc{embeddingmagibu_152m_2025,
|
| 330 |
+
title={embeddingmagibu-152m: A Turkish-Focused Long-Context Sentence Embedding Model},
|
| 331 |
+
author={Bayram, M. Ali},
|
| 332 |
+
year={2025},
|
| 333 |
+
url={https://huggingface.co/alibayram/embeddingmagibu-152m}
|
| 334 |
+
}
|
| 335 |
+
```
|
| 336 |
|
| 337 |
+
### EmbeddingGemma
|
| 338 |
+
|
| 339 |
+
EmbeddingGemma model kartında verilen BibTeX:
|
| 340 |
+
|
| 341 |
+
```bibtex
|
| 342 |
+
@article{embedding_gemma_2025,
|
| 343 |
+
title={EmbeddingGemma: Powerful and Lightweight Text Representations},
|
| 344 |
+
author={Schechter Vera, Henrique* and Dua, Sahil* and Zhang, Biao and Salz, Daniel and Mullins, Ryan and Raghuram Panyam, Sindhu and others},
|
| 345 |
+
year={2025},
|
| 346 |
+
url={https://arxiv.org/abs/2509.20354}
|
| 347 |
+
}
|
| 348 |
+
```
|
| 349 |
|
| 350 |
+
### distil-trainer
|
| 351 |
+
|
| 352 |
+
PyPI sayfasında önerilen referans:
|
| 353 |
+
|
| 354 |
+
```bibtex
|
| 355 |
+
@software{distil_trainer,
|
| 356 |
+
title = {Distil Trainer: A Comprehensive Knowledge Distillation Framework},
|
| 357 |
+
author = {Bayram, M. Ali},
|
| 358 |
+
year = {2025},
|
| 359 |
+
url = {https://github.com/malibayram/distil-trainer}
|
| 360 |
+
}
|
| 361 |
+
```
|
| 362 |
+
|
| 363 |
+
### transformer-cloner
|
| 364 |
+
|
| 365 |
+
```bibtex
|
| 366 |
+
@software{transformer_cloner,
|
| 367 |
+
title = {Transformer Cloner: Clone and prune transformer models with new tokenizers},
|
| 368 |
+
author = {Bayram, M. Ali},
|
| 369 |
+
year = {2025},
|
| 370 |
+
url = {https://github.com/malibayram/transformer-cloner}
|
| 371 |
+
}
|
| 372 |
+
```
|
| 373 |
+
|
| 374 |
+
### MTEB
|
| 375 |
+
|
| 376 |
+
```bibtex
|
| 377 |
+
@article{muennighoff2022mteb,
|
| 378 |
+
title = {MTEB: Massive Text Embedding Benchmark},
|
| 379 |
+
author = {Muennighoff, Niklas and Tazi, Nouamane and Magne, Loic and Reimers, Nils},
|
| 380 |
+
year = {2022},
|
| 381 |
+
url = {https://arxiv.org/abs/2210.07316}
|
| 382 |
+
}
|
| 383 |
+
```
|
| 384 |
+
|
| 385 |
+
### MTEB-TR
|
| 386 |
+
|
| 387 |
+
```bibtexbibtex
|
| 388 |
+
inproceedings{baysan-gungor-2025-tr,
|
| 389 |
+
title = "{TR}-{MTEB}: A Comprehensive Benchmark and Embedding Model Suite for {T}urkish Sentence Representations",
|
| 390 |
+
author = "Baysan, Mehmet Selman and Gungor, Tunga",
|
| 391 |
+
booktitle = "Findings of the Association for Computational Linguistics: EMNLP 2025",
|
| 392 |
+
month = nov,
|
| 393 |
+
year = "2025",
|
| 394 |
+
publisher = "Association for Computational Linguistics",
|
| 395 |
+
url = "https://aclanthology.org/2025.findings-emnlp.471/",
|
| 396 |
+
doi = "10.18653/v1/2025.findings-emnlp.471",
|
| 397 |
+
pages = "8867--8887",
|
| 398 |
+
ISBN = "979-8-89176-335-7",
|
| 399 |
+
}
|
| 400 |
+
```
|
| 401 |
+
|
| 402 |
+
---
|
| 403 |
|
| 404 |
+
## Model Card Authors / Contact
|
|
|
|
| 405 |
|
| 406 |
+
- Ali Bayram (alibayram)
|
|
|