🚀 MFAQ
私たちは、MFAQデータセットで学習させた多言語FAQ検索モデルを提供しています。このモデルは、与えられた質問に対して候補となる回答をランク付けします。
🚀 クイックスタート
このモデルは、与えられた質問に対して候補となる回答をランク付けする多言語FAQ検索モデルです。以下にインストール方法と使用例を示します。
✨ 主な機能
- 多言語対応:
cs
, da
, de
, en
, es
, fi
, fr
, he
, hr
, hu
, id
, it
, nl
, no
, pl
, pt
, ro
, ru
, sv
, tr
, vi
の言語に対応。
- 質問に対する回答のランク付け: 与えられた質問に対して候補となる回答をランク付けします。
📦 インストール
pip install sentence-transformers transformers
💻 使用例
基本的な使用法
MFAQは、sentence-transformersまたはHuggingFaceモデルを直接使用して利用できます。どちらの場合も、質問の前に <Q>
を、回答の前に <A>
を付ける必要があります。
Sentence Transformers
from sentence_transformers import SentenceTransformer
question = "<Q>How many models can I host on HuggingFace?"
answer_1 = "<A>All plans come with unlimited private models and datasets."
answer_2 = "<A>AutoNLP is an automatic way to train and deploy state-of-the-art NLP models, seamlessly integrated with the Hugging Face ecosystem."
answer_3 = "<A>Based on how much training data and model variants are created, we send you a compute cost and payment link - as low as $10 per job."
model = SentenceTransformer('clips/mfaq')
embeddings = model.encode([question, answer_1, answer_3, answer_3])
print(embeddings)
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)
question = "<Q>How many models can I host on HuggingFace?"
answer_1 = "<A>All plans come with unlimited private models and datasets."
answer_2 = "<A>AutoNLP is an automatic way to train and deploy state-of-the-art NLP models, seamlessly integrated with the Hugging Face ecosystem."
answer_3 = "<A>Based on how much training data and model variants are created, we send you a compute cost and payment link - as low as $10 per job."
tokenizer = AutoTokenizer.from_pretrained('clips/mfaq')
model = AutoModel.from_pretrained('clips/mfaq')
encoded_input = tokenizer([question, answer_1, answer_3, answer_3], 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'])
📚 ドキュメント
学習
モデルの学習スクリプトはこちらで見つけることができます。
開発者
このモデルは、Maxime De Bruyn、Ehsan Lotfi、Jeska Buhmann、Walter Daelemansによって開発されました。
引用情報
@misc{debruyn2021mfaq,
title={MFAQ: a Multilingual FAQ Dataset},
author={Maxime De Bruyn and Ehsan Lotfi and Jeska Buhmann and Walter Daelemans},
year={2021},
eprint={2109.12870},
archivePrefix={arXiv},
primaryClass={cs.CL}
}
📄 ライセンス
このプロジェクトは、Apache-2.0ライセンスの下で公開されています。
属性 |
详情 |
パイプラインタグ |
文の類似度 |
モデルタイプ |
sentence-transformers、feature-extraction、sentence-similarity、transformers |
学習データ |
clips/mfaq |
言語 |
cs, da, de, en, es, fi, fr, he, hr, hu, id, it, nl, no, pl, pt, ro, ru, sv, tr, vi |