🚀 SciRus-tiny
SciRus-tinyは、ロシア語と英語の科学テキストの埋め込みを取得するためのモデルです。このモデルは、eLibraryのデータを使用し、habrの記事で説明されている対照的な手法で学習されました。ruSciBenchベンチマークで高い指標値を達成しています。
🚀 クイックスタート
💻 使用例
基本的な使用法
from transformers import AutoTokenizer, AutoModel
import torch.nn.functional as F
import torch
tokenizer = AutoTokenizer.from_pretrained("mlsa-iai-msu-lab/sci-rus-tiny")
model = AutoModel.from_pretrained("mlsa-iai-msu-lab/sci-rus-tiny")
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)
def get_sentence_embedding(title, abstract, model, tokenizer, max_length=None):
sentence = '</s>'.join([title, abstract])
encoded_input = tokenizer(
[sentence], padding=True, truncation=True, return_tensors='pt', max_length=max_length).to(model.device)
with torch.no_grad():
model_output = model(**encoded_input)
sentence_embeddings = mean_pooling(model_output, encoded_input['attention_mask'])
sentence_embeddings = F.normalize(sentence_embeddings, p=2, dim=1)
return sentence_embeddings.cpu().detach().numpy()[0]
print(get_sentence_embedding('some title', 'some abstract', model, tokenizer).shape)
高度な使用法
from sentence_transformers import SentenceTransformer
model = SentenceTransformer('mlsa-iai-msu-lab/sci-rus-tiny')
embeddings = model.encode(['some title' + '</s>' + 'some abstract'])
print(embeddings[0].shape)
👥 作者
このベンチマークは、モスクワ大学人工知能研究所のMLSA Labによって開発されました。
🙏 謝辞
この研究は、モスクワ大学のプロジェクト #23 - Ш05 - 21 SES「大量のテキスト科学情報を処理するための機械学習の数学的手法の開発」の一部です。eLibraryに提供されたデータセットに感謝します。
📞 連絡先
Nikolai Gerasimenko (nikgerasimenko@gmail.com), Alexey Vatolin (vatolinalex@gmail.com)
📚 引用
@article{Gerasimenko2024,
author = {Gerasimenko, N. and Vatolin, A. and Ianina, A. and Vorontsov, K.},
title = {SciRus: Tiny and Powerful Multilingual Encoder for Scientific Texts},
journal = {Doklady Mathematics},
year = {2024},
volume = {110},
number = {1},
pages = {S193--S202},
month = {dec},
issn = {1531-8362},
doi = {10.1134/S1064562424602178},
url = {https://doi.org/10.1134/S1064562424602178}
}
📄 ライセンス
このプロジェクトはMITライセンスの下で公開されています。