我正在尝试使用huggingface的模型来实现一个QA系统。我不理解的一件事是,当我没有具体说明我正在使用哪个预先训练好的模型进行问答时,这个模型是随机选择的吗?
from transformers import pipeline
# Allocate a pipeline for question-answering
question_answerer = pipeline('question-answering')
question_answerer({
'question': 'What is the name of the repository ?',
'context': 'Pipeline have been included in the huggingface/transformers repository'
})输出:
{'score': 0.5135612454720828, 'start': 35, 'end': 59, 'answer': 'huggingface/transformers'}
我知道如何通过添加模型的名称(例如,bert-base- one )作为模型参数来指定模型,但是当您没有指定任何内容时,它使用的是哪一个?它在huggingface上使用了所有模型的组合吗?我找不到答案。
发布于 2021-02-03 18:24:18
模型不是随机选择的。流水线中的每个任务都会选择与任务最接近的适当模型。选择一个根据所需任务和数据集的目标进行紧密训练的模型。例如,sentiment-analysis流水线可以选择在SST任务上训练的模型。
同样,对于question-answering,它选择带有distilbert-base-cased-distilled-squad的AutoModelForQuestionAnswering类作为默认模型,因为小队数据集与问答任务相关联。
要获取该列表,可以查看变量SUPPORTED_TASKS here
https://stackoverflow.com/questions/66015068
复制相似问题