CN111782767A - Question and answer method, device, equipment and storage medium - Google Patents

Question and answer method, device, equipment and storage medium Download PDF

Info

Publication number
CN111782767A
CN111782767A CN202010613891.3A CN202010613891A CN111782767A CN 111782767 A CN111782767 A CN 111782767A CN 202010613891 A CN202010613891 A CN 202010613891A CN 111782767 A CN111782767 A CN 111782767A
Authority
CN
China
Prior art keywords
question
vector
information
answer
answer information
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202010613891.3A
Other languages
Chinese (zh)
Other versions
CN111782767B (en
Inventor
李世杰
张子健
陈欢
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shanghai Liangxin Technology Co ltd
Beijing Sankuai Online Technology Co Ltd
Original Assignee
Beijing Sankuai Online Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Sankuai Online Technology Co Ltd filed Critical Beijing Sankuai Online Technology Co Ltd
Priority to CN202010613891.3A priority Critical patent/CN111782767B/en
Publication of CN111782767A publication Critical patent/CN111782767A/en
Application granted granted Critical
Publication of CN111782767B publication Critical patent/CN111782767B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/33Querying
    • G06F16/332Query formulation
    • G06F16/3329Natural language query formulation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/33Querying
    • G06F16/3331Query processing
    • G06F16/334Query execution
    • G06F16/3344Query execution using natural language analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/21Design or setup of recognition systems or techniques; Extraction of features in feature space; Blind source separation
    • G06F18/214Generating training patterns; Bootstrap methods, e.g. bagging or boosting
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/20Natural language analysis
    • G06F40/279Recognition of textual entities
    • G06F40/289Phrasal analysis, e.g. finite state techniques or chunking
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N20/00Machine learning

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • Artificial Intelligence (AREA)
  • General Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • Computational Linguistics (AREA)
  • Mathematical Physics (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Software Systems (AREA)
  • Databases & Information Systems (AREA)
  • Evolutionary Computation (AREA)
  • Bioinformatics & Cheminformatics (AREA)
  • Medical Informatics (AREA)
  • Computing Systems (AREA)
  • Bioinformatics & Computational Biology (AREA)
  • Health & Medical Sciences (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • General Health & Medical Sciences (AREA)
  • Evolutionary Biology (AREA)
  • Human Computer Interaction (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

本申请公开了一种问答方法、装置、设备及存储介质,属于自然语言处理领域。方法包括:调用答案生成模型,根据第一问题信息的第一问题向量和至少一条第二问题向量,获取至少一条答案信息,根据第一问题信息或第一问题向量,在问答数据库中进行检索;调用排序模型,按照与第一问题信息的匹配度从高到低的顺序,对获取到的多条答案信息进行排序,将排在第一位的答案信息确定为目标答案信息。保证了即使在采用检索方式检索不到答案信息的情况下也能生成答案信息,不会出现答案信息缺失的情况,而且也综合考虑了上下文的影响以及答案信息与问题信息的匹配程度,提高了答案信息的准确性。

Figure 202010613891

The present application discloses a question and answer method, apparatus, device and storage medium, which belong to the field of natural language processing. The method includes: calling an answer generation model, obtaining at least one piece of answer information according to the first question vector and at least one second question vector of the first question information, and searching in the question-and-answer database according to the first question information or the first question vector; The sorting model is invoked to sort the obtained multiple pieces of answer information in order of matching degree with the first question information from high to low, and the answer information ranked first is determined as the target answer information. It ensures that the answer information can be generated even if the answer information cannot be retrieved by the retrieval method, and there will be no missing answer information, and the influence of the context and the matching degree of the answer information and the question information are also considered comprehensively. Accuracy of answer information.

Figure 202010613891

Description

问答方法、装置、设备及存储介质Question and answer method, device, equipment and storage medium

技术领域technical field

本申请涉及自然语言处理领域,特别涉及一种问答方法、装置、设备及存储介质。The present application relates to the field of natural language processing, and in particular, to a question answering method, apparatus, device and storage medium.

背景技术Background technique

随着互联网的普及和自然语言处理技术的广泛应用,智能问答功能逐渐兴起,用户输入问题信息后,利用智能问答功能可以自动回答用户的问题,从而与用户进行互动。With the popularization of the Internet and the wide application of natural language processing technology, the intelligent question answering function has gradually emerged. After the user enters the question information, the intelligent question answering function can automatically answer the user's question, thereby interacting with the user.

相关技术中,用户输入问题信息后,获取该问题信息中的关键词,基于获取的关键词,在数据库中检索与该关键词匹配的答案信息,以完成对问题信息的回答。In the related art, after a user inputs question information, a keyword in the question information is acquired, and based on the acquired keyword, answer information matching the keyword is retrieved in a database to complete the answer to the question information.

但是,无法在数据库中检索到匹配的答案信息时,则无法对该问题信息进行回答,因此上述方法具有局限性。However, when the matching answer information cannot be retrieved in the database, the question information cannot be answered, so the above method has limitations.

发明内容SUMMARY OF THE INVENTION

本申请实例提供了一种问答方法、装置、设备及存储介质,提高了获取的答案信息的准确性。所述技术方案如下:The examples of the present application provide a question and answer method, apparatus, device and storage medium, which improve the accuracy of the obtained answer information. The technical solution is as follows:

一方面,提供了一种问答方法,所述方法包括:In one aspect, a question answering method is provided, the method comprising:

获取第一问题信息的第一问题向量和至少一条第二问题信息的第二问题向量,所述至少一条第二问题信息为在所述第一问题信息之前获取的问题信息;acquiring a first question vector of first question information and at least one second question vector of second question information, where the at least one piece of second question information is question information obtained before the first question information;

调用答案生成模型,根据所述第一问题向量和至少一条第二问题向量,获取至少一条答案信息,所述答案生成模型用于根据任一问题向量生成所述任一问题向量匹配的答案信息;Invoke the answer generation model, obtain at least one piece of answer information according to the first question vector and at least one second question vector, and the answer generation model is used to generate the answer information matched by any question vector according to any question vector;

根据所述第一问题信息或所述第一问题向量,在问答数据库中进行检索;According to the first question information or the first question vector, searching in the question answering database;

调用排序模型,按照与所述第一问题信息的匹配度从高到低的顺序,对获取到的多条答案信息进行排序,将排在第一位的答案信息确定为所述目标答案信息。The sorting model is invoked to sort the obtained pieces of answer information in descending order of matching degree with the first question information, and the answer information ranked first is determined as the target answer information.

在一种可能实现方式中,所述方法还包括:In a possible implementation, the method further includes:

获取样本问题信息和对应的样本答案信息,以及所述样本问题信息与所述样本答案信息的样本匹配度;Obtain sample question information and corresponding sample answer information, as well as the sample matching degree between the sample question information and the sample answer information;

根据所述样本问题信息、所述样本答案信息和所述样本匹配度,对所述排序模型进行训练,得到训练后的排序模型。According to the sample question information, the sample answer information and the sample matching degree, the ranking model is trained to obtain a trained ranking model.

在另一种可能实现方式中,所述根据所述样本问题信息、所述样本答案信息和所述样本匹配度,对所述排序模型进行训练,得到训练后的排序模型,包括:In another possible implementation manner, the sorting model is trained according to the sample question information, the sample answer information and the sample matching degree to obtain a trained sorting model, including:

将所述样本问题信息与所述样本答案信息输入至所述排序模型中,获取所述样本问题信息与所述样本答案信息的预测匹配度;inputting the sample question information and the sample answer information into the ranking model, and obtaining the predicted matching degree between the sample question information and the sample answer information;

根据所述样本匹配度和所述预测匹配度,对所述排序模型进行训练,得到训练后的排序模型。According to the sample matching degree and the predicted matching degree, the ranking model is trained to obtain a trained ranking model.

在另一种可能实现方式中,所述排序模型包括多个匹配层、一个融合层和一个排序层,所述调用排序模型,按照与所述第一问题信息的匹配度从高到低的顺序,对获取到的多条答案信息进行排序,将排在第一位的答案信息确定为所述目标答案信息,包括:In another possible implementation manner, the ranking model includes a plurality of matching layers, a fusion layer and a ranking layer, and the ranking model is invoked in descending order of matching degree with the first question information , sort the multiple pieces of obtained answer information, and determine the first answer information as the target answer information, including:

调用所述多个匹配层,分别获取每条答案信息与所述第一问题信息的匹配度;Calling the multiple matching layers to obtain the matching degree of each piece of answer information and the first question information respectively;

调用所述融合层,获取所述每条答案信息的多个匹配度的融合匹配度;Call the fusion layer to obtain the fusion matching degree of the multiple matching degrees of each piece of answer information;

调用所述排序层,按照融合匹配度由高到低的顺序,对所述多条答案信息进行排序,将排在第一位的答案信息确定为所述目标答案信息。The sorting layer is called to sort the multiple pieces of answer information according to the order of fusion matching degree from high to low, and the answer information ranked first is determined as the target answer information.

在另一种可能实现方式中,所述获取第一问题信息的第一问题向量,包括:In another possible implementation manner, the obtaining the first question vector of the first question information includes:

对所述第一问题信息进行分词处理,得到分词后的多个第一词语;Perform word segmentation processing on the first question information to obtain a plurality of first words after word segmentation;

获取所述多个第一词语的相似词语;obtaining similar words of the plurality of first words;

每次将至少一个第一词语替换为对应的相似词语,生成一条相似问题信息;Each time at least one first word is replaced with a corresponding similar word to generate a piece of similar question information;

根据所述第一问题信息和所述至少一条相似问题信息,获取所述第一问题向量。Obtain the first question vector according to the first question information and the at least one piece of similar question information.

在另一种可能实现方式中,所述获取所述多个第一词语的相似词语,包括:In another possible implementation manner, the acquiring similar words of the plurality of first words includes:

从知识数据库中,获取所述多个第一词语中每个第一词语关联的相似词语,所述知识数据库用于存储各个词语与每个词语关联的相似词语;或者,Obtain, from a knowledge database, similar words associated with each of the plurality of first words, where the knowledge database is used to store similar words associated with each word; or,

获取所述多个第一词语中每个第一词语与至少一个预设词语的相似度,将与任一第一词语的相似度大于第一预设相似度的预设词语,作为所述任一第一词语的相似词语。Obtain the similarity between each first word in the plurality of first words and at least one preset word, and use a preset word whose similarity with any first word is greater than the first preset similarity as the arbitrary first word. A similar word to the first word.

在另一种可能实现方式中,所述根据所述第一问题信息和所述至少一条相似问题信息,获取所述第一问题向量,包括:In another possible implementation manner, the obtaining the first question vector according to the first question information and the at least one piece of similar question information includes:

获取所述至少一条相似问题信息的特征向量和所述第一问题信息的特征向量的平均向量,作为所述第一问题向量。An average vector of the feature vector of the at least one piece of similar question information and the feature vector of the first question information is acquired as the first question vector.

在另一种可能实现方式中,所述调用答案生成模型,根据所述第一问题向量和至少一条第二问题向量,获取至少一条答案信息,包括:In another possible implementation manner, the invoking the answer generation model obtains at least one piece of answer information according to the first question vector and at least one second question vector, including:

将所述第一问题向量和所述至少一条第二问题向量进行拼接,得到第三问题向量;splicing the first problem vector and the at least one second problem vector to obtain a third problem vector;

调用所述答案生成模型,根据所述第三问题向量,获取所述至少一条答案信息。The answer generation model is called, and the at least one piece of answer information is acquired according to the third question vector.

在另一种可能实现方式中,所述根据所述第一问题信息或所述第一问题向量,在问答数据库中进行检索,包括:In another possible implementation manner, the retrieval in the question and answer database according to the first question information or the first question vector includes:

将所述第一问题向量和所述至少一条第二问题向量进行拼接,得到第三问题向量;splicing the first problem vector and the at least one second problem vector to obtain a third problem vector;

根据所述第三问题向量与所述问答数据库中的每个预设答案信息的特征向量之间的相似度,获取至少一条答案信息,所述至少一条答案信息的特征向量与所述第三问题向量的相似度大于其他预设答案信息的特征向量与所述第三问题向量的相似度。According to the similarity between the third question vector and the feature vector of each preset answer information in the question answering database, at least one piece of answer information is obtained, and the feature vector of the at least one piece of answer information is related to the third question The similarity of the vectors is greater than the similarity between the feature vectors of other preset answer information and the third question vector.

在另一种可能实现方式中,所述至少一条第二问题向量包括多条第二问题向量,所述调用答案生成模型,根据所述第一问题向量和至少一条第二问题向量,获取至少一条答案信息,包括:In another possible implementation manner, the at least one second question vector includes multiple second question vectors, and the answer generation model is invoked to obtain at least one second question vector according to the first question vector and the at least one second question vector Answer information, including:

对所述多条第二问题向量进行加权平均,得到第四问题向量;performing a weighted average on the plurality of second problem vectors to obtain a fourth problem vector;

将所述第一问题向量和所述第四问题向量进行拼接,得到融合问题向量;Splicing the first problem vector and the fourth problem vector to obtain a fusion problem vector;

根据所述融合问题向量,调用所述答案生成模型,获取所述至少一条答案信息。According to the fusion question vector, the answer generation model is called to obtain the at least one piece of answer information.

在另一种可能实现方式中,所述根据所述第一问题信息或所述第一问题向量,在问答数据库中进行检索,包括:In another possible implementation manner, the retrieval in the question and answer database according to the first question information or the first question vector includes:

对所述多个第二问题向量进行加权平均,得到第四问题向量;performing a weighted average on the plurality of second problem vectors to obtain a fourth problem vector;

将所述第一问题向量和所述第四问题向量进行拼接,得到融合问题向量;Splicing the first problem vector and the fourth problem vector to obtain a fusion problem vector;

根据所述融合问题向量与所述问答数据库中的每个预设答案信息的特征向量之间的相似度,获取至少一条答案信息,所述至少一条答案信息的特征向量与所述融合问题向量的相似度大于其他预设答案信息的特征向量与所述融合问题向量的相似度。At least one piece of answer information is obtained according to the similarity between the fusion question vector and the feature vector of each preset answer information in the question answering database, and the feature vector of the at least one piece of answer information is the difference between the fusion question vector and the fusion question vector. The similarity is greater than the similarity between the feature vector of other preset answer information and the fusion question vector.

在另一种可能实现方式中,所述根据所述第一问题信息或所述第一问题向量,在问答数据库中进行检索,包括:In another possible implementation manner, the retrieval in the question and answer database according to the first question information or the first question vector includes:

根据所述第一问题向量,在所述问答数据库中进行检索,确定至少一条第五问题向量,所述至少一条第五问题向量包括所述第一问题向量相似的问题向量;或者,According to the first question vector, perform retrieval in the question answering database to determine at least one fifth question vector, where the at least one fifth question vector includes question vectors similar to the first question vector; or,

根据所述第一问题向量和所述至少一条第二问题向量,在所述问答数据库中进行检索,确定至少一条第五问题向量,所述至少一条第五问题向量包括所述第一问题向量相似的问题向量或所述至少一条第二问题向量相似的问题向量中的至少一种;According to the first question vector and the at least one second question vector, perform retrieval in the question answering database to determine at least one fifth question vector, the at least one fifth question vector including the first question vector is similar At least one of the problem vectors of or the problem vectors that are similar to the at least one second problem vector;

从所述问答数据库中,获取所述至少一条第五问题向量的答案信息,作为所述至少一条答案信息。From the question and answer database, the answer information of the at least one fifth question vector is obtained as the at least one piece of answer information.

在另一种可能实现方式中,所述根据所述第一问题信息或所述第一问题向量,在问答数据库中进行检索,包括:In another possible implementation manner, the retrieval in the question and answer database according to the first question information or the first question vector includes:

根据所述第一问题向量与所述问答数据库中的每个预设答案信息的特征向量之间的相似度,获取所述至少一条答案信息,所述至少一条答案信息的特征向量与所述第一问题向量的相似度大于其他预设答案信息的特征向量与所述第一问题向量的相似度。The at least one piece of answer information is acquired according to the similarity between the first question vector and the feature vector of each preset answer information in the question answering database, and the feature vector of the at least one piece of answer information is the same as the first piece of answer information. The similarity of a question vector is greater than the similarity between the feature vectors of other preset answer information and the first question vector.

在另一种可能实现方式中,所述根据所述第一问题信息或所述第一问题向量,在问答数据库中进行检索,包括:In another possible implementation manner, the retrieval in the question and answer database according to the first question information or the first question vector includes:

对所述第一问题信息进行分词处理,得到所述第一问题信息的关键词或实体;Perform word segmentation processing on the first question information to obtain keywords or entities of the first question information;

对所述问答数据库中预设答案信息进行分词处理,得到所述预设答案信息的关键词或实体;Perform word segmentation processing on the preset answer information in the question and answer database to obtain keywords or entities of the preset answer information;

根据所述第一问题信息的关键词或实体,以及所述问答数据库中预设答案信息的关键词或实体,获取至少一条答案信息。At least one piece of answer information is acquired according to the keywords or entities of the first question information and the keywords or entities of the preset answer information in the question-and-answer database.

另一方面,提供了一种问答装置,所述装置包括:In another aspect, a question and answer device is provided, the device comprising:

获取模块,用于获取第一问题信息的第一问题向量和至少一条第二问题信息的第二问题向量,所述至少一条第二问题信息为在所述第一问题信息之前获取的问题信息;an acquisition module, configured to acquire the first question vector of the first question information and the second question vector of at least one piece of second question information, where the at least one piece of second question information is the question information acquired before the first question information;

生成模块,用于调用答案生成模型,根据所述第一问题向量和至少一条第二问题向量,获取至少一条答案信息,所述答案生成模型用于根据任一问题向量生成所述任一问题向量匹配的答案信息;The generation module is used to call the answer generation model to obtain at least one piece of answer information according to the first question vector and at least one second question vector, and the answer generation model is used to generate the any question vector according to any question vector matching answer information;

检索模块,用于根据所述第一问题信息或所述第一问题向量,在问答数据库中进行检索;a retrieval module, configured to perform retrieval in the question and answer database according to the first question information or the first question vector;

排序模块,用于调用排序模型,按照与所述第一问题信息的匹配度从高到低的顺序,对获取到的多条答案信息进行排序,将排在第一位的答案信息确定为所述目标答案信息。The sorting module is used to call the sorting model, sort the obtained multiple pieces of answer information in the order of matching degree with the first question information from high to low, and determine the answer information ranked first as the Describe the target answer information.

在一种可能实现方式中,所述装置还包括:In a possible implementation, the apparatus further includes:

所述获取模块,用于获取样本问题信息和对应的样本答案信息,以及所述样本问题信息与所述样本答案信息的样本匹配度;the obtaining module, configured to obtain sample question information and corresponding sample answer information, and a sample matching degree between the sample question information and the sample answer information;

训练模块,用于根据所述样本问题信息、所述样本答案信息和所述样本匹配度,对所述排序模型进行训练,得到训练后的排序模型。A training module, configured to train the ranking model according to the sample question information, the sample answer information and the sample matching degree to obtain a trained ranking model.

在另一种可能实现方式中,所述训练模块,包括:In another possible implementation, the training module includes:

输入单元,用于将所述样本问题信息与所述样本答案信息输入至所述排序模型中,获取所述样本问题信息与所述样本答案信息的预测匹配度;an input unit, configured to input the sample question information and the sample answer information into the ranking model, and obtain the predicted matching degree between the sample question information and the sample answer information;

训练单元,用于根据所述样本匹配度和所述预测匹配度,对所述排序模型进行训练,得到训练后的排序模型。A training unit, configured to train the ranking model according to the sample matching degree and the predicted matching degree to obtain a trained ranking model.

在另一种可能实现方式中,所述排序模型包括多个匹配层、一个融合层和一个排序层,所述生成模块,包括:In another possible implementation, the ranking model includes multiple matching layers, a fusion layer and a ranking layer, and the generation module includes:

匹配度获取单元,用于调用所述多个匹配层,分别获取每条答案信息与所述第一问题信息的匹配度;a matching degree obtaining unit, configured to invoke the multiple matching layers to obtain the matching degree of each piece of answer information and the first question information respectively;

融合单元,用于调用所述融合层,获取每条答案信息的多个匹配度的融合匹配度;a fusion unit, used for calling the fusion layer to obtain a fusion matching degree of multiple matching degrees of each piece of answer information;

排序单元,用于调用所述排序层,按照融合匹配度由高到低的顺序,对所述多条答案信息进行排序,将排在第一位的答案信息确定为所述目标答案信息。The sorting unit is used for invoking the sorting layer, sorting the multiple pieces of answer information according to the order of fusion matching degree from high to low, and determining the answer information ranked first as the target answer information.

在另一种可能实现方式中,所述获取模块,用于执行以下任一项:In another possible implementation manner, the obtaining module is configured to execute any one of the following:

对所述第一问题信息进行分词处理,得到分词后的多个第一词语;Perform word segmentation processing on the first question information to obtain a plurality of first words after word segmentation;

获取所述多个第一词语的相似词语;obtaining similar words of the plurality of first words;

每次将至少一个第一词语替换为对应的相似词语,生成一条相似问题信息;Each time at least one first word is replaced with a corresponding similar word to generate a piece of similar question information;

根据所述第一问题信息和所述至少一条相似问题信息,获取所述第一问题向量。Obtain the first question vector according to the first question information and the at least one piece of similar question information.

在另一种可能实现方式中,所述获取模块,用于执行以下任一项:In another possible implementation manner, the obtaining module is configured to execute any one of the following:

从知识数据库中,获取所述多个第一词语中每个第一词语关联的相似词语,所述知识数据库用于存储各个词语与每个词语关联的相似词语;或者,Obtain, from a knowledge database, similar words associated with each of the plurality of first words, where the knowledge database is used to store similar words associated with each word; or,

获取所述多个第一词语中每个第一词语与至少一个预设词语的相似度,将与任一第一词语的相似度大于第一预设相似度的预设词语,作为所述任一第一词语的相似词语。Obtain the similarity between each first word in the plurality of first words and at least one preset word, and use a preset word whose similarity with any first word is greater than the first preset similarity as the arbitrary first word. A similar word to the first word.

在另一种可能实现方式中,所述获取模块,用于获取所述至少一条相似问题信息的特征向量和所述第一问题信息的特征向量的平均向量,作为所述第一问题向量。In another possible implementation manner, the obtaining module is configured to obtain an average vector of the feature vector of the at least one piece of similar question information and the feature vector of the first question information, as the first question vector.

在另一种可能实现方式中,所述生成模块,用于执行以下任一项:In another possible implementation manner, the generating module is configured to execute any one of the following:

将所述第一问题向量和所述至少一条第二问题向量进行拼接,得到第三问题向量;splicing the first problem vector and the at least one second problem vector to obtain a third problem vector;

调用所述答案生成模型,根据所述第三问题向量,获取所述至少一条答案信息。The answer generation model is called, and the at least one piece of answer information is acquired according to the third question vector.

在另一种可能实现方式中,所述检索模块,用于执行以下任一项:In another possible implementation manner, the retrieval module is configured to perform any one of the following:

将所述第一问题向量和所述至少一条第二问题向量进行拼接,得到第三问题向量;splicing the first problem vector and the at least one second problem vector to obtain a third problem vector;

根据所述第三问题向量与所述问答数据库中的每个预设答案信息的特征向量之间的相似度,获取至少一条答案信息,所述至少一条答案信息的特征向量与所述第三问题向量的相似度大于其他预设答案信息的特征向量与所述第三问题向量的相似度。According to the similarity between the third question vector and the feature vector of each preset answer information in the question answering database, at least one piece of answer information is obtained, and the feature vector of the at least one piece of answer information is related to the third question The similarity of the vectors is greater than the similarity between the feature vectors of other preset answer information and the third question vector.

在另一种可能实现方式中,所述至少一条第二问题向量包括多条第二问题向量,所述生成模块,用于执行以下任一项:In another possible implementation manner, the at least one second problem vector includes a plurality of second problem vectors, and the generating module is configured to perform any one of the following:

对所述多条第二问题向量进行加权平均,得到第四问题向量;performing a weighted average on the plurality of second problem vectors to obtain a fourth problem vector;

将所述第一问题向量和所述第四问题向量进行拼接,得到融合问题向量;Splicing the first problem vector and the fourth problem vector to obtain a fusion problem vector;

根据所述融合问题向量,调用所述答案生成模型,获取所述至少一条答案信息。According to the fusion question vector, the answer generation model is called to obtain the at least one piece of answer information.

在另一种可能实现方式中,所述检索模块,用于执行以下任一项:In another possible implementation manner, the retrieval module is configured to perform any one of the following:

对所述多个第二问题向量进行加权平均,得到第四问题向量;performing a weighted average on the plurality of second problem vectors to obtain a fourth problem vector;

将所述第一问题向量和所述第四问题向量进行拼接,得到融合问题向量;Splicing the first problem vector and the fourth problem vector to obtain a fusion problem vector;

根据所述融合问题向量与所述问答数据库中的每个预设答案信息的特征向量之间的相似度,获取至少一条答案信息,所述至少一条答案信息的特征向量与所述融合问题向量的相似度大于其他预设答案信息的特征向量与所述融合问题向量的相似度。At least one piece of answer information is obtained according to the similarity between the fusion question vector and the feature vector of each preset answer information in the question answering database, and the feature vector of the at least one piece of answer information is the difference between the fusion question vector and the fusion question vector. The similarity is greater than the similarity between the feature vector of other preset answer information and the fusion question vector.

在另一种可能实现方式中,所述检索模块,用于执行以下任一项:In another possible implementation manner, the retrieval module is configured to perform any one of the following:

根据所述第一问题向量,在所述问答数据库中进行检索,确定至少一条第五问题向量,所述至少一条第五问题向量包括所述第一问题向量相似的问题向量;或者,According to the first question vector, perform retrieval in the question answering database to determine at least one fifth question vector, where the at least one fifth question vector includes question vectors similar to the first question vector; or,

根据所述第一问题向量和所述至少一条第二问题向量,在所述问答数据库中进行检索,确定至少一条第四问题向量,所述至少一条第四问题向量包括所述第一问题向量相似的问题向量或所述至少一条第二问题向量相似的问题向量中的至少一种;According to the first question vector and the at least one second question vector, searching in the question answering database to determine at least one fourth question vector, the at least one fourth question vector including the first question vector is similar At least one of the problem vectors of or the problem vectors that are similar to the at least one second problem vector;

从所述问答数据库中,获取所述至少一条第四问题向量的答案信息,作为所述至少一条答案信息。From the question and answer database, the answer information of the at least one fourth question vector is obtained as the at least one piece of answer information.

在另一种可能实现方式中,所述检索模块,用于执行以下任一项:In another possible implementation manner, the retrieval module is configured to perform any one of the following:

对所述第一问题信息进行分词处理,得到所述第一问题信息的关键词或实体;Perform word segmentation processing on the first question information to obtain keywords or entities of the first question information;

对所述问答数据库中预设答案信息进行分词处理,得到所述预设答案信息的关键词或实体;Perform word segmentation processing on the preset answer information in the question and answer database to obtain keywords or entities of the preset answer information;

根据所述第一问题信息的关键词或实体,以及所述问答数据库中预设答案信息的关键词或实体,获取至少一条答案信息。At least one piece of answer information is acquired according to the keywords or entities of the first question information and the keywords or entities of the preset answer information in the question-and-answer database.

另一方面,提供了一种电子设备,所述电子设备包括一个或多个处理器和一个或多个存储器,所述一个或多个存储器中存储有至少一条指令,所述至少一条指令由所述一个或多个处理器加载并执行以实现如所述问答方法所执行的操作。In another aspect, an electronic device is provided, the electronic device comprising one or more processors and one or more memories, the one or more memories having at least one instruction stored therein, the at least one instruction being The one or more processors are loaded and executed to implement operations as performed by the question answering method.

另一方面,提供了一种计算机可读存储介质,所述存储介质中存储有至少一条指令,所述至少一条指令由处理器加载并执行以实现如所述的问答方法所执行的操作。In another aspect, there is provided a computer-readable storage medium having stored therein at least one instruction, the at least one instruction being loaded and executed by a processor to implement operations performed by the question-and-answer method as described.

本申请实施例提供的问答方法、装置、设备及存储介质,采用了基于模型自动生成的方式和检索方式来获取答案信息,再调用排序模型,按照答案信息与问题信息的匹配度对获取的多条答案信息进行排序,获取排在第一位的答案信息,即为与第一问题信息最为匹配的答案信息,保证了即使在采用检索方式检索不到答案信息的情况下也能生成答案信息,不会出现答案信息缺失的情况,而且也综合考虑了上下文的影响以及答案信息与问题信息的匹配程度,提高了答案信息的准确性。The question and answer method, device, device, and storage medium provided by the embodiments of the present application adopt the method of automatic generation and retrieval based on the model to obtain answer information, and then call the sorting model, according to the matching degree between the answer information and the question information. The answer information is sorted, and the answer information in the first place is obtained, which is the answer information that best matches the first question information, which ensures that the answer information can be generated even if the answer information cannot be retrieved by the retrieval method. There is no situation where the answer information is missing, and the influence of the context and the degree of matching between the answer information and the question information are comprehensively considered, and the accuracy of the answer information is improved.

附图说明Description of drawings

为了更清楚地说明本申请实施例中的技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to illustrate the technical solutions in the embodiments of the present application more clearly, the following briefly introduces the drawings that are used in the description of the embodiments. Obviously, the drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, other drawings can also be obtained from these drawings without creative effort.

图1是本申请实施例提供的一种实施环境的结构示意图;1 is a schematic structural diagram of an implementation environment provided by an embodiment of the present application;

图2是本申请实施例提供的一种问答方法的流程图;2 is a flowchart of a question-and-answer method provided by an embodiment of the present application;

图3是本申请实施例提供的一种问答方法的流程图;3 is a flowchart of a question and answer method provided by an embodiment of the present application;

图4是本申请实施例提供的一种答案生成模型的框图;4 is a block diagram of an answer generation model provided by an embodiment of the present application;

图5是本申请实施例提供的一种检索答案信息的框图;5 is a block diagram of a retrieval answer information provided by an embodiment of the present application;

图6是本申请实施例提供的一种排序模型进行排序的框图;6 is a block diagram of sorting by a sorting model provided by an embodiment of the present application;

图7是本申请实施例提供的一种确定答案的框图;7 is a block diagram of a determination answer provided by an embodiment of the present application;

图8是本申请实施例提供的一种输入模块所执行操作的框图;8 is a block diagram of operations performed by an input module provided by an embodiment of the present application;

图9是本申请实施例提供的一种问答装置的结构示意图;9 is a schematic structural diagram of a question and answer device provided by an embodiment of the present application;

图10是本申请实施例提供的一种问答装置的结构示意图;10 is a schematic structural diagram of a question and answer device provided by an embodiment of the present application;

图11是本申请实施例提供的一种终端的结构示意图;FIG. 11 is a schematic structural diagram of a terminal provided by an embodiment of the present application;

图12是本申请实施例提供的一种服务器的结构示意图。FIG. 12 is a schematic structural diagram of a server provided by an embodiment of the present application.

具体实施方式Detailed ways

为使本申请的目的、技术方案和优点更加清楚,下面将结合附图对本申请实施方式作进一步地详细描述。In order to make the objectives, technical solutions and advantages of the present application clearer, the embodiments of the present application will be further described in detail below with reference to the accompanying drawings.

本申请提供的问答方法,可以在线上自动为用户提问的问题提供答案,提高了对问题进行回答的准确性,且可以应用于多种场景下:The question-and-answer method provided by this application can automatically provide answers to the questions asked by users online, improve the accuracy of answering questions, and can be applied in various scenarios:

例如,本申请提供的问答方法,应用于智能客服场景中,在用户使用任一应用程序时,该任一应用程序可以为用户提供客服问答功能的服务,用户可以在该应用程序中输入问题信息,当应用程序检测到用户输入的问题信息后,然后采用本申请实施例提供的问答方法,根据该问题信息,确定出匹配的答案,供用户查看确定出的答案。For example, the question-and-answer method provided in this application is applied in an intelligent customer service scenario. When a user uses any application, the application can provide the user with the service of the customer service Q&A function, and the user can enter question information in the application. , when the application detects the question information input by the user, and then adopts the question-and-answer method provided by the embodiment of the present application to determine a matching answer according to the question information, so that the user can view the determined answer.

或者,本申请提供的问答方法,应用于娱乐互动场景中,当用户需要进行娱乐时,可以与智能机器人进行互动交流,用户可以向智能机器人输入问题信息,然后采用本申请实施例提供的问答方法,根据用户输入的问题信息,确定出匹配的答案,然后再向用户回复该答案,进而与用户进行互动。Alternatively, the question-and-answer method provided by the present application is applied in an entertainment interaction scenario. When the user needs to have entertainment, he can interact with the intelligent robot, and the user can input question information to the intelligent robot, and then use the question-and-answer method provided by the embodiment of the present application. , according to the question information input by the user, determine the matching answer, and then reply the answer to the user, and then interact with the user.

另外,本申请实施例提供的方法应用于电子设备中,该电子设备可以包括终端,还可以包括服务器。In addition, the method provided by the embodiment of the present application is applied to an electronic device, and the electronic device may include a terminal, and may also include a server.

当电子设备包括终端时,本申请实施例提供的方法由终端执行。When the electronic device includes a terminal, the methods provided by the embodiments of the present application are executed by the terminal.

或者,图1示出了本申请实施例的实施环境结构示意图,参见图1,当电子设备包括终端101和服务器102时,终端101与服务器102之间通过通信网络连接,当终端101获取第一问题信息后,通过通信网络将该第一问题信息发送给服务器102,服务器102根据本申请实施例提供的方法,确定目标答案信息,然后再将目标答案信息反馈给终端101,用户即可通过终端101查看该目标问题信息。Alternatively, FIG. 1 shows a schematic structural diagram of an implementation environment of an embodiment of the present application. Referring to FIG. 1 , when the electronic device includes a terminal 101 and a server 102, the terminal 101 and the server 102 are connected through a communication network, and when the terminal 101 obtains the first After the question information, the first question information is sent to the server 102 through the communication network, the server 102 determines the target answer information according to the method provided by the embodiment of the present application, and then feeds back the target answer information to the terminal 101, and the user can pass the terminal 101 View the target problem information.

其中,该终端可以为手机、平板电脑、计算机等多种类型的终端,该服务器可以为一台服务器、或者由若干服务器组成的服务器集群,或者是一个云计算服务中心。Wherein, the terminal may be a mobile phone, a tablet computer, a computer and other types of terminals, and the server may be a server, a server cluster composed of several servers, or a cloud computing service center.

图2是本申请实施例提供的一种问答方法的流程图,参见图2,该方法包括:FIG. 2 is a flowchart of a question and answer method provided by an embodiment of the present application. Referring to FIG. 2 , the method includes:

201、获取第一问题信息的第一问题向量和至少一条第二问题信息的第二问题向量。201. Acquire a first question vector of first question information and a second question vector of at least one piece of second question information.

其中,至少一条第二问题信息为在第一问题信息之前获取的问题信息。Wherein, at least one piece of second question information is question information obtained before the first question information.

202、调用答案生成模型,根据第一问题向量和至少一条第二问题向量,获取至少一条答案信息。202. Call the answer generation model, and obtain at least one piece of answer information according to the first question vector and at least one second question vector.

其中,答案生成模型用于根据任一问题向量生成任一问题向量匹配的答案信息。The answer generation model is used to generate answer information matched by any question vector according to any question vector.

203、根据第一问题信息或第一问题向量,在问答数据库中进行检索。203. Search in the question answering database according to the first question information or the first question vector.

204、调用排序模型,按照与第一问题信息的匹配度从高到低的顺序,对获取到的多条答案信息进行排序,将排在第一位的答案信息确定为目标答案信息。204. Invoke the sorting model, sort the obtained multiple pieces of answer information in order of matching degree with the first question information from high to low, and determine the answer information ranked first as the target answer information.

本申请实施例提供的方法,采用了基于模型自动生成的方式和检索方式来获取答案信息,再调用排序模型,按照答案信息与问题信息的匹配度对获取的多条答案信息进行排序,获取排在第一位的答案信息,即为与第一问题信息最为匹配的答案信息,保证了即使在采用检索方式检索不到答案信息的情况下也能生成答案信息,不会出现答案信息缺失的情况,而且也综合考虑了上下文的影响以及答案信息与问题信息的匹配程度,提高了答案信息的准确性。The method provided by the embodiment of the present application adopts the method of automatic generation and retrieval based on the model to obtain the answer information, and then invokes the sorting model to sort the obtained multiple pieces of answer information according to the matching degree between the answer information and the question information, and obtain the ranking. The answer information in the first place is the answer information that best matches the first question information, which ensures that the answer information can be generated even if the answer information cannot be retrieved by the retrieval method, and there will be no missing answer information. , and also comprehensively considers the influence of context and the degree of matching between answer information and question information, which improves the accuracy of answer information.

在一种可能实现方式中,方法还包括:In one possible implementation, the method further includes:

获取样本问题信息和对应的样本答案信息,以及样本问题信息与样本答案信息的样本匹配度;Obtain the sample question information and the corresponding sample answer information, as well as the sample matching degree between the sample question information and the sample answer information;

根据样本问题信息、样本答案信息和样本匹配度,对排序模型进行训练,得到训练后的排序模型。According to the sample question information, sample answer information and sample matching degree, the ranking model is trained to obtain the trained ranking model.

在另一种可能实现方式中,根据样本问题信息、样本答案信息和样本匹配度,对排序模型进行训练,得到训练后的排序模型,包括:In another possible implementation, the sorting model is trained according to the sample question information, the sample answer information and the sample matching degree, and the trained sorting model is obtained, including:

将样本问题信息与样本答案信息输入至排序模型中,获取样本问题信息与样本答案信息的预测匹配度;Input the sample question information and sample answer information into the ranking model, and obtain the predicted matching degree between the sample question information and the sample answer information;

根据样本匹配度和预测匹配度,对排序模型进行训练,得到训练后的排序模型。According to the sample matching degree and the predicted matching degree, the sorting model is trained, and the trained sorting model is obtained.

在另一种可能实现方式中,排序模型包括多个匹配层、一个融合层和一个排序层,调用排序模型,按照与第一问题信息的匹配度从高到低的顺序,对获取到的多条答案信息进行排序,将排在第一位的答案信息确定为目标答案信息,包括:In another possible implementation manner, the ranking model includes multiple matching layers, a fusion layer, and a ranking layer, and the ranking model is called, and according to the order of matching degree with the first question information from high to low, the obtained more The answer information is sorted, and the first answer information is determined as the target answer information, including:

调用多个匹配层,分别获取每条答案信息与第一问题信息的匹配度;Call multiple matching layers to obtain the matching degree of each answer information and the first question information respectively;

调用融合层,获取每条答案信息的多个匹配度的融合匹配度;Call the fusion layer to obtain the fusion matching degree of multiple matching degrees of each answer information;

调用排序层,按照融合匹配度由高到低的顺序,对多条答案信息进行排序,将排在第一位的答案信息确定为目标答案信息。The sorting layer is called to sort multiple pieces of answer information according to the order of fusion matching degree from high to low, and the answer information ranked first is determined as the target answer information.

在另一种可能实现方式中,获取第一问题信息的第一问题向量,包括:In another possible implementation manner, acquiring the first question vector of the first question information includes:

对第一问题信息进行分词处理,得到分词后的多个第一词语;Perform word segmentation processing on the first question information to obtain a plurality of first words after word segmentation;

获取多个第一词语的相似词语;Obtain similar words of multiple first words;

每次将至少一个第一词语替换为对应的相似词语,生成一条相似问题信息;Each time at least one first word is replaced with a corresponding similar word to generate a piece of similar question information;

根据第一问题信息和至少一条相似问题信息,获取第一问题向量。Obtain a first question vector according to the first question information and at least one piece of similar question information.

在另一种可能实现方式中,获取多个第一词语的相似词语,包括:In another possible implementation manner, a plurality of similar words of the first word are obtained, including:

从知识数据库中,获取多个第一词语中每个第一词语关联的相似词语,知识数据库用于存储各个词语与每个词语关联的相似词语;或者,From the knowledge database, obtain similar words associated with each of the first words in the plurality of first words, and the knowledge database is used to store the similar words associated with each word and each word; or,

获取多个第一词语中每个第一词语与至少一个预设词语的相似度,将与任一第一词语的相似度大于第一预设相似度的预设词语,作为任一第一词语的相似词语。Obtain the similarity between each first word in the plurality of first words and at least one preset word, and use a preset word whose similarity with any first word is greater than the first preset similarity as any first word similar words.

在另一种可能实现方式中,根据第一问题信息和至少一条相似问题信息,获取第一问题向量,包括:In another possible implementation manner, obtaining the first question vector according to the first question information and at least one piece of similar question information, including:

获取至少一条相似问题信息的特征向量和第一问题信息的特征向量的平均向量,作为第一问题向量。The average vector of the feature vector of at least one piece of similar question information and the feature vector of the first question information is obtained as the first question vector.

在另一种可能实现方式中,调用答案生成模型,根据第一问题向量和至少一条第二问题向量,获取至少一条答案信息,包括:In another possible implementation manner, the answer generation model is called to obtain at least one piece of answer information according to the first question vector and at least one second question vector, including:

将第一问题向量和至少一条第二问题向量进行拼接,得到第三问题向量;splicing the first problem vector and at least one second problem vector to obtain a third problem vector;

调用答案生成模型,根据第三问题向量,获取至少一条答案信息。The answer generation model is called to obtain at least one piece of answer information according to the third question vector.

在另一种可能实现方式中,根据第一问题信息或第一问题向量,在问答数据库中进行检索,包括:In another possible implementation manner, searching in the question answering database according to the first question information or the first question vector, including:

将第一问题向量和至少一条第二问题向量进行拼接,得到第三问题向量;splicing the first problem vector and at least one second problem vector to obtain a third problem vector;

根据第三问题向量与问答数据库中的每个预设答案信息的特征向量之间的相似度,获取至少一条答案信息,至少一条答案信息的特征向量与第三问题向量的相似度大于其他预设答案信息的特征向量与第三问题向量的相似度。Obtain at least one piece of answer information according to the similarity between the third question vector and the feature vector of each preset answer information in the question answering database, and the similarity between the feature vector of at least one piece of answer information and the third question vector is greater than that of other preset answers The similarity between the feature vector of the answer information and the third question vector.

在另一种可能实现方式中,至少一条第二问题向量包括多条第二问题向量,调用答案生成模型,根据第一问题向量和至少一条第二问题向量,获取至少一条答案信息,包括:In another possible implementation manner, the at least one second question vector includes multiple second question vectors, and the answer generation model is invoked to obtain at least one piece of answer information according to the first question vector and the at least one second question vector, including:

对多条第二问题向量进行加权平均,得到第四问题向量;Perform a weighted average on multiple second problem vectors to obtain a fourth problem vector;

将第一问题向量和第四问题向量进行拼接,得到融合问题向量;Splicing the first problem vector and the fourth problem vector to obtain a fusion problem vector;

根据融合问题向量,调用答案生成模型,获取至少一条答案信息。According to the fused question vector, the answer generation model is called to obtain at least one piece of answer information.

在另一种可能实现方式中,根据第一问题信息或第一问题向量,在问答数据库中进行检索,包括:In another possible implementation manner, searching in the question answering database according to the first question information or the first question vector, including:

对多个第二问题向量进行加权平均,得到第四问题向量;Perform a weighted average on a plurality of second problem vectors to obtain a fourth problem vector;

将第一问题向量和第四问题向量进行拼接,得到融合问题向量;Splicing the first problem vector and the fourth problem vector to obtain a fusion problem vector;

根据融合问题向量与问答数据库中的每个预设答案信息的特征向量之间的相似度,获取至少一条答案信息,至少一条答案信息的特征向量与融合问题向量的相似度大于其他预设答案信息的特征向量与融合问题向量的相似度。Obtain at least one piece of answer information according to the similarity between the fusion question vector and the feature vector of each preset answer information in the question answering database, and the similarity between the feature vector of at least one piece of answer information and the fusion question vector is greater than that of other preset answer information The similarity between the feature vector of and the fusion problem vector.

在另一种可能实现方式中,根据第一问题信息或第一问题向量,在问答数据库中进行检索,包括:In another possible implementation manner, searching in the question answering database according to the first question information or the first question vector, including:

根据第一问题向量,在问答数据库中进行检索,确定至少一条第五问题向量,至少一条第五问题向量包括第一问题向量相似的问题向量;或者,According to the first question vector, perform retrieval in the question answering database to determine at least one fifth question vector, and at least one fifth question vector includes question vectors similar to the first question vector; or,

根据第一问题向量和至少一条第二问题向量,在问答数据库中进行检索,确定至少一条第五问题向量,至少一条第五问题向量包括第一问题向量相似的问题向量或至少一条第二问题向量相似的问题向量中的至少一种;According to the first question vector and the at least one second question vector, perform a search in the question answering database to determine at least one fifth question vector, and the at least one fifth question vector includes a question vector similar to the first question vector or at least one second question vector at least one of similar problem vectors;

从问答数据库中,获取至少一条第五问题向量的答案信息,作为至少一条答案信息。Obtain at least one piece of answer information of the fifth question vector from the question answering database as at least one piece of answer information.

在另一种可能实现方式中,根据第一问题信息或第一问题向量,在问答数据库中进行检索,包括:In another possible implementation manner, searching in the question answering database according to the first question information or the first question vector, including:

根据第一问题向量与问答数据库中的每个预设答案信息的特征向量之间的相似度,获取至少一条答案信息,至少一条答案信息的特征向量与第一问题向量的相似度大于其他预设答案信息的特征向量与融合问题向量的相似度。Obtain at least one piece of answer information according to the similarity between the first question vector and the feature vector of each preset answer information in the question answering database, and the similarity between the feature vector of at least one piece of answer information and the first question vector is greater than that of other preset answers The similarity between the feature vector of the answer information and the fused question vector.

在另一种可能实现方式中,根据第一问题信息或第一问题向量,在问答数据库中进行检索,包括:In another possible implementation manner, searching in the question answering database according to the first question information or the first question vector, including:

对第一问题信息进行分词处理,得到第一问题信息的关键词或实体;Perform word segmentation processing on the first question information to obtain keywords or entities of the first question information;

对问答数据库中预设答案信息进行分词处理,得到预设答案信息的关键词或实体;Perform word segmentation on the preset answer information in the question-and-answer database to obtain keywords or entities of the preset answer information;

根据第一问题信息的关键词或实体,以及问答数据库中预设答案信息的关键词或实体,获取至少一条答案信息。At least one piece of answer information is acquired according to the keywords or entities of the first question information and the keywords or entities of the preset answer information in the question-and-answer database.

图3是本申请实施例提供的一种问答方法的流程图,参见图3,该方法应用于电子设备中,该方法包括:FIG. 3 is a flowchart of a question and answer method provided by an embodiment of the present application. Referring to FIG. 3 , the method is applied to an electronic device, and the method includes:

301、获取第一问题信息的第一问题向量和至少一条第二问题信息的第二问题向量。301. Acquire a first question vector of the first question information and a second question vector of at least one piece of second question information.

其中,该第一问题信息为用户当前输入的问题信息。例如,该第一问题信息可以为用户询问操作的问题信息、或者为用户询问名称的问题信息、或者为用户询问物品价格的问题信息等等。The first question information is the question information currently input by the user. For example, the first question information may be question information for a user to inquire about an operation, or for a user to inquire about a name, or for a user to inquire about the price of an item, and so on.

本申请实施例中,在针对第一问题信息进行回答时,不仅根据获取的第一问题信息的第一问题向量进行回答,而且还需要获取该第一问题信息之前的至少一条第二问题信息,后续根据该第一问题信息和至少一条第二问题信息进行回答。In the embodiment of the present application, when answering the first question information, the answer is not only based on the obtained first question vector of the first question information, but also needs to obtain at least one piece of second question information before the first question information, Subsequently, the answer is made according to the first question information and at least one second question information.

该第一问题信息为用户当前所询问的问题,在该第一问题信息之前,用户还询问过其他问题,因此,获取该第一问题信息之前的至少一个第二问题信息,后续综合该用户在之前询问的问题信息,对用户的第一问题信息进行回答,可以提高生成的答案信息的准确率。The first question information is the question currently asked by the user. Before the first question information, the user has also asked other questions. Therefore, at least one second question information before the first question information is acquired, and the user's Answering the first question information of the user based on the previously asked question information can improve the accuracy of the generated answer information.

在一种可能实现方式中,将获取的至少一条第二问题信息输入至向量编码模型中,获取该至少一个第二问题信息的第二问题向量。其中,该向量编码模型用于获取任一问题信息的问题向量。In a possible implementation manner, the obtained at least one piece of second question information is input into a vector coding model, and a second question vector of the at least one second question information is obtained. Among them, the vector encoding model is used to obtain the question vector of any question information.

可选地,对第一问题信息进行分词处理,得到分词后的多个第一词语,获取多个第一词语的相似词语,每次将至少一个第一词语替换为对应的相似词语,生成一条相似问题信息,根据第一问题信息和至少一条相似问题信息,获取第一问题向量。Optionally, perform word segmentation processing on the first question information, obtain a plurality of first words after word segmentation, obtain similar words of the plurality of first words, replace at least one first word with a corresponding similar word each time, and generate a Similar problem information, obtain a first problem vector according to the first problem information and at least one piece of similar problem information.

其中,获取第一词语的相似词语,在用相似词语将第一词语替换后,可以获取到与第一问题信息相似的相似问题信息,通过对获取的第一词语的扩展,进而实现了对第一问题信息的扩展,能够获取更多的与第一问题信息相似的其他问题信息,能够充分考虑到同一信息的不同表达方式。Among them, similar words of the first word are obtained, and after the first word is replaced with similar words, similar question information similar to the first question information can be obtained. The expansion of the first question information can obtain more other question information similar to the first question information, and can fully consider different expressions of the same information.

获取到分词的多个第一词语的相似词语后,可以将至少一个第一词语替换为对应的相似词语,例如,将其中的一个第一词语替换为对应的相似词语,将其中的两个第一词语替换为对应的相似词语等等,然后可以生成替换后的一条相似问题信息,然后再根据该第一问题信息和至少一条相似问题信息,获取第一问题向量。After obtaining the similar words of multiple first words of the segmented words, at least one first word can be replaced with a corresponding similar word, for example, one of the first words is replaced with a corresponding similar word, and two of the first words are replaced with corresponding similar words. A word is replaced with a corresponding similar word, etc., and then a replaced piece of similar question information can be generated, and then a first question vector can be obtained according to the first question information and at least one piece of similar question information.

在一种可能实现方式中,从知识数据库中,获取多个第一词语中每个第一词语关联的相似词语。In a possible implementation manner, similar words associated with each of the multiple first words are obtained from the knowledge database.

其中,该知识数据库用于存储各个词语与每个词语关联的相似词语。且该知识数据库可以描述各个词语之间的关系,在每个词语之间建立关联,形成词语之间的网状结构。Wherein, the knowledge database is used to store similar words associated with each word and each word. And the knowledge database can describe the relationship between each word, establish an association between each word, and form a network structure between the words.

当对第一问题信息进行分词处理,再根据分词得到的第一词语查询该知识数据库,即可确定该知识数据库中与第一词语关联的相似词语。When word segmentation is performed on the first question information, and then the knowledge database is queried according to the first word obtained from the word segmentation, the similar words associated with the first word in the knowledge database can be determined.

在另一种可能实现方式中,获取多个第一词语中每个第一词语与至少一个预设词语的相似度,将与任一第一词语的相似度大于第一预设相似度的预设词语,作为任一第一词语的相似词语。In another possible implementation manner, the similarity between each first word in the plurality of first words and at least one preset word is obtained, and the similarity with any first word is greater than the first preset similarity. Let words be similar to any of the first words.

在本申请实施例中,对第一问题信息进行分词处理后,获取多个第一词语,然后计算每个第一词语与至少一个预设词语的相似度,然后再判断每个第一词语与至少一个预设词语的相似度是否大于第一预设相似度,当确定任一第一词语与预设词语的相似度大于第一预设相似度时,则将该预设词语作为该任一第一词语的相似词语。In the embodiment of the present application, after word segmentation is performed on the first question information, a plurality of first words are obtained, and then the similarity between each first word and at least one preset word is calculated, and then the similarity between each first word and at least one preset word is calculated. Whether the similarity of at least one preset word is greater than the first preset similarity, when it is determined that the similarity between any first word and the preset word is greater than the first preset similarity, then the preset word is used as the any one Similar words for the first word.

其中,该第一预设相似度由服务器设置、或者由技术人员设置,或者采用其他方式设置。该第一预设相似度可以为0.7、0.8或者其他数值。Wherein, the first preset similarity is set by a server, or set by a technician, or set by other methods. The first preset similarity may be 0.7, 0.8 or other values.

例如,当用户输入的第一问题信息为“我要查询一下这个订单”时,分词得到的多个第一词语分别为“我”、“要”、“查询”、“一下”、“这个”、“订单”,可以确定“查询”的相似词语为“查找”,“订单”的相似词语为“账单”,将“查询”替换为“查找”,则生成的相似问题信息为“我要查找一下这个订单”,将“订单”替换为“账单”,则生成的相似问题信息为“我要查询一下这个账单”,而同时将“查询”替换为“查找”,将“订单”替换为“账单”,生成的相似问题信息为“我要查找一下这个账单”,然后再根据第一问题信息和至少一条相似问题信息,获取第一问题向量。For example, when the first question information input by the user is "I want to inquire about this order", the multiple first words obtained by word segmentation are "I", "Want", "Inquiry", "Ask", "This" , "order", it can be determined that the similar word of "query" is "find", and the similar word of "order" is "billing", replace "query" with "find", the generated similar question information is "I want to find Check this order", replace "order" with "billing", the generated similar question information is "I want to check this bill", and at the same time, replace "query" with "find", and replace "order" with " Bill", the generated similar question information is "I want to look up this bill", and then the first question vector is obtained according to the first question information and at least one similar question information.

可选地,获取至少一条相似问题信息的特征向量和第一问题信息的特征向量的平均向量,作为第一问题向量。Optionally, an average vector of the feature vector of at least one piece of similar question information and the feature vector of the first question information is obtained as the first question vector.

在根据第一问题信息和至少一条形似问题信息生成第一问题向量时,先获取该至少一个相似问题信息的特征向量和第一问题信息的特征向量,然后再计算该至少一个相似问题信息的特征向量和第一问题信息的特征向量的平均向量,作为第一问题向量。When generating the first question vector according to the first question information and at least one piece of similar question information, first obtain the feature vector of the at least one similar question information and the feature vector of the first question information, and then calculate the feature of the at least one similar question information The average vector of the vector and the eigenvectors of the first question information, as the first question vector.

在一种可能实现方式中,获取到第一问题信息和至少一个相似问题信息后,将该第一问题信息和至少一个相似问题信息输入到句向量编码模型中,然后获取该第一问题信息的特征向量和相似问题信息的特征向量。In a possible implementation manner, after obtaining the first question information and at least one similar question information, input the first question information and at least one similar question information into the sentence vector coding model, and then obtain the first question information Eigenvectors and eigenvectors of similar question information.

302、调用答案生成模型,根据第一问题向量和至少一条第二问题向量,获取至少一条答案信息。302. Call the answer generation model, and obtain at least one piece of answer information according to the first question vector and at least one second question vector.

其中,该答案生成模型用于根据任一问题向量生成任一问题向量匹配的答案信息。Wherein, the answer generation model is used to generate answer information matched by any question vector according to any question vector.

其中,该答案生成模型可以为seq2seq-attention(一种模型结构)模型,encoder-decoder(一种模型结构)模型、transformer(一种模型结构)模型等等。Among them, the answer generation model can be a seq2seq-attention (a model structure) model, an encoder-decoder (a model structure) model, a transformer (a model structure) model, and so on.

可选地,该答案生成模型中包括向量解码模块、注意力机制加权模块、答案纠错模块和生成式答案模块,例如,如图4所示,将问题向量输入至该答案生成模型中后,通过注意力机制加权模块对该问题向量进行加权,获取在问题向量中最有影响力的部分,然后再通过向量解码模块获取预测答案,在通过答案纠错模块对该预测答案进行语法纠错,最终得到答案信息,该答案信息也即是生成式答案信息。Optionally, the answer generation model includes a vector decoding module, an attention mechanism weighting module, an answer error correction module and a generative answer module. For example, as shown in Figure 4, after the question vector is input into the answer generation model, The question vector is weighted by the attention mechanism weighting module to obtain the most influential part in the question vector, and then the predicted answer is obtained through the vector decoding module, and the predicted answer is corrected by the answer error correction module. Finally, the answer information is obtained, which is also the generative answer information.

获取到第一问题向量和至少一条第二问题向量后,调用该答案生成模型,根据第一问题向量和至少一条第二问题向量,可以获取至少一条答案信息。After the first question vector and the at least one second question vector are obtained, the answer generation model is invoked, and at least one piece of answer information can be obtained according to the first question vector and the at least one second question vector.

在一种可能实现方式中,将第一问题向量和至少一条第二问题向量进行拼接,得到第三问题向量,调用答案生成模型,根据第三问题向量,获取至少一条答案信息。In a possible implementation manner, the first question vector and at least one second question vector are spliced to obtain a third question vector, the answer generation model is called, and at least one piece of answer information is obtained according to the third question vector.

将第一问题向量和至少一个第二问题向量按照顺序依次拼接,得到拼接后的第三问题向量,然后再将该第三问题向量输入至答案生成模型中,生成至少一条答案信息。The first question vector and at least one second question vector are spliced in sequence to obtain a spliced third question vector, and then the third question vector is input into the answer generation model to generate at least one piece of answer information.

可选地,在按照顺序依次拼接第一问题向量和至少一个第二问题向量时,按照获取第一问题向量和至少一个第二问题向量的先后顺序依次进行拼接,得到拼接后的第三问题向量。Optionally, when splicing the first problem vector and the at least one second problem vector in sequence, the splicing is performed in the order in which the first problem vector and the at least one second problem vector are obtained, and a third problem vector after splicing is obtained. .

或者,按照随机顺序,依次将第一问题向量和至少一个第二问题向量进行拼接,得到拼接后的第三问题向量。Alternatively, in a random order, the first problem vector and at least one second problem vector are spliced in sequence to obtain a spliced third problem vector.

在另一种可能实现方式中,获取的至少一条第二问题向量中包括多条第二问题向量。In another possible implementation manner, the obtained at least one second problem vector includes multiple second problem vectors.

为了减少第二问题向量的数据量,先对多条第二问题向量进行加权平均,得到第四问题向量,再将第一问题向量和第四问题向量进行拼接,得到融合问题向量,根据融合问题向量,调用答案生成模型,获取至少一条答案信息。In order to reduce the data amount of the second problem vector, firstly weighted and average multiple second problem vectors to obtain the fourth problem vector, and then splicing the first problem vector and the fourth problem vector to obtain the fusion problem vector, according to the fusion problem Vector, call the answer generation model to obtain at least one answer information.

可选地,调用的答案生成模型可以直接对该融合问题向量进行处理,生成一条答案信息。Optionally, the called answer generation model can directly process the fused question vector to generate a piece of answer information.

或者,调用的答案生成模型可以采用多个处理层,分别对该融合问题向量进行处理,得到处理后的多个问题向量,然后每个处理层均会根据一个问题向量生成一条答案信息,则最终可以获取多条答案信息。Alternatively, the called answer generation model can use multiple processing layers to process the fused question vector respectively to obtain multiple processed question vectors, and then each processing layer will generate an answer information according to a question vector, then finally Multiple answer information can be obtained.

可选地,在对多条第二问题向量进行加权平均的过程中,根据多条第二问题向量的先后顺序,确定每条第二问题向量的权重,再根据每条第二问题向量的权重对多条第二问题向量进行加权平均,得到第四问题向量。Optionally, in the process of performing the weighted average on the plurality of second problem vectors, the weight of each second problem vector is determined according to the sequence of the plurality of second problem vectors, and then according to the weight of each second problem vector. A weighted average is performed on a plurality of second problem vectors to obtain a fourth problem vector.

例如,将每条第二问题向量与第一问题向量的间隔轮数的倒数作为每条第二问题向量的权重,当第二问题向量与第一问题向量的间隔轮数为1时,则权重为1,当第二问题向量与第一问题向量的间隔轮数为2时,则权重为1/2,以此类推,第二问题向量与第一问题向量的间隔轮数越大,则权重越小。For example, the reciprocal of the interval between each second problem vector and the first problem vector is used as the weight of each second problem vector. When the interval between the second problem vector and the first problem vector is 1, the weight is 1. When the interval between the second problem vector and the first problem vector is 2, the weight is 1/2, and so on. The larger the interval between the second problem vector and the first problem vector, the weight smaller.

其中,从获取问题信息,根据该问题信息获取答案信息,到输出答案信息的过程为一轮问答过程,因此,第二问题向量与第一问题向量的间隔轮数为在该第一问题向量和第二问题向量之间进行的问答过程的轮数。Among them, the process from obtaining question information, obtaining answer information according to the question information, and outputting the answer information is one round of questioning and answering. Therefore, the interval between the second question vector and the first question vector is the number of rounds between the first question vector and the first question vector. The number of rounds of the question answering process between the second question vectors.

另外,在调用该答案生成模型之前,需要先对答案生成模型进行训练,进而调用训练后的答案生成模型。其中,训练答案生成模型的步骤包括:先获取初始的答案生成模型或已经经过一次或多次训练的答案生成模型,再获取样本问题向量和对应的样本答案信息,根据该样本问题向量和对应的样本答案信息,对该初始答案生成模型进行训练,得到训练后的答案生成模型。In addition, before calling the answer generation model, the answer generation model needs to be trained first, and then the trained answer generation model is called. The step of training the answer generation model includes: first obtaining an initial answer generation model or an answer generation model that has been trained one or more times, and then obtaining a sample question vector and corresponding sample answer information, according to the sample question vector and corresponding The sample answer information is used to train the initial answer generation model to obtain the trained answer generation model.

在训练过程中,将至少一个样本问题向量输入至答案生成模型中,基于该答案生成模型获取预测答案信息,再获取样本答案信息和预测答案信息之间的误差,对答案生成模型进行调整,以使调整后的答案生成模型获取的误差收敛,完成对答案生成模型的训练。In the training process, input at least one sample question vector into the answer generation model, obtain the predicted answer information based on the answer generation model, and then obtain the error between the sample answer information and the predicted answer information, and adjust the answer generation model to The error obtained by the adjusted answer generation model is converged, and the training of the answer generation model is completed.

303、根据第一问题信息或第一问题向量,在问答数据库中进行检索。303. Search in the question answering database according to the first question information or the first question vector.

其中,该问答数据库中存储有多条答案信息,且多条答案信息中的每条答案信息均对应有问题信息,因此,根据获取的第一问题向量和至少一条第二问题向量,在该问答数据库中进行检索,检索后即可确定是否存在于第一问题信息匹配的答案信息。Among them, there are multiple pieces of answer information stored in the question and answer database, and each piece of answer information in the multiple pieces of answer information corresponds to question information. Therefore, according to the obtained first question vector and at least one second question vector, in the question and answer The database is searched, and after the search, it can be determined whether there is answer information that matches the first question information.

在问答数据库中进行检索的过程中,可以根据第一问题信息进行检索,还可以根据第一问题向量进行检索,后续可以通过检索获取到答案信息。During the retrieval process in the question-and-answer database, retrieval may be performed according to the first question information, and may also be retrieved according to the first question vector, and the answer information may be obtained through subsequent retrieval.

在一种可能实现方式中,将第一问题向量和至少一条第二问题向量进行拼接,得到第三问题向量,根据第三问题向量与问答数据库中的每个预设答案信息的特征向量之间的相似度,获取至少一条答案信息,至少一条答案信息的特征向量与第三问题向量的相似度大于其他预设答案信息的特征向量与第三问题向量的相似度。In a possible implementation manner, the first question vector and at least one second question vector are spliced together to obtain a third question vector. According to the relationship between the third question vector and the feature vector of each preset answer information in the question answering database The similarity of at least one piece of answer information is obtained, and the similarity between the feature vector of at least one piece of answer information and the third question vector is greater than the similarity between the feature vectors of other preset answer information and the third question vector.

其中,可以获取问答数据库中的每个预设答案信息的特征向量,然后再计算第三问题向量与每个预设答案信息的特征向量之间的相似度,再按照相似度由大到小的顺序对预设答案信息进行排序,根据排列顺序获取至少一条答案信息。Among them, the feature vector of each preset answer information in the question and answer database can be obtained, and then the similarity between the third question vector and the feature vector of each preset answer information can be calculated, and then the similarity is from large to small. Sort the preset answer information in order, and obtain at least one piece of answer information according to the sorting order.

可选地,根据排列顺序,选取前预设数量的预设答案信息作为检索得到的答案信息。Optionally, according to the arrangement order, the preset answer information of the first preset number is selected as the answer information obtained by retrieval.

其中,该预设数量可以由服务器设置、或者由技术人员设置,或者采用其他方式设置。该预设数量可以为2、3、4或者其他数值。Wherein, the preset number can be set by the server, or set by the technician, or set by other methods. The preset number can be 2, 3, 4 or other values.

可选地,根据获取的第三问题向量与每个预设答案信息的特征向量之间的相似度,选取相似度大于预设相似度的预设答案信息作为检索得到的答案信息。Optionally, according to the similarity between the acquired third question vector and the feature vector of each preset answer information, the preset answer information whose similarity is greater than the preset similarity is selected as the retrieved answer information.

在另一种可能实现方式中,对多个第二问题向量进行加权平均,得到第四问题向量,将第一问题向量和第四问题向量进行拼接,得到融合问题向量,根据融合问题向量与问答数据库中的每个预设答案信息的特征向量之间的相似度,获取至少一条答案信息,至少一条答案信息的特征向量与融合问题向量的相似度大于其他预设答案信息的特征向量与融合问题向量的相似度。In another possible implementation manner, a weighted average is performed on a plurality of second question vectors to obtain a fourth question vector, the first question vector and the fourth question vector are spliced to obtain a fusion question vector, and according to the fusion question vector and the question and answer The similarity between the feature vectors of each preset answer information in the database, obtain at least one piece of answer information, and the similarity between the feature vector of at least one piece of answer information and the fusion question vector is greater than that of other preset answer information. similarity of vectors.

其中,对多个第二问题向量进行加权平均的过程与上述步骤中的加权平均过程类似,在此不再赘述。另外,计算融合特征向量和预设答案信息的特征向量之间的相似度的过程与上述过程中计算第三特征向量和预设答案信息的特征向量之间的相似度的过程类似,在此也不再赘述。The process of performing the weighted average on the plurality of second problem vectors is similar to the weighted average process in the above steps, and details are not repeated here. In addition, the process of calculating the similarity between the fusion feature vector and the feature vector of the preset answer information is similar to the process of calculating the similarity between the third feature vector and the feature vector of the preset answer information in the above process. No longer.

在另一种可能实现方式中,根据该第一问题向量和问答数据库中的每个预设答案信息的特征向量之间的相似度,获取至少一条答案信息。In another possible implementation manner, at least one piece of answer information is acquired according to the similarity between the first question vector and the feature vector of each preset answer information in the question answering database.

其中,该至少一条答案信息的特征向量与第一问题向量的相似度大于其他预设答案信息的特征向量与第一问题向量的相似度。Wherein, the similarity between the feature vector of the at least one piece of answer information and the first question vector is greater than the similarity between the feature vector of other preset answer information and the first question vector.

其中,根据相似度获取至少一条答案信息的过程与上述获取至少一条答案信息的过程类似,在此不再赘述。The process of acquiring at least one piece of answer information according to the similarity is similar to the above-mentioned process of acquiring at least one piece of answer information, and details are not repeated here.

可选地,在根据第一问题向量获取至少一条答案信息的过程中,通过设置的预设数量即可确定控制获取的答案信息的数量,例如,当预设数量为1时,则获取的答案信息为1个,而当设置的预设数量为2时,获取的答案信息为多个。Optionally, in the process of obtaining at least one piece of answer information according to the first question vector, the quantity of the obtained answer information can be determined by setting a preset quantity. For example, when the preset quantity is 1, the obtained answer information The information is 1, and when the preset number is set to 2, the obtained answer information is multiple.

或者,当根据预设相似度获取答案信息时,由于获取的第三问题向量或者融合特征向量与预设答案信息的特征向量之间的相似度不固定,如果均小于预设相似度,则不会获取到答案信息,如果仅有一个大于预设相似度,则仅会获取到一条答案信息,如果有多个相似度大于预设相似度,则会获取到多条答案信息。Or, when the answer information is obtained according to the preset similarity, since the similarity between the obtained third question vector or the fusion feature vector and the feature vector of the preset answer information is not fixed, if both are smaller than the preset similarity, the similarity is not fixed. Answer information will be obtained. If only one is greater than the preset similarity, only one answer information will be obtained. If there are multiple similarities greater than the preset similarity, multiple answer information will be obtained.

在另一种可能实现方式中,根据第一问题向量,在问答数据库中进行检索,确定至少一条第五问题向量。其中,至少一条第五问题向量包括与该第一问题向量相似的问题向量。In another possible implementation manner, according to the first question vector, a question-and-answer database is searched to determine at least one fifth question vector. Wherein, at least one fifth question vector includes a question vector similar to the first question vector.

可选地,至少一条第五问题向量与第一问题向量的相似度大于其他预设问题向量与第一问题向量的相似度。Optionally, the similarity between at least one fifth question vector and the first question vector is greater than the similarity between other preset question vectors and the first question vector.

在另一种可能实现方式中,根据第一问题向量和至少一条第二问题向量,在问答数据库中进行检索,确定至少一条第五问题向量,至少一条第五问题向量包括第一问题向量相似的问题向量或至少一条第二问题向量相似的问题向量中的至少一种,从问答数据库中,获取至少一条第五问题向量的答案信息,作为检索得到的至少一条答案信息。In another possible implementation manner, according to the first question vector and at least one second question vector, retrieval is performed in the question answering database, and at least one fifth question vector is determined, and the at least one fifth question vector includes a similarity between the first question vector and the At least one of the question vector or at least one question vector similar to the second question vector is obtained from the question answering database, and the answer information of at least one fifth question vector is obtained as the at least one piece of answer information obtained by retrieval.

其中,通过检索获取至少一条第五问题向量的过程中,由于是确定与问题向量相似的问题向量,为了减少获取不到第五问题向量的情况,则获取的第五问题向量可以为与第一问题向量相似的向量,或者为与第二问题向量相似的向量。Among them, in the process of obtaining at least one fifth problem vector through retrieval, since a problem vector similar to the problem vector is determined, in order to reduce the situation that the fifth problem vector cannot be obtained, the obtained fifth problem vector can be the same as the first problem vector. A vector similar to the problem vector, or a vector similar to the second problem vector.

可选地,由于是根据第一问题向量和至少一条第二问题向量,获取第五问题向量,则会出现三种情况,分别为未获取到第五问题向量、获取到一个第五问题向量、获取到多个第五问题向量。Optionally, since the fifth problem vector is obtained according to the first problem vector and at least one second problem vector, there will be three situations: the fifth problem vector is not obtained, a fifth problem vector is obtained, A plurality of fifth question vectors are obtained.

可选地,将第一问题向量和至少一条第二问题向量进行拼接,得到第三问题向量,根据第三问题向量,在问答数据库中进行检索,确定至少一条第五问题向量。Optionally, the first question vector and at least one second question vector are spliced to obtain a third question vector, and according to the third question vector, the question and answer database is searched to determine at least one fifth question vector.

其中,根据第三问题向量与问答数据库中的每个预设问题向量之间的相似度,获取至少一条第五问题向量,至少一条第四问题向量与第三问题向量的相似度大于其他预设问题向量与第三问题向量的相似度。Among them, at least one fifth question vector is obtained according to the similarity between the third question vector and each preset question vector in the question answering database, and the similarity between at least one fourth question vector and the third question vector is greater than other preset question vectors The similarity of the question vector to the third question vector.

可选地,对多个第二问题向量进行加权平均,得到第六问题向量,将第一问题向量和第六问题向量进行拼接,得到融合问题向量,根据融合问题向量,在问答数据库中进行检索,确定至少一条第五问题向量。Optionally, a weighted average is performed on a plurality of second question vectors to obtain a sixth question vector, the first question vector and the sixth question vector are spliced to obtain a fusion question vector, and a search is performed in the question answering database according to the fusion question vector. , determine at least one fifth problem vector.

其中,根据融合问题向量与问答数据库中的每个预设问题向量之间的相似度,获取至少一条第五问题向量,至少一条第五问题向量与第三问题向量的相似度大于其他预设问题向量与融合问题向量的相似度。Among them, at least one fifth question vector is obtained according to the similarity between the fusion question vector and each preset question vector in the question answering database, and the similarity between at least one fifth question vector and the third question vector is greater than that of other preset questions The similarity of the vector to the fusion problem vector.

需要说明的是,本申请实施例仅是以根据第一问题向量,在问答数据库中进行检索获取答案信息为例进行说明。在另一实施例中,可以直接根据第一问题信息,在问答数据库中进行检索,得到至少一条答案信息。It should be noted that, the embodiments of the present application are only described by taking an example of performing retrieval in a question-and-answer database to obtain answer information according to the first question vector. In another embodiment, at least one piece of answer information can be obtained by searching in the question and answer database directly according to the first question information.

在一种可能实现方式中,对第一问题信息进行分词处理,获取该第一问题信息中的关键词或实体,以及对问答数据库中的预设答案信息进行分词处理,获取预设答案信息的关键词或实体,当第一问题信息中的关键词或实体与预设答案信息中的关键词或实体匹配时,将该预设答案信息确定为答案信息。In a possible implementation manner, word segmentation processing is performed on the first question information, keywords or entities in the first question information are obtained, and word segmentation processing is performed on the preset answer information in the question-and-answer database to obtain the information of the preset answer information. The keyword or entity, when the keyword or entity in the first question information matches the keyword or entity in the preset answer information, the preset answer information is determined as the answer information.

在另一种可能实现方式中,对第一问题信息进行分词处理,获取该第一问题信息的关键词或实体,对问答数据库中的预设问题信息进行分词处理,得到预设答案信息的关键词或实体,根据第一问题信息的关键词或实体,以及问答数据库中预设答案信息的关键词或实体,在问答数据库中进行检索,确定与第一问题信息相似的至少一条第三问题信息,再将至少一条第三问题信息对应的答案信息确定为答案信息。In another possible implementation manner, word segmentation processing is performed on the first question information, keywords or entities of the first question information are obtained, and word segmentation processing is performed on the preset question information in the question-and-answer database to obtain the key of the preset answer information. word or entity, according to the keywords or entities of the first question information and the keywords or entities of the preset answer information in the question and answer database, search in the question and answer database, and determine at least one third question information similar to the first question information , and then determine the answer information corresponding to at least one piece of third question information as the answer information.

例如,如图5所示,在检索过程中,从问答数据库中获取多个预设答案信息,根据向量编码模型,获取每个预设答案信息的特征向量,再计算预设答案信息和当前的问题向量的相似度,根据获取的相似度获取答案信息。或者,还可以获取预设答案信息的关键词或实体,以及当前的问题信息的关键词或实体,计算预设答案信息和关键词以及当前的问题信息的关键词的相似度,或者计算预设答案信息和实体以及当前的问题信息的实体的相似度,根据获取的相似度获取答案信息。采用上述两种方式获取的答案信息均可以成为是检索式答案信息。For example, as shown in Figure 5, during the retrieval process, multiple preset answer information is obtained from the question-and-answer database, and the feature vector of each preset answer information is obtained according to the vector coding model, and then the preset answer information and the current The similarity of the question vector, and the answer information is obtained according to the obtained similarity. Alternatively, the keywords or entities of the preset answer information and the keywords or entities of the current question information can also be obtained, and the similarity between the preset answer information and the keywords and the keywords of the current question information can be calculated, or the preset answer information can be calculated. The similarity between the answer information and the entity and the entity of the current question information, and the answer information is obtained according to the obtained similarity. The answer information obtained by the above two methods can be regarded as retrieval type answer information.

304、调用排序模型中的多个匹配层,分别获取每条答案信息与第一问题信息的匹配度。304. Invoke multiple matching layers in the sorting model to obtain the matching degree of each piece of answer information and the first question information respectively.

其中,该排序模型包括多个匹配层、一个融合层和一个排序层。该多个匹配层中的每个匹配层用于获取问题信息和答案信息的匹配度。该融合层用于将每个问题信息和答案信息的匹配度进行融合,得到该问题信息和答案信息的融合匹配度。该排序层用于按照问题信息和每条答案信息的融合匹配度,对答案信息进行排序,将排在第一位的答案信息作为问题信息的目标答案信息。Among them, the ranking model includes multiple matching layers, a fusion layer and a ranking layer. Each matching layer in the multiple matching layers is used to obtain the matching degree of the question information and the answer information. The fusion layer is used to fuse the matching degree of each question information and answer information to obtain the fusion matching degree of the question information and the answer information. The sorting layer is used to sort the answer information according to the fusion matching degree of the question information and each piece of answer information, and take the answer information ranked first as the target answer information of the question information.

获取多条答案信息后,调用排序模型中的多个匹配层,通过一个匹配层即可获取每条答案信息与第一问题信息的一个匹配度,则同一答案信息和第一问题信息通过多个匹配层可以获取多个匹配度。After obtaining multiple pieces of answer information, multiple matching layers in the sorting model are called, and a matching degree between each answer information and the first question information can be obtained through one matching layer, then the same answer information and the first question information pass through multiple matching layers. The matching layer can obtain multiple matching degrees.

可选地,多个匹配层中采用不同的方式获取第一问题信息和答案信息的匹配度。Optionally, the matching degrees of the first question information and the answer information are acquired in different ways in multiple matching layers.

其中,可以采用LSTM(Long short-term memory,长短期记忆)、CNN(Convolutional Neural Networks,卷积神经网络)、MLP(Multi-Layer Perceptron,多层神经网络)、GBDT(Gradient Boosting Decision Tree,梯度提升迭代决策树)等机器学习算法获取匹配度,或者采用其他方式获取匹配度。Among them, LSTM (Long short-term memory, long short-term memory), CNN (Convolutional Neural Networks, convolutional neural network), MLP (Multi-Layer Perceptron, multi-layer neural network), GBDT (Gradient Boosting Decision Tree, gradient) can be used Machine learning algorithms such as improving iterative decision tree) to obtain the matching degree, or use other methods to obtain the matching degree.

305、调用排序模型中的融合层,获取每条答案信息的多个匹配度的融合匹配度。305. Call the fusion layer in the sorting model to obtain a fusion matching degree of multiple matching degrees of each piece of answer information.

获取每条答案信息的多个匹配度后,再调用融合层,获取每条答案信息的多个匹配度的融合匹配度。After obtaining multiple matching degrees of each answer information, the fusion layer is then called to obtain the fusion matching degree of multiple matching degrees of each answer information.

可选地,获取每条答案信息的多个匹配度的平均值,作为该答案信息的融合匹配度。Optionally, the average value of multiple matching degrees of each piece of answer information is obtained as the fusion matching degree of the answer information.

可选地,每个匹配层均具有一个对应的权重,且多个匹配层对应的权重的和为1,则根据每个匹配层对应的权重,对每条答案信息的多个匹配度进行加权平均,得到该答案信息的融合匹配度。Optionally, each matching layer has a corresponding weight, and the sum of the corresponding weights of the multiple matching layers is 1, then according to the corresponding weight of each matching layer, the multiple matching degrees of each piece of answer information are weighted. Averaged to obtain the fusion matching degree of the answer information.

306、调用排序模型中的排序层,按照融合匹配度由高到低的顺序,对多条答案信息进行排序,将排在第一位的答案信息确定为目标答案信息。306. Call the sorting layer in the sorting model, sort the multiple pieces of answer information in the order of the fusion matching degree from high to low, and determine the answer information ranked first as the target answer information.

例如,如图6所示,获取多条答案信息后,调用排序模型,即可确定目标答案信息。For example, as shown in FIG. 6 , after obtaining multiple pieces of answer information, the sorting model is invoked to determine the target answer information.

另外,在本申请实施例中,在调用排序模型,从多条答案信息中获取目标答案信息时,通过步骤303获取的至少一条答案信息的优先级大于通过步骤302获取的至少一条答案信息的优先级,因此,在排序模型对多条答案信息进行排序时,对通过步骤303获取的答案信息设置的权重大于通过步骤303获取的答案信息设置的权重,则在根据融合匹配度进行排序时,先通过设置的权重,对融合匹配度进行加权,得到加权后的融合匹配度,再根据加权后的融合匹配度进行排序,获取目标答案信息。In addition, in this embodiment of the present application, when the sorting model is invoked to obtain target answer information from multiple pieces of answer information, the priority of at least one piece of answer information obtained through step 303 is higher than the priority of at least one piece of answer information obtained through step 302 Therefore, when the sorting model sorts multiple pieces of answer information, the weight set for the answer information obtained in step 303 is greater than the weight set for the answer information obtained in step 303, then when sorting according to the fusion matching degree, first Through the set weights, the fusion matching degree is weighted to obtain the weighted fusion matching degree, and then sorting is performed according to the weighted fusion matching degree to obtain the target answer information.

需要说明的是,本申请实施例仅是以排序模型中包括多个匹配层、一个融合层和一个排序层为例进行说明,在另一实施例中,步骤304-306为可选步骤,在排序模型中无需设置多个匹配层,可以直接调用排序模型,获取答案信息和第一问题信息的一个匹配度,根据获取的匹配度确定目标答案信息。It should be noted that the embodiment of the present application only takes the sorting model including multiple matching layers, one fusion layer and one sorting layer as an example for description. In another embodiment, steps 304 to 306 are optional steps, and in There is no need to set up multiple matching layers in the ranking model, and the ranking model can be directly called to obtain a matching degree between the answer information and the first question information, and determine the target answer information according to the obtained matching degree.

在一种可能实现方式中,调用排序模型,按照与第一问题信息的匹配度从高到低的顺序,对至多条答案信息进行排序,将排在第一位的答案信息确定为目标答案信息。In a possible implementation manner, the sorting model is invoked to sort at most pieces of answer information in descending order of matching degree with the first question information, and the answer information ranked first is determined as the target answer information .

在本申请实施例中,调用排序模型,分别获取多条答案信息中每条答案信息与第一问题信息的匹配度,由于每条答案信息均对应一个匹配度,则直接按照与第一问题信息的匹配度从高到低的顺序,对多条答案信息进行排序,将排在第一位的答案信息确定为目标答案信息即可。In the embodiment of the present application, the sorting model is invoked to obtain the matching degree of each piece of answer information among the multiple pieces of answer information and the first question information. Sort multiple pieces of answer information in the order of the matching degree from high to low, and determine the answer information in the first place as the target answer information.

另外,在调用排序模型之前,需要先对排序模型进行训练,得到训练后的排序模型,后续再调用训练后的排序模型获取目标答案。训练排序模型的过程如下:In addition, before calling the sorting model, it is necessary to train the sorting model to obtain the trained sorting model, and then call the trained sorting model to obtain the target answer. The process of training a ranking model is as follows:

获取样本问题信息和对应的样本答案信息,以及样本问题信息与样本答案信息的样本匹配度,根据样本问题信息、样本答案信息和样本匹配度,对排序模型进行训练,得到训练后的排序模型。Obtain the sample question information and the corresponding sample answer information, as well as the sample matching degree between the sample question information and the sample answer information, train the sorting model according to the sample question information, the sample answer information and the sample matching degree, and obtain the trained sorting model.

其中,该样本问题信息和样本答案信息为对应关系,也就是样本问题信息的答案为样本答案信息。另外,该样本问题信息和样本答案信息的样本匹配度用于表示该样本问题信息和样本答案信息匹配。The sample question information and the sample answer information are in a corresponding relationship, that is, the answer of the sample question information is the sample answer information. In addition, the sample matching degree of the sample question information and the sample answer information is used to indicate that the sample question information and the sample answer information match.

获取到样本问题信息和对应的样本答案信息,以及样本问题信息和对应的样本答案信息的样本匹配度后,即可根据该样本问题信息、样本答案信息和样本匹配度,对排序模型进行训练,得到训练后的排序模型。After obtaining the sample question information and the corresponding sample answer information, and the sample matching degree between the sample question information and the corresponding sample answer information, the sorting model can be trained according to the sample question information, the sample answer information and the sample matching degree. Get the trained ranking model.

可选地,将样本问题信息与样本答案信息输入至排序模型中,获取样本问题信息与样本答案信息的预测匹配度,根据样本匹配度和预测匹配度,对排序模型进行训练,得到训练后的排序模型。Optionally, input the sample question information and sample answer information into the ranking model, obtain the predicted matching degree between the sample question information and the sample answer information, train the ranking model according to the sample matching degree and the predicted matching degree, and obtain the training results. Sort the model.

在训练过程中,将至少一个样本问题信息与对应的样本答案信息输入至排序模型中,基于该排序模型获取预测匹配度,再获取样本匹配度和预测匹配度之间的误差,对排序模型进行调整,以使调整后的排序模型获取的误差收敛,完成对排序模型的训练。In the training process, input at least one sample question information and corresponding sample answer information into the ranking model, obtain the predicted matching degree based on the ranking model, and then obtain the error between the sample matching degree and the predicted matching degree, and perform the ranking model. Adjust so that the error obtained by the adjusted ranking model converges, and the training of the ranking model is completed.

本申请实施例提供的方法的流程如图7所示,步骤301由输入模块执行,步骤302由生成答案模块执行,获得至少一个生成式答案,步骤303由检索答案模块执行,获得至少一个检索式答案,步骤304-306由答案排序模块执行,将至少一个生成式答案和至少一个检索式答案进行排序,获取当前轮次的答案。The flow of the method provided by this embodiment of the present application is shown in FIG. 7 , step 301 is executed by the input module, step 302 is executed by the answer generation module to obtain at least one generative answer, and step 303 is executed by the retrieval answer module to obtain at least one retrieval formula Answers, steps 304-306 are executed by the answer sorting module, which sorts at least one generative answer and at least one retrieval answer, and obtains the answer of the current round.

另外,输入模块中的过程如图8所示,先获取当前轮次用户输入的第一问题信息,对第一问题信息进行分词处理,再对分词后的词语进行扩展,得到相似问题信息,根据第一问题信息和相似问题信息以及第二问题信息,该第二问题信息即为场景上下文信息,调用场景上下文编码模型,获取场景上下文信息向量,调用句向量编码模型获取第一问题信息和相似问题信息的第一问题向量,再根据场景上下文信息向量和第一问题向量生成融合特征向量,该融合特征向量即为后续生成式模块和检索式模块的输入,并且成为下一次问题信息的场景上下文信息。In addition, the process in the input module is shown in Figure 8. First, the first question information input by the user in the current round is obtained, the first question information is word-segmented, and then the words after word segmentation are expanded to obtain similar question information. The first question information, similar question information and second question information, the second question information is the scene context information, call the scene context coding model to obtain the scene context information vector, and call the sentence vector coding model to obtain the first question information and similar questions The first question vector of the information, and then generate a fusion feature vector according to the scene context information vector and the first question vector. The fusion feature vector is the input of the subsequent generative module and retrieval module, and becomes the scene context information of the next question information. .

上述所有可选技术方案,可以采用任意结合形成本公开的可选实施例,在此不再一一赘述。All the above-mentioned optional technical solutions can be combined arbitrarily to form optional embodiments of the present disclosure, which will not be repeated here.

本申请实施例提供的方法,采用了基于模型自动生成的方式和检索方式来获取答案信息,再调用排序模型,按照答案信息与问题信息的匹配度对获取的多条答案信息进行排序,获取排在第一位的答案信息,即为与第一问题信息最为匹配的答案信息,保证了即使在采用检索方式检索不到答案信息的情况下也能生成答案信息,不会出现答案信息缺失的情况,而且也综合考虑了上下文的影响以及答案信息与问题信息的匹配程度,提高了答案信息的准确性。The method provided by the embodiment of the present application adopts the method of automatic generation and retrieval based on the model to obtain the answer information, and then invokes the sorting model to sort the obtained multiple pieces of answer information according to the matching degree between the answer information and the question information, and obtain the ranking. The answer information in the first place is the answer information that best matches the first question information, which ensures that the answer information can be generated even if the answer information cannot be retrieved by the retrieval method, and there will be no missing answer information. , and also comprehensively considers the influence of context and the degree of matching between answer information and question information, which improves the accuracy of answer information.

并且,采用多种获取匹配度的方式来获取问题信息与答案信息的多个匹配度,将多个匹配度进行融合得到融合匹配度,该融合匹配度综合了多种匹配度,更为准确,因此将融合匹配度最高的答案信息确定为目标答案信息,能够提高该目标答案信息的准确性。In addition, multiple matching degrees of question information and answer information are obtained by adopting a variety of ways to obtain matching degrees, and the multiple matching degrees are fused to obtain a fusion matching degree, which integrates multiple matching degrees and is more accurate. Therefore, determining the answer information with the highest fusion matching degree as the target answer information can improve the accuracy of the target answer information.

并且,采用先分词再对词语进行扩展的方式,实现了对第一问题信息的扩展,能够获取与第一问题信息相似的更多问题信息,充分考虑到同一信息的不同表达方式,提高后续获取的答案信息的准确性。In addition, by adopting the method of word segmentation and then expanding the words, the expansion of the first question information is realized, and more question information similar to the first question information can be obtained, and the different expressions of the same information can be fully considered to improve the subsequent acquisition. accuracy of the answer information.

图9是本申请实施例提供的一种问答装置的结构示意图。参见图9,该装置包括:FIG. 9 is a schematic structural diagram of a question and answer device provided by an embodiment of the present application. Referring to Figure 9, the device includes:

获取模块901,用于获取第一问题信息的第一问题向量和至少一条第二问题信息的第二问题向量,所述至少一条第二问题信息为在所述第一问题信息之前获取的问题信息;Obtaining module 901, configured to obtain a first question vector of first question information and a second question vector of at least one piece of second question information, where the at least one piece of second question information is question information obtained before the first question information ;

生成模块902,用于调用答案生成模型,根据所述第一问题向量和至少一条第二问题向量,获取至少一条答案信息,所述答案生成模型用于根据任一问题向量生成所述任一问题向量匹配的答案信息;The generation module 902 is configured to call an answer generation model, obtain at least one piece of answer information according to the first question vector and at least one second question vector, and the answer generation model is used to generate the any question according to any question vector vector matching answer information;

检索模块903,用于根据所述第一问题信息或所述第一问题向量,在问答数据库中进行检索;A retrieval module 903, configured to perform retrieval in the question and answer database according to the first question information or the first question vector;

排序模块904,用于调用排序模型,按照与所述第一问题信息的匹配度从高到低的顺序,对获取到的多条答案信息进行排序,将排在第一位的答案信息确定为所述目标答案信息。The sorting module 904 is used to call the sorting model, sort the obtained multiple pieces of answer information according to the order of matching degree with the first question information from high to low, and determine the first answer information as The target answer information.

本申请实施例提供的装置,采用了基于模型自动生成的方式和检索方式来获取答案信息,再调用排序模型,按照答案信息与问题信息的匹配度对获取的多条答案信息进行排序,获取排在第一位的答案信息,即为与第一问题信息最为匹配的答案信息,保证了即使在采用检索方式检索不到答案信息的情况下也能生成答案信息,不会出现答案信息缺失的情况,而且也综合考虑了上下文的影响以及答案信息与问题信息的匹配程度,提高了答案信息的准确性。The device provided by the embodiment of the present application adopts the method of automatic generation and retrieval based on the model to obtain the answer information, and then invokes the sorting model, sorts the obtained multiple pieces of answer information according to the matching degree between the answer information and the question information, and obtains the ranking. The answer information in the first place is the answer information that best matches the first question information, which ensures that the answer information can be generated even if the answer information cannot be retrieved by the retrieval method, and there will be no missing answer information. , and also comprehensively considers the influence of context and the degree of matching between answer information and question information, which improves the accuracy of answer information.

在一种可能实现方式中,所述装置还包括:In a possible implementation, the apparatus further includes:

所述获取模块901,用于获取样本问题信息和对应的样本答案信息,以及所述样本问题信息与所述样本答案信息的样本匹配度;The obtaining module 901 is configured to obtain sample question information and corresponding sample answer information, and a sample matching degree between the sample question information and the sample answer information;

训练模块905,用于根据所述样本问题信息、所述样本答案信息和所述样本匹配度,对所述排序模型进行训练,得到训练后的排序模型。The training module 905 is configured to train the ranking model according to the sample question information, the sample answer information and the sample matching degree to obtain a trained ranking model.

在另一种可能实现方式中,所述训练模块905,包括:In another possible implementation, the training module 905 includes:

输入单元9051,用于将所述样本问题信息与所述样本答案信息输入至所述排序模型中,获取所述样本问题信息与所述样本答案信息的预测匹配度;an input unit 9051, configured to input the sample question information and the sample answer information into the ranking model, and obtain the predicted matching degree of the sample question information and the sample answer information;

训练单元9052,用于根据所述样本匹配度和所述预测匹配度,对所述排序模型进行训练,得到训练后的排序模型。A training unit 9052, configured to train the ranking model according to the sample matching degree and the predicted matching degree, to obtain a trained ranking model.

在另一种可能实现方式中,所述排序模型包括多个匹配层、一个融合层和一个排序层,所述生成模块902,包括:In another possible implementation, the ranking model includes multiple matching layers, a fusion layer and a ranking layer, and the generation module 902 includes:

匹配度获取单元9021,用于调用所述多个匹配层,分别获取每条答案信息与所述第一问题信息的匹配度;a matching degree obtaining unit 9021, configured to invoke the multiple matching layers to obtain the matching degree of each piece of answer information and the first question information respectively;

融合单元9022,用于调用所述融合层,获取每条答案信息的多个匹配度的融合匹配度;The fusion unit 9022 is used to call the fusion layer to obtain the fusion matching degree of multiple matching degrees of each piece of answer information;

排序单元9023,用于调用所述排序层,按照融合匹配度由高到低的顺序,对所述多条答案信息进行排序,将排在第一位的答案信息确定为所述目标答案信息。The sorting unit 9023 is configured to call the sorting layer, sort the multiple pieces of answer information in the order of the fusion matching degree from high to low, and determine the answer information ranked first as the target answer information.

在另一种可能实现方式中,所述获取模块901,用于执行以下任一项:In another possible implementation manner, the obtaining module 901 is configured to execute any one of the following:

对所述第一问题信息进行分词处理,得到分词后的多个第一词语;Perform word segmentation processing on the first question information to obtain a plurality of first words after word segmentation;

获取所述多个第一词语的相似词语;obtaining similar words of the plurality of first words;

每次将至少一个第一词语替换为对应的相似词语,生成一条相似问题信息;Each time at least one first word is replaced with a corresponding similar word to generate a piece of similar question information;

根据所述第一问题信息和所述至少一条相似问题信息,获取所述第一问题向量。Obtain the first question vector according to the first question information and the at least one piece of similar question information.

在另一种可能实现方式中,所述获取模块901,用于执行以下任一项:In another possible implementation manner, the obtaining module 901 is configured to execute any one of the following:

从知识数据库中,获取所述多个第一词语中每个第一词语关联的相似词语,所述知识数据库用于存储各个词语与每个词语关联的相似词语;或者,Obtain, from a knowledge database, similar words associated with each of the plurality of first words, where the knowledge database is used to store similar words associated with each word; or,

获取所述多个第一词语中每个第一词语与至少一个预设词语的相似度,将与任一第一词语的相似度大于第一预设相似度的预设词语,作为所述任一第一词语的相似词语。Obtain the similarity between each first word in the plurality of first words and at least one preset word, and use a preset word whose similarity with any first word is greater than the first preset similarity as the arbitrary first word. A similar word to the first word.

在另一种可能实现方式中,所述获取模块901,用于获取所述至少一条相似问题信息的特征向量和所述第一问题信息的特征向量的平均向量,作为所述第一问题向量。In another possible implementation manner, the obtaining module 901 is configured to obtain the average vector of the feature vector of the at least one piece of similar question information and the feature vector of the first question information, as the first question vector.

在另一种可能实现方式中,所述生成模块902,用于执行以下任一项:In another possible implementation manner, the generating module 902 is configured to perform any one of the following:

将所述第一问题向量和所述至少一条第二问题向量进行拼接,得到第三问题向量;splicing the first problem vector and the at least one second problem vector to obtain a third problem vector;

调用所述答案生成模型,根据所述第三问题向量,获取所述至少一条答案信息。The answer generation model is called, and the at least one piece of answer information is acquired according to the third question vector.

在另一种可能实现方式中,所述检索模块903,用于执行以下任一项:In another possible implementation manner, the retrieval module 903 is configured to perform any one of the following:

将所述第一问题向量和所述至少一条第二问题向量进行拼接,得到第三问题向量;splicing the first problem vector and the at least one second problem vector to obtain a third problem vector;

根据所述第三问题向量与所述问答数据库中的每个预设答案信息的特征向量之间的相似度,获取至少一条答案信息,所述至少一条答案信息的特征向量与所述第三问题向量的相似度大于其他预设答案信息的特征向量与所述第三问题向量的相似度。According to the similarity between the third question vector and the feature vector of each preset answer information in the question answering database, at least one piece of answer information is obtained, and the feature vector of the at least one piece of answer information is related to the third question The similarity of the vectors is greater than the similarity between the feature vectors of other preset answer information and the third question vector.

在另一种可能实现方式中,所述至少一条第二问题向量包括多条第二问题向量,所述生成模块902,用于执行以下任一项:In another possible implementation manner, the at least one second problem vector includes a plurality of second problem vectors, and the generating module 902 is configured to perform any one of the following:

对所述多条第二问题向量进行加权平均,得到第四问题向量;performing a weighted average on the plurality of second problem vectors to obtain a fourth problem vector;

将所述第一问题向量和所述第四问题向量进行拼接,得到融合问题向量;Splicing the first problem vector and the fourth problem vector to obtain a fusion problem vector;

根据所述融合问题向量,调用所述答案生成模型,获取所述至少一条答案信息。According to the fusion question vector, the answer generation model is called to obtain the at least one piece of answer information.

在另一种可能实现方式中,所述检索模块903,用于执行以下任一项:In another possible implementation manner, the retrieval module 903 is configured to perform any one of the following:

对所述多个第二问题向量进行加权平均,得到第四问题向量;performing a weighted average on the plurality of second problem vectors to obtain a fourth problem vector;

将所述第一问题向量和所述第四问题向量进行拼接,得到融合问题向量;Splicing the first problem vector and the fourth problem vector to obtain a fusion problem vector;

根据所述融合问题向量与所述问答数据库中的每个预设答案信息的特征向量之间的相似度,获取至少一条答案信息,所述至少一条答案信息的特征向量与所述融合问题向量的相似度大于其他预设答案信息的特征向量与所述融合问题向量的相似度。At least one piece of answer information is obtained according to the similarity between the fusion question vector and the feature vector of each preset answer information in the question answering database, and the feature vector of the at least one piece of answer information is the difference between the fusion question vector and the fusion question vector. The similarity is greater than the similarity between the feature vector of other preset answer information and the fusion question vector.

在另一种可能实现方式中,所述检索模块903,用于执行以下任一项:In another possible implementation manner, the retrieval module 903 is configured to perform any one of the following:

根据所述第一问题向量,在所述问答数据库中进行检索,确定至少一条第五问题向量,所述至少一条第五问题向量包括所述第一问题向量相似的问题向量;或者,According to the first question vector, perform retrieval in the question answering database to determine at least one fifth question vector, where the at least one fifth question vector includes question vectors similar to the first question vector; or,

根据所述第一问题向量和所述至少一条第二问题向量,在所述问答数据库中进行检索,确定至少一条第四问题向量,所述至少一条第四问题向量包括所述第一问题向量相似的问题向量或所述至少一条第二问题向量相似的问题向量中的至少一种;According to the first question vector and the at least one second question vector, searching in the question answering database to determine at least one fourth question vector, the at least one fourth question vector including the first question vector is similar At least one of the problem vectors of or the problem vectors that are similar to the at least one second problem vector;

从所述问答数据库中,获取所述至少一条第四问题向量的答案信息,作为所述至少一条答案信息。From the question and answer database, the answer information of the at least one fourth question vector is obtained as the at least one piece of answer information.

在另一种可能实现方式中,所述检索模块903,用于执行以下任一项:In another possible implementation manner, the retrieval module 903 is configured to perform any one of the following:

对所述第一问题信息进行分词处理,得到所述第一问题信息的关键词或实体;Perform word segmentation processing on the first question information to obtain keywords or entities of the first question information;

对所述问答数据库中预设答案信息进行分词处理,得到所述预设答案信息的关键词或实体;Perform word segmentation processing on the preset answer information in the question and answer database to obtain keywords or entities of the preset answer information;

根据所述第一问题信息的关键词或实体,以及所述问答数据库中预设答案信息的关键词或实体,获取至少一条答案信息。At least one piece of answer information is acquired according to the keywords or entities of the first question information and the keywords or entities of the preset answer information in the question-and-answer database.

需要说明的是:上述实施例提供的问答装置在进行问答时,仅以上述各功能模块的划分进行举例说明,实际应用中,可以根据需要而将上述功能分配由不同的功能模块完成,即将电子设备的内部结构划分成不同的功能模块,以完成以上描述的全部或者部分功能。另外,上述实施例提供的问答装置的实施例与问答方法实施例属于同一构思,其具体实现过程详见方法实施例,这里不再赘述。It should be noted that when the question-and-answer device provided in the above-mentioned embodiments conducts questions and answers, only the division of the above-mentioned functional modules is used for illustration. The internal structure of the device is divided into different functional modules to complete all or part of the functions described above. In addition, the question-answering device and question-answering method embodiments provided by the above embodiments belong to the same concept, and the specific implementation process thereof is detailed in the method embodiments, which will not be repeated here.

图11是本申请实施例提供的一种终端的结构示意图。该终端1100可以是便携式移动终端,比如:智能手机、平板电脑、MP3播放器(Moving Picture Experts Group AudioLayer III,动态影像专家压缩标准音频层面3)、MP4(Moving Picture Experts GroupAudio Layer IV,动态影像专家压缩标准音频层面4)播放器、笔记本电脑、台式电脑、头戴式设备,或其他任意智能终端。终端1100还可能被称为用户设备、便携式终端、膝上型终端、台式终端等其他名称。FIG. 11 is a schematic structural diagram of a terminal provided by an embodiment of the present application. The terminal 1100 may be a portable mobile terminal, such as: a smart phone, a tablet computer, an MP3 player (Moving Picture Experts Group AudioLayer III, Moving Picture Experts Group Audio Layer III), MP4 (Moving Picture Experts Group Audio Layer IV, Moving Picture Experts Group Audio Layer IV) Compression standard audio layer 4) Player, notebook computer, desktop computer, head-mounted device, or any other intelligent terminal. Terminal 1100 may also be called user equipment, portable terminal, laptop terminal, desktop terminal, and the like by other names.

通常,终端1100包括有:处理器1101和存储器1102。Generally, the terminal 1100 includes: a processor 1101 and a memory 1102 .

处理器1101可以包括一个或多个处理核心,比如4核心处理器、8核心处理器等。处理器1101可以采用DSP(Digital Signal Processing,数字信号处理)、FPGA(Field-Programmable Gate Array,现场可编程门阵列)、PLA(Programmable Logic Array,可编程逻辑阵列)中的至少一种硬件形式来实现。处理器1101也可以包括主处理器和协处理器,主处理器是用于对在唤醒状态下的数据进行处理的处理器,也称CPU(Central ProcessingUnit,中央处理器);协处理器是用于对在待机状态下的数据进行处理的低功耗处理器。在一些实施例中,处理器1101可以集成有GPU(Graphics Processing Unit,图像处理器),GPU用于负责显示屏所需要显示的内容的渲染和绘制。一些实施例中,处理器1101还可以包括AI(Artificial Intelligence,人工智能)处理器,该AI处理器用于处理有关机器学习的计算操作。The processor 1101 may include one or more processing cores, such as a 4-core processor, an 8-core processor, and the like. The processor 1101 may use at least one hardware form of DSP (Digital Signal Processing, digital signal processing), FPGA (Field-Programmable Gate Array, field programmable gate array), and PLA (Programmable Logic Array, programmable logic array). accomplish. The processor 1101 may also include a main processor and a coprocessor. The main processor is a processor used to process data in a wake-up state, also called a CPU (Central Processing Unit, central processing unit); A low-power processor for processing data in a standby state. In some embodiments, the processor 1101 may be integrated with a GPU (Graphics Processing Unit, image processor), and the GPU is used for rendering and drawing the content that needs to be displayed on the display screen. In some embodiments, the processor 1101 may further include an AI (Artificial Intelligence, artificial intelligence) processor, where the AI processor is used to process computing operations related to machine learning.

存储器1102可以包括一个或多个计算机可读存储介质,该计算机可读存储介质可以是非暂态的。存储器1102还可包括高速随机存取存储器,以及非易失性存储器,比如一个或多个磁盘存储设备、闪存存储设备。在一些实施例中,存储器1102中的非暂态的计算机可读存储介质用于存储至少一个指令,该至少一个指令用于被处理器1101所具有以实现本申请中方法实施例提供的问答方法。Memory 1102 may include one or more computer-readable storage media, which may be non-transitory. Memory 1102 may also include high-speed random access memory, as well as non-volatile memory, such as one or more disk storage devices, flash storage devices. In some embodiments, the non-transitory computer-readable storage medium in the memory 1102 is used to store at least one instruction, the at least one instruction is used by the processor 1101 to implement the question answering method provided by the method embodiments of the present application .

在一些实施例中,终端1100还可选包括有:外围设备接口1103和至少一个外围设备。处理器1101、存储器1102和外围设备接口1103之间可以通过总线或信号线相连。各个外围设备可以通过总线、信号线或电路板与外围设备接口1103相连。具体地,外围设备包括:射频电路1104、显示屏1105、摄像头组件1106、音频电路1107、定位组件1108和电源11011中的至少一种。In some embodiments, the terminal 1100 may optionally further include: a peripheral device interface 1103 and at least one peripheral device. The processor 1101, the memory 1102 and the peripheral device interface 1103 may be connected through a bus or a signal line. Each peripheral device can be connected to the peripheral device interface 1103 through a bus, a signal line or a circuit board. Specifically, the peripheral device includes: at least one of a radio frequency circuit 1104 , a display screen 1105 , a camera assembly 1106 , an audio circuit 1107 , a positioning assembly 1108 and a power supply 11011 .

外围设备接口1103可被用于将I/O(Input/Output,输入/输出)相关的至少一个外围设备连接到处理器1101和存储器1102。在一些实施例中,处理器1101、存储器1102和外围设备接口1103被集成在同一芯片或电路板上;在一些其他实施例中,处理器1101、存储器1102和外围设备接口1103中的任意一个或两个可以在单独的芯片或电路板上实现,本实施例对此不加以限定。The peripheral device interface 1103 may be used to connect at least one peripheral device related to I/O (Input/Output) to the processor 1101 and the memory 1102 . In some embodiments, processor 1101, memory 1102, and peripherals interface 1103 are integrated on the same chip or circuit board; in some other embodiments, any one of processor 1101, memory 1102, and peripherals interface 1103 or The two can be implemented on a separate chip or circuit board, which is not limited in this embodiment.

射频电路1104用于接收和发射RF(Radio Frequency,射频)信号,也称电磁信号。射频电路1104通过电磁信号与通信网络以及其他通信设备进行通信。射频电路1104将电信号转换为电磁信号进行发送,或者,将接收到的电磁信号转换为电信号。可选地,射频电路1104包括:天线系统、RF收发器、一个或多个放大器、调谐器、振荡器、数字信号处理器、编解码芯片组、用户身份模块卡等等。射频电路1104可以通过至少一种无线通信协议来与其它终端进行通信。该无线通信协议包括但不限于:城域网、各代移动通信网络(2G、3G、4G及8G)、无线局域网和/或WiFi(Wireless Fidelity,无线保真)网络。在一些实施例中,射频电路1104还可以包括NFC(Near Field Communication,近距离无线通信)有关的电路,本申请对此不加以限定。The radio frequency circuit 1104 is used for receiving and transmitting RF (Radio Frequency, radio frequency) signals, also called electromagnetic signals. The radio frequency circuit 1104 communicates with communication networks and other communication devices via electromagnetic signals. The radio frequency circuit 1104 converts electrical signals into electromagnetic signals for transmission, or converts received electromagnetic signals into electrical signals. Optionally, the radio frequency circuit 1104 includes an antenna system, an RF transceiver, one or more amplifiers, a tuner, an oscillator, a digital signal processor, a codec chipset, a subscriber identity module card, and the like. The radio frequency circuit 1104 may communicate with other terminals through at least one wireless communication protocol. The wireless communication protocols include, but are not limited to, metropolitan area networks, mobile communication networks of various generations (2G, 3G, 4G and 8G), wireless local area networks and/or WiFi (Wireless Fidelity, wireless fidelity) networks. In some embodiments, the radio frequency circuit 1104 may further include a circuit related to NFC (Near Field Communication, short-range wireless communication), which is not limited in this application.

显示屏1105用于显示UI(UserInterface,用户界面)。该UI可以包括图形、文本、图标、视频及其它们的任意组合。当显示屏1105是触摸显示屏时,显示屏1105还具有采集在显示屏1105的表面或表面上方的触摸信号的能力。该触摸信号可以作为控制信号输入至处理器1101进行处理。此时,显示屏1105还可以用于提供虚拟按钮和/或虚拟键盘,也称软按钮和/或软键盘。在一些实施例中,显示屏1105可以为一个,设置在终端1100的前面板;在另一些实施例中,显示屏1105可以为至少两个,分别设置在终端1100的不同表面或呈折叠设计;在另一些实施例中,显示屏1105可以是柔性显示屏,设置在终端1100的弯曲表面上或折叠面上。甚至,显示屏1105还可以设置成非矩形的不规则图形,也即异形屏。显示屏1105可以采用LCD(Liquid Crystal Display,液晶显示屏)、OLED(Organic Light-Emitting Diode,有机发光二极管)等材质制备。The display screen 1105 is used for displaying UI (User Interface, user interface). The UI can include graphics, text, icons, video, and any combination thereof. When the display screen 1105 is a touch display screen, the display screen 1105 also has the ability to acquire touch signals on or above the surface of the display screen 1105 . The touch signal can be input to the processor 1101 as a control signal for processing. At this time, the display screen 1105 may also be used to provide virtual buttons and/or virtual keyboards, also referred to as soft buttons and/or soft keyboards. In some embodiments, there may be one display screen 1105, which is arranged on the front panel of the terminal 1100; in other embodiments, there may be at least two display screens 1105, which are respectively arranged on different surfaces of the terminal 1100 or in a folded design; In other embodiments, the display screen 1105 may be a flexible display screen, which is disposed on a curved surface or a folding surface of the terminal 1100 . Even, the display screen 1105 can also be set as a non-rectangular irregular figure, that is, a special-shaped screen. The display screen 1105 can be made of materials such as LCD (Liquid Crystal Display, liquid crystal display), OLED (Organic Light-Emitting Diode, organic light emitting diode).

摄像头组件1106用于采集图像或视频。可选地,摄像头组件1106包括前置摄像头和后置摄像头。通常,前置摄像头设置在终端的前面板,后置摄像头设置在终端的背面。在一些实施例中,后置摄像头为至少两个,分别为主摄像头、景深摄像头、广角摄像头、长焦摄像头中的任意一种,以实现主摄像头和景深摄像头融合实现背景虚化功能、主摄像头和广角摄像头融合实现全景拍摄以及VR(Virtual Reality,虚拟现实)拍摄功能或者其它融合拍摄功能。在一些实施例中,摄像头组件1106还可以包括闪光灯。闪光灯可以是单色温闪光灯,也可以是双色温闪光灯。双色温闪光灯是指暖光闪光灯和冷光闪光灯的组合,可以用于不同色温下的光线补偿。The camera assembly 1106 is used to capture images or video. Optionally, the camera assembly 1106 includes a front camera and a rear camera. Usually, the front camera is arranged on the front panel of the terminal, and the rear camera is arranged on the back of the terminal. In some embodiments, there are at least two rear cameras, which are any one of a main camera, a depth-of-field camera, a wide-angle camera, and a telephoto camera, so as to realize the fusion of the main camera and the depth-of-field camera to realize the background blur function, the main camera It is integrated with the wide-angle camera to achieve panoramic shooting and VR (Virtual Reality, virtual reality) shooting functions or other integrated shooting functions. In some embodiments, the camera assembly 1106 may also include a flash. The flash can be a single color temperature flash or a dual color temperature flash. Dual color temperature flash refers to the combination of warm light flash and cold light flash, which can be used for light compensation under different color temperatures.

音频电路1107可以包括麦克风和扬声器。麦克风用于采集用户及环境的声波,并将声波转换为电信号输入至处理器1101进行处理,或者输入至射频电路1104以实现语音通信。出于立体声采集或降噪的目的,麦克风可以为多个,分别设置在终端1100的不同部位。麦克风还可以是阵列麦克风或全向采集型麦克风。扬声器则用于将来自处理器1101或射频电路1104的电信号转换为声波。扬声器可以是传统的薄膜扬声器,也可以是压电陶瓷扬声器。当扬声器是压电陶瓷扬声器时,不仅可以将电信号转换为人类可听见的声波,也可以将电信号转换为人类听不见的声波以进行测距等用途。在一些实施例中,音频电路1107还可以包括耳机插孔。Audio circuitry 1107 may include a microphone and speakers. The microphone is used to collect the sound waves of the user and the environment, convert the sound waves into electrical signals, and input them to the processor 1101 for processing, or to the radio frequency circuit 1104 to realize voice communication. For the purpose of stereo collection or noise reduction, there may be multiple microphones, which are respectively disposed in different parts of the terminal 1100 . The microphone may also be an array microphone or an omnidirectional collection microphone. The speaker is used to convert the electrical signal from the processor 1101 or the radio frequency circuit 1104 into sound waves. The loudspeaker can be a traditional thin-film loudspeaker or a piezoelectric ceramic loudspeaker. When the speaker is a piezoelectric ceramic speaker, it can not only convert electrical signals into sound waves audible to humans, but also convert electrical signals into sound waves inaudible to humans for distance measurement and other purposes. In some embodiments, audio circuitry 1107 may also include a headphone jack.

定位组件1108用于定位终端1100的当前地理位置,以实现导航或LBS(LocationBased Service,基于位置的服务)。定位组件1108可以是基于美国的GPS(GlobalPositioning System,全球定位系统)、中国的北斗系统、俄罗斯的格雷纳斯系统或欧盟的伽利略系统的定位组件。The positioning component 1108 is used to locate the current geographic location of the terminal 1100 to implement navigation or LBS (Location Based Service, location-based service). The positioning component 1108 may be a positioning component based on the GPS (Global Positioning System, global positioning system) of the United States, the Beidou system of China, the Grenas system of Russia, or the Galileo system of the European Union.

电源1109用于为终端1100中的各个组件进行供电。电源1109可以是交流电、直流电、一次性电池或可充电电池。当电源1109包括可充电电池时,该可充电电池可以支持有线充电或无线充电。该可充电电池还可以用于支持快充技术。The power supply 1109 is used to power various components in the terminal 1100 . The power source 1109 may be alternating current, direct current, disposable batteries, or rechargeable batteries. When the power source 1109 includes a rechargeable battery, the rechargeable battery can support wired charging or wireless charging. The rechargeable battery can also be used to support fast charging technology.

在一些实施例中,终端1100还包括有一个或多个传感器1110。该一个或多个传感器1110包括但不限于:加速度传感器1111、陀螺仪传感器1112、压力传感器1113、指纹传感器1114、光学传感器1115以及接近传感器1116。In some embodiments, the terminal 1100 also includes one or more sensors 1110 . The one or more sensors 1110 include, but are not limited to, an acceleration sensor 1111 , a gyro sensor 1112 , a pressure sensor 1113 , a fingerprint sensor 1114 , an optical sensor 1115 , and a proximity sensor 1116 .

加速度传感器1111可以检测以终端1100建立的坐标系的三个坐标轴上的加速度大小。比如,加速度传感器1111可以用于检测重力加速度在三个坐标轴上的分量。处理器1101可以根据加速度传感器1111采集的重力加速度信号,控制显示屏1105以横向视图或纵向视图进行用户界面的显示。加速度传感器1111还可以用于游戏或者用户的运动数据的采集。The acceleration sensor 1111 can detect the magnitude of acceleration on the three coordinate axes of the coordinate system established by the terminal 1100 . For example, the acceleration sensor 1111 can be used to detect the components of the gravitational acceleration on the three coordinate axes. The processor 1101 can control the display screen 1105 to display the user interface in a landscape view or a portrait view according to the gravitational acceleration signal collected by the acceleration sensor 1111 . The acceleration sensor 1111 can also be used for game or user movement data collection.

陀螺仪传感器1112可以检测终端1100的机体方向及转动角度,陀螺仪传感器1112可以与加速度传感器1111协同采集用户对终端1100的3D动作。处理器1101根据陀螺仪传感器1112采集的数据,可以实现如下功能:动作感应(比如根据用户的倾斜操作来改变UI)、拍摄时的图像稳定、游戏控制以及惯性导航。The gyroscope sensor 1112 can detect the body direction and rotation angle of the terminal 1100 , and the gyroscope sensor 1112 can cooperate with the acceleration sensor 1111 to collect 3D actions of the user on the terminal 1100 . The processor 1101 can implement the following functions according to the data collected by the gyro sensor 1112: motion sensing (such as changing the UI according to the user's tilt operation), image stabilization during shooting, game control, and inertial navigation.

压力传感器1113可以设置在终端1100的侧边框和/或显示屏1105的下层。当压力传感器1113设置在终端1100的侧边框时,可以检测用户对终端1100的握持信号,由处理器1101根据压力传感器1113采集的握持信号进行左右手识别或快捷操作。当压力传感器1113设置在显示屏1105的下层时,由处理器1101根据用户对显示屏1105的压力操作,实现对UI界面上的可操作性控件进行控制。可操作性控件包括按钮控件、滚动条控件、图标控件、菜单控件中的至少一种。The pressure sensor 1113 may be disposed on the side frame of the terminal 1100 and/or the lower layer of the display screen 1105 . When the pressure sensor 1113 is disposed on the side frame of the terminal 1100, the user's holding signal of the terminal 1100 can be detected, and the processor 1101 can perform left and right hand identification or shortcut operations according to the holding signal collected by the pressure sensor 1113. When the pressure sensor 1113 is disposed on the lower layer of the display screen 1105, the processor 1101 controls the operability controls on the UI interface according to the user's pressure operation on the display screen 1105. The operability controls include at least one of button controls, scroll bar controls, icon controls, and menu controls.

指纹传感器1114用于采集用户的指纹,由处理器1101根据指纹传感器1114采集到的指纹识别用户的身份,或者,由指纹传感器1114根据采集到的指纹识别用户的身份。在识别出用户的身份为可信身份时,由处理器1101授权该用户具有相关的敏感操作,该敏感操作包括解锁屏幕、查看加密信息、下载软件、支付及更改设置等。指纹传感器1114可以被设置在终端1100的正面、背面或侧面。当终端1100上设置有物理按键或厂商Logo时,指纹传感器1114可以与物理按键或厂商标志集成在一起。The fingerprint sensor 1114 is used to collect the user's fingerprint, and the processor 1101 identifies the user's identity according to the fingerprint collected by the fingerprint sensor 1114, or the fingerprint sensor 1114 identifies the user's identity according to the collected fingerprint. When the user's identity is identified as a trusted identity, the processor 1101 authorizes the user to perform relevant sensitive operations, including unlocking the screen, viewing encrypted information, downloading software, making payments, and changing settings. The fingerprint sensor 1114 may be disposed on the front, back or side of the terminal 1100 . When the terminal 1100 is provided with physical buttons or a manufacturer's logo, the fingerprint sensor 1114 may be integrated with the physical buttons or the manufacturer's logo.

光学传感器1115用于采集环境光强度。在一个实施例中,处理器1101可以根据光学传感器1115采集的环境光强度,控制显示屏1105的显示亮度。具体地,当环境光强度较高时,调高显示屏1105的显示亮度;当环境光强度较低时,调低显示屏1105的显示亮度。在另一个实施例中,处理器1101还可以根据光学传感器1115采集的环境光强度,动态调整摄像头组件1106的拍摄参数。Optical sensor 1115 is used to collect ambient light intensity. In one embodiment, the processor 1101 can control the display brightness of the display screen 1105 according to the ambient light intensity collected by the optical sensor 1115 . Specifically, when the ambient light intensity is high, the display brightness of the display screen 1105 is increased; when the ambient light intensity is low, the display brightness of the display screen 1105 is decreased. In another embodiment, the processor 1101 can also dynamically adjust the shooting parameters of the camera assembly 1106 according to the ambient light intensity collected by the optical sensor 1115 .

接近传感器1116,也称距离传感器,通常设置在终端1100的前面板。接近传感器1116用于采集用户与终端1100的正面之间的距离。在一个实施例中,当接近传感器1116检测到用户与终端1100的正面之间的距离逐渐变小时,由处理器1101控制显示屏1105从亮屏状态切换为息屏状态;当接近传感器1116检测到用户与终端1100的正面之间的距离逐渐变大时,由处理器1101控制显示屏1105从息屏状态切换为亮屏状态。A proximity sensor 1116 , also called a distance sensor, is usually disposed on the front panel of the terminal 1100 . The proximity sensor 1116 is used to collect the distance between the user and the front of the terminal 1100 . In one embodiment, when the proximity sensor 1116 detects that the distance between the user and the front of the terminal 1100 is gradually decreasing, the processor 1101 controls the display screen 1105 to switch from the bright screen state to the off screen state; when the proximity sensor 1116 detects When the distance between the user and the front of the terminal 1100 gradually increases, the processor 1101 controls the display screen 1105 to switch from the screen-off state to the screen-on state.

本领域技术人员可以理解,图11中示出的结构并不构成对终端1100的限定,可以包括比图示更多或更少的组件,或者组合某些组件,或者采用不同的组件布置。Those skilled in the art can understand that the structure shown in FIG. 11 does not constitute a limitation on the terminal 1100, and may include more or less components than the one shown, or combine some components, or adopt different component arrangements.

图12是本申请实施例提供的一种服务器的结构示意图,该服务器1200可因配置或性能不同而产生比较大的差异,可以包括一个或一个以上处理器(Central ProcessingUnits,CPU)1201和一个或一个以上的存储器1202,其中,所述存储器1202中存储有至少一条指令,所述至少一条指令由所述处理器1201加载并执行以实现上述各个方法实施例提供的方法。当然,该服务器还可以具有有线或无线网络接口、键盘以及输入输出接口等部件,以便进行输入输出,该服务器还可以包括其他用于实现设备功能的部件,在此不做赘述。12 is a schematic structural diagram of a server provided by an embodiment of the present application. The server 1200 may vary greatly due to different configurations or performance, and may include one or more processors (Central Processing Units, CPU) 1201 and one or more One or more memories 1202, wherein at least one instruction is stored in the memory 1202, and the at least one instruction is loaded and executed by the processor 1201 to implement the methods provided by the above method embodiments. Of course, the server may also have components such as a wired or wireless network interface, a keyboard, and an input/output interface for input and output, and the server may also include other components for implementing device functions, which will not be described here.

服务器1200可以用于执行上述问答方法中服务器所执行的步骤。The server 1200 may be used to perform the steps performed by the server in the above question and answer method.

本申请实施例还提供了一种电子设备,电子设备包括一个或多个处理器和一个或多个存储器,一个或多个存储器中存储有至少一条指令,至少一条指令由一个或多个处理器加载并执行以实现如问答方法所执行的操作。An embodiment of the present application further provides an electronic device, the electronic device includes one or more processors and one or more memories, at least one instruction is stored in the one or more memories, and at least one instruction is executed by the one or more processors Load and execute to do what the Q&A method does.

本申请实施例还提供了一种计算机可读存储介质,存储介质中存储有至少一条指令,至少一条指令由处理器加载并执行以实现如的问答方法所执行的操作。Embodiments of the present application further provide a computer-readable storage medium, where at least one instruction is stored, and the at least one instruction is loaded and executed by a processor to implement operations performed by the question-and-answer method.

本领域普通技术人员可以理解实现上述实施例的全部或部分步骤可以通过硬件来完成,也可以通过程序来指令相关的硬件完成,所述的程序可以存储于一种计算机可读存储介质中,上述提到的存储介质可以是只读存储器,磁盘或光盘等。Those of ordinary skill in the art can understand that all or part of the steps of implementing the above embodiments can be completed by hardware, or can be completed by instructing relevant hardware through a program, and the program can be stored in a computer-readable storage medium. The storage medium mentioned may be a read-only memory, a magnetic disk or an optical disk, etc.

以上所述仅为本申请的较佳实施例,并不用以限制本申请,凡在本申请的精神和原则之内,所作的任何修改、等同替换、改进等,均应包含在本申请的保护范围之内。The above descriptions are only preferred embodiments of the present application, and are not intended to limit the present application. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present application shall be included in the protection of the present application. within the range.

Claims (15)

1.一种问答方法,其特征在于,所述方法包括:1. a question and answer method, it is characterised in that the method comprises: 获取第一问题信息的第一问题向量和至少一条第二问题信息的第二问题向量,所述至少一条第二问题信息为在所述第一问题信息之前获取的问题信息;acquiring a first question vector of first question information and at least one second question vector of second question information, where the at least one piece of second question information is question information obtained before the first question information; 调用答案生成模型,根据所述第一问题向量和至少一条第二问题向量,获取至少一条答案信息,所述答案生成模型用于根据任一问题向量生成所述任一问题向量匹配的答案信息;Invoke the answer generation model, obtain at least one piece of answer information according to the first question vector and at least one second question vector, and the answer generation model is used to generate the answer information matched by any question vector according to any question vector; 根据所述第一问题信息或所述第一问题向量,在问答数据库中进行检索;According to the first question information or the first question vector, searching in the question answering database; 调用排序模型,按照与所述第一问题信息的匹配度从高到低的顺序,对获取到的多条答案信息进行排序,将排在第一位的答案信息确定为所述目标答案信息。The sorting model is invoked to sort the obtained pieces of answer information in descending order of matching degree with the first question information, and the answer information ranked first is determined as the target answer information. 2.根据权利要求1所述的方法,其特征在于,所述方法还包括:2. The method according to claim 1, wherein the method further comprises: 获取样本问题信息和对应的样本答案信息,以及所述样本问题信息与所述样本答案信息的样本匹配度;Obtain sample question information and corresponding sample answer information, as well as the sample matching degree between the sample question information and the sample answer information; 根据所述样本问题信息、所述样本答案信息和所述样本匹配度,对所述排序模型进行训练,得到训练后的排序模型。According to the sample question information, the sample answer information and the sample matching degree, the ranking model is trained to obtain a trained ranking model. 3.根据权利要求2所述的方法,其特征在于,所述根据所述样本问题信息、所述样本答案信息和所述样本匹配度,对所述排序模型进行训练,得到训练后的排序模型,包括:3. The method according to claim 2, wherein the sorting model is trained according to the sample question information, the sample answer information and the sample matching degree to obtain a trained sorting model ,include: 将所述样本问题信息与所述样本答案信息输入至所述排序模型中,获取所述样本问题信息与所述样本答案信息的预测匹配度;inputting the sample question information and the sample answer information into the ranking model, and obtaining the predicted matching degree between the sample question information and the sample answer information; 根据所述样本匹配度和所述预测匹配度,对所述排序模型进行训练,得到训练后的排序模型。According to the sample matching degree and the predicted matching degree, the ranking model is trained to obtain a trained ranking model. 4.根据权利要求1所述的方法,其特征在于,所述排序模型包括多个匹配层、一个融合层和一个排序层,所述调用排序模型,按照与所述第一问题信息的匹配度从高到低的顺序,对获取到的多条答案信息进行排序,将排在第一位的答案信息确定为所述目标答案信息,包括:4 . The method according to claim 1 , wherein the ranking model comprises a plurality of matching layers, a fusion layer and a ranking layer, and the calling ranking model is based on the degree of matching with the first question information. 5 . Sort the obtained pieces of answer information in order from high to low, and determine the first answer information as the target answer information, including: 调用所述多个匹配层,分别获取每条答案信息与所述第一问题信息的匹配度;Calling the multiple matching layers to obtain the matching degree of each piece of answer information and the first question information respectively; 调用所述融合层,获取所述每条答案信息的多个匹配度的融合匹配度;Call the fusion layer to obtain the fusion matching degree of the multiple matching degrees of each piece of answer information; 调用所述排序层,按照融合匹配度由高到低的顺序,对所述多条答案信息进行排序,将排在第一位的答案信息确定为所述目标答案信息。The sorting layer is called to sort the multiple pieces of answer information according to the order of fusion matching degree from high to low, and the answer information ranked first is determined as the target answer information. 5.根据权利要求1所述的方法,其特征在于,所述获取第一问题信息的第一问题向量,包括:5. The method according to claim 1, wherein the acquiring the first question vector of the first question information comprises: 对所述第一问题信息进行分词处理,得到分词后的多个第一词语;Perform word segmentation processing on the first question information to obtain a plurality of first words after word segmentation; 获取所述多个第一词语的相似词语;obtaining similar words of the plurality of first words; 每次将至少一个第一词语替换为对应的相似词语,生成一条相似问题信息;Each time at least one first word is replaced with a corresponding similar word to generate a piece of similar question information; 根据所述第一问题信息和所述至少一条相似问题信息,获取所述第一问题向量。Obtain the first question vector according to the first question information and the at least one piece of similar question information. 6.根据权利要求5所述的方法,其特征在于,所述获取所述多个第一词语的相似词语,包括:6. The method according to claim 5, wherein the acquiring similar words of the plurality of first words comprises: 从知识数据库中,获取所述多个第一词语中每个第一词语关联的相似词语,所述知识数据库用于存储各个词语与每个词语关联的相似词语;或者,Obtain, from a knowledge database, similar words associated with each of the plurality of first words, where the knowledge database is used to store similar words associated with each word; or, 获取所述多个第一词语中每个第一词语与至少一个预设词语的相似度,将与任一第一词语的相似度大于第一预设相似度的预设词语,作为所述任一第一词语的相似词语。Obtain the similarity between each first word in the plurality of first words and at least one preset word, and use a preset word whose similarity with any first word is greater than the first preset similarity as the arbitrary first word. A similar word to the first word. 7.根据权利要求5所述的方法,其特征在于,所述根据所述第一问题信息和所述至少一条相似问题信息,获取所述第一问题向量,包括:7. The method according to claim 5, wherein the obtaining the first question vector according to the first question information and the at least one piece of similar question information comprises: 获取所述至少一条相似问题信息的特征向量和所述第一问题信息的特征向量的平均向量,作为所述第一问题向量。An average vector of the feature vector of the at least one piece of similar question information and the feature vector of the first question information is acquired as the first question vector. 8.根据权利要求1所述的方法,其特征在于,所述调用答案生成模型,根据所述第一问题向量和至少一条第二问题向量,获取至少一条答案信息,包括:8. The method according to claim 1, wherein the invoking the answer generation model, according to the first question vector and at least one second question vector, obtains at least one piece of answer information, comprising: 将所述第一问题向量和所述至少一条第二问题向量进行拼接,得到第三问题向量;splicing the first problem vector and the at least one second problem vector to obtain a third problem vector; 调用所述答案生成模型,根据所述第三问题向量,获取所述至少一条答案信息。The answer generation model is called, and the at least one piece of answer information is acquired according to the third question vector. 9.根据权利要求1所述的方法,其特征在于,所述根据所述第一问题信息或所述第一问题向量,在问答数据库中进行检索,包括:9. The method according to claim 1, wherein the retrieval in the question and answer database according to the first question information or the first question vector comprises: 将所述第一问题向量和所述至少一条第二问题向量进行拼接,得到第三问题向量;splicing the first problem vector and the at least one second problem vector to obtain a third problem vector; 根据所述第三问题向量与所述问答数据库中的每个预设答案信息的特征向量之间的相似度,获取至少一条答案信息,所述至少一条答案信息的特征向量与所述第三问题向量的相似度大于其他预设答案信息的特征向量与所述第三问题向量的相似度。According to the similarity between the third question vector and the feature vector of each preset answer information in the question answering database, at least one piece of answer information is obtained, and the feature vector of the at least one piece of answer information is related to the third question The similarity of the vectors is greater than the similarity between the feature vectors of other preset answer information and the third question vector. 10.根据权利要求1所述的方法,其特征在于,所述至少一条第二问题向量包括多条第二问题向量,所述调用答案生成模型,根据所述第一问题向量和至少一条第二问题向量,获取至少一条答案信息,包括:10. The method according to claim 1, wherein the at least one second question vector comprises a plurality of second question vectors, and the invoking answer generation model is based on the first question vector and the at least one second question vector. Question vector, get at least one answer information, including: 对所述多条第二问题向量进行加权平均,得到第四问题向量;performing a weighted average on the plurality of second problem vectors to obtain a fourth problem vector; 将所述第一问题向量和所述第四问题向量进行拼接,得到融合问题向量;Splicing the first problem vector and the fourth problem vector to obtain a fusion problem vector; 根据所述融合问题向量,调用所述答案生成模型,获取所述至少一条答案信息。According to the fusion question vector, the answer generation model is called to obtain the at least one piece of answer information. 11.根据权利要求1所述的方法,其特征在于,所述根据所述第一问题信息或所述第一问题向量,在问答数据库中进行检索,包括:11. The method according to claim 1, wherein the retrieval in the question and answer database according to the first question information or the first question vector comprises: 对所述多个第二问题向量进行加权平均,得到第四问题向量;performing a weighted average on the plurality of second problem vectors to obtain a fourth problem vector; 将所述第一问题向量和所述第四问题向量进行拼接,得到融合问题向量;Splicing the first problem vector and the fourth problem vector to obtain a fusion problem vector; 根据所述融合问题向量与所述问答数据库中的每个预设答案信息的特征向量之间的相似度,获取至少一条答案信息,所述至少一条答案信息的特征向量与所述融合问题向量的相似度大于其他预设答案信息的特征向量与所述融合问题向量的相似度。At least one piece of answer information is obtained according to the similarity between the fusion question vector and the feature vector of each preset answer information in the question answering database, and the feature vector of the at least one piece of answer information is the difference between the fusion question vector and the fusion question vector. The similarity is greater than the similarity between the feature vector of other preset answer information and the fusion question vector. 12.根据权利要求1所述的方法,其特征在于,所述根据所述第一问题信息或所述第一问题向量,在问答数据库中进行检索,包括:12. The method according to claim 1, wherein the retrieval in the question and answer database according to the first question information or the first question vector comprises: 根据所述第一问题向量,在所述问答数据库中进行检索,确定至少一条第五问题向量,所述至少一条第五问题向量包括所述第一问题向量相似的问题向量;或者,According to the first question vector, perform retrieval in the question answering database to determine at least one fifth question vector, where the at least one fifth question vector includes question vectors similar to the first question vector; or, 根据所述第一问题向量和所述至少一条第二问题向量,在所述问答数据库中进行检索,确定至少一条第五问题向量,所述至少一条第五问题向量包括所述第一问题向量相似的问题向量或所述至少一条第二问题向量相似的问题向量中的至少一种;According to the first question vector and the at least one second question vector, perform retrieval in the question answering database to determine at least one fifth question vector, the at least one fifth question vector including the first question vector is similar At least one of the problem vectors of or the problem vectors that are similar to the at least one second problem vector; 从所述问答数据库中,获取所述至少一条第五问题向量的答案信息,作为所述至少一条答案信息。From the question and answer database, the answer information of the at least one fifth question vector is obtained as the at least one piece of answer information. 13.一种问答装置,其特征在于,所述装置包括:13. A question and answer device, characterized in that the device comprises: 获取模块,用于获取第一问题信息的第一问题向量和至少一条第二问题信息的第二问题向量,所述至少一条第二问题信息为在所述第一问题信息之前获取的问题信息;an acquisition module, configured to acquire the first question vector of the first question information and the second question vector of at least one piece of second question information, where the at least one piece of second question information is the question information acquired before the first question information; 生成模块,用于调用答案生成模型,根据所述第一问题向量和至少一条第二问题向量,获取至少一条答案信息,所述答案生成模型用于根据任一问题向量生成所述任一问题向量匹配的答案信息;The generation module is used to call the answer generation model to obtain at least one piece of answer information according to the first question vector and at least one second question vector, and the answer generation model is used to generate the any question vector according to any question vector matching answer information; 检索模块,用于根据所述第一问题信息或所述第一问题向量,在问答数据库中进行检索;a retrieval module, configured to perform retrieval in the question and answer database according to the first question information or the first question vector; 排序模块,用于调用排序模型,按照与所述第一问题信息的匹配度从高到低的顺序,对获取到的多条答案信息进行排序,将排在第一位的答案信息确定为所述目标答案信息。The sorting module is used to call the sorting model, sort the obtained multiple pieces of answer information in the order of matching degree with the first question information from high to low, and determine the answer information ranked first as the Describe the target answer information. 14.一种电子设备,其特征在于,所述电子设备包括一个或多个处理器和一个或多个存储器,所述一个或多个存储器中存储有至少一条指令,所述至少一条指令由所述一个或多个处理器加载并执行以实现如权利要求1至12任一项所述的问答方法所执行的操作。14. An electronic device, characterized in that the electronic device comprises one or more processors and one or more memories, wherein the one or more memories store at least one instruction, the at least one instruction is The one or more processors are loaded and executed to implement the operations performed by the question answering method of any one of claims 1 to 12. 15.一种计算机可读存储介质,其特征在于,所述存储介质中存储有至少一条指令,所述至少一条指令由处理器加载并执行以实现如权利要求1至12任一项所述的问答方法所执行的操作。15. A computer-readable storage medium, wherein at least one instruction is stored in the storage medium, and the at least one instruction is loaded and executed by a processor to implement the method according to any one of claims 1 to 12. The action performed by the Q&A method.
CN202010613891.3A 2020-06-30 2020-06-30 Question and answer method, device, equipment and storage medium Active CN111782767B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010613891.3A CN111782767B (en) 2020-06-30 2020-06-30 Question and answer method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010613891.3A CN111782767B (en) 2020-06-30 2020-06-30 Question and answer method, device, equipment and storage medium

Publications (2)

Publication Number Publication Date
CN111782767A true CN111782767A (en) 2020-10-16
CN111782767B CN111782767B (en) 2024-08-27

Family

ID=72761439

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010613891.3A Active CN111782767B (en) 2020-06-30 2020-06-30 Question and answer method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN111782767B (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113239169A (en) * 2021-06-01 2021-08-10 平安科技(深圳)有限公司 Artificial intelligence-based answer generation method, device, equipment and storage medium
CN119760057A (en) * 2024-11-07 2025-04-04 北京市农林科学院信息技术研究中心 Response large model retrieval enhancement method and device based on hierarchical cluster index structure

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20160247068A1 (en) * 2013-11-01 2016-08-25 Tencent Technology (Shenzhen) Company Limited System and method for automatic question answering
CN109241258A (en) * 2018-08-23 2019-01-18 江苏索迩软件技术有限公司 A kind of deep learning intelligent Answer System using tax field
CN109684452A (en) * 2018-12-25 2019-04-26 中科国力(镇江)智能技术有限公司 A kind of neural network problem generation method based on answer Yu answer location information
CN110287296A (en) * 2019-05-21 2019-09-27 平安科技(深圳)有限公司 Method, device, computer equipment and storage medium for selecting answers to questions

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20160247068A1 (en) * 2013-11-01 2016-08-25 Tencent Technology (Shenzhen) Company Limited System and method for automatic question answering
CN109241258A (en) * 2018-08-23 2019-01-18 江苏索迩软件技术有限公司 A kind of deep learning intelligent Answer System using tax field
CN109684452A (en) * 2018-12-25 2019-04-26 中科国力(镇江)智能技术有限公司 A kind of neural network problem generation method based on answer Yu answer location information
CN110287296A (en) * 2019-05-21 2019-09-27 平安科技(深圳)有限公司 Method, device, computer equipment and storage medium for selecting answers to questions

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113239169A (en) * 2021-06-01 2021-08-10 平安科技(深圳)有限公司 Artificial intelligence-based answer generation method, device, equipment and storage medium
CN113239169B (en) * 2021-06-01 2023-12-05 平安科技(深圳)有限公司 Answer generation method, device, equipment and storage medium based on artificial intelligence
CN119760057A (en) * 2024-11-07 2025-04-04 北京市农林科学院信息技术研究中心 Response large model retrieval enhancement method and device based on hierarchical cluster index structure

Also Published As

Publication number Publication date
CN111782767B (en) 2024-08-27

Similar Documents

Publication Publication Date Title
CN110471858B (en) Application program testing method, device and storage medium
WO2022057435A1 (en) Search-based question answering method, and storage medium
CN110163380A (en) Data analysing method, model training method, device, equipment and storage medium
CN111506758A (en) Method and device for determining article name, computer equipment and storage medium
CN111782950A (en) Sample data set acquisition method, device, equipment and storage medium
CN112148899A (en) Multimedia recommendation method, device, equipment and storage medium
CN111581958A (en) Dialogue state determination method, device, computer equipment and storage medium
CN110837557B (en) Abstract generation method, device, equipment and medium
CN112052354A (en) Video recommendation method, video display method and device and computer equipment
CN109902089B (en) Query method and device using heterogeneous index, electronic equipment and medium
CN111782767B (en) Question and answer method, device, equipment and storage medium
CN114117206B (en) Recommendation model processing method and device, electronic equipment and storage medium
WO2021218634A1 (en) Content pushing
CN112100528B (en) Method, device, equipment and medium for training search result scoring model
CN114328815A (en) Text mapping model processing method and device, computer equipment and storage medium
CN114547429A (en) Data recommendation method, device, server and storage medium
CN114817709A (en) Sorting method, device, equipment and computer readable storage medium
CN113593521B (en) Speech synthesis method, device, equipment and readable storage medium
CN114741602A (en) Object recommendation method, target model training method, device and equipment
CN113139613A (en) Feature extraction method and device, electronic equipment and storage medium
CN113139614A (en) Feature extraction method and device, electronic equipment and storage medium
CN114764480A (en) Group type identification method and device, computer equipment and medium
CN112487162A (en) Method, device and equipment for determining text semantic information and storage medium
CN111597823A (en) Central word extraction method, device, equipment and storage medium
CN113869272B (en) Processing method, device, electronic device and medium based on feature extraction model

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
TR01 Transfer of patent right

Effective date of registration: 20241118

Address after: Room 301, Building 2, No. 18 Tianshan West Road, Changning District, Shanghai, 200335

Patentee after: Shanghai Liangxin Technology Co.,Ltd.

Country or region after: China

Patentee after: BEIJING SANKUAI ONLINE TECHNOLOGY Co.,Ltd.

Address before: 100080 2106-030, 9 North Fourth Ring Road, Haidian District, Beijing.

Patentee before: BEIJING SANKUAI ONLINE TECHNOLOGY Co.,Ltd.

Country or region before: China

TR01 Transfer of patent right