Question and answer model training method, question and answer method, device, equipment and program product
By constructing timing knowledge graphs and state predictions, the accuracy and interpretability of the question-and-answer model are improved, and the problem of insufficient accuracy and interpretability of the existing question-and-answer model is solved, and more accurate and timely answers and event trend predictions are achieved.
Patent Information
- Application Number
- CN202411329814.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-19
- Publication Date
- 2024-12-24
AI Technical Summary
The existing question-and-answer models have shortcomings in terms of accuracy and interpretability, especially the correctness and interpretability of the model inference process are low, making it difficult to provide accurate and timely answers.
By constructing a time series knowledge graph, combining historical data and time information, the timing vectors of natural language problems are obtained, state prediction and combination vector calculations are performed, and the question-answer model is input for training to improve the correctness and interpretability of the model's inference process.
Enhance the interpretability of the model and the user's trust in the answers, provide more accurate and comprehensive answers, and help users understand the development trend of events through time reasoning and prediction, solving the correctness and explanatory nature of the model reasoning process. Sexual issues.
Smart Images

Figure CN119180340A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the technical field of natural language processing, and in particular, to a question-answering model training method, a question-answering method, a question-answering model training device, a question-answering device, an electronic device, and a computer program product. Background Art
[0002] In the information explosion era of the 21st century, knowledge management and information retrieval have become important cornerstones of scientific and technological development. As an intelligent information retrieval tool, the question-answering system not only provides an efficient and convenient way to acquire knowledge, but also plays a vital role in promoting scientific and technological development.
[0003] The question-answering system uses natural language processing technology to accurately understand user questions and find answers in massive data, greatly improving the efficiency and accuracy of knowledge acquisition. In the field of scientific research, the question-answering system can provide researchers with fast and accurate knowledge services, accelerate the scientific research process, and improve the quality of scientific research results. At the same time, the question-answering system can also promote interdisciplinary knowledge exchange and integration, and provide new perspectives and ideas for scientific and technological innovation.
[0004] Although the current question-answering model can achieve rapid retrieval and reasoning of answers, it still has problems such as low accuracy and weak model interpretability.
[0005] It should be noted that the information disclosed in the above background technology section is only used to enhance the understanding of the background of the present disclosure, and therefore may include information that does not constitute the prior art known to ordinary technicians in the field. Summary of the invention
[0006] The purpose of the present disclosure is to provide a question-answering model training method, a question-answering method, a question-answering model training device, a question-answering device, an electronic device and a computer program product, thereby at least to a certain extent being able to improve the correctness and interpretability of the model reasoning process and provide more accurate and timely answers.
[0007] According to a first aspect of the present disclosure, a method for training a question-answering model is provided, comprising:
[0008] Obtaining a question sample at a first moment and a time series knowledge graph at the first moment from the question-answering dataset, wherein the time series knowledge graph at the first moment includes element information and time information of the question sample at the first moment;
[0009] Obtaining the element vector at the first moment according to the time series knowledge graph at the first moment, and converting the question sample at the first moment into the question vector at the first moment;
[0010] Performing state prediction on the element vector at the first moment to obtain a predicted element vector at the second moment;
[0011] Based on the question vector and the element vector at the first moment, and the predicted element vector at the second moment, a combination vector at the first moment is calculated, and the combination vector at the first moment is input into the question-answering model for training.
[0012] According to a second aspect of the present disclosure, a question-answering method is provided, comprising:
[0013] Obtaining element information of the question at the target moment according to the temporal knowledge graph at the target moment, obtaining an element vector at the target moment according to the element information at the target moment, and converting the question at the target moment into the question vector at the target moment;
[0014] Performing state prediction on the element vector at the target moment to obtain a predicted element vector at the next moment of the target moment;
[0015] Calculate the combination vector of the target moment according to the problem vector and the element vector at the target moment and the predicted element vector at the next moment;
[0016] The combination vector at the target moment is input into a question-answering model, and the answer to the question at the target moment is obtained based on the combination vector at the target moment, wherein the question-answering model is obtained by the above-mentioned question-answering model training method.
[0017] According to a third aspect of the present disclosure, a training device for a question-answering model is provided, comprising:
[0018] A question sample acquisition module, used to acquire a question sample at a first moment and a time series knowledge graph at the first moment from a question-answering dataset, wherein the time series knowledge graph at the first moment includes element information and time information of the question sample at the first moment;
[0019] An element vector conversion module, used to obtain the element vector at the first moment according to the time series knowledge graph at the first moment, and convert the question sample at the first moment into the question vector at the first moment;
[0020] An element vector prediction module, used to perform state prediction on the element vector at the first moment to obtain a predicted element vector at a second moment;
[0021] The question-answering model training module is used to calculate the combination vector at the first moment based on the question vector and element vector at the first moment, and the predicted element vector at the second moment, and input the combination vector at the first moment into the question-answering model for training.
[0022] According to a fourth aspect of the present disclosure, a question-answering device is provided, comprising:
[0023] Vector conversion module Vector prediction module Vector combination module Answer determination module Vector conversion module, used to obtain the element information of the question at the target moment according to the time series knowledge graph at the target moment, obtain the element vector at the target moment according to the element information at the target moment, and convert the question at the target moment into the question vector at the target moment;
[0024] A vector prediction module, used to perform state prediction on the element vector at the target moment to obtain a predicted element vector at the next moment of the target moment;
[0025] A vector combination module, used to calculate the combination vector at the target moment according to the problem vector and the element vector at the target moment and the predicted element vector at the next moment;
[0026] An answer determination module is used to input the combination vector at the target moment into a question-answering model, and obtain the answer to the question at the target moment based on the combination vector at the target moment, wherein the question-answering model is obtained by the training method of the above-mentioned question-answering model.
[0027] According to a fifth aspect of the present disclosure, an electronic device is provided, comprising: a processor; and a memory for storing executable instructions of the processor; wherein the processor is configured to execute any one of the above-mentioned question-answering model training methods or question-answering methods by executing the executable instructions.
[0028] According to a sixth aspect of the present disclosure, a computer program product is provided, including a computer program, which, when executed by a processor, implements any one of the above-mentioned question-answering model training methods or question-answering methods.
[0029] The exemplary embodiments of the present disclosure may have the following beneficial effects:
[0030] In the training method of the question-answering model of the example implementation method of the present disclosure, by constructing a temporal knowledge graph question-answering dataset and providing an interpretable framework, the model can reason on the temporal knowledge graph according to the input natural language question and give an interpretable answer. By combining historical data and time information, it can help users obtain knowledge and information that changes over time, make the answers to questions more timely and accurate, provide more accurate and comprehensive answers, and explain the process and reasons for the answers, so that users can understand how the model is reasoning based on facts and time, thereby enhancing the interpretability of the model and increasing the user's trust in the answers. Through the temporal knowledge graph, the system can perform time reasoning and prediction, help users understand the development trend of events, and even predict future situations, while pursuing accuracy, ensuring the correctness and interpretability of the model reasoning process. Secondly, by constructing a large-scale temporal knowledge graph question-answering dataset, rich annotation information is provided for the temporal knowledge graph question-answering task, thereby solving the problem of lack of strong supervision signals and facilitating the training, verification and testing of the model.
[0031] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] The accompanying drawings herein are incorporated into the specification and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the specification are used to explain the principles of the present disclosure. Obviously, the accompanying drawings described below are only some embodiments of the present disclosure, and for ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without creative work.
[0033] Figure 1 A schematic diagram schematically shows the overall design architecture of a question-answering system in a related embodiment of the present disclosure;
[0034] Figure 2 A schematic diagram schematically shows the overall design architecture of a question-answering system in another related embodiment of the present disclosure;
[0035] Figure 3 A flowchart of a method for training a question-answering model according to an exemplary embodiment of the present disclosure is shown;
[0036] Figure 4 A schematic diagram of a process for determining a model loss of a question-answering model according to an exemplary embodiment of the present disclosure is shown;
[0037] Figure 5 A flowchart of a weakly supervised multi-hop temporal knowledge graph reasoning question-answering method based on reinforcement learning in a specific embodiment of the present disclosure is shown;
[0038] Figure 6 A framework diagram of a weakly supervised multi-hop temporal knowledge graph reasoning question-answering method based on reinforcement learning in a specific embodiment of the present disclosure is schematically shown;
[0039] Figure 7 A flowchart of a question-answering method according to an exemplary embodiment of the present disclosure is shown;
[0040] Figure 8 A block diagram of a training apparatus for a question-answering model according to an exemplary embodiment of the present disclosure is shown;
[0041] Fig. 9 A block diagram of a question-answering device according to an exemplary embodiment of the present disclosure is shown;
[0042] Fig.10 A schematic diagram of the structure of a computer system suitable for implementing the electronic device of the embodiment of the present disclosure is shown. DETAILED DESCRIPTION
[0043] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be implemented in a variety of forms and should not be construed as being limited to the examples set forth herein; on the contrary, these embodiments are provided so that the present disclosure will be more comprehensive and complete, and the concepts of the example embodiments are fully conveyed to those skilled in the art. The described features, structures, or characteristics may be combined in one or more embodiments in any suitable manner. In the following description, many specific details are provided to provide a full understanding of the embodiments of the present disclosure. However, those skilled in the art will appreciate that the technical solutions of the present disclosure may be practiced while omitting one or more of the specific details, or other methods, components, devices, steps, etc. may be adopted. In other cases, known technical solutions are not shown or described in detail to avoid obscuring various aspects of the present disclosure.
[0044] In addition, the accompanying drawings are only schematic illustrations of the present disclosure and are not necessarily drawn to scale. The same reference numerals in the figures represent the same or similar parts, and their repeated description will be omitted. Some of the block diagrams shown in the accompanying drawings are functional entities and do not necessarily correspond to physically or logically independent entities. These functional entities can be implemented in software form, or implemented in one or more hardware modules or integrated circuits, or implemented in different networks and / or processor devices and / or microcontroller devices.
[0045] In some related embodiments, an intelligent question-answering system may be constructed based on a knowledge graph. Figure 1A schematic diagram of the overall design architecture of the question-answering system in a related embodiment of the present disclosure is schematically shown. First, a knowledge graph is constructed through steps such as ontology layer construction, data crawling, and data storage. Secondly, the BERT (Bidirectional Encoder Representations from Transformers, Bidirectional Encoder Representations from Transformers) + BiLSTM (Bidirectional Long Short-Term Memory, Bidirectional Long Short-Term Memory Network) + CRF (Conditional Random Fields) model and the BERT + TextCNN (CNN-based text classification model) model can be used for named entity recognition and user intent recognition. Finally, Flask (application framework) is used to encapsulate the background API (Application Programming Interface) to provide more flexible and personalized services.
[0046] The intelligent question-answering system includes three main tasks, namely the construction of the knowledge graph, the design of the technical model related to the question-answering system, and the design of the question-answering system. The design and training of the technical model related to the question-answering system is mainly divided into named entity recognition and user question intention recognition. The overall question-answering system uses Flask to encapsulate the backend API. The user's needs are input, and then it is determined whether it is text or picture. If it is a picture, DBnet (Detection and Recognition Neural Network) is used to identify the picture content. If it is text, the question entity is constructed through NLP (Natural Language Processing) BERT+BiLSTM+CRF, and then CNN (Convolutional Neural Network) is used for classification to identify the intent, and finally the query statement is constructed to return the data to the user.
[0047] The disadvantage of the intelligent question-answering method in the above-mentioned related embodiments is that it has poor interpretability. Weak model interpretability means that when a machine learning model makes a prediction, its internal reasoning process is difficult for people to understand. Weak model interpretability is an important issue because in many application scenarios, it is crucial to explain the decision-making process of the model.
[0048] Although the intelligent question-answering method in the above-mentioned related embodiments has achieved good results in the question-answering task, the internal operation process of the model is difficult to understand and explain. Because the model is constructed by a neural network model, including Dbnet, BERT, BiLSTM, CRF and CNN. The construction principle of this method is that after obtaining the data of the question and answer, it is first mapped into the embedding space, and then the corresponding distance function is defined to calculate the similarity between the question and the answer, and finally the predicted answer is selected. However, the black box nature of the neural network makes it impossible for the model to clearly understand the intermediate reasoning process and the staged reasoning results, which limits the in-depth understanding of the model decision and cannot reveal the specific reason why the model chooses a certain answer. This is unacceptable in some application scenarios, especially for some important decisions or tasks with clear requirements for model prediction.
[0049] Based on the above problems, we need to explore how to increase the interpretability of neural network models, including designing methods that can generate intermediate reasoning processes, or using interpretable models to explain the decision-making process of neural network models. In this way, we can better understand the reasoning path of the model and know the contribution of each reasoning step to the final answer, thereby improving the interpretability of the model and the user's trust.
[0050] In other related embodiments, the Uhop (Unrestricted-Hop) framework can also be used. The UHop framework is designed to handle unrestricted relation jumps and make it compatible with existing relation extraction models. UHop achieves this goal by decomposing unrestricted jump relation extraction into two subtasks: single-hop relation extraction and comparison termination decision. Given a question and a subject entity extracted by an existing entity linking method, UHop first queries the knowledge graph for candidate outbound relations connected to the entity. For each relationship, UHop extracts a single-hop relationship and selects a relationship to transfer to the next entity. After the transfer, UHop decides whether to terminate, that is, whether to continue this process, and then extracts the next relationship in the path and decides whether to terminate based on the termination decision. If the decision is false, the knowledge graph is searched again to find new outbound relations and the search process is restarted. Starting from the second iteration, the candidate relations will be connected to the previously selected relations to keep a historical record. UHop continues this cycle until the decision is termination. Therefore, the termination decision enables UHop to know when to stop searching to extract relations. At termination, UHop returns the extracted relations. In the UHop framework, the model is trained to prefer correct relations over incorrect relations. The model prefers correct relations over other relations when selecting outbound single-hop relations of the current entity, and prefers correct relations linked to the current entity over outbound relations when terminating. UHop successfully exploits this relation preference to train the same model to perform single-hop relation extraction and termination decisions.
[0051] Figure 2 A schematic diagram of the overall design architecture of the question-answering system in another related embodiment of the present disclosure is schematically shown. The UHop framework is an unrestricted relation separation framework for knowledge question answering. The framework relaxes the restriction of exhaustively searching all one-hop relations, two-hop relations, etc. in the knowledge graph by replacing the relation chain-based search framework with a transition-based search framework. In the UHop framework, the model is trained to give priority to correct relations rather than incorrect relations to perform single-hop relation extraction and termination decisions. The framework is able to stop and cooperate with the most advanced models to achieve competitive performance without exhaustive search and open up performance gaps for long-term relations. In addition, the UHop framework also successfully uses the preference for relations to train the same model so that it can perform both single-hop relation extraction and termination decisions.
[0052] In the above-mentioned related embodiments, the disadvantage of UHop is the strong supervision signal. Although UHop has achieved relatively good question-answering effects, the model requires the results of each step in the reasoning process to be known and supervised at all times. Specifically, UHop introduces negative log-likelihood loss as an optimization target, which reflects the difference between the intermediate prediction results and the true reasoning results. This type of method is called a strong supervision method. However, due to the high cost of annotating the intermediate reasoning process, many data sets only provide the final predicted answer and ignore the intermediate process. This means that the format of the training samples only contains questions and answers, without providing information about the intermediate process. Therefore, it is necessary to enable the model to have the ability to perform question-answering under weakly supervised training conditions.
[0053] Weakly supervised learning is a learning method that processes only partially labeled information. In the multi-hop knowledge base question answering task, weakly supervised training means that there is no labeled data for each intermediate step, but only the final question answer pair. Therefore, it is necessary to design a method that allows the model to learn effective intermediate reasoning processes under such data conditions.
[0054] Based on the above analysis, this example implementation first provides a method for training a question-answering model. Figure 3 As shown, the training method of the above question-answering model may include the following steps:
[0055] Step S310. Obtain the question sample at the first moment and the time series knowledge graph at the first moment from the question and answer dataset, wherein the time series knowledge graph at the first moment includes the element information and time information of the question sample at the first moment.
[0056] Step S320. Obtain the element vector at the first moment according to the temporal knowledge graph at the first moment, and convert the question sample at the first moment into the question vector at the first moment.
[0057] Step S330: Perform state prediction on the element vector at the first moment to obtain a predicted element vector at the second moment.
[0058] Step S340. Based on the question vector and element vector at the first moment, and the predicted element vector at the second moment, calculate the combination vector at the first moment, and input the combination vector at the first moment into the question-answering model for training.
[0059] In the training method of the question-answering model of the example implementation method of the present disclosure, by constructing a temporal knowledge graph question-answering dataset and providing an interpretable framework, the model can reason on the temporal knowledge graph according to the input natural language question and give an interpretable answer. By combining historical data and time information, it can help users obtain knowledge and information that changes over time, make the answers to questions more timely and accurate, provide more accurate and comprehensive answers, and explain the process and reasons for the answers, so that users can understand how the model is reasoning based on facts and time, thereby enhancing the interpretability of the model and increasing the user's trust in the answers. Through the temporal knowledge graph, the system can perform time reasoning and prediction, help users understand the development trend of events, and even predict future situations, while pursuing accuracy, ensuring the correctness and interpretability of the model reasoning process. Secondly, by constructing a large-scale temporal knowledge graph question-answering dataset, rich annotation information is provided for the temporal knowledge graph question-answering task, thereby solving the problem of lack of strong supervision signals and facilitating the training, verification and testing of the model.
[0060] Below, the implementation of obtaining the question sample at the first moment and the time series knowledge graph at the first moment from the question and answer dataset is described in detail, wherein the time series knowledge graph at the first moment includes the element information and time information of the question sample at the first moment.
[0061] As the core technology of the question-answering system, the knowledge graph is a graphical data structure used to describe real-world entities and their relationships. It integrates scattered and disordered knowledge into a huge network, making the relationship between knowledge clear and visible. The advantage of the knowledge graph lies in its structured and networked storage method, which can efficiently process large-scale knowledge data and realize rapid retrieval and reasoning of knowledge. Through the knowledge graph, the question-answering system can achieve a deep understanding and accurate answer to user questions, improving the quality and efficiency of information retrieval.
[0062] In this example implementation, the element information of the knowledge graph refers to the three basic elements that constitute the knowledge graph, including subject, relationship, and object. On the basis of the three basic element information of the knowledge graph, by adding time information, a temporal knowledge graph in the form of a quadruple can be constructed.
[0063] In this example implementation, a temporal knowledge graph question-answering dataset can be constructed, which contains multiple natural language questions that require temporal reasoning answers, and multiple temporal knowledge graphs (Temporal Knowledge Graph, TKG) corresponding to the facts. Each temporal knowledge graph can be represented in the form of a quadruple (topic, relationship, object, timestamp), where the topic and object are entities, and the timestamp is the time information of the question sample at the first moment, which can be expressed as [start time, end time].
[0064] Based on the knowledge graph, the time series knowledge graph can bring a new perspective to knowledge representation and learning. The time series knowledge graph not only contains information about entities and relationships, but also adds the time dimension, allowing the knowledge graph to describe the dynamic process of entities and events changing over time. This time-series knowledge representation method provides a richer and more accurate source of information for the question-answering system, enabling the question-answering system to better understand and answer time-related questions. The number of entities and events in the real world is huge and the relationships are complex. By building a high-quality time series knowledge graph, time series data can be effectively acquired, integrated, and represented.
[0065] In this example implementation, the input data of the question-answering model may include two parts: time series knowledge graph data (TKG data) and natural language questions, i.e., question samples. TKG data consists of entities, relationships, and facts related to timestamps. Natural language questions are user query questions that are used to guide the subsequent reasoning process. Specifically, the input data set can be expressed as D = (KG t ,Q t ,A t ), where KG t is the temporal knowledge graph at the first moment t, Q t is the natural language question corresponding to the first moment, A t is the answer to the first moment question.
[0066] Next, the implementation of obtaining the feature vector at the first moment according to the temporal knowledge graph at the first moment and converting the question sample at the first moment into the question vector at the first moment is described in detail.
[0067] In this example implementation, the question sample can be converted into a question vector at the corresponding time by means of question encoding. The question encoding part can use the Transformer architecture. Transformer converts natural language questions into vector representations, which contain the semantic information of the question and are used in the subsequent reasoning process. Specifically, the Transformer model T can be used to convert question Q t Encoded as question vector Right now:
[0068] In the question encoding stage, the Transformer architecture is used to parse natural language questions and convert them into vector form. This step can pave the way for the subsequent reasoning process.
[0069] In this example implementation, the feature information can be converted into feature vectors at the corresponding time by using the Temporal Knowledge Graph Embedding (TKGE) method. In this step, the algorithm learns and generates low-dimensional vector representations of entities and relationships at different time points. These embeddings capture the changes of entities and relationships over time, providing a basis for temporal reasoning. Specifically, assuming that the temporal knowledge graph KG at the first time t is t =(e i ,r k ,e j ,t), where e i ,e j is an entity, r k is a relation, and t is a timestamp. The TKGE part can map each entity and relation into a low-dimensional vector: in, For entity e i The corresponding low-dimensional vector, For entity e j The corresponding low-dimensional vector, For the relationship k The corresponding low-dimensional vector.
[0070] Learning multi-dimensional representations of entities and relations over time through Temporal Knowledge Graph Embedding (TKGE) can provide a basis for capturing and leveraging the dynamic nature of knowledge.
[0071] Next, the implementation of performing state prediction on the element vector at the first moment to obtain the predicted element vector at the second moment is described in detail.
[0072] In this example implementation, LSTM or other sequence models can be used to predict the possible states of entities and relationships in TKG data at future time points, which is crucial for reasoning on the timeline. This step is to support time series problems that require predicting future information. For example, suppose is the entity e at time t i A set of states, using LSTM or other sequence models S() to predict future states S t+1 , that is, S t+1 =S(S t ). Among them, entity prediction and relationship prediction are two different tasks, which can be performed simultaneously or only one of them can be performed.
[0073] Below, the implementation of calculating the combination vector at the first moment based on the question vector and element vector at the first moment and the predicted element vector at the second moment, and inputting the combination vector at the first moment into the question-answering model for training is described in detail.
[0074] After sequence prediction, a combined vector can be obtained based on the question vector, embedding vector and prediction embedding vector, that is, the output of TKGE, the output of sequence prediction and the output of question encoding are combined to form a comprehensive state representation.
[0075] After obtaining the combination vector, the question-answering model can be trained based on the combination vector. Specifically, the combination vector at the first moment can be input into the question-answering model, and the predicted answer to the question sample at the first moment can be obtained based on the combination vector at the first moment. The model loss of the question-answering model is then obtained based on the question sample and the predicted answer, and the model parameters in the question-answering model are updated based on the model loss.
[0076] In this example implementation, a question-and-answer data state space may be generated based on the question-and-answer data set, and a search may be performed in the question-and-answer data state space according to the combination vector at the first moment to obtain a predicted answer to the question sample at the first moment.
[0077] The question-answering data state space is a comprehensive state representation of the vectors of the question samples in the question-answering data set at each time. When generating the question-answering data state space, the combined vectors corresponding to the question samples in the question-answering data set at each time can be input into the target neural network, and the question-answering data state space is output through the target neural network.
[0078] The state space is a comprehensive state representation formed by combining the output of TKGE, the output of sequence prediction, and the output of question encoding. These state representations are fed into a target neural network, such as a graph neural network (GNN), which further processes the information to provide the reinforcement learning agent with a comprehensive view of the current state of the environment. The origin of the state space can be attributed to the combination of the embedded representation of the temporal knowledge graph, question encoding, and future state prediction, which provide a comprehensive view of entities, relations, time, and semantics. In this state space, the ability to search for the right path comes from the ability of the reinforcement learning agent, which can explore in the state space through algorithms such as PPO (Proximal Policy Optimization) and learn how to choose strategies and actions to maximize the expected return.
[0079] In this example implementation, the combined vector at the first moment can be input into the target neural network to obtain the state representation vector of the question sample at the first moment, and then a search is performed in the state space of the question and answer data based on the state representation vector to obtain the target answer path of the question sample at the first moment. Based on the state representation vector of the question sample at the first moment and the target answer path, the predicted answer to the question sample at the first moment is obtained.
[0080] The combined vector is composed of the outputs of TKGE, question encoding, and sequence prediction. The state representation is further processed by the target neural network, such as GNN, to obtain the corresponding state representation vector: Among them, G represents the GNN model, For entity e i The low-dimensional vector corresponding to the first moment t, S t+1 For entity e i The predicted state at the next time point, is the question vector. Then, based on the state representation vector, algorithms such as PPO are used to search in the state space and learn how to select actions to find the correct answer path in multi-hop reasoning.
[0081] Explainable multi-hop reasoning plays a key role in question-answering systems, and can improve the system's ability to interpret reasoning logic for complex problems and the reliability of decision-making. Multi-hop reasoning can comprehensively consider the complex relationships between multiple entities and relationships, as well as the impact of time information on the reasoning results. Therefore, by designing effective reasoning algorithms and models, accurate and explainable multi-hop reasoning can be achieved. In this example implementation, when searching in the state space of question-answering data according to the state representation vector, multiple groups of different search strategies and search actions can be obtained, and searches are performed in the state space of question-answering data according to the state representation vector and each group of search strategies and search actions, and the search reward value of each group of search strategies and search actions at the first moment is obtained; then, a set of target search strategies and target search actions are determined based on the search reward value, and the target answer path of the question sample at the first moment is obtained based on the target search strategy and target search action.
[0082] When searching, the reinforcement learning agent uses the goal search policy π to select the goal search action a to maximize the expected reward R: a t =π(v *t+te ), where r t is the immediate return obtained at time t, γ is the discount factor, and v "tate is the state representation vector of the problem sample at the first moment. By maximizing the expected return value, the target search strategy and target search action used during the search can be determined, so that the agent can search for the best target answer path.
[0083] In this example implementation, during the reinforcement learning phase, the current and predicted states are integrated through the graph neural network to obtain the state space of the question-answering data, providing the agent with a rich representation of the environment state, allowing the agent to learn and improve its decision-making strategy in interaction with the environment, so that it can autonomously learn to solve problems through trial and error without relying on predetermined rules. Reinforcement learning can be applied to complex environments and problem areas, allowing agents to cope with diverse and changing situations.
[0084] In this example implementation, the answer can also be effectively searched through a dynamic beam search algorithm. Specifically, the search width can be dynamically adjusted based on the search confidence and search depth when searching for the target answer path, and then the search can be performed in the state space based on the adjusted search width to obtain the target answer path for the question sample.
[0085] During the search process, the dynamic beam search algorithm can be used to effectively search for answers. This algorithm can dynamically adjust the search width according to the current search confidence and search depth to balance exploration and utilization and optimize search efficiency. Specifically, the dynamic beam search algorithm B is used to effectively search for the answer path P. The algorithm adjusts the search width b according to the search confidence c and the search depth d, that is, P = B (v "tate ,c,d,b), where v "tate It is the state representation vector of the problem sample at the first moment.
[0086] The size of the search width affects the degree of exploration of candidate answers by the agent. A wider beam width allows the agent to consider more candidate answers at the same time, increasing the breadth of exploration and helping to discover more possibilities. A narrower beam width, on the other hand, places more emphasis on utilizing existing information and concentrating the search near candidate answers with higher confidence, thereby accelerating convergence. Dynamically adjusting the beam width can flexibly balance exploration and utilization based on the current confidence and search depth, enabling the agent to achieve the best balance between exploration and utilization, thereby improving search efficiency.
[0087] In addition, a wider beam width will lead to an exponential growth of the search space, increasing computational complexity and memory consumption. On the other hand, a narrower beam width can reduce the size of the search space to a certain extent, reducing computational overhead. Dynamically adjusting the beam width can flexibly balance between exploration and utilization according to the current situation, effectively reducing unnecessary computational overhead and improving search efficiency.
[0088] In this example implementation, the training data set can also be expanded through weakly supervised learning. Specifically, basic training data can be obtained from the question and answer data set, and extended data can be obtained from the extended knowledge base. The basic training data and the extended data can be input into the weakly supervised learning model to obtain pseudo-label data, and the pseudo-label data can be added to the question and answer data set to obtain the expanded question and answer data set.
[0089] In order to expand the training data set, weakly supervised learning uses heuristic rules and external knowledge bases to generate pseudo labels. These pseudo labels are used to train and fine-tune the model, even if they are not completely accurate. Through proper weight adjustment and verification, these pseudo labels help improve the performance of the model, especially when labeled data is scarce. Specifically, the weakly supervised learning model W uses heuristic rules H and external knowledge base K to generate pseudo labels Pseudo labels can be used to train and fine-tune models:
[0090] Weakly supervised learning usually uses incompletely labeled and noisy labeled data to train models. Compared with supervised learning that requires complete and detailed labeling, it can save a lot of manpower costs and time. On large-scale data sets, it may become costly to fully label each data sample. Weakly supervised learning uses heuristic rules and external knowledge bases to generate pseudo labels and expand the training data set. It can train models at a faster speed and adapt to large-scale data. It is particularly suitable for scenarios with insufficient labeled data. Weakly supervised learning can handle various types of label noise, such as labeling errors, incomplete labeling, label bias, etc., making the model more robust to various interferences in the data set. Although these pseudo labels are not completely accurate, they can effectively improve the performance of the model through appropriate weight adjustment and verification.
[0091] In this example implementation, the model loss of the question-answering model may include at least three parts, namely, answer prediction loss, vector embedding loss, and weak supervision model loss. Figure 4 As shown in the figure, the model loss of the question-answering model is obtained based on the question samples and the predicted answers. Specifically, the following steps can be included:
[0092] Step S410. Obtain the answer sample corresponding to the question sample from the question and answer dataset, and obtain the answer prediction loss in the question and answer model based on the predicted answer of the question sample and the answer sample.
[0093] In this example implementation, the output of the question-answering model is the answer to the natural language question, which is found in the temporal knowledge graph through multi-hop reasoning. Specifically, the model outputs the answer
[0094]
[0095] Among them, v "tate is the state representation vector of the question sample at the first moment, a is the target search action, π is the target search strategy, and P represents the search path. The model outputs the answer It can be used to evaluate and optimize the loss function L. In order to incorporate the output answer into the loss function, the difference between the answer predicted by the model and the true answer can be considered as part of the loss. Assuming there is a true answer A, a loss term Lanswer can be defined to measure the model output answer The difference between the true answer (A) and the true answer (A). One possible form is the cross entropy loss function; that is:
[0096]
[0097] Among them, A i represents the i-th element of the true answer, Represents the i-th element of the model output answer. This loss term measures the difference between the probability distribution of the model output answer and the probability distribution of the true answer.
[0098] Step S420. Obtain the vector embedding loss in the question-answering model based on the feature vector and the preset embedding scoring function.
[0099] Embedding learning can be achieved by minimizing the time-aware loss function LTKGE, such as:
[0100]
[0101] where f(·) is a scoring function, such as the transposed scoring function (TransE), Entity e i ,e j And the relationship k The corresponding low-dimensional vector.
[0102] Step S430. Obtain the weak supervision model loss in the question-answering model based on the pseudo-label data, the question sample and the corresponding target answer path.
[0103] The question answering model can be optimized by minimizing the weakly supervised loss function LWS:
[0104]
[0105] where g(·) is the loss function suitable for weakly supervised learning, Q t is the natural language question corresponding to the first moment, P represents the search path, represents a pseudo label.
[0106] Step S440. Obtain the model loss of the question-answering model according to the answer prediction loss, the vector embedding loss, and the weakly supervised model loss.
[0107] Finally, the above loss terms are added to the total loss L:
[0108] L=LTKGE+LWS+...+Lanswer
[0109] In addition to the above three types of model losses, other types of model losses can be selected according to needs and added to the total loss to update the model parameters, which is not specifically limited in this example implementation.
[0110] During the training process, the model simultaneously optimizes multiple aspects of loss, including the loss of TKGE and weakly supervised learning parts, as well as the loss of output answers, so that the model can better learn and optimize parameters to accurately answer natural language questions.
[0111] The training of question-answering models is an iterative process, where each step provides necessary information for the next step. The above approach allows the model to effectively learn and reason even with limited labeled data, thereby handling complex multi-hop time series problems.
[0112] like Figure 5 The figure is a flowchart of a weakly supervised multi-hop temporal knowledge graph reasoning question answering method based on reinforcement learning in a specific embodiment of the present disclosure, which is an example of the above steps in this example embodiment. The flowchart may specifically include the following steps:
[0113] Step S510. Obtain a time series knowledge graph.
[0114] Get natural language questions and corresponding temporal knowledge graphs from the question-answering dataset.
[0115] Step S520. Temporal Knowledge Graph Embedding (TKGE).
[0116] The entities and relations are converted into embedding vectors at the corresponding moments through the temporal knowledge graph embedding method.
[0117] Step S530. Question coding.
[0118] Through question encoding, the question is converted into the question vector at the corresponding moment.
[0119] Step S540: Sequence prediction.
[0120] LSTM is used to predict the possible states of entities and relations in TKG data at future time points.
[0121] Step S550: Reinforcement learning.
[0122] The outputs of TKGE, question encoding, and sequence prediction are combined to obtain a combined vector, which is input into the state space for search to learn how to select actions to find the correct answer path in multi-hop reasoning.
[0123] Step S560: Dynamic beam search.
[0124] The search width is dynamically adjusted according to the search confidence and search depth to optimize the search efficiency.
[0125] Step S570: Weakly supervised learning.
[0126] Expand the training data set through weakly supervised learning for overall optimization and feedback.
[0127] The above steps in this example implementation can be called a reinforcement learning-based weakly supervised multi-hop temporal knowledge graph reasoning question answering (RSMTQA) method, which is designed to solve complex multi-hop reasoning problems involving temporal knowledge graphs. It combines temporal knowledge graph embedding, natural language processing, sequence prediction, and reinforcement learning techniques to process and predict how entities and their relationships change over time.
[0128] Figure 6 The framework diagram of a weakly supervised multi-hop temporal knowledge graph reasoning question-answering method based on reinforcement learning in a specific implementation of the present disclosure is schematically shown.
[0129] Based on the framework diagram, the method uses temporal knowledge graphs (TKGs), in which not only the information of entities and relationships is embedded, but also the changes of this information over time are encoded. First, through the temporal knowledge graph embedding (TKGE) step, the algorithm learns the representation of entities and relationships at different time points, which is the basis for understanding how knowledge evolves over time. Secondly, the question encoding stage uses the Transformer architecture to process natural language questions and generate vector representations of questions, which are used to associate candidate answers in the subsequent process and as part of the input of the agent in the reinforcement learning phase. Next, the algorithm uses sequence models (such as LSTM) to predict the future state of the knowledge graph to provide support for temporal reasoning. In the reinforcement learning phase, a graph neural network (GNN) is used to integrate the current and predicted entity relationship embeddings to provide the agent with a rich representation of the environment state. The agent uses policy gradient methods (such as PPO or SAC (Soft Actor Critic, a model-free deep reinforcement learning algorithm based on maximum entropy)) to learn how to choose the best path in multi-hop reasoning. To search for answers more efficiently, RSMTQA uses a dynamic beam search algorithm, which dynamically adjusts the search width based on the current confidence and search depth to find the best answer more efficiently. Ultimately, the RSMTQA algorithm is optimized at each step to improve the accuracy and robustness of question answering. In this way, the algorithm can not only answer questions based on the current situation, but also predict and understand the evolution of the knowledge graph over time and handle more complex multi-hop temporal problems. The integration of weak supervision further enhances the adaptability of the algorithm, enabling it to effectively learn and reason even with limited labeled data, thereby improving the accuracy and interpretability of question answering. This method of combining time series data and weak supervision signals provides a powerful solution for complex time series knowledge graph question answering.
[0130] On the other hand, this example embodiment also provides a question-answering method. Figure 7 As shown, the above question-answering method may include the following steps:
[0131] Step S710. Obtain the element information of the question at the target time according to the temporal knowledge graph at the target time, obtain the element vector at the target time according to the element information at the target time, and convert the question at the target time into the question vector at the target time.
[0132] In this example implementation, the time series knowledge graph corresponding to the target moment may be extracted based on the question at the target moment, such as a time series knowledge graph quadruple (topic, relationship, object, timestamp), wherein the element information may include topic, relationship, and object.
[0133] Through question encoding, the question at the target moment can be converted into the question vector at the target moment, and through temporal knowledge graph embedding, the feature information can be converted into the feature vector at the target moment.
[0134] Step S720: Perform state prediction on the element vector at the target moment to obtain the element vector at the next moment of the predicted target moment.
[0135] In this example implementation, LSTM or other sequence models may be used to predict the possible state of the feature vector at the next moment, and obtain the feature vector at the next moment of the predicted target moment.
[0136] Step S730: Calculate the combination vector at the target moment based on the question vector and the element vector at the target moment and the element vector at the predicted next moment.
[0137] According to the problem vector and the element vector at the target moment, and the prediction result of the element vector at the next moment, the combination vector at the target moment can be obtained.
[0138] Step S740. Input the combination vector at the target time into the question-answering model, and obtain the answer to the question at the target time based on the combination vector at the target time.
[0139] Among them, the question-answering model can be obtained through the training method of the question-answering model as mentioned above.
[0140] In this example implementation, a search may be performed in the state space through the combination vector at the target time to obtain a target answer path corresponding to the question at the target time, and the answer to the question at the target time may be obtained based on the target answer path.
[0141] During the search, the search width can be dynamically adjusted according to the search confidence and search depth when searching for the target answer path, and the search can be performed in the state space according to the adjusted search width to obtain the target answer path corresponding to the question.
[0142] In the question-answering method of this example implementation, the user asks a natural language question as an input parameter, and the model understands and processes the question, extracts relevant information from the knowledge base, and obtains the target time series knowledge graph. Subsequently, the model uses a multi-hop reasoning method to perform a multi-step search in the state space of the question-answering data to find the path to the final answer, and integrates the found answer path into a natural language form to output to the user, which can improve the accuracy of the question-answering.
[0143] It should be noted that although the steps of the method in the present disclosure are described in a specific order in the drawings, this does not require or imply that the steps must be performed in this specific order, or that all the steps shown must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step, and / or one step may be decomposed into multiple steps, etc.
[0144] Furthermore, the present disclosure also provides a training device for a question-answering model. Figure 8 As shown, the training device of the question-answering model may include a question sample acquisition module 810, an element vector conversion module 820, an element vector prediction module 830 and a question-answering model training module 840. Among them:
[0145] The question sample acquisition module 810 may be used to acquire a question sample at a first moment and a time series knowledge graph at the first moment from the question and answer dataset, wherein the time series knowledge graph at the first moment includes element information and time information of the question sample at the first moment;
[0146] The element vector conversion module 820 may be used to obtain an element vector at the first moment according to the temporal knowledge graph at the first moment, and convert the question sample at the first moment into the question vector at the first moment;
[0147] The element vector prediction module 830 may be used to perform state prediction on the element vector at the first moment to obtain a predicted element vector at the second moment;
[0148] The question-answering model training module 840 can be used to calculate the combination vector at the first moment based on the question vector and element vector at the first moment, and the predicted element vector at the second moment, and input the combination vector at the first moment into the question-answering model for training.
[0149] In some exemplary embodiments of the present disclosure, the question-answering model training module 840 may include a predicted answer determination unit and a model loss determination unit.
[0150] The predicted answer determination unit may be used to input the combination vector at the first moment into the question-answering model, and obtain the predicted answer of the question sample at the first moment based on the combination vector at the first moment;
[0151] The model loss determination unit can be used to obtain the model loss of the question-answering model according to the question sample and the predicted answer, and update the model parameters in the question-answering model based on the model loss.
[0152] In some exemplary embodiments of the present disclosure, the predicted answer determination unit can be specifically used to generate a question and answer data state space based on the question and answer data set, search in the question and answer data state space according to the combination vector at the first moment, and obtain the predicted answer to the question sample at the first moment.
[0153] In some exemplary embodiments of the present disclosure, the predicted answer determination unit may include a state space generation unit, which can be used to input the combined vectors corresponding to the question samples in the question and answer data set at each time into the target neural network, and output the question and answer data state space through the target neural network, wherein the question and answer data state space is a comprehensive state representation of the vectors of the question samples in the question and answer data set at each time.
[0154] In some exemplary embodiments of the present disclosure, the predicted answer determination unit may further include a state representation vector determination unit, a target answer path search unit, and a sample predicted answer determination unit.
[0155] in:
[0156] The state representation vector determination unit can be used to input the combination vector at the first moment into the target neural network to obtain the state representation vector of the problem sample at the first moment;
[0157] The target answer path search unit can be used to search in the question and answer data state space according to the state representation vector to obtain the target answer path of the question sample at the first moment;
[0158] The sample predicted answer determination unit can be used to obtain the predicted answer of the question sample at the first moment according to the state representation vector of the question sample at the first moment and the target answer path.
[0159] In some exemplary embodiments of the present disclosure, the target answer path search unit may include a search strategy determination unit, a search reward value determination unit, and a target answer path determination unit.
[0160] The search strategy determination unit may be used to obtain multiple sets of different search strategies and search actions;
[0161] The search reward value determination unit may be used to search in the question-answer data state space according to the state representation vector and each group of search strategies and search actions, and obtain the search reward value of each group of search strategies and search actions at the first moment;
[0162] The target answer path determination unit can be used to determine a set of target search strategies and target search actions according to the search reward value, and obtain the target answer path of the question sample at the first moment according to the target search strategies and target search actions.
[0163] In some exemplary embodiments of the present disclosure, the target answer path search unit may further include a search width adjustment unit, which may be used to dynamically adjust the search width according to the search confidence and search depth when searching for the target answer path.
[0164] In some exemplary embodiments of the present disclosure, a training device for a question-answering model provided by the present disclosure may further include a training data expansion module. The training data expansion module may include a basic training data determination unit, a pseudo-label data determination unit, and a question-answering data set expansion. Among them:
[0165] The basic training data determination unit may be used to obtain basic training data from the question-answering dataset;
[0166] The pseudo-label data determination unit can be used to obtain the extended data from the extended knowledge base, and input the basic training data and the extended data into the weakly supervised learning model to obtain the pseudo-label data;
[0167] The question-answering dataset expansion unit can be used to add pseudo-label data into the question-answering dataset to obtain an expanded question-answering dataset.
[0168] In some exemplary embodiments of the present disclosure, the model loss determination unit may include an answer prediction loss determination unit, a vector embedding loss determination unit, a weak supervision model loss determination unit, and a comprehensive model loss determination unit.
[0169] The answer prediction loss determination unit can be used to obtain an answer sample corresponding to a question sample from a question-answering dataset, and obtain an answer prediction loss in a question-answering model according to the predicted answer of the question sample and the answer sample;
[0170] The vector embedding loss determination unit may be used to obtain a vector embedding loss in a question-answering model according to a feature vector and a preset embedding scoring function;
[0171] The weak supervision model loss determination unit can be used to obtain the weak supervision model loss in the question answering model according to the pseudo-label data, the question sample and the corresponding target answer path;
[0172] The comprehensive model loss determination unit can be used to obtain the model loss of the question-answering model according to the answer prediction loss, the vector embedding loss, and the weakly supervised model loss.
[0173] Furthermore, the present disclosure also provides a question-answering device. Fig. 9 As shown, the question-answering device may include a vector conversion module 910, a vector prediction module 920, a vector combination module 930, and an answer determination module 940. Among them:
[0174] The vector conversion module 910 may be used to obtain the element information of the question at the target time according to the temporal knowledge graph at the target time, obtain the element vector at the target time according to the element information at the target time, and convert the question at the target time into the question vector at the target time;
[0175] The vector prediction module 920 may be used to perform state prediction on the element vector at the target moment to obtain the element vector at the next moment of the predicted target moment;
[0176] The vector combination module 930 may be used to calculate a combination vector at a target moment based on the problem vector and the element vector at the target moment and the element vector at the predicted next moment;
[0177] The answer determination module 940 can be used to input the combination vector at the target time into the question-answering model, and obtain the answer to the question at the target time based on the combination vector at the target time, wherein the question-answering model is obtained by the training method of the above-mentioned question-answering model.
[0178] The specific details of the training device of the above-mentioned question-answering model and each module / unit in the question-answering device have been described in detail in the corresponding method implementation example part and will not be repeated here.
[0179] It should be noted that, although several modules or units of the device for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the exemplary embodiments of the present disclosure, the features and functions of two or more modules or units described above can be embodied in one module or unit. Conversely, the features and functions of one module or unit described above can be further divided into multiple modules or units to be embodied.
[0180] Fig.10 A schematic diagram of the structure of a computer system suitable for implementing an electronic device of an embodiment of the present disclosure is shown.
[0181] It should be noted that Fig.10 The computer system 1000 of the electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0182] like Fig.10As shown, the computer system 1000 includes a central processing unit (CPU) 1001, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 1002 or a program loaded from a storage part 1008 into a random access memory (RAM) 1003. Various programs and data required for system operation are also stored in the RAM 1003. The CPU 1001, the ROM 1002, and the RAM 1003 are connected to each other via a bus 1004. An input / output (I / O) interface 1005 is also connected to the bus 1004.
[0183] The following components are connected to the I / O interface 1005: an input section 1006 including a keyboard, a mouse, etc.; an output section 1007 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 1008 including a hard disk, etc.; and a communication section 1009 including a network interface card such as a LAN card, a modem, etc. The communication section 1009 performs communication processing via a network such as the Internet. A drive 1010 is also connected to the I / O interface 1005 as needed. A removable medium 1011, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 1010 as needed, so that a computer program read therefrom is installed into the storage section 1008 as needed.
[0184] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program contains a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication part 1009, and / or installed from a removable medium 1011. When the computer program is executed by a central processing unit (CPU) 1001, various functions defined in the system of the present disclosure are executed.
[0185] The exemplary embodiments of the present disclosure also provide a computer program product, which includes a computer program, and when the computer program is executed by a processor, the training method of the question-answering model is implemented.
[0186] In one embodiment, the computer program product may be a tangible product containing a computer program, such as a computer-readable storage medium storing a computer program. The readable storage medium may be a storage medium based on electrical, magnetic, optical, electromagnetic, infrared, or other signals, including but not limited to: random access memory (RAM), read-only memory (ROM), magnetic tape, floppy disk, flash memory (Flash), mechanical hard disk (HDD), solid-state drive (SSD), and the like. Exemplarily, the computer program product may be implemented as a non-volatile storage medium storing a computer program, such as a read-only memory, a NAND flash memory, and the like.
[0187] In one embodiment, the computer program product may be an intangible product including a computer program. Exemplarily, the computer program product may be implemented as a virtual digital product, such as a digital file storing an executable file, an installation package, etc. of the computer program.
[0188] The code of the computer program can be written in one or more programming languages. Programming languages such as C language, Java, C++, etc. The program code can be executed entirely on the user computing device, or partially on the user computing device, or as a separate software package, or partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server. In the case of a remote computing device, the remote computing device can be connected to the user computing device through any type of network, such as a local area network (LAN), a wide area network (WAN), etc., or can be connected to an external computing device (e.g., an Internet connection provided by an operator).
[0189] The computer program can be carried or transmitted by electrical, magnetic, optical, electromagnetic, infrared, or other signals. The electronic device can convert the signal carrying the computer program into a digital signal, thereby running the computer program. When the computer program is run on an electronic device, its code is used to enable the electronic device to execute (more specifically, the processor of the electronic device can execute) the method steps of various exemplary embodiments of the present disclosure, such as the training method of the above-mentioned question-answering model.
[0190] The flow charts and block diagrams in the accompanying drawings illustrate the possible architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0191] It should be noted that, although several modules of the device for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiments of the present disclosure, the features and functions of two or more modules described above can be concretized in one module. Conversely, the features and functions of one module described above can be further divided into multiple modules to be concretized.
[0192] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. The present disclosure is intended to cover any variations, uses or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary technical means in the art that are not disclosed in the present disclosure.
[0193] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
Claims
1. A training method for a question-answering model, characterized in that: include: Obtaining a question sample at a first moment and a time series knowledge graph at the first moment from the question-answering dataset, wherein the time series knowledge graph at the first moment includes element information and time information of the question sample at the first moment; Obtaining the element vector at the first moment according to the time series knowledge graph at the first moment, and converting the question sample at the first moment into the question vector at the first moment; Performing state prediction on the element vector at the first moment to obtain a predicted element vector at the second moment; Based on the question vector and the element vector at the first moment, and the predicted element vector at the second moment, a combination vector at the first moment is calculated, and the combination vector at the first moment is input into the question-answering model for training.
2. The training method of the question-answering model according to claim 1, characterized in that: The step of inputting the combined vector at the first moment into the question-answering model for training includes: Inputting the combination vector at the first moment into the question-answering model, and obtaining a predicted answer to the question sample at the first moment based on the combination vector at the first moment; A model loss of the question-answering model is obtained according to the question sample and the predicted answer, and model parameters in the question-answering model are updated based on the model loss.
3. The training method of the question-answering model according to claim 2, characterized in that: The obtaining a predicted answer to the question sample at the first moment based on the combined vector at the first moment includes: A question-and-answer data state space is generated based on the question-and-answer data set, and a search is performed in the question-and-answer data state space according to the combination vector at the first moment to obtain a predicted answer to the question sample at the first moment.
4. The training method of the question-answering model according to claim 3, characterized in that: Generating a question-and-answer data state space based on the question-and-answer data set includes: The combined vectors corresponding to the question samples in the question and answer dataset at each moment are input into the target neural network, and the question and answer data state space is output through the target neural network, wherein the question and answer data state space is a comprehensive state representation of the vectors of the question samples in the question and answer dataset at each moment.
5. The training method of the question-answering model according to claim 3, characterized in that: The searching in the question-answer data state space according to the combination vector at the first moment to obtain the predicted answer to the question sample at the first moment includes: Inputting the combination vector at the first moment into the target neural network to obtain a state representation vector of the problem sample at the first moment; Searching in the question-answer data state space according to the state representation vector to obtain a target answer path for the question sample at the first moment; According to the state representation vector of the question sample at the first moment and the target answer path, a predicted answer of the question sample at the first moment is obtained.
6. The training method of the question-answering model according to claim 5, characterized in that: The searching in the question-answer data state space according to the state representation vector to obtain a target answer path for the question sample at the first moment includes: Get multiple sets of different search strategies and search actions; According to the state representation vector and each group of the search strategies and the search actions, searching is performed in the question-answer data state space, and a search reward value of each group of the search strategies and the search actions at the first moment is obtained; A set of target search strategies and target search actions are determined according to the search reward value, and a target answer path of the question sample at the first moment is obtained according to the target search strategies and the target search actions.
7. The training method of the question-answering model according to claim 5 or 6, characterized in that: The method further comprises: The search width is dynamically adjusted according to the search confidence and search depth when searching for the target answer path.
8. The training method of the question-answering model according to claim 2, characterized in that: The method further comprises: Acquire basic training data from the question-answering dataset; Acquire extended data from an extended knowledge base, and input the basic training data and the extended data into a weakly supervised learning model to obtain pseudo-label data; The pseudo-label data is added to the question-answering dataset to obtain the expanded question-answering dataset.
9. The method for training a question-answering model according to claim 8, characterized in that: Obtaining a model loss of the question-answering model according to the question sample and the predicted answer includes: Obtaining an answer sample corresponding to the question sample from the question-answering dataset, and obtaining an answer prediction loss in the question-answering model according to the predicted answer to the question sample and the answer sample; Obtaining a vector embedding loss in the question-answering model according to the feature vector and a preset embedding scoring function; Obtaining a weakly supervised model loss in the question-answering model according to the pseudo-label data, the question sample, and the target answer path of the question sample; The model loss of the question-answering model is obtained according to the answer prediction loss, the vector embedding loss and the weakly supervised model loss.
10. A question-answering method, characterized in that: include: Obtaining element information of the question at the target moment according to the temporal knowledge graph at the target moment, obtaining an element vector at the target moment according to the element information at the target moment, and converting the question at the target moment into the question vector at the target moment; Performing state prediction on the element vector at the target moment to obtain a predicted element vector at the next moment of the target moment; Calculate the combination vector of the target moment according to the problem vector and the element vector at the target moment and the predicted element vector at the next moment; The combination vector at the target moment is input into a question-answering model, and the answer to the question at the target moment is obtained based on the combination vector at the target moment, wherein the question-answering model is obtained by the training method of the question-answering model as described in any one of claims 1 to 9.
11. A training device for a question-answering model, characterized in that: include: A question sample acquisition module, used to acquire a question sample at a first moment and a time series knowledge graph at the first moment from a question-answering dataset, wherein the time series knowledge graph at the first moment includes element information and time information of the question sample at the first moment; An element vector conversion module, used to obtain the element vector at the first moment according to the time series knowledge graph at the first moment, and convert the question sample at the first moment into the question vector at the first moment; An element vector prediction module, used to perform state prediction on the element vector at the first moment to obtain a predicted element vector at a second moment; The question-answering model training module is used to calculate the combination vector at the first moment based on the question vector and element vector at the first moment, and the predicted element vector at the second moment, and input the combination vector at the first moment into the question-answering model for training.
12. A question-answering device, characterized in that: include: A vector conversion module, used to obtain element information of the question at the target moment according to the temporal knowledge graph at the target moment, obtain the element vector at the target moment according to the element information at the target moment, and convert the question at the target moment into the question vector at the target moment; A vector prediction module, used to perform state prediction on the element vector at the target moment to obtain a predicted element vector at the next moment of the target moment; A vector combination module, used to calculate the combination vector at the target moment according to the problem vector and the element vector at the target moment and the predicted element vector at the next moment; An answer determination module is used to input the combination vector at the target moment into a question-answering model, and obtain the answer to the question at the target moment based on the combination vector at the target moment, wherein the question-answering model is obtained by the training method of the question-answering model as described in any one of claims 1 to 9.
13. An electronic device, characterized in that: include: processor; as well as A memory for storing one or more programs, which, when executed by the processor, enables the processor to implement the training method of the question-answering model as described in any one of claims 1 to 9 or the question-answering method as described in claim 10.
14. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, it implements the training method of the question-answering model according to any one of claims 1 to 9 or the question-answering method according to claim 10.
