🚀 sbert-roberta-large-anli-mnli-snli
このモデルはsentence-transformersを用いたもので、文章や段落を768次元の密ベクトル空間にマッピングし、クラスタリングや意味検索などのタスクに利用できます。
モデルはRoBERTa-largeで重み初期化され、ANLI (Nie et al., 2020)、MNLI (Williams et al., 2018)、およびSNLI (Bowman et al., 2015) を使用して、training_nli.py
のサンプルスクリプトで学習されています。
学習の詳細:
🚀 クイックスタート
📦 インストール
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("usc-isi/sbert-roberta-large-anli-mnli-snli")
embeddings = model.encode(sentences)
print(embeddings)
高度な使用法 (Hugging Face Transformers)
sentence-transformers を使用せずにモデルを使用するには、まず入力をTransformerモデルに通し、その後文脈化された単語埋め込みに対して適切なプーリング操作を適用する必要があります。
import torch
from transformers import AutoModel, AutoTokenizer
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("usc-isi/sbert-roberta-large-anli-mnli-snli")
model = AutoModel.from_pretrained("usc-isi/sbert-roberta-large-anli-mnli-snli")
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)
📚 ドキュメント
評価結果
評価結果については、論文のセクション4.1を参照してください。
モデルのアーキテクチャ
SentenceTransformer(
(0): Transformer({'max_seq_length': 128, 'do_lower_case': False}) with Transformer model: RobertaModel
(1): Pooling({'word_embedding_dimension': 768, 'pooling_mode_cls_token': False, 'pooling_mode_mean_tokens': True, 'pooling_mode_max_tokens': False, 'pooling_mode_mean_sqrt_len_tokens': False})
)
引用と著者
このプロジェクトの詳細については、以下の論文を参照してください。
Ciosici, Manuel, et al. "Machine-Assisted Script Curation." Proceedings of the 2021 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies: Demonstrations, Association for Computational Linguistics, 2021, pp. 8–17. ACLWeb, https://www.aclweb.org/anthology/2021.naacl-demos.2.
参考文献
- Samuel R. Bowman, Gabor Angeli, Christopher Potts, and Christopher D. Manning. 2015. A large annotated corpus for learning natural language inference. In Proceedings of the 2015 Conference on Empirical Methods in Natural Language Processing, pages 632–642, Lisbon, Portugal. Association for Computational Linguistics.
- Yixin Nie, Adina Williams, Emily Dinan, Mohit Bansal, Jason Weston, and Douwe Kiela. 2020. AdversarialNLI: A new benchmark for natural language understanding. In Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics, pages 4885–4901, Online. Association for Computational Linguistics.
- Adina Williams, Nikita Nangia, and Samuel Bowman. 2018. A broad-coverage challenge corpus for sentence understanding through inference. In Proceedings of the 2018 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long Papers), pages 1112–1122, New Orleans, Louisiana. Association for Computational Linguistics.
📄 情報テーブル
属性 |
详情 |
パイプラインタグ |
文章の類似度 |
タグ |
sentence-transformers, feature-extraction, sentence-similarity, transformers |
学習データセット |
anli, multi_nli, snli |