A reply method and device based on a question and answer model and an electronic device

By identifying the type of user input and retrieving response information from a description database, a pre-trained question-answering model was used to solve the problem of answer mismatch in question-answering systems, achieving higher-precision responses.

CN115658870BActive Publication Date: 2026-01-27NAT UNIV OF DEFENSE TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211368135.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-11-03
Publication Date
2026-01-27
Estimated Expiration
2042-11-03

Smart Images

  • Figure CN115658870B_ABST
    Figure CN115658870B_ABST
Patent Text Reader

Abstract

The embodiment of the application discloses a reply method based on a question and answer model, comprising: obtaining a to-be-replied sentence input by a user; identifying a target object involved in the to-be-replied sentence; searching for description information of the target object from a pre-set description information library; identifying a type of the to-be-replied sentence; if the type of the to-be-replied sentence is the type with an answer, obtaining reply information corresponding to the to-be-replied sentence according to the target description information and outputting. Through identifying the type of the to-be-replied sentence, the question is classified and replied, the precision of the reply is improved, and feature extraction is not needed, avoiding the problem of difficult feature extraction. Through obtaining the target description information related to the to-be-replied content, then obtaining the reply according to the target description information, the precision of the model is improved, and the user obtains a more satisfactory and comprehensive answer.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular to a response method, apparatus, and electronic device based on a question-and-answer model. Background Technology

[0002] A question-answering system (QA) is an intelligent information search system that can answer user questions accurately and concisely using natural language. Typically, a QA system finds the question with the highest similarity to the user's input from a pre-stored question-and-answer database and outputs the answer to that question. However, QA systems are limited by the question-and-answer database, and the types of questions they can answer are relatively limited.

[0003] Traditional machine learning methods train question-answering systems by extracting semantic features from questions as training samples. The operations involved in traditional semantic feature extraction include rule matching, segmentation, and syntactic analysis. However, these operations all have various problems: rule matching relies on pre-designed rules to identify semantic feature words in the initial question, which is difficult to extend and lacks generality; segmentation methods segment the initial question by analyzing its word organization rules and semantic features, but the segmentation accuracy is low, leading to inaccurate semantic feature words; syntactic analysis is affected by the analysis results, resulting in poor accuracy of the training samples.

[0004] Among existing semantic feature extraction methods, some are rule-based, have poor applicability, and produce training samples with poor diversity. Other methods lack precision, resulting in poor accuracy of the training samples. Consequently, the question-answering system trained by these methods performs poorly, and the output answers do not match the questions. Summary of the Invention

[0005] This application provides a response method, apparatus, and electronic device based on a question-and-answer model, which can solve the problem that existing question-and-answer systems have poor performance and the output answer does not match the input question.

[0006] In a first aspect, embodiments of this application provide a response method based on a question-and-answer model, the method comprising:

[0007] Get the user's input statement to be replied to;

[0008] Identify the target object involved in the statement to be replied to;

[0009] The description information of the target object is retrieved from a pre-set description information database and used as the target description information;

[0010] Identify the type of the statement to be replied to, which is one of the following: no answer or answer; the no answer type refers to a type where no valid answer can be obtained, and the answer type refers to a type where a valid answer can be obtained.

[0011] If the type of the statement to be replied to is the type with an answer, obtain the reply information corresponding to the statement to be replied to based on the target description information and output it.

[0012] In one alternative design, it also includes:

[0013] If the type of the statement to be replied to is the first type with an answer, extract the descriptive words of the target object from the statement to be replied to, calculate the probability that the answer to the statement to be replied to is a positive answer and the probability that it is a negative answer based on the descriptive words of the target object and the target description information, and output the answer with the higher probability.

[0014] If the type of the statement to be replied to is the second type with an answer, search for the reply information corresponding to the statement to be replied to in the target description information, determine the start position and end position of the reply information in the target description information, and output the text between the start position and the end position as the answer.

[0015] In one alternative design, it also includes:

[0016] If the type of the statement to be replied to is "no answer", output the preset reply information, which includes error information or default reply information.

[0017] In one alternative design, identifying the type of the statement to be replied to includes:

[0018] After integrating the target description information into the statement to be replied to, the text to be identified is obtained;

[0019] Add a start identifier and an end identifier to the text to be recognized;

[0020] Based on the start identifier and the end identifier, obtain the segment vector, position vector and word vector corresponding to the text to be identified;

