🚀 TeluguSBERT-STS
這是一個在STS數據集上微調的TeluguSBERT模型(l3cube - pune/telugu - sentence - bert - nli)。
作為MahaNLP項目的一部分發布:https://github.com/l3cube - pune/MarathiNLP
支持主要印度語言和跨語言句子相似度的該模型多語言版本可在此處獲取 indic - sentence - similarity - sbert
有關數據集、模型和基線結果的更多詳細信息可在我們的論文中找到。
@article{deode2023l3cube,
title={L3Cube-IndicSBERT: A simple approach for learning cross-lingual sentence representations using multilingual BERT},
author={Deode, Samruddhi and Gadre, Janhavi and Kajale, Aditi and Joshi, Ananya and Joshi, Raviraj},
journal={arXiv preprint arXiv:2304.11434},
year={2023}
}
@article{joshi2022l3cubemahasbert,
title={L3Cube-MahaSBERT and HindSBERT: Sentence BERT Models and Benchmarking BERT Sentence Representations for Hindi and Marathi},
author={Joshi, Ananya and Kajale, Aditi and Gadre, Janhavi and Deode, Samruddhi and Joshi, Raviraj},
journal={arXiv preprint arXiv:2211.11187},
year={2022}
}
單語言印度SBERT論文
多語言印度SBERT論文
其他單語言相似度模型如下:
馬拉地語相似度
印地語相似度
卡納達語相似度
泰盧固語相似度
馬拉雅拉姆語相似度
泰米爾語相似度
古吉拉特語相似度
奧里亞語相似度
孟加拉語相似度
旁遮普語相似度
印度語相似度(多語言)
其他單語言印度句子BERT模型如下:
馬拉地語SBERT
印地語SBERT
卡納達語SBERT
泰盧固語SBERT
馬拉雅拉姆語SBERT
泰米爾語SBERT
古吉拉特語SBERT
奧里亞語SBERT
孟加拉語SBERT
旁遮普語SBERT
印度語SBERT(多語言)
🚀 快速開始
安裝依賴
若要使用此模型,你需要安裝相關依賴。以下是不同使用方式下的安裝步驟。
📦 安裝指南
使用sentence - transformers庫
當你安裝了sentence - transformers時,使用該模型會變得很簡單,可通過以下命令進行安裝:
pip install -U sentence-transformers
💻 使用示例
使用sentence - transformers庫
安裝好sentence - transformers
後,你可以按以下方式使用模型:
from sentence_transformers import SentenceTransformer
sentences = ["This is an example sentence", "Each sentence is converted"]
model = SentenceTransformer('{MODEL_NAME}')
embeddings = model.encode(sentences)
print(embeddings)
使用HuggingFace Transformers庫
若未安裝sentence - transformers,你可以按以下方式使用模型:首先,將輸入傳遞給transformer模型,然後對上下文詞嵌入應用正確的池化操作。
from transformers import AutoTokenizer, AutoModel
import torch
def mean_pooling(model_output, attention_mask):
token_embeddings = model_output[0]
input_mask_expanded = attention_mask.unsqueeze(-1).expand(token_embeddings.size()).float()
return torch.sum(token_embeddings * input_mask_expanded, 1) / torch.clamp(input_mask_expanded.sum(1), min=1e-9)
sentences = ['This is an example sentence', 'Each sentence is converted']
tokenizer = AutoTokenizer.from_pretrained('{MODEL_NAME}')
model = AutoModel.from_pretrained('{MODEL_NAME}')
encoded_input = tokenizer(sentences, padding=True, truncation=True, return_tensors='pt')
with torch.no_grad():
model_output = model(**encoded_input)
sentence_embeddings = mean_pooling(model_output, encoded_input['attention_mask'])
print("Sentence embeddings:")
print(sentence_embeddings)
📄 許可證
本項目採用CC - BY - 4.0許可證。