Run this model with HF Jobs
Run ytu-ce-cosmos/turkish-colbert on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/ytu-ce-cosmos/turkish-colbert. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/ytu-ce-cosmos/turkish-colbert on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Instructions to use ytu-ce-cosmos/turkish-colbert with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use ytu-ce-cosmos/turkish-colbert with sentence-transformers:
from sentence_transformers import MultiVectorEncoder model = MultiVectorEncoder("ytu-ce-cosmos/turkish-colbert") queries = ["Which planet is known as the Red Planet?"] documents = [ "Venus is often called Earth's twin because of its similar size and proximity.", "Mars, known for its reddish appearance, is often referred to as the Red Planet.", "Jupiter, the largest planet in our solar system, has a prominent red spot.", ] query_embeddings = model.encode_query(queries) document_embeddings = model.encode_document(documents) similarities = model.similarity(query_embeddings, document_embeddings) print(similarities) - Notebooks
- Google Colab
- Kaggle
Turkish-ColBERT
This is a Turkish passage retrieval model based on the ColBERT architecture.
The Cosmos Turkish Base BERT model was fine-tuned on 500k triplets (query, positive passage, negative passage) from a Turkish-translated version of the MS MARCO dataset.
⚠ Uncased use requires manual lowercase conversion
Convert your text to lower case as follows:
text.replace("I", "ı").lower()
This is due to a known issue with the tokenizer.
Example Usage
Sentence Transformers
This model can be used with Sentence Transformers as a multi-vector (ColBERT-style late interaction) retriever via the MultiVectorEncoder:
pip install "sentence-transformers>=6.0.0"
from sentence_transformers import MultiVectorEncoder
model = MultiVectorEncoder("ytu-ce-cosmos/turkish-colbert")
query = "Birden fazla Nobel Ödülü alan bilim insanı kimdir?"
documents = [
"Marie Curie, radyoaktivite üzerine yaptığı çalışmalarla bilim dünyasına büyük katkılar sağlamıştır. Polonyum ve radyum elementlerini keşfetmiştir. İki farklı dalda Nobel Ödülü alan ilk kişi olmuştur.",
"Isaac Newton, fizik ve matematik alanında yaptığı çalışmalarla bilinir. Yerçekimi teorisi ve hareket yasaları, bilim dünyasında çığır açmıştır.",
"Albert Einstein, izafiyet teorisini geliştirerek modern fiziğin temellerini atmıştır. 1921 yılında Nobel Fizik Ödülü kazanmıştır.",
"Alexander Fleming, 1928 yılında penisilini keşfederek modern tıpta devrim yaratmıştır. Bu keşfi sayesinde 1945 yılında Nobel Tıp Ödülü kazanmıştır.",
"Nikola Tesla, alternatif akım sistemini geliştirmiştir. Kablosuz enerji aktarımı üzerine projeleriyle tanınır.",
]
# turkish-colbert is trained on lowercased text with Turkish dotless-i handling
query = query.replace("I", "ı").lower()
documents = [doc.replace("I", "ı").lower() for doc in documents]
query_embeddings = model.encode_query(query)
document_embeddings = model.encode_document(documents)
print(query_embeddings.shape, document_embeddings[0].shape)
# (32, 256) (39, 256)
# MaxSim late-interaction scoring (higher is more relevant)
scores = model.similarity(query_embeddings, document_embeddings)
print(scores)
# tensor([[20.8741, 16.5549, 18.2056, 17.7900, 15.1087]])
RAGatouille
!pip install ragatouille
from ragatouille import RAGPretrainedModel
rag = RAGPretrainedModel.from_pretrained("ytu-ce-cosmos/turkish-colbert")
docs = [
"Marie Curie, radyoaktivite üzerine yaptığı çalışmalarla bilim dünyasına büyük katkılar sağlamıştır. Polonyum ve radyum elementlerini keşfetmiştir. İki farklı dalda Nobel Ödülü alan ilk kişi olmuştur.",
"Isaac Newton, fizik ve matematik alanında yaptığı çalışmalarla bilinir. Yerçekimi teorisi ve hareket yasaları, bilim dünyasında çığır açmıştır. Ayrıca, matematiksel analiz üzerinde de önemli katkıları vardır.",
"Albert Einstein, izafiyet teorisini geliştirerek modern fiziğin temellerini atmıştır. 1921 yılında Nobel Fizik Ödülü'nü kazanmıştır. Kütle-enerji eşitliği (E=mc²) onun en ünlü formülüdür.",
"Alexander Fleming, 1928 yılında penisilini keşfederek modern tıpta devrim yaratmıştır. Bu keşfi sayesinde 1945 yılında Nobel Tıp Ödülü kazanmıştır. Fleming'in çalışmaları antibiyotiklerin gelişimine öncülük etmiştir.",
"Nikola Tesla, alternatif akım (AC) sistemini geliştirmiştir. Elektrik mühendisliği alanında devrim niteliğinde çalışmalar yapmıştır. Kablosuz enerji aktarımı üzerine projeleriyle tanınır."
]
docs = [doc.replace("I", "ı").lower() for doc in docs]
rag.index(docs, index_name="sampleTest")
query = "Birden fazla Nobel Ödülü alan bilim insanı kimdir?"
query = query.replace("I", "ı").lower()
results = rag.search(query, k= 1)
print(results[0]['content']) # "marie curie, radyoaktivite üzerine yaptığı çalışmalarla bilim dünyasına büyük katkılar sağlamıştır. polonyum ve radyum elementlerini keşfetmiştir. i̇ki farklı dalda nobel ödülü alan ilk kişi olmuştur."
Evaluation
| Dataset | R@1 | R@5 | R@10 | MRR@10 |
|---|---|---|---|---|
| Scifact-tr | 48.38 | 67.85 | 75.52 | 56.88 |
| WikiRAG-TR | 31.21 | 75.63 | 79.63 | 49.08 |
Acknowledgments
- Research supported with Cloud TPUs from Google's TensorFlow Research Cloud (TFRC). Thanks for providing access to the TFRC ❤️
- Thanks to the generous support from the Hugging Face team, it is possible to download models from their S3 storage 🤗
Citations
@article{kesgin2023developing,
title={Developing and Evaluating Tiny to Medium-Sized Turkish BERT Models},
author={Kesgin, Himmet Toprak and Yuce, Muzaffer Kaan and Amasyali, Mehmet Fatih},
journal={arXiv preprint arXiv:2307.14134},
year={2023}
}
Contact
COSMOS AI Research Group, Yildiz Technical University Computer Engineering Department
https://cosmos.yildiz.edu.tr/
cosmos@yildiz.edu.tr
- Downloads last month
- 132
Model tree for ytu-ce-cosmos/turkish-colbert
Base model
ytu-ce-cosmos/turkish-base-bert-uncased