[0021] The input vector is obtained by adding the segment vector, the position vector, and the word vector corresponding to the text to be identified.

[0022] The input vector is fed into a pre-trained question-answering model to identify the type of the statement to be answered.

[0023] In an optional design, calculating the probability that the answer to the statement to be replied to is an affirmative answer and the probability that it is a negative answer based on the descriptive words of the target object and the target description information includes:

[0024] Record the index vector of the descriptor of the target object in the statement to be replied to, and obtain the position output vector of the index vector in the statement to be replied to;

[0025] The semantic relationship score is obtained by encoding the position output vector with the segment vector, position vector and word vector corresponding to the text to be identified;

[0026] The probability of an affirmative answer and the probability of a negative answer to the statement to be replied to are calculated based on the semantic relationship score.

[0027] In one optional design, determining the start and end positions of the response information in the target description information includes:

[0028] The word vectors corresponding to each character in the text to be identified are processed to obtain the hidden layer vectors;

[0029] The probability P of using the position of each character in the target description information as the starting position of the answer is calculated based on the hidden vector. istart And the probability P that represents the ending position of the answer. jend ;

[0030] Calculate P istart *P jend The result is that the position i corresponding to the position combination with the largest calculation result is taken as the starting position and the position j is taken as the ending position, where i and j represent the position of each character in the target description information, M is the length of the target description information, i, j = 1, 2, ..., M, and i is less than j.

[0031] In one alternative design, the pre-trained question-answering model is trained using the following method:

[0032] Obtain a training dataset, which includes: a query judgment dataset, an inference yes / no dataset, and an extracted prediction dataset;

[0033] The training dataset is divided into a training set, a validation set, and a test set according to a preset ratio. The training set is used for model fitting, the validation set is used to adjust the degree of fitting, and the test set is used to evaluate the trained question-answering model.

[0034] The training dataset is processed according to preset rules and input into the model to be trained. The model to be trained includes: a query judgment model to be trained, an inference yes / no model to be trained, and an extraction prediction model to be trained.

[0035] The model to be trained is jointly trained to obtain the pre-trained question-answering model.

[0036] Secondly, embodiments of this application provide a response device based on a question-and-answer model, the device comprising:

[0037] The acquisition module is used to acquire the user's input statement to be replied to;

[0038] The processing module is used to identify the target object involved in the statement to be replied to; and to search for the description information of the target object from a preset description information database as the target description information.

[0039] The identification module is used to identify the type of the statement to be replied to, which is one of the following: no answer or answer. The no answer type refers to the type in which no valid answer can be obtained, and the answer type refers to the type in which a valid answer can be obtained.

[0040] The response module is used to obtain and output the response information corresponding to the statement to be responded to, based on the target description information, if the type of the statement to be responded to is the type with an answer.

[0041] Thirdly, embodiments of this application provide an electronic device, the electronic device including a memory and one or more processors; wherein, the memory is used to store computer program code, the computer program code including computer instructions; when the computer instructions are executed by the processor, the electronic device performs some or all of the steps of the method in the first aspect or various possible implementations of the first aspect.

[0042] Fourthly, embodiments of this application provide a computer storage medium storing instructions that, when executed on a computer, cause the computer to perform some or all of the steps of the method in the first aspect or various possible implementations of the first aspect.

[0043] This application provides a response method based on a question-answering model, comprising: acquiring a user-inputted statement to be responded to; identifying the target object involved in the statement to be responded to; searching for the description information of the target object from a pre-set description information database as target description information; identifying the type of the statement to be responded to, wherein the type of the statement to be responded to is one of the following: no answer or answerable, wherein no answer refers to a type in which a valid answer cannot be obtained, and answerable refers to a type in which a valid answer can be obtained; if the type of the statement to be responded to is answerable, obtaining the response information corresponding to the statement to be responded to based on the target description information and outputting it. By identifying the type of the statement to be responded to, questions are classified and responded to, improving the accuracy of the response, and avoiding the problem of feature extraction difficulties by eliminating the need for feature extraction. By acquiring target description information related to the content to be responded to, and then obtaining the response based on the target description information, the accuracy of the model is improved, allowing users to receive more satisfactory and comprehensive answers. Attached Figure Description

