Views
No views yet
1import torch
2from transformers import AutoModel, AutoTokenizer
3
4# Load model
5model = AutoModel.from_pretrained("Basar2004/turkish-sentence-encoder", trust_remote_code=True)
6tokenizer = AutoTokenizer.from_pretrained("Basar2004/turkish-sentence-encoder")
7
8# Encode sentences
9sentences = ["Bugün hava çok güzel.", "Hava bugün oldukça hoş."]
10
11inputs = tokenizer(sentences, padding=True, truncation=True, max_length=64, return_tensors="pt")
12with torch.no_grad():
13 embeddings = model(**inputs)
14
15# Compute similarity
16from torch.nn.functional import cosine_similarity
17similarity = cosine_similarity(embeddings[0].unsqueeze(0), embeddings[1].unsqueeze(0))
18print(f"Similarity: {similarity.item():.4f}")1from sentence_transformers import SentenceTransformer
2
3model = SentenceTransformer("Basar2004/turkish-sentence-encoder")
4embeddings = model.encode(["Merhaba dünya!", "Selam dünya!"])| Metric | Score |
|---|---|
| Spearman Correlation | 0.7315 |
| Pearson Correlation | 0.8593 |
| Paraphrase Accuracy | 0.9695 |
| MRR | 0.9172 |
| Recall@1 | 0.87 |
| Recall@5 | 0.97 |