🚀 inokufu/bertheo-en
このモデルは、sentence-transformers を使用して、コースの文章に対してファインチューニングされたものです。文章や段落を768次元の密ベクトル空間にマッピングし、クラスタリングや意味検索などのタスクに使用できます。
🚀 クイックスタート
このモデルは、コース文章に対してファインチューニングされた sentence-transformers モデルです。文章や段落を768次元の密ベクトル空間にマッピングし、クラスタリングや意味検索などのタスクに使用できます。
✨ 主な機能
- 文章や段落を768次元の密ベクトル空間にマッピングすることができます。
- クラスタリングや意味検索などのタスクに使用できます。
📦 インストール
sentence-transformers をインストールすることで、このモデルを簡単に使用できます。
pip install -U sentence-transformers
💻 使用例
基本的な使用法
from sentence_transformers import SentenceTransformer
sentences = ["Learn to code in python", "Become an expert in accounting"]
model = SentenceTransformer('inokufu/bert-base-uncased-xnli-sts-finetuned-education')
embeddings = model.encode(sentences)
print(embeddings)
高度な使用法
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 = ["Learn to code in python", "Become an expert in accounting"]
tokenizer = AutoTokenizer.from_pretrained('inokufu/bert-base-uncased-xnli-sts-finetuned-education')
model = AutoModel.from_pretrained('inokufu/bert-base-uncased-xnli-sts-finetuned-education')
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)
📚 ドキュメント
詳細
このモデルは、英語の bert-base-uncased 事前学習モデル [1, 2] をベースにしています。
まず、学習オブジェクト (LO) の文章データセットでファインチューニングされました。このデータセットは、コース説明の50万文のサンプルで構成されています。元のBERT論文 [2] で述べられている標準的なパラメータ設定を使用してファインチューニングを行いました。これにより、モデルは特定ドメインの文章に対するターゲットタスク (Masked Language Model) のパフォーマンスを向上させることができます。
次に、自然言語推論タスク (XNLI) [3] でファインチューニングされました。このタスクは、文章間の関係 (矛盾、中立、含意) を認識するようにモデルを学習させるものです。
最後に、テキストの意味的類似性タスク (STSデータ) [4] でファインチューニングされました。このタスクは、2つの文章間の類似性を推定するようにモデルを学習させるものです。
このファインチューニングプロセスにより、モデルはベースモデルよりもはるかに優れた単語の意味表現を持つことができます。
評価結果
STS (en) スコア: 84.61%
モデルアーキテクチャ
SentenceTransformer(
(0): Transformer({'max_seq_length': 512, 'do_lower_case': True}) with Transformer model: BertModel
(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})
)
参考文献
[1] https://huggingface.co/bert-base-uncased
[2] https://arxiv.org/abs/1810.04805
[3] https://arxiv.org/abs/1809.05053
[4] https://huggingface.co/datasets/stsb_multi_mt
情報テーブル
| 属性 | 详情 |
|------|------|
| パイプラインタグ | 文章の類似性 |
| 言語 | 英語 |
| タグ | 文章の類似性、transformers、教育、英語、bert、sentence-transformers、特徴抽出、xnli、stsb_multi_mt |
| データセット | xnli、stsb_multi_mt |