🚀 MixQG (3b规模模型)
MixQG是一个新的问题生成模型,它在包含多种答案类型的问答数据集集合上进行了预训练。该模型在论文MixQG: Neural Question Generation with Mixed Answer Types中被提出,相关代码发布在此仓库中。
🚀 快速开始
如何使用
基础用法
使用Huggingface的pipeline抽象:
from transformers import pipeline
nlp = pipeline("text2text-generation", model='Salesforce/mixqg-3b', tokenizer='Salesforce/mixqg-3b')
CONTEXT = "In the late 17th century, Robert Boyle proved that air is necessary for combustion."
ANSWER = "Robert Boyle"
def format_inputs(context: str, answer: str):
return f"{answer} \\n {context}"
text = format_inputs(CONTEXT, ANSWER)
nlp(text)
高级用法
直接使用预训练模型:
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
tokenizer = AutoTokenizer.from_pretrained('Salesforce/mixqg-3b')
model = AutoModelForSeq2SeqLM.from_pretrained('Salesforce/mixqg-3b')
CONTEXT = "In the late 17th century, Robert Boyle proved that air is necessary for combustion."
ANSWER = "Robert Boyle"
def format_inputs(context: str, answer: str):
return f"{answer} \\n {context}"
text = format_inputs(CONTEXT, ANSWER)
input_ids = tokenizer(text, return_tensors="pt").input_ids
generated_ids = model.generate(input_ids, max_length=32, num_beams=4)
output = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)
print(output)
📚 详细文档
引用
@misc{murakhovska2021mixqg,
title={MixQG: Neural Question Generation with Mixed Answer Types},
author={Lidiya Murakhovs'ka and Chien-Sheng Wu and Tong Niu and Wenhao Liu and Caiming Xiong},
year={2021},
eprint={2110.08175},
archivePrefix={arXiv},
primaryClass={cs.CL}
}
🔧 技术细节
伦理考量
本次发布仅用于支持学术论文的研究目的。我们的模型、数据集和代码并非专门为所有下游用途而设计或评估。我们强烈建议用户在部署此模型之前,评估并解决与准确性、安全性和公平性相关的潜在问题。我们鼓励用户考虑人工智能的常见局限性,遵守适用法律,并在选择用例时采用最佳实践,特别是在错误或滥用可能对人们的生活、权利或安全产生重大影响的高风险场景中。有关用例的进一步指导,请参考我们的可接受使用政策(AUP)和人工智能可接受使用政策(AI AUP)。