Question and answer model training method, question and answer processing method and related equipment
By constructing knowledge bases and data fusion training in the Q&A system, the existing Q&A system cannot effectively respond to professional questions, improve the Q&A accuracy and knowledge reasoning ability, and enhance the system's knowledge reserve.
Patent Information
- Application Number
- CN202411671457.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-21
- Publication Date
- 2024-12-27
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The existing Q&A system cannot effectively respond to professional questions online, resulting in low Q&A accuracy and knowledge inference accuracy, which cannot meet users' high-precision Q&A needs and answer explanation requirements.
By obtaining training inquiry data, entity extraction and relationship extraction are performed based on the preset knowledge base, knowledge structure is constructed, and training inquiry data and knowledge data are input into the question and answer model for fusion training, generating predictive reply data, and through information encoding and attention Weight operations obtain contextual semantic features, fuse predictive reply data and knowledge data, and adjust policy parameters to improve model performance.
It improves the depth of knowledge reserve and knowledge inference accuracy of the question-and-answer system, fills the knowledge gaps in the model in multiple fields, and enhances the ability to respond to professional questions.
Smart Images

Figure CN119202199A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence technology, and in particular to a question-answering model training method, a question-answering processing method, and related equipment. Background Art
[0002] Question answering system (QA) is an advanced form of information retrieval system, which can answer questions raised by users in natural language accurately and concisely. The main reason for the rise of its research is people's demand for fast and accurate information acquisition. Question answering system is a research direction in the field of artificial intelligence and natural language processing that has attracted much attention and has broad development prospects. However, due to the limited scope of knowledge, the question answering system in related technologies cannot effectively answer professional questions online, resulting in relatively low question answering accuracy and knowledge reasoning accuracy, which cannot meet users' high-precision question answering needs and explainable answers. Summary of the invention
[0003] The purpose of this application is to provide a question-answering model training method, a question-answering processing method and related equipment, which can enhance the knowledge reserve depth of the question-answering system, and improve the accuracy of question-answering and knowledge reasoning.
[0004] The present application embodiment provides a question-answering model training method, including: Obtain training query data; Retrieving training knowledge data from a preset knowledge base according to the training query data; The training inquiry data and the training knowledge data are input into the question-answering model to be trained to obtain training answer data; the training answer data is obtained by fusing the predicted answer data obtained by the question-answering model to be trained based on the training inquiry data and the training knowledge data; The question-answering model to be trained is trained based on the training reply data to obtain a question-answering model.
[0005] In some embodiments, before retrieving the training knowledge data from a preset knowledge base according to the training query data, the method further includes: Acquiring knowledge data; Performing entity extraction and relationship extraction on the knowledge data to obtain a plurality of knowledge entities in the knowledge data and knowledge entity relationships between the knowledge entities; The knowledge base is constructed according to the knowledge entities and the knowledge entity relationships.
[0006] In some embodiments, the retrieving training knowledge data from a preset knowledge base according to the training query data includes: Performing entity extraction and relationship extraction on the training query data to obtain a plurality of training entities in the training query data and training entity relationships between the training entities; Constructing a retrieval structure according to the training entities and the training entity relationships; Calling a preset search engine to search for a knowledge structure in the knowledge base, and performing a similarity analysis on the search structure and the knowledge structure to obtain a similarity analysis result; The training knowledge data is output according to the similarity analysis result.
[0007] In some embodiments, inputting the training query data and the training knowledge data into the question-answering model to be trained to obtain training answer data includes: Performing information encoding on the training query data to obtain an embedding vector sequence; Performing linear transformation processing on the embedding vector sequence, performing attention weight operation on the word vector after the linear transformation processing, and obtaining contextual semantic features of the training query data; Perform context prediction based on the context semantic features to obtain the predicted answer data; The predicted answer data and the training knowledge data are fused according to a preset weight ratio or a preset fusion range to obtain the training answer data.
[0008] In some embodiments, the question-answering model training method further includes: Obtaining user evaluation information on the training response data to obtain first evaluation information; Performing fusion accuracy evaluation on the training response data to obtain second evaluation information; According to the first evaluation information and the second evaluation information, a strategy parameter for fusing the predicted answer data and the training knowledge data is adjusted.
[0009] In some embodiments, the step of training the question-answering model to be trained based on the training answer data to obtain the question-answering model includes: Determine model loss information; the model loss information represents the deviation between the training response data and the expected response data, the expected response data is obtained by fusing the preset response data corresponding to the training query data and the training knowledge data; Determining whether the model loss information is within a loss threshold range; If not, adjust the weight parameters of the question-answering model to be trained; return to the step of inputting the training query data and the training knowledge data into the question-answering model to be trained to obtain training answer data; If yes, determine whether the number of training query data resets reaches the reset threshold; If not reached, return to the step of obtaining training query data; If it is reached, the training is terminated and the question-answering model is obtained.
[0010] The present application also provides a question-answering processing method, including: Get the query data entered by the user; According to the query data, target knowledge data is retrieved from a preset knowledge base; The query data and the target knowledge data are input into a question-answering model to obtain reply data; the reply data is obtained by fusing the pre-reply data obtained by the question-answering model based on the query data for question-answer prediction and the target knowledge data, and the question-answering model is trained by the question-answering model training method described above.
[0011] In some embodiments, the question-answering processing method further includes: extracting a hyperlink to the query data; Determining whether the hyperlink of the query data is a valid link; If valid, a hyperlink to the query data is embedded in the response data.
[0012] An embodiment of the present application further provides an electronic device, which includes a memory and a processor, wherein the memory stores a computer program, and the processor implements the above method when executing the computer program.
[0013] An embodiment of the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and the computer program implements the above method when executed by a processor.
[0014] The beneficial effects of the present application are as follows: training knowledge data is retrieved from a preset knowledge base according to the training query data, and the question-answering model to be trained is trained using the training query data and the training knowledge data, so that the question-answering model to be trained performs question-answer prediction based on the training query data and obtains predicted reply data, and then the predicted reply data and the training knowledge data are merged to obtain the training reply data, which can ensure that the question-answering model to be trained can effectively utilize the knowledge data in the knowledge base for training, fill the knowledge gaps in multiple fields of the question-answering model to be trained, and enable the trained question-answering model to have a deep knowledge reserve, thereby improving the question-answering accuracy and knowledge reasoning accuracy. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] Figure 1 It is a flowchart of the question-answering model training method provided in an embodiment of the present application.
[0016] Figure 2It is a flowchart of the method before step S102 provided in an embodiment of the present application.
[0017] Figure 3 It is a flowchart of the specific method of step S102 provided in an embodiment of the present application.
[0018] Figure 4 It is a flowchart of the specific method of step S103 provided in an embodiment of the present application.
[0019] Figure 5 It is a flowchart of the specific method of step S104 provided in an embodiment of the present application.
[0020] Figure 6 It is a flowchart of the question and answer processing method provided in an embodiment of the present application.
[0021] Figure 7 It is a schematic diagram of the hardware structure of the electronic device provided in the embodiment of the present application. DETAILED DESCRIPTION
[0022] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0023] It should be noted that, although the functional modules are divided in the device schematic diagram and the logical order is shown in the flowchart, in some cases, the steps shown can be performed in a different order than the module division in the device or the order in the flowchart. The terms "first", "second" and the like in the specification, claims and drawings are used to distinguish similar objects, and are not used to describe a specific order or sequence.
[0024] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.
[0025] An embodiment of the present application provides a question-answering model training method.
[0026] Figure 1 is a flow chart of the question-answering model training method provided in the embodiment of the present application. Figure 1 In some embodiments, the question-answering model training method may include but is not limited to steps S101 to S104.
[0027] It should be noted that the execution entity of the question-answering model training method provided in the embodiment of this specification can be applied to terminal-side devices or cloud-side devices, and this embodiment does not limit this.
[0028] Step S101, obtaining training query data.
[0029] The execution subject may obtain training query data, where the training query data is query data used for training.
[0030] The inquiry data can be understood as the content of the questions that the user needs to wait for answers to, for example, "Which team did Person A play for in 2010?" or "How is Person A's career going?"
[0031] Step S102: Retrieve training knowledge data from a preset knowledge base according to the training query data.
[0032] In this embodiment, the knowledge base is a knowledge graph.
[0033] The knowledge graph can represent the relationship between multiple entities. The entities in the knowledge graph are nodes, and the relationship between two entities is an edge, which connects the corresponding two nodes to form a structured knowledge network. Based on the relationship between entities in the knowledge graph, knowledge retrieval can be performed.
[0034] A knowledge tuple is a knowledge unit in the knowledge graph, which is used to represent the relationship between two entities, and the above two entities constitute an entity pair. Exemplarily, knowledge tuple a is "<entity 1, entity 2, entity relationship between entity 1 and entity 2>". Optionally, there is a same entity between different knowledge tuples. Exemplarily, another knowledge tuple b in the knowledge graph is "<entity 1, entity 3, entity relationship between entity 1 and entity 3>". Knowledge tuple a and knowledge tuple b are represented in the knowledge graph as two edges extending from the node of entity 1, and the other end of one of the two edges is the node of entity 2, and the other end of the other edge is the node of entity 3.
[0035] In a specific implementation, entity extraction and relationship extraction are performed on the training query data, the query entities obtained by performing entity extraction on the training query data are summarized to obtain a query entity set, the query entity relationships obtained by performing relationship extraction on the training query data are summarized to obtain a query entity relationship set, the query entity set and the query entity relationship set are input into the knowledge base, the knowledge base is searched for knowledge tuples that hit the query entities in the query entity set and the query entity relationships in the query entity relationship set, the searched knowledge tuples are output, and the training knowledge data is obtained.
[0036] Figure 2 is a flowchart of the method before step S102 provided in an embodiment of the present application. Figure 2 In some embodiments, the method includes but is not limited to steps S201 to S203.
[0037] Step S201, acquiring knowledge data.
[0038] Step S202: perform entity extraction and relationship extraction on the knowledge data to obtain a plurality of knowledge entities in the knowledge data and knowledge entity relationships between two knowledge entities.
[0039] Step S203: construct a knowledge base based on knowledge entities and knowledge entity relationships.
[0040] In step S201, knowledge data is first collected from multiple sources, such as internal enterprise data, public data sets, web pages and documents obtained by web crawlers, etc., and then the legality and compliance of the knowledge data are verified to ensure compliance with relevant copyright and privacy regulations. After obtaining the knowledge data, the knowledge data is preprocessed and cleaned to remove noise, duplicates and irrelevant content.
[0041] In step S202, the knowledge data is processed using a natural language processing model, and the knowledge data is segmented, stop words are removed, stems are extracted, etc., the knowledge data is split into feature words, and each feature word is subjected to part-of-speech tagging and dependency syntactic analysis to obtain a feature combination including the part of speech, named entity, and dependency relationship corresponding to each feature word in the knowledge data. Entity attribute mining is then performed on each feature word in the knowledge data, and the mining results include three elements of entity attribute information: knowledge entity, attribute, and attribute value, as well as evaluation scores corresponding to the above three elements. Corresponding knowledge entities are extracted based on the evaluation scores in the mining results to obtain multiple knowledge entities in the knowledge data, and knowledge entity relationships are determined based on the attributes and attribute values of the knowledge entities.
[0042] In step S203, the knowledge entities and knowledge entity relationships in the knowledge data are formatted according to a preset structured template to obtain structured representations of the knowledge entities and knowledge entity relationships, and a knowledge base is constructed using the structured representations of the knowledge entities and knowledge entity relationships.
[0043] Figure 3 is a flowchart of a specific method of step S102 provided in an embodiment of the present application. Figure 3 In some embodiments, the method includes but is not limited to steps S301 to S304.
[0044] Step S301 , performing entity extraction and relationship extraction on the training query data to obtain a plurality of training entities in the training query data and training entity relationships between each two of the training entities.
[0045] Step S302: construct a retrieval structure according to the training entities and training entity relationships.
[0046] Step S303: calling a preset search engine to search for knowledge structures in the knowledge base, and performing similarity analysis on the search structure and the knowledge structure to obtain a similarity analysis result.
[0047] Step S304: output the training knowledge data according to the similarity analysis result.
[0048] In step S301, the training query data is processed by a natural language processing model, and the knowledge data is segmented, stop words are removed, stems are extracted, etc. The training query data is split into feature words, and each feature word is subjected to part-of-speech tagging and dependency syntactic analysis to obtain a feature combination including the part of speech, named entity, and dependency relationship corresponding to each feature word in the training query data. Then, entity attribute mining is performed on each feature word in the training query data, and the mining results include three elements of entity attribute information: training entity, attribute, and attribute value, as well as evaluation scores corresponding to the above three elements. Then, the corresponding training entities are extracted according to the evaluation scores in the mining results to obtain multiple training entities in the training query data, and the training entity relationships are determined according to the attributes and attribute values of the training entities.
[0049] In step S302, the training entities and training entity relationships in the training query data are formatted according to a preset structured template to obtain structured representations of the training entities and training entity relationships, and a retrieval structure is constructed using the structured representations of the training entities and training entity relationships.
[0050] In step S303, the search structure is first converted into a corresponding search feature vector, and then a preset searcher is called to retrieve the feature vector as key information, to perform a search in the knowledge base, to calculate the vector similarity between the search feature vector and the feature vector converted from the knowledge structure in the knowledge base, and to obtain a similarity calculation result. Preferably, the searcher can be a keyword-based search engine or a more complex semantic search system, such as a search system based on vector similarity, and the vector similarity can be Euclidean distance, cosine similarity, Manhattan distance, Chebyshev distance or Hamming distance.
[0051] In step S304, the vector similarity is compared with a preset similarity threshold. If the vector similarity between the retrieved feature vector and the feature vector converted from the knowledge structure is greater than the preset similarity threshold, the knowledge structure is selected and output to obtain training knowledge data.
[0052] Step S103, input the training inquiry data and the training knowledge data into the question-answering model to be trained to obtain training answer data.
[0053] The training answer data is obtained by fusing the predicted answer data obtained by the question-answer prediction of the question-answer model to be trained based on the training inquiry data and the training knowledge data.
[0054] In the specific implementation, the training query data and the training knowledge data are input into the question-answering model to be trained, and the contextual semantic features of the training query data are understood based on the multi-head attention mechanism and the feedforward neural network to obtain the contextual semantic extraction results of the training query data. A word is generated at each time step, and the previously generated word is used as the context to generate the next word. The text content is generated step by step until the required text length is reached or an end symbol is generated to obtain the predicted reply data. Then, according to the preset fusion mechanism, the predicted reply data and the training knowledge data are fused to obtain the training reply data.
[0055] Figure 4 is a flowchart of a specific method of step S103 provided in an embodiment of the present application. Figure 4 In some embodiments, the method includes but is not limited to steps S401 to S404.
[0056] Step S401, information encoding is performed on the training query data to obtain an embedding vector sequence.
[0057] Step S402, linear transformation is performed on the embedding vector sequence, and attention weight operation is performed on the word vector after the linear transformation to obtain contextual semantic features of the training query data.
[0058] Step S403, performing context prediction based on context semantic features to obtain predicted response data.
[0059] Step S404: Fusion the predicted answer data and the training knowledge data according to a preset weight ratio or a preset fusion range to obtain training answer data.
[0060] Step S401 is executed by calling the vector embedding layer in the question-answering model to be trained. In the specific implementation, for the training query data, after the vector embedding layer performs vector embedding processing on the training query data, the training query data is mapped into a vector sequence consisting of word vectors of multiple feature words, that is, an embedded vector sequence, and the embedded vector sequence contains the word vector of each feature word of the training query data.
[0061] Step S402 is executed by calling the encoder layer in the question-answering model to be trained. In the specific implementation, after obtaining the embedding vector sequence, the word vector of each feature word in the embedding vector sequence is linearly transformed, and the attention weight operation is performed on each word vector after the linear transformation, so as to obtain the contextual semantic features of the training query data. More specifically, the embedding vector sequence is input into the encoder layer, and the encoder layer connects the multi-head mechanism and the feedforward layer through the residual network result. The multi-head mechanism performs multiple linear transformations on the input vector to obtain different linear values, and then the attention weight is calculated. The attention weight calculation formula is as follows: , , Among them, Q, K and V are the input word vector matrices, , and is a trainable weight matrix, Attention is the attention weight operation, Concat is the concatenation process, is the i-th hyperparameter head, i is an integer greater than or equal to 1 and less than or equal to h. Through the above formula, the word vector of each feature word in the embedding vector sequence is linearly transformed, and the principle of attention weight operation is to perform Attention operation on each word vector after linear transformation: Q, K, V are mapped through the corresponding weight matrix, and the calculation results are concatenated after repeating h times to obtain the contextual semantic features of the training query data. The contextual semantic features of the training query data reflect the semantic relationship and grammatical structure of the training query data.
[0062] Step S403 is executed by calling the decoder layer in the question-answering model to be trained. After obtaining the contextual semantic features of the training query data, the contextual semantic information of the training query data is understood layer by layer through the contextual semantic features of the training query data to generate predicted reply data based on the training query data. In the specific implementation, the contextual semantic features are input into the decoder layer, and the decoder layer connects the multi-head mechanism and the feedforward layer through the residual network result. The multi-head mechanism performs multiple linear transformations on the input vector to obtain different linear values, and then operates the attention weights to capture the representation of different features obtained by different linear transformations, thereby capturing the global information in the training query data. Combined with the global information in the training query data, a word is generated at each time step based on the training query data, and the previously generated word is used as the context to generate the next word, and the text content is generated step by step until the required text length is reached or the end symbol is generated to obtain the predicted reply data.
[0063] Step S404 is executed by calling the information fusion layer in the question-answering model to be trained. In the specific implementation, the predicted answer data and the training knowledge data are input into the information fusion layer, and the predicted answer data and the training knowledge data are fused according to the preset weight ratio, or part of the content is selected from the predicted answer data and the training knowledge data according to the preset fusion range for fusion to obtain the fusion result, and then the text content is generated according to the fusion result to obtain the training answer data. In the fusion process, the predicted answer data and the training knowledge data are fused according to the preset priority rules to avoid knowledge conflicts and contradictions.
[0064] In some embodiments, the question-answering model training method further includes: Obtaining user evaluation information on the training response data to obtain first evaluation information; Performing fusion accuracy evaluation on the training response data to obtain second evaluation information; According to the first evaluation information and the second evaluation information, the strategy parameters for fusing the predicted answer data and the training knowledge data are adjusted.
[0065] In the specific implementation, the users' evaluation information on the training reply data is collected and summarized to obtain the first evaluation information, and the fusion accuracy of the training reply data is evaluated according to the preset fusion accuracy evaluation mechanism to obtain the second evaluation information. The first evaluation information and the second evaluation information are comprehensively considered to adjust the weight parameters of the question-answering model to be trained for the fusion of predicted reply data and training knowledge data, so as to optimize the fusion effect of the predicted reply data and the training knowledge data.
[0066] In a specific embodiment, the evaluation formula of the second evaluation information is: , , , Among them, F is the second evaluation information of the training answer data, precision is the precision rate, recall is the recall rate, TP is the number of true positive examples, FP is the number of false positive examples, and FN is the number of false negative examples.
[0067] It should be noted that precision refers to the ratio of correctly predicted positive observations to the total number of predicted positive observations, and recall, also known as sensitivity, refers to the ratio of correctly predicted positive observations to the total number of actually positive observations.
[0068] Step S104: training the question-answering model to be trained based on the training reply data to obtain a question-answering model.
[0069] In the specific implementation, multiple training query data are traversed, and the question-answering model to be trained is used to generate training response data based on the training query data and training knowledge data to iteratively train the neural network model until the model loss information meets the training end conditions. After the training, the question-answering model is obtained.
[0070] Figure 5 is a flowchart of a specific method of step S104 provided in an embodiment of the present application. Figure 5 In some embodiments, the method includes but is not limited to steps S501 to S505.
[0071] Step S501, determining model loss information.
[0072] Among them, the model loss information represents the deviation between the training response data and the expected response data. The expected response data is obtained by fusing the preset response data corresponding to the training query data and the training knowledge data.
[0073] Step S502, determining whether the model loss information is within a loss threshold range.
[0074] If not, execute step S503; if so, execute step S504.
[0075] Step S503, adjust the weight parameters of the question-answering model to be trained. Return to step S103.
[0076] Step S504, determining whether the number of training query data resets reaches a reset threshold.
[0077] If not, return to step S101; if reached, execute step S505.
[0078] Step S505, end the training and obtain the question-answering model.
[0079] In step S501 to step S505, a loss threshold interval and a reset threshold are preset as the training end condition. When the model loss information is within the loss threshold interval and the number of resets of the training query data reaches the reset threshold, the training is terminated, and the last iteration of the question-answering model to be trained is obtained, which is the question-answering model. When the number of resets of the training query data does not reach the reset threshold, the weight parameters of the question-answering model to be trained are adjusted according to the degree of deviation of the model loss information from the loss threshold interval, so that the model loss information gradually approaches the loss threshold interval during the iteration process and finally falls within the loss threshold interval, and then the training query data is reset, and the reset training query data is used to iteratively train the question-answering model to be trained until the model loss information is within the loss threshold interval, and the above steps are repeated until the number of resets of the training query data reaches the reset threshold, and the training is terminated to obtain the question-answering model, which can adapt the obtained question-answering model to the question-answering prediction of a variety of training query data.
[0080] An embodiment of the present application provides a question-answering processing method.
[0081] Figure 6 is a flowchart of the question-answering processing method provided in the embodiment of the present application. Figure 6 In some embodiments, the question-answer processing method may include but is not limited to steps S601 to S603.
[0082] Step S601: Obtain inquiry data input by the user.
[0083] Step S602: Retrieve target knowledge data from a preset knowledge base according to the query data.
[0084] Step S603: input the query data and target knowledge data into the question-answering model to obtain response data.
[0085] Among them, the reply data is obtained by fusing the pre-reply data obtained by the question-answering model based on the inquiry data and the target knowledge data, and the question-answering model is trained by the question-answering model training method described in the above embodiment.
[0086] The question-and-answer processing method provided in steps S601 to S603 of the embodiment of the present application retrieves corresponding target knowledge data from a preset knowledge base based on the query data input by the user, and then inputs the query data and the target knowledge data into a pre-trained question-and-answer model. The question-and-answer model performs question-and-answer prediction on the query data and obtains pre-reply data, and then fuses the pre-reply data and the target knowledge data to obtain reply data, thereby improving the question-and-answer accuracy and the knowledge reasoning accuracy.
[0087] In some embodiments, the question-answering processing method further includes: Extract hyperlinks to query data; Determine whether the hyperlink to the query data is a valid link; If valid, a hyperlink to the query data is embedded in the response data.
[0088] In a specific implementation, before generating the reply data, the inquiry data is preprocessed to identify and extract hyperlinks in the inquiry data, and the extracted hyperlinks are verified to ensure that they are valid links, that is, the hyperlinks point to accessible resources. The hyperlinks are then processed according to task requirements, for example, the hyperlinks are parsed to obtain more relevant information, or the hyperlinks are replaced with short descriptive text data. The processed hyperlinks (or the descriptive text of the links) are merged with the generated text data and embedded in the reply data to enrich the information in the reply data.
[0089] Figure 7is a block diagram of an electronic device provided in an embodiment of the present application. Figure 7 An electronic device 700 according to this embodiment of the present disclosure is described. Figure 7 The electronic device 700 shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0090] like Figure 7 As shown, the electronic device 700 is in the form of a general computing device. The components of the electronic device 700 may include, but are not limited to: at least one processing unit 710, at least one storage unit 720, a bus 730 connecting different system components (including the storage unit 720 and the processing unit 710), a display unit 740, etc.
[0091] The storage unit stores program codes, and the program codes can be executed by the processing unit 710, so that the processing unit 710 executes the steps according to various exemplary embodiments of the present disclosure described in the above method part of this specification.
[0092] The storage unit 720 may include a readable medium in the form of a volatile storage unit, such as a random access storage unit (RAM) 7201 and / or a cache storage unit 7202 , and may further include a read-only storage unit (ROM) 7203 .
[0093] The storage unit 720 may also include a program / utility 7204 having a set (at least one) of program modules 7205, such program modules 7205 including but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment.
[0094] Bus 730 may represent one or more of several types of bus structures, including a memory unit bus or memory unit controller, a peripheral bus, an accelerated graphics port, a processing unit, or a local bus using any of a variety of bus architectures.
[0095] The electronic device 700 may also communicate with one or more external devices 700' (e.g., keyboards, pointing devices, Bluetooth devices, etc.), may also communicate with one or more devices that enable a user to interact with the electronic device 700, and / or communicate with any device that enables the electronic device 700 to communicate with one or more other computing devices (e.g., routers, modems, etc.). Such communication may be performed via an input / output (I / O) interface 750. Furthermore, the electronic device 700 may also communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) via a network adapter 760. The network adapter 760 may communicate with other modules of the electronic device 700 via a bus 730. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the electronic device 700, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0096] An embodiment of the present application further provides a computer-readable storage medium, which stores a computer program, and the computer program implements the above method when executed by a processor.
[0097] The question-answering model training method, question-answering processing method and related equipment provided in the embodiments of the present application retrieve training knowledge data from a preset knowledge base based on training query data, and use the training query data and training knowledge data to train the question-answering model to be trained, so that the question-answering model to be trained performs question-answer prediction based on the training query data and obtains predicted reply data, and then fuses the predicted reply data with the training knowledge data to obtain the training reply data, which can ensure that the question-answering model to be trained can effectively use the knowledge data in the knowledge base for training, fill the knowledge gaps in the question-answering model to be trained in multiple fields, and enable the trained question-answering model to have a deep knowledge reserve, thereby improving the question-answering accuracy and knowledge reasoning accuracy.
[0098] Through the description of the above implementation, it is easy for those skilled in the art to understand that the example implementation described here can be implemented by software, or by software combined with necessary hardware. Therefore, the technical solution according to the implementation of the present disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, including several instructions to enable a computing device (which can be a personal computer, a server, or a network device, etc.) to execute the above method according to the implementation of the present disclosure.
[0099] The program product may use any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of readable storage media (a non-exhaustive list) include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.
[0100] Computer readable storage media may include data signals propagated in baseband or as part of a carrier wave, wherein readable program codes are carried. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. The readable storage medium may also be any readable medium other than a readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, device, or device. The program codes contained on the readable storage medium may be transmitted using any suitable medium, including but not limited to wireless, wired, optical cable, RF, etc., or any suitable combination thereof.
[0101] Those skilled in the art will appreciate that the above modules can be distributed in the device according to the description of the embodiment, or can be changed accordingly and only used in one or more devices different from the embodiment. The modules of the above embodiments can be combined into one module, or further divided into multiple sub-modules.
[0102] The exemplary embodiments of the present disclosure are specifically shown and described above. It should be understood that the present disclosure is not limited to the detailed structures, configurations or implementations described herein; on the contrary, the present disclosure is intended to cover various modifications and equivalent configurations included in the spirit and scope of the appended claims.
Claims
1. A question-answering model training method, characterized in that: include: Obtain training query data; Retrieving training knowledge data from a preset knowledge base according to the training query data; The training inquiry data and the training knowledge data are input into the question-answering model to be trained to obtain training answer data; the training answer data is obtained by fusing the predicted answer data obtained by the question-answering model to be trained based on the training inquiry data and the training knowledge data; The question-answering model to be trained is trained based on the training reply data to obtain a question-answering model.
2. The question-answering model training method according to claim 1, characterized in that: Before retrieving the training knowledge data from the preset knowledge base according to the training query data, the method further includes: Acquiring knowledge data; Performing entity extraction and relationship extraction on the knowledge data to obtain a plurality of knowledge entities in the knowledge data and knowledge entity relationships between the knowledge entities; The knowledge base is constructed according to the knowledge entities and the knowledge entity relationships.
3. The question-answering model training method according to claim 1, characterized in that: The step of retrieving training knowledge data from a preset knowledge base according to the training query data includes: Performing entity extraction and relationship extraction on the training query data to obtain a plurality of training entities in the training query data and training entity relationships between the training entities; Constructing a retrieval structure according to the training entities and the training entity relationships; Calling a preset search engine to search for a knowledge structure in the knowledge base, and performing a similarity analysis on the search structure and the knowledge structure to obtain a similarity analysis result; The training knowledge data is output according to the similarity analysis result.
4. The question-answering model training method according to claim 1, characterized in that: The step of inputting the training query data and the training knowledge data into the question-answering model to be trained to obtain training answer data includes: Information encoding is performed on the training query data to obtain an embedding vector sequence; Performing linear transformation processing on the embedding vector sequence, performing attention weight operation on the word vector after the linear transformation processing, and obtaining contextual semantic features of the training query data; Perform context prediction based on the context semantic features to obtain the predicted answer data; The predicted answer data and the training knowledge data are fused according to a preset weight ratio or a preset fusion range to obtain the training answer data.
5. The question-answering model training method according to claim 1, characterized in that: Also includes: Obtaining user evaluation information on the training response data to obtain first evaluation information; Performing fusion accuracy evaluation on the training response data to obtain second evaluation information; According to the first evaluation information and the second evaluation information, a strategy parameter for fusing the predicted answer data and the training knowledge data is adjusted.
6. The question-answering model training method according to claim 1, characterized in that: The step of training the question-answering model to be trained based on the training answer data to obtain the question-answering model comprises: Determine model loss information; the model loss information represents the deviation between the training response data and the expected response data, the expected response data is obtained by fusing the preset response data corresponding to the training query data and the training knowledge data; Determining whether the model loss information is within a loss threshold range; If not, adjusting the weight parameters of the question-answering model to be trained; returning to the step of inputting the training query data and the training knowledge data into the question-answering model to be trained to obtain training answer data; If yes, determine whether the number of training query data resets reaches the reset threshold; If not reached, return to the step of obtaining training query data; If it is reached, the training is terminated and the question-answering model is obtained.
7. A question-answering processing method, characterized in that: include: Get the query data entered by the user; According to the query data, target knowledge data is retrieved from a preset knowledge base; The query data and the target knowledge data are input into a question-answering model to obtain reply data; the reply data is obtained by fusing the pre-reply data obtained by the question-answering model based on the query data for question-answer prediction and the target knowledge data, and the question-answering model is trained by the question-answering model training method described in any one of claims 1 to 6.
8. The question-answer processing method according to claim 7, characterized in that: Also includes: extracting a hyperlink to the query data; Determining whether the hyperlink of the query data is a valid link; If valid, a hyperlink to the query data is embedded in the response data.
9. An electronic device, characterized in that: The electronic device comprises a memory and a processor, the memory stores a computer program, and the processor implements the method according to any one of claims 1 to 8 when executing the computer program.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 8 is implemented.
Citation Information
Patent Citations
Causal relationship extraction method and device and electronic equipment
CN114330718A
Question answering method and device, electronic equipment and storage medium
CN116303916A
Dialogue generation model training method and device, equipment and medium
CN116992833A
Apparatus and system for training knowledge tracking model based on data augmentation and operation method thereof
US20220284315A1
