Downloads · 30 days
18
7% of all-time downloads
sfidan42/turkish_embedding_fine_tuned_a_enc
turkish_embedding_fine_tuned_a_enc is a feature extraction model from sfidan42. Use it when you need embeddings to search or compare text. It is set up for sentence-transformers. The card lists the license as apache-2.0.
Fine-tuned from selmanbaysan/turkishembeddingmodelfinetuned using a dual-encoder (bi-encoder) architecture with in-batch contrastive loss on Turkish QA pairs.
Downloads · 30 days
18
7% of all-time downloads
All-time downloads
261
Public
Parameters
111M
890 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors448 MB · 100%
From the Hugging Face model README
Fine-tuned from selmanbaysan/turkish_embedding_model_fine_tuned using a dual-encoder (bi-encoder) architecture with in-batch contrastive loss on Turkish QA pairs.
| Repo | Role |
|---|---|
sfidan42/turkish_embedding_fine_tuned_q_enc | Query encoder |
sfidan42/turkish_embedding_fine_tuned_a_enc | Answer / passage encoder |
sfidan42/Quora_QA_Turkish_First_Answers, sfidan42/Quora_QA_Turkish_Second_Answerssfidan42/Turkish-QA-Rankedfrom transformers import AutoTokenizer, AutoModel
import torch
tokenizer = AutoTokenizer.from_pretrained("sfidan42/turkish_embedding_fine_tuned_a_enc")
model = AutoModel.from_pretrained("sfidan42/turkish_embedding_fine_tuned_a_enc")
def embed(texts):
enc = tokenizer(texts, padding=True, truncation=True, max_length=128, return_tensors="pt")
with torch.no_grad():
o = model(**enc).last_hidden_state
m = enc["attention_mask"].unsqueeze(-1)
return (o * m).sum(1) / m.sum(1) # mean pooling
query_vec = embed(["Türkiye'nin başkenti neresidir?"])
passage_vec = embed(["Türkiye'nin başkenti Ankara'dır."])
score = torch.nn.functional.cosine_similarity(query_vec, passage_vec)