🚀 旁遮普语SBERT(PunjabiSBERT)
旁遮普语SBERT是在自然语言推理(NLI)数据集上训练的旁遮普语BERT模型(l3cube - pune/punjabi - bert)。它是MahaNLP项目的一部分,项目链接:https://github.com/l3cube - pune/MarathiNLP 。此外,还提供了支持主要印度语言和跨语言能力的多语言版本模型,链接为 indic - sentence - bert - nli 。同时,还有一个更好的句子相似度模型(此模型的微调版本),链接为:https://huggingface.co/l3cube - pune/punjabi - sentence - similarity - sbert 。
🚀 快速开始
示例展示
以下是模型的使用示例:
pipeline_tag: sentence-similarity
tags:
- sentence-transformers
- feature-extraction
- sentence-similarity
- transformers
license: cc-by-4.0
language: pa
widget:
- source_sentence: "ਪੇਂਟਿੰਗ ਮੇਰਾ ਸ਼ੌਕ ਹੈ"
sentences:
- "ਨੱਚਣਾ ਮੇਰਾ ਸ਼ੌਕ ਹੈ"
- "ਮੇਰੇ ਬਹੁਤ ਸਾਰੇ ਸ਼ੌਕ ਹਨ"
- "ਮੈਨੂੰ ਪੇਂਟਿੰਗ ਅਤੇ ਡਾਂਸ ਦੋਵਾਂ ਦਾ ਆਨੰਦ ਆਉਂਦਾ ਹੈ"
example_title: "示例 1"
- source_sentence: "ਕੁਝ ਲੋਕ ਗਾ ਰਹੇ ਹਨ"
sentences:
- "ਲੋਕਾਂ ਦਾ ਇੱਕ ਸਮੂਹ ਗਾ ਰਿਹਾ ਹੈ"
- "ਇੱਕ ਬਿੱਲੀ ਦੁੱਧ ਪੀ ਰਹੀ ਹੈ"
- "ਦੋ ਆਦਮੀ ਲੜ ਰਹੇ ਹਨ"
example_title: "示例 2"
- source_sentence: "ਮੇਰੇ ਘਰ ਵਿੱਚ ਤੁਹਾਡਾ ਸੁਆਗਤ ਹੈ"
sentences:
- "ਮੈਂ ਤੁਹਾਡੇ ਘਰ ਵਿੱਚ ਤੁਹਾਡਾ ਸੁਆਗਤ ਕਰਾਂਗਾ "
- "ਮੇਰਾ ਘਰ ਕਾਫੀ ਵੱਡਾ ਹੈ"
- "ਅੱਜ ਮੇਰੇ ਘਰ ਵਿੱਚ ਰਹੋ"
example_title: "示例 3"
✨ 主要特性
- 基于旁遮普语BERT模型(l3cube - pune/punjabi - bert)训练,适用于旁遮普语句子相似度任务。
- 作为MahaNLP项目的一部分,具有良好的扩展性和可维护性。
- 提供多语言版本和微调版本,满足不同场景需求。
📦 安装指南
若要使用此模型,需要安装 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)
高级用法(不使用sentence - transformers库,使用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)
📚 详细文档
更多关于数据集、模型和基线结果的详细信息,请参考我们的 论文 。
以下是论文的引用信息:
@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。