我需要编写一个程序(像聊天机器人),它根据问题用户的提问从CSV数据文件中检索答案。因此,例如,如果CSV将产品列表及其规范存储在5-10列中,那么如果用户询问产品X的规范Y的问题,程序应该根据CSV返回正确的答案。我需要使用NLP,因为用户可以编写特定单词的同义词,或者提出与dataset中的关键字略有不同的问题。
我认为我应该使用使用HuggingFace转换器的BERT模型,但我不知道如何使用NLP,因为这是结构化数据。此外,我没有已经生成的问题列表。
有人建议我该怎么做吗。
还有一些规格是价格之类的价值。我在想,如果用户问这个问题,该程序是否有办法返回两个或两个以上产品的平均值或总和。
发布于 2022-06-19 13:15:08
一种有效的方法是使用roberta基地小队2模型,使用您的文本作为上下文,然后提出问题。它应该工作良好,模型可以直接下载。
git lfs install
git clone https://huggingface.co/deepset/roberta-base-squad2下面是使用它的代码摘录:
from transformers import AutoModelForQuestionAnswering, AutoTokenizer, pipeline
model_name = "deepset/roberta-base-squad2"
# a) Get predictions
nlp = pipeline('question-answering', model=model_name, tokenizer=model_name)
QA_input = {
'question': 'Why is model conversion important?',
'context': 'The option to convert models between FARM and transformers gives freedom to the user and let people easily switch between frameworks.'
}
res = nlp(QA_input)
# b) Load model & tokenizer
model = AutoModelForQuestionAnswering.from_pretrained(model_name)
tokenizer = AutoTokenizer.from_pretrained(model_name)您还可以使用以下链接测试Robert 2模型:
您还可以根据数据对模型进行微调:https://github.com/deepset-ai/haystack/blob/master/tutorials/Tutorial2_菲涅图恩_一个_模型_在……上面_你的_data.ipynb。
https://datascience.stackexchange.com/questions/111948
复制相似问题