đ MFAQ
MFAQ is a multilingual FAQ retrieval model. Trained on the MFAQ dataset, it ranks candidate answers according to a given question, offering a practical solution for multilingual FAQ retrieval scenarios.
đ Quick Start
MFAQ is a multilingual FAQ retrieval model. It ranks candidate answers based on a given question, trained on the MFAQ dataset.
⨠Features
- Multilingual Support: Supports multiple languages including Czech, Danish, German, English, etc.
- Based on Popular Frameworks: Can be used with sentence-transformers and HuggingFace Transformers.
đĻ Installation
pip install sentence-transformers transformers
đģ Usage Examples
Basic Usage
You can use MFAQ with sentence-transformers or directly with a HuggingFace model. In both cases, questions need to be prepended with <Q>
, and answers with <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'])
đ Documentation
Training
You can find the training script for the model here.
People
This model was developed by Maxime De Bruyn, Ehsan Lotfi, Jeska Buhmann and Walter Daelemans.
Citation information
@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}
}
đ License
This project is licensed under the Apache 2.0 license.