The dataset viewer is not available for this split.
Error code: StreamingRowsError
Exception: CastError
Message: Couldn't cast
magibu: struct<threshold: double, f1: double, precision: double, recall: double, tp: int64, fp: int64, fn: i (... 92 chars omitted)
child 0, threshold: double
child 1, f1: double
child 2, precision: double
child 3, recall: double
child 4, tp: int64
child 5, fp: int64
child 6, fn: int64
child 7, tn: int64
child 8, recall_at_1: double
child 9, recall_at_3: double
child 10, recall_at_5: double
child 11, mrr: double
e5: struct<threshold: double, f1: double, precision: double, recall: double, tp: int64, fp: int64, fn: i (... 92 chars omitted)
child 0, threshold: double
child 1, f1: double
child 2, precision: double
child 3, recall: double
child 4, tp: int64
child 5, fp: int64
child 6, fn: int64
child 7, tn: int64
child 8, recall_at_1: double
child 9, recall_at_3: double
child 10, recall_at_5: double
child 11, mrr: double
id: string
label: string
ground_truth_chunk: string
question: string
to
{'id': Value('string'), 'question': Value('string'), 'label': Value('string'), 'ground_truth_chunk': Value('string')}
because column names don't match
Traceback: Traceback (most recent call last):
File "/src/services/worker/src/worker/utils.py", line 149, in get_rows_or_raise
return get_rows(
dataset=dataset,
...<4 lines>...
column_names=column_names,
)
File "/src/libs/libcommon/src/libcommon/utils.py", line 272, in decorator
return func(*args, **kwargs)
File "/src/services/worker/src/worker/utils.py", line 129, in get_rows
rows_plus_one = list(itertools.islice(safe_iter(ds, dataset=dataset), rows_max_number + 1))
File "/src/services/worker/src/worker/utils.py", line 489, in safe_iter
yield from ds.decode(False) if ds.features else ds
File "/usr/local/lib/python3.14/site-packages/datasets/iterable_dataset.py", line 2818, in __iter__
for key, example in ex_iterable:
^^^^^^^^^^^
File "/usr/local/lib/python3.14/site-packages/datasets/iterable_dataset.py", line 2355, in __iter__
for key, pa_table in self._iter_arrow():
~~~~~~~~~~~~~~~~^^
File "/usr/local/lib/python3.14/site-packages/datasets/iterable_dataset.py", line 2380, in _iter_arrow
for key, pa_table in self.ex_iterable._iter_arrow():
~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
File "/usr/local/lib/python3.14/site-packages/datasets/iterable_dataset.py", line 536, in _iter_arrow
for key, pa_table in iterator:
^^^^^^^^
File "/usr/local/lib/python3.14/site-packages/datasets/iterable_dataset.py", line 419, in _iter_arrow
for key, pa_table in self.generate_tables_fn(**gen_kwags):
~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^
File "/usr/local/lib/python3.14/site-packages/datasets/packaged_modules/json/json.py", line 343, in _generate_tables
self._cast_table(pa_table, json_field_paths=json_field_paths),
~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.14/site-packages/datasets/packaged_modules/json/json.py", line 132, in _cast_table
pa_table = table_cast(pa_table, self.info.features.arrow_schema)
File "/usr/local/lib/python3.14/site-packages/datasets/table.py", line 2369, in table_cast
return cast_table_to_schema(table, schema)
File "/usr/local/lib/python3.14/site-packages/datasets/table.py", line 2297, in cast_table_to_schema
raise CastError(
...<3 lines>...
)
datasets.table.CastError: Couldn't cast
magibu: struct<threshold: double, f1: double, precision: double, recall: double, tp: int64, fp: int64, fn: i (... 92 chars omitted)
child 0, threshold: double
child 1, f1: double
child 2, precision: double
child 3, recall: double
child 4, tp: int64
child 5, fp: int64
child 6, fn: int64
child 7, tn: int64
child 8, recall_at_1: double
child 9, recall_at_3: double
child 10, recall_at_5: double
child 11, mrr: double
e5: struct<threshold: double, f1: double, precision: double, recall: double, tp: int64, fp: int64, fn: i (... 92 chars omitted)
child 0, threshold: double
child 1, f1: double
child 2, precision: double
child 3, recall: double
child 4, tp: int64
child 5, fp: int64
child 6, fn: int64
child 7, tn: int64
child 8, recall_at_1: double
child 9, recall_at_3: double
child 10, recall_at_5: double
child 11, mrr: double
id: string
label: string
ground_truth_chunk: string
question: string
to
{'id': Value('string'), 'question': Value('string'), 'label': Value('string'), 'ground_truth_chunk': Value('string')}
because column names don't matchNeed help to make the dataset viewer work? Make sure to review how to configure the dataset viewer, and open a discussion for direct support.
Turkish Medical RAG — Vektör Arama ve Eşik Yönetimi
Teslim formatı: Hugging Face Dataset Reposu Kapsam: Türkçe tıbbi makaleler üzerinde RAG pipeline'ının retrieval + abstention katmanı.
1. Veri Seti
Kaynak: umutertugrul/turkish-hospital-medical-articles
Seçilen hastaneler: Acıbadem, Memorial, Medicana
Temizlik Akışı
| Adım | Kalan Kayıt |
|---|---|
| Ham makale (3 kaynak) | 13.840 |
| Boilerplate temizliği (471 kalıp) | 13.551 |
| Minimum karakter filtresi (≥300) | 13.516 |
| Exact dedup | 13.275 |
| Near-dup (MinHash LSH, Jaccard ≥ 0.85) | 13.085 |
| Dengeli örnekleme (seed=42) | 400 |
Kaynak dağılımı: Acıbadem 177 · Memorial 158 · Medicana 65
Boilerplate tespiti: Corpus genelinde ≥15 kez tekrar eden satırlar frekans analizi ile otomatik tespit edilip çıkarıldı. Sabit regex yerine veri-güdümlü yaklaşım tercih edildi.
Near-dup: MinHash + LSH ile Jaccard ≥ 0.85 olan çiftlerin yalnızca biri tutuldu.
2. Chunking Stratejisi
Seçilen yöntem: Fixed-token (sabit pencere + overlap)
Parametreler: max_tokens=400 · overlap=64
Neden 400 token?
| Metrik | Değer |
|---|---|
| Median | 1.238 token |
| 95. yüzdelik | 3.289 token |
| Maksimum | 7.462 token |
| 450+ token makale | 380 / 400 (%95) |
Makalelerin %95'i 450 token'ı aşıyor; chunking zorunlu. Benchmark'taki ikinci model ytu-ce-cosmos/turkish-e5-large 512 token limitine sahip. Adil karşılaştırma için her iki modele de sığacak boyut olan 400 token seçildi. Böylece e5'in truncation kayıpları karşılaştırmayı çarpıtmaz.
Overlap = 64 token: Cümle sınırlarında kopan bağlamı korur.
Sonuç: 400 makaleden 1.892 chunk (ort. 4,7 chunk/makale).
3. Embedding Modeli
İki model benchmark edildi:
| Model | Boyut | Context |
|---|---|---|
magibu/embeddingmagibu-200m |
768 | 8.192 token |
ytu-ce-cosmos/turkish-e5-large |
1.024 | 512 token |
Seçim: magibu/embeddingmagibu-200m (768 boyut)
Retrieval metrikleri iki modelde neredeyse özdeş (F1=0.974, Precision=1.000). Tercih gerekçeleri:
- Üretim dayanıklılığı: magibu'nun optimal threshold'u 0.583, e5'inki 0.643. Daha geniş ayrışma bölgesi, threshold ince ayarını kolaylaştırır.
- 8.192 token context: Uzun tıbbi dokümanlar için yapısal avantaj.
- Prompt ayrımı:
prompt_name="document"/prompt_name="query"ayrımı doğru uygulandı.
Normalizasyon: Tüm vektörler L2 normalize edildi; cosine similarity = dot product.
4. Vektör Veritabanı Şeması
Teknoloji: ChromaDB (PersistentClient, hnsw:space: cosine)
| Alan | Tip | Açıklama |
|---|---|---|
chunk_id |
string | Benzersiz kimlik (chunk_00000) |
doc_id |
string | Üst makale kimliği — SHA1(url)[:12] |
url |
string | Orijinal makale URL'i |
title |
string | Makale başlığı |
__source |
string | Kaynak hastane |
chunk_index |
int | Makale içindeki sıra |
chunk_text |
string | Parçalanmış metin |
chunk_vector |
float[] | 768 boyutlu embedding |
Parent-Child: Her chunk doc_id ile üst makaleye bağlıdır; tam bağlam articles_clean.parquet'ten çekilebilir.
5. Test Seti
Toplam: 30 soru (data/test_set.jsonl)
| Tür | Adet | Açıklama |
|---|---|---|
| Pozitif | 20 | Ground-truth chunk_id etiketli |
| Negatif (zor) | 5 | Tıbbi ama veri setinde yok (Parkinson, MS vb.) |
| Negatif (kolay) | 5 | Tamamen alakasız konular |
Zor negatifler threshold'u stres testine tabi tutar; yalnızca kolay negatif kullanmak eşik seçimini yapay olarak kolaylaştırırdı.
6. Eşik (Threshold) Analizi
Yöntem
0–1 arası 200 nokta süpürülerek F1'i maksimize eden eşik veri-güdümlü olarak belirlendi (gözle seçim yapılmadı): for t in linspace(0, 1, 200): f1 = 2precisionrecall / (precision+recall) optimal = argmax(f1)
Sonuç (magibu)
| Metrik | Değer |
|---|---|
| Optimal threshold | 0.583 |
| F1 | 0.974 |
| Precision | 1.000 |
| Recall | 0.950 |
| TP / FP / FN / TN | 19 / 0 / 1 / 10 |
| Recall@1 / @3 / @5 | 0.650 / 0.900 / 0.950 |
| MRR | 0.777 |
Abstention Davranışı
Benzerlik skoru < 0.583 olan sorgularda sistem yanıt üretmez:
"Bu sorunun cevabı dokümanlarımda yer almamaktadır."
10 negatif sorunun tamamı eşiğin altında kaldı → FP = 0, sistem hiç uydurma yapmadı.
7. Model Karşılaştırması
| Metrik | magibu | e5-large |
|---|---|---|
| Threshold | 0.583 | 0.643 |
| F1 | 0.974 | 0.974 |
| Precision | 1.000 | 1.000 |
| Recall | 0.950 | 0.950 |
| Recall@1 | 0.650 | 0.650 |
| Recall@3 | 0.900 | 0.950 |
| Recall@5 | 0.950 | 0.950 |
| MRR | 0.777 | 0.783 |
8. Reprodüksiyon
pip install -r requirements.txt
python -m src.prepare_data --config config.yaml # Faz 1: veri temizligi + ornekleme
python -m src.chunk --config config.yaml # Faz 2: chunking (400 token, 64 overlap)
python -m src.embed_index --config config.yaml # Faz 3: embedding + ChromaDB indeksleme
python -m src.evaluate --config config.yaml # Faz 4: test seti + threshold analizi
Tüm parametreler config.yaml'da, seed=42 sabit. Aynı komutlar aynı çıktıyı üretir.
Kaynak veri: umutertugrul/turkish-hospital-medical-articles
- Downloads last month
- 62