[0044] To more clearly illustrate the technical solution of this application, the drawings used in the embodiments will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0045] Figure 1 A flowchart illustrating the question-and-answer model-based response method provided in this application embodiment;

[0046] Figure 2 A flowchart illustrating a second question-and-answer model-based response method provided in this application embodiment;

[0047] Figure 3 A flowchart of the training process for a pre-trained question-answering model provided in this application embodiment;

[0048] Figure 4 A schematic diagram illustrating an exemplary composition of a question-and-answer model-based response device provided in an embodiment of this application;

[0049] Figure 5 This is an exemplary structural diagram of an electronic device provided in an embodiment of this application. Detailed Implementation

[0050] The technical solutions of the embodiments of this application will now be described with reference to the accompanying drawings.

[0051] The terminology used in the following embodiments of this application is for the purpose of describing particular embodiments only and is not intended to be limiting of this application. As used in the specification and appended claims of this application, the singular expressions “a,” “an,” “the,” “the,” “the,” and “this” are intended to include the plural expressions as well, unless the context clearly indicates otherwise. It should also be understood that although the terms first, second, etc., may be used in the following embodiments to describe a class of objects, the objects are not limited to these terms. These terms are only used to distinguish specific objects of that class of objects. For example, the terms first, second, etc., may be used in the following embodiments to describe types, but types are not limited to these terms. These terms are only used to distinguish different types. Other classes of objects that may be described using the terms first, second, etc. in the following embodiments are similarly not described here.

[0052] This application provides a response method, apparatus, and electronic device based on a question-answering model. This method can classify and respond to user-inputted questions without requiring feature extraction, effectively avoiding the problems of difficult and inaccurate feature extraction.

[0053] The following describes the response method based on the question-answering model involved in the embodiments of this application through several implementation methods.

[0054] The following uses a museum scenario as an example to introduce the method involved in the embodiments of this application. It should be noted that the museum scenario involved below is only an exemplary description and does not limit the response method based on the question-answering model in the embodiments of this application. In practical applications, the method implemented in this application can also be applied to other scenarios.

[0055] like Figure 1 As shown, Figure 1 This illustrates a response method 100 based on a question-answering model (hereinafter referred to as method 100), which includes the following steps:

[0056] Step S101: Obtain the reply statement entered by the user.

[0057] The user's input statement to be answered can be a judgmental question or a query question. For example, in a museum setting, the user's input might be "Where is the restroom?", "What dynasty does exhibit number 123 belong to?", or "Are exhibits number 123 and 456 from the same dynasty?" The user's input statement to be answered can also be in other forms. Of course, the method of this application can also be applied in other scenarios. The system of this invention can be applied in any scenario where there is an intelligent robot or question-and-answer system.

[0058] Step S102: Identify the target object involved in the statement to be replied to.

[0059] The response statement may involve one or more target objects. For example, in the user's input "Which dynasty does exhibit number 123 belong to?", the target object is "exhibit number 123". When the user's input is "Where is the restroom?", the target object is "restroom". When the user inputs "Are exhibits number 123 and 456 from the same dynasty?", the target objects are "exhibit number 132" and "exhibit number 456". Of course, the target objects involved in the response statement are not limited to those mentioned above; in other scenarios, the target objects can also be other individuals.

[0060] Step S103: Search for the description information of the target object in the preset description information database, and use it as the target description information.

[0061] The pre-set description information database contains all descriptive information for the current scene. Taking a museum scene as an example, the pre-set description information database may include: information on all exhibits in the museum, room information in the exhibition hall, background historical information of the museum, etc. The exhibit information may include: exhibit number, year, acquisition time, background story, etc. Of course, the pre-set description information database in the museum scene includes, but is not limited to, the above, and may also include other museum-related descriptive information.

[0062] After identifying the target object, the system searches the pre-set description information database based on the target object. For example, if the user inputs the question to be answered as "What dynasty does exhibit number 123 belong to?", the target object is "exhibit number 123". Then, the system searches the pre-set description information database for description information related to "exhibit number 123".

[0063] Step S104: Identify the type of the statement to be replied to. The type of the statement to be replied to is one of the following: no answer or answer. The no answer type refers to the type in which a valid answer cannot be obtained, and the answer type refers to the type in which a valid answer can be obtained.

