🚀 MalayalamSBERT
MalayalamSBERT是一個基於馬拉雅拉姆語的模型,它在NLI數據集上對MalayalamBERT模型(l3cube - pune/malayalam - bert)進行了訓練。該模型作為MahaNLP項目的一部分發布,能有效處理句子相似度任務,為馬拉雅拉姆語的語義理解提供支持。
🚀 快速開始
本模型可以通過兩種方式使用,分別是藉助sentence - transformers
庫和HuggingFace Transformers
庫。下面為你詳細介紹使用方法。
📦 安裝指南
若要使用sentence - transformers
庫來調用本模型,你需要先安裝它:
pip install -U 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庫
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)
📚 詳細文檔
- 本模型作為MahaNLP項目的一部分發布,項目鏈接:https://github.com/l3cube - pune/MarathiNLP
- 支持主要印度語言和跨語言能力的多語言版本模型: indic - sentence - bert - nli
- 一個更好的句子相似度模型(本模型的微調版本):https://huggingface.co/l3cube - pune/malayalam - 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}
}
相關論文鏈接
其他單語言印度句子BERT模型
其他單語言相似度模型
📄 許可證
本模型採用CC - BY - 4.0許可證。