🚀 upskyy/e5-small-korean
このモデルは、intfloat/multilingual-e5-small を korsts と kornli でファインチューニングしたモデルです。文章や段落を384次元の密ベクトル空間にマッピングし、意味的な文章の類似性、意味検索、パラフレーズマイニング、テキスト分類、クラスタリングなどに使用できます。
🚀 クイックスタート
このモデルは、文章や段落を384次元の密ベクトル空間にマッピングし、様々な自然言語処理タスクに使用できます。以下に、具体的な使用方法を説明します。
✨ 主な機能
- 文章や段落を384次元の密ベクトル空間にマッピングすることができます。
- 意味的な文章の類似性、意味検索、パラフレーズマイニング、テキスト分類、クラスタリングなどのタスクに使用できます。
📦 インストール
まず、Sentence Transformers ライブラリをインストールします。
pip install -U sentence-transformers
💻 使用例
基本的な使用法
from sentence_transformers import SentenceTransformer
model = SentenceTransformer("upskyy/e5-small-korean")
sentences = [
'아이를 가진 엄마가 해변을 걷는다.',
'두 사람이 해변을 걷는다.',
'한 남자가 해변에서 개를 산책시킨다.',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
高度な使用法
Sentence 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 = ["안녕하세요?", "한국어 문장 임베딩을 위한 버트 모델입니다."]
tokenizer = AutoTokenizer.from_pretrained("upskyy/e5-small-korean")
model = AutoModel.from_pretrained("upskyy/e5-small-korean")
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)
📚 ドキュメント
モデルの詳細
モデルの説明
完全なモデルアーキテクチャ
SentenceTransformer(
(0): Transformer({'max_seq_length': 512, 'do_lower_case': False}) with Transformer model: BertModel
(1): Pooling({'word_embedding_dimension': 384, 'pooling_mode_cls_token': False, 'pooling_mode_mean_tokens': True, 'pooling_mode_max_tokens': False, 'pooling_mode_mean_sqrt_len_tokens': False, 'pooling_mode_weightedmean_tokens': False, 'pooling_mode_lasttoken': False, 'include_prompt': True})
)
評価
メトリクス
意味的類似性
メトリクス |
値 |
pearson_cosine |
0.848 |
spearman_cosine |
0.8467 |
pearson_manhattan |
0.8309 |
spearman_manhattan |
0.8373 |
pearson_euclidean |
0.8328 |
spearman_euclidean |
0.8395 |
pearson_dot |
0.8212 |
spearman_dot |
0.8226 |
pearson_max |
0.848 |
spearman_max |
0.8467 |
フレームワークのバージョン
- Python: 3.10.13
- Sentence Transformers: 3.0.1
- Transformers: 4.42.4
- PyTorch: 2.3.0+cu121
- Accelerate: 0.30.1
- Datasets: 2.16.1
- Tokenizers: 0.19.1
🔧 技術詳細
このモデルは、intfloat/multilingual-e5-small を korsts と kornli でファインチューニングしたものです。文章や段落を384次元の密ベクトル空間にマッピングすることができます。
📄 ライセンス
このモデルは MIT ライセンスの下で提供されています。
📖 引用
BibTeX
@article{wang2024multilingual,
title={Multilingual E5 Text Embeddings: A Technical Report},
author={Wang, Liang and Yang, Nan and Huang, Xiaolong and Yang, Linjun and Majumder, Rangan and Wei, Furu},
journal={arXiv preprint arXiv:2402.05672},
year={2024}
}
@inproceedings{reimers-2019-sentence-bert,
title = "Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks",
author = "Reimers, Nils and Gurevych, Iryna",
booktitle = "Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing",
month = "11",
year = "2019",
publisher = "Association for Computational Linguistics",
url = "https://arxiv.org/abs/1908.10084",
}