[0064] The user-inputted statement to be replied to can be of any type. Therefore, the target description information may or may not contain a corresponding reply. Accordingly, based on whether there is a corresponding reply in the target description information, the statements to be replied to are divided into those with no answer and those with an answer.

[0065] Step S105: If the type of the statement to be replied to is the type with an answer, obtain the reply information corresponding to the statement to be replied to based on the target description information and output it.

[0066] If the statement to be replied to is an answer-type statement, then the corresponding reply information is determined in the target description information. For example, if the user inputs the statement to be replied to as "What dynasty does exhibit number 123 belong to?", the target description information should include all information related to "exhibit number 123", including the age information of the exhibit. Therefore, the dynasty of "exhibit number 123" is determined to be "Qing Dynasty", and then output.

[0067] This application provides a response method based on a question-answering model. By identifying the type of the statement to be responded to, the method classifies the questions and provides responses accordingly, thereby improving the accuracy of the responses. Furthermore, it eliminates the need for feature extraction, thus avoiding the difficulty of feature extraction. By obtaining target description information related to the content to be responded to, and then obtaining the response based on the target description information, the accuracy of the model is improved, allowing users to receive more satisfactory and comprehensive answers.

[0068] In some alternative implementations, it also includes:

[0069] If the type of the statement to be replied to is the first type with an answer, extract the descriptive words of the target object from the statement to be replied to, calculate the probability that the answer to the statement to be replied to is a positive answer and the probability that it is a negative answer based on the descriptive words of the target object and the target description information, and output the answer with the higher probability.

[0070] If the type of the statement to be replied to is the second type with an answer, search for the reply information corresponding to the statement to be replied to in the target description information, determine the start position and end position of the reply information in the target description information, and output the text between the start position and the end position as the answer.

[0071] In this embodiment, such as Figure 2 As shown, Figure 2The flowchart of the second question-and-answer model-based response method provided in this application embodiment, still taking a museum scenario as an example, shows that if there is response information corresponding to the statement to be responded to in the target description information, then the statement to be responded to is of the type with an answer. The type with an answer includes two types: the first type with an answer and the second type with an answer. If the statement to be responded to is determined to be of the first type with an answer, for example, "Are exhibits numbered 123 and 456 from the same dynasty?", the response to this question can only be a yes or a no answer, so the current statement to be responded to is determined to be of the first type with an answer. The target objects "exhibits numbered 123" and "exhibits numbered 456" are obtained from the statement to be responded to. The dynasties of the two exhibits are determined from the target description information, and then it is determined whether the answer is a yes or a no answer. For example, the response information in this embodiment can be "yes" or "no". Of course, the response information can also be "yes" or "no". Any response expressing a positive or negative meaning is acceptable, and this application does not impose any restrictions on this.

[0072] In this embodiment, if the statement to be replied to is "Which dynasty does exhibit number 123 belong to?", then the current statement to be replied to is determined to be the second type with an answer. Then, the relevant reply information is searched from the target description information. The keywords for searching can be "exhibit number 123" and "dynasty". Finally, the corresponding reply information "exhibit number 132 is a cultural relic from the Qing Dynasty" is output.

[0073] In some alternative implementations, it also includes:

[0074] If the type of the statement to be replied to is "no answer", output the preset reply information, which includes error information or default reply information.

[0075] In this embodiment, if no information corresponding to the statement to be replied to is found in the target description information, then the current statement to be replied to is determined to be of the "no answer" type. For example, if the user inputs the statement to be replied to as "How to get to the hot pot restaurant," where the target object is the hot pot restaurant, and there is no description information related to the hot pot restaurant in the target description information, then the model will output a preset reply such as "Input error, please re-enter," "None," or "No answer found, please search for other text." Of course, the preset reply can also be other replies, and this application does not limit this.

[0076] In some alternative implementations, identifying the type of the statement to be replied to includes:

[0077] After integrating the target description information into the statement to be replied to, the text to be identified is obtained;

[0078] Add a start identifier and an end identifier to the text to be recognized;

[0079] Based on the start identifier and the end identifier, obtain the segment vector, position vector and word vector corresponding to the text to be identified;

[0080] The input vector is obtained by adding the segment vector, the position vector, and the word vector corresponding to the text to be identified.

[0081] The input vector is fed into a pre-trained question-answering model to identify the type of the statement to be answered.

[0082] In some implementations, the pre-trained question-answering model of this application can be implemented as a Roberta model, which is a Chinese-oriented pre-trained model based on the BERT model. The BERT model can be used to segment and label the input text to obtain character vectors and sentence vectors. Then, based on the character vectors and sentence vectors, the semantic representation of each character in the text is obtained.

[0083] In this embodiment, after obtaining the statement to be replied to and the target description information, the data is input into the Roberta model. This BERT model segments the text in the statement to be replied to and the target description information and removes punctuation marks to obtain individual characters. Then, the Roberta model adds the tags [CLS] and [SEP], as well as the labels token embeddings, segment embeddings, and position embeddings to all text, so as to represent the word vectors, segment vectors, and position vectors of each character in the text.

[0084] The [CLS] tag is used to indicate the first character of the text. The [SEP] tag is used to indicate the end of a sentence, for example, adding the [SEP] tag after the statement to be replied to, and adding the [SEP] tag after the target description information. Token embeddings are used to identify each character. Segment embeddings are used to identify each sentence; for example, adding the token "0" to each character in the statement to be replied to, and adding the token "1" to each character in the target description information. Position embeddings are used to identify the position of each word in each sentence within the text.

[0085] Furthermore, the Roberta model obtains the semantic representation of each word in the text based on the aforementioned labels. Optionally, the Roberta model can contain a 12-layer bidirectional Transformer structure, which can capture dependencies over longer distances and obtain the semantic representation of each character in the text based on the aforementioned word vectors, segment vectors, and position vectors.

[0086] Furthermore, the Roberta model adds a question-judgment layer, takes the final hidden state of the word vector labeled [CLS], and after weighting the question-judgment layer, predicts the probability that the reply statement belongs to one of the three types. The category with the highest probability is the type of the reply statement.

[0087] In some implementations, calculating the probability that the answer to the statement to be replied to is an affirmative answer and the probability that it is a negative answer based on the descriptive words of the target object and the target description information includes:

[0088] Record the index vector of the descriptor of the target object in the statement to be replied to, and obtain the position output vector of the index vector in the statement to be replied to;

[0089] The semantic relationship score is obtained by encoding the position output vector with the segment vector, position vector and word vector corresponding to the text to be identified;

[0090] The probability of an affirmative answer and the probability of a negative answer to the statement to be replied to are calculated based on the semantic relationship score.

[0091] In some implementations, determining the start and end positions of the response information in the target description information includes:

[0092] The word vectors corresponding to each character in the text to be identified are processed to obtain the hidden layer vectors;

[0093] The probability P of using the position of each character in the target description information as the starting position of the answer is calculated based on the hidden vector. istart And the probability P that represents the ending position of the answer. jend ;

[0094] Calculate P istart *P jend The result is that the position i corresponding to the position combination with the largest calculation result is taken as the starting position and the position j is taken as the ending position, where i and j represent the position of each character in the target description information, M is the length of the target description information, i, j = 1, 2, ..., M, and i is less than j.

[0095] In some implementations, the pre-trained question-answering model is trained using the following methods:

[0096] Obtain a training dataset, which includes: a query judgment dataset, an inference yes / no dataset, and an extracted prediction dataset;

[0097] The training dataset is divided into a training set, a validation set, and a test set according to a preset ratio. The training set is used for model fitting, the validation set is used to adjust the degree of fitting, and the test set is used to evaluate the trained question-answering model.

[0098] The training dataset is processed according to preset rules and input into the model to be trained. The model to be trained includes: a query judgment model to be trained, an inference yes / no model to be trained, and an extraction prediction model to be trained.

[0099] The model to be trained is jointly trained to obtain the pre-trained question-answering model.

[0100] like Figure 3 As shown, the query judgment dataset contains three types of labels, corresponding to the types of statements to be answered: no answer, first answer, and second answer; the inference yes / no dataset is labeled with the answer types of the statements to be answered: affirmative and negative; the extraction prediction dataset is labeled with the text at the beginning and end of the response information in the target description. The three datasets are divided into training, validation, and test sets in an 8:1:1 ratio. The training set is used for model fitting, the validation set is used to adjust the fit during model training, and the test set is used to evaluate the model after training. Then, the models are trained separately and then jointly trained, thus combining the trained query judgment model, inference yes / no model, and extraction prediction model as the pre-trained question-answering model of this application. Finally, the trained model is output once per round, all models are saved, and the Roberta model is evaluated on the test set using metrics. The model with the best performance is selected as the Roberta model to be used in this method.

[0101] In summary, the question-answering model-based response method of this application improves the accuracy of responses by identifying the type of the statement to be responded to and classifying the questions accordingly. It also avoids the problem of feature extraction difficulties by eliminating the need for feature extraction. Furthermore, by obtaining target description information related to the content to be responded to and then obtaining a response based on the target description information, the accuracy of the model is improved, allowing users to receive more satisfactory and comprehensive answers.

[0102] correspond Figures 1 to 3 In addition to the method described above, this application also provides an apparatus for performing the above method.

[0103] like Figure 4 As shown, Figure 4 This illustrates a response device based on a question-and-answer model, the device comprising:

[0104] The acquisition module 401 is used to acquire the user-inputted response statement;

[0105] Processing module 402 is used to identify the target object involved in the statement to be replied to; and to search for the description information of the target object from a preset description information database as the target description information;

[0106] The identification module 403 is used to identify the type of the statement to be replied to, wherein the type of the statement to be replied to is one of the following: no answer or answer, wherein no answer means that no valid answer can be obtained, and answer means that a valid answer can be obtained;

[0107] The response module 404 is used to obtain and output the response information corresponding to the statement to be responded to based on the target description information if the type of the statement to be responded to is the type with an answer.

[0108] It is understandable that the above division of modules / units is merely a logical functional division. In actual implementation, the functions of these modules can be integrated into hardware entities. For example, the functions of the processing module and the identification module can be integrated into the processor, and the functions of the acquisition module and the response module can be integrated into the transceiver. The programs and instructions that implement the functions of these modules can be maintained in memory. For example, Figure 5 An electronic device 500 is provided, which may include a processor 511, a transceiver 512, and a memory 513. The transceiver 512 is used for transmitting and receiving data and signals in method 100. The memory 513 can be used to store programs / code required by the processor 511 to execute method 100.

[0109] In a specific implementation, corresponding to the aforementioned electronic device 500, this application embodiment also provides a computer storage medium. The computer storage medium disposed in the electronic device 500 may store a program. When the program is executed, it may implement some or all of the steps in the various embodiments of method 100. The storage medium may be a magnetic disk, optical disk, read-only memory (ROM), or random access memory (RAM), etc.

[0110] Those skilled in the art will understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.

[0111] In the several embodiments provided in this application, it should be understood that the disclosed methods, apparatuses, and systems can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection between devices or units through some interfaces, and may be electrical, mechanical, or other forms.

[0112] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0113] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0114] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, a cloud gaming control device, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0115] Although alternative embodiments of this application have been described, those skilled in the art, upon learning the basic inventive concept, can make further changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of this application.

[0116] The specific embodiments described above further illustrate the purpose, technical solution, and beneficial effects of this application. It should be understood that the above description is only a specific embodiment of this application and is not intended to limit the scope of protection of this application. Any modifications, equivalent substitutions, improvements, etc., made on the basis of the technical solution of this application should be included within the scope of protection of this invention.

Claims

1. A response method based on a question-answering model, characterized in that, The method includes: Get the user's input statement to be replied to; Identify the target object involved in the statement to be replied to; The description information of the target object is retrieved from a pre-set description information database and used as the target description information; Identify the type of the statement to be replied to, which is one of the following: no answer or answer; the no answer type refers to a type where no valid answer can be obtained, and the answer type refers to a type where a valid answer can be obtained. If the type of the statement to be replied to is the type with an answer, obtain the reply information corresponding to the statement to be replied to based on the target description information and output it; If the type of the statement to be replied to is the first type with an answer, extract the descriptive words of the target object from the statement to be replied to, calculate the probability that the answer to the statement to be replied to is a positive answer and the probability that it is a negative answer based on the descriptive words of the target object and the target description information, and output the answer with the higher probability. If the type of the statement to be replied to is the second type with an answer, search for the reply information corresponding to the statement to be replied to from the target description information, determine the start position and end position of the reply information in the target description information, and output the text between the start position and the end position as the answer. The identification of the type of the statement to be replied to includes: After integrating the target description information into the statement to be replied to, the text to be identified is obtained; Add a start identifier and an end identifier to the text to be recognized; Based on the start identifier and the end identifier, obtain the segment vector, position vector and word vector corresponding to the text to be identified; The input vector is obtained by adding the segment vector, the position vector, and the word vector corresponding to the text to be identified. The input vector is fed into a pre-trained question-answering model to identify the type of the statement to be answered.

2. The method as described in claim 1, characterized in that, Also includes: If the type of the statement to be replied to is "no answer", output the preset reply information, which includes error information or default reply information.

3. The method as described in claim 1, characterized in that, The step of calculating the probability that the answer to the statement to be replied to is an affirmative answer and the probability that it is a negative answer based on the descriptive words of the target object and the target description information includes: Record the index vector of the descriptor of the target object in the statement to be replied to, and obtain the position output vector of the index vector in the statement to be replied to; The semantic relationship score is obtained by encoding the position output vector with the segment vector, position vector and word vector corresponding to the text to be identified; The probability of an affirmative answer and the probability of a negative answer to the statement to be replied to are calculated based on the semantic relationship score.

4. The method as described in claim 1, characterized in that, Determining the start and end positions of the response information in the target description information includes: The word vectors corresponding to each character in the text to be identified are processed to obtain the hidden layer vectors; Calculate the probability Pistart of the position of each character in the target description information as the starting position of the answer and the probability Pjend of the position as the ending position of the answer based on the hidden layer vector; Calculate the result of Pistart*Pjend, take the position i corresponding to the position combination with the largest calculation result as the starting position, and the position j as the ending position, where i and j represent the position of each word in the target description information, M is the length of the target description information, i, j=1,2,...,M, and i is less than j.

5. The method as described in claim 1, characterized in that, The pre-trained question-answering model was trained using the following method: Obtain a training dataset, which includes: a query judgment dataset, an inference yes / no dataset, and an extracted prediction dataset; The training dataset is divided into a training set, a validation set, and a test set according to a preset ratio. The training set is used for model fitting, the validation set is used to adjust the degree of fitting, and the test set is used to evaluate the trained question-answering model. The training dataset is processed according to preset rules and input into the model to be trained. The model to be trained includes: a query judgment model to be trained, an inference yes / no model to be trained, and an extraction prediction model to be trained. The model to be trained is jointly trained to obtain the pre-trained question-answering model.

6. A response device based on a question-and-answer model, characterized in that, The device includes: The acquisition module is used to acquire the user's input statement to be replied to; The processing module is used to identify the target object involved in the statement to be replied to; and to search for the description information of the target object from a preset description information database as the target description information. The identification module is used to identify the type of the statement to be replied to, wherein the type of the statement to be replied to is one of the following: no answer or answerable, wherein no answer means that no valid answer can be obtained, and answerable means that a valid answer can be obtained; the identification of the type of the statement to be replied to includes: After integrating the target description information into the statement to be replied to, the text to be identified is obtained; Add a start identifier and an end identifier to the text to be recognized; Based on the start identifier and the end identifier, obtain the segment vector, position vector and word vector corresponding to the text to be identified; The input vector is obtained by adding the segment vector, the position vector, and the word vector corresponding to the text to be identified. The input vector is fed into a pre-trained question-answering model to identify the type of the statement to be answered; The response module is used to obtain and output the response information corresponding to the statement to be responded to if the type of the statement to be responded to is the type with an answer, based on the target description information; if the type of the statement to be responded to is the first type with an answer, it extracts the descriptive words of the target object from the statement to be responded to, calculates the probability that the answer to the statement to be responded to is a positive answer and the probability that it is a negative answer based on the descriptive words of the target object and the target description information, and outputs the answer with the higher probability. If the type of the statement to be replied to is the second type with an answer, search for the reply information corresponding to the statement to be replied to in the target description information, determine the start position and end position of the reply information in the target description information, and output the text between the start position and the end position as the answer.

7. An electronic device, characterized in that, The electronic device includes a memory and one or more processors; wherein the memory is used to store computer program code, the computer program code including computer instructions; when the computer instructions are executed by the processor, the electronic device performs the method as described in any one of claims 1 to 5.

8. A computer-readable storage medium, characterized in that, Includes a computer program that, when run on a computer, causes the computer to perform the method as described in any one of claims 1 to 5.

Citation Information

Patent Citations

  • Information searching method and device

    CN113821612A

  • Knowledge question and answer model training method and device, knowledge question and answer method and device and computer equipment

    CN115062134A