A keyword template-based time sequence knowledge graph question and answer matching method

CN123013966APending Publication Date: 2026-10-30苗雨欣
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611213323.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-08-11
Publication Date
2026-10-30

AI Technical Summary

Technical Problem

[0005]针对现有技术的不足,本发明提供了一种基于关键词模板的时序知识图谱问答匹配方法,解决了现有静态知识图谱问答方法无法有效利用时序信息进行多跳问题推理、难以同时兼顾问答精准率和推理效率的技术问题

Benefits of technology

(1)本发明通过设计固定的关键词槽位,将多跳问题退化为模板填充问题,对问题的主干和时序关键词进行识别和提取,填充到预定义的SQL语句模板中,将自然语言问句的识别解析问题转化为模板填充问题,避免了传统方法中复杂的语义解析和多跳推理过程,在提高问答精准率的同时提升了推理效率;

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123013966A_ABST
    Figure CN123013966A_ABST
Patent Text Reader

Abstract

The application discloses a kind of based on keyword template's time sequence knowledge graph question and answer matching method, the present application relates to knowledge graph question and answer technical field, solve the technical problem that current static knowledge graph question and answer method cannot effectively utilize time sequence information to carry out multi-hop problem reasoning, difficult to simultaneously consider question and answer precision and reasoning efficiency, the present application is by designing fixed keyword slot, multi-hop problem is degraded into template filling problem, the main stem and time sequence keyword of question are identified and extracted, fill in the pre-defined SQL sentence template, the identification analysis problem of natural language question sentence is converted into template filling problem, avoid the complex semantic analysis and multi-hop reasoning process in traditional method, improve question and answer precision while improving reasoning efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of knowledge graph question answering technology, specifically a time-series knowledge graph question answering matching method based on keyword templates. Background Technology

[0002] Knowledge graphs describe entities and their relationships in a structured form and have been widely used in fields such as intelligent search, personalized recommendation, and question answering systems. Question answering based on knowledge graphs uses facts within the knowledge graph to answer natural language questions, finding the most suitable answer through information retrieval and semantic parsing to achieve efficient problem solving. Static knowledge graphs use a Resource Description Framework (RDF) to model entities and their relationships in the form of triples (source node, relation, target node), such as (China, capital, Beijing). Nodes in the graph represent entities, edges represent relations, and different triples are interconnected, forming more complex topological relationships. The knowledge graph structure provides data support for tasks such as retrieval, querying, and question answering.

[0003] However, conventional knowledge graph question answering uses static knowledge graphs as a knowledge base to answer natural language questions. The knowledge and information within these graphs are static, while in question answering scenarios with temporal constraints, the data carries temporal information labels, requiring consideration of the time dimension during question-answering matching. Conventional question-answering matching methods based on static knowledge graphs cannot organize and analyze data with temporal constraints, making it difficult to utilize temporal information for effective reasoning and answering.

[0004] Specifically, existing technologies have the following drawbacks when addressing the above problems: On the one hand, existing methods mostly use fixed template matching or rule matching, which have limited semantic understanding of questions and make it difficult to accurately identify time constraints and multi-hop logical relationships in user questions; on the other hand, when faced with complex questions containing multiple temporal constraints, existing methods usually need to rely on complex semantic parsing models or multi-hop inference models, which have high computational complexity, low inference efficiency, and difficulty in achieving both accuracy and efficiency in answering questions. Summary of the Invention

[0005] To address the shortcomings of existing technologies, this invention provides a temporal knowledge graph question-answering matching method based on keyword templates. This method solves the technical problems of existing static knowledge graph question-answering methods, which cannot effectively utilize temporal information for multi-hop question reasoning and struggle to simultaneously achieve both question-answering accuracy and reasoning efficiency.

[0006] To achieve the above objectives, the present invention provides the following technical solution: a time-series knowledge graph question-answering matching method based on keyword templates, comprising the following steps: The system obtains natural language questions input by the user, performs word segmentation and word vector mapping on the natural language questions, and obtains a vector representation of the word sequence. The vector representation of the word sequence is encoded through a bidirectional long short-term memory network to obtain a semantic vector that incorporates contextual information; The semantic vector is classified and identified according to multiple predefined slots. The filling content corresponding to each slot is extracted from the word sequence. The multiple slots include at least multiple types of slots corresponding to entities, relations and time constraints in the temporal knowledge graph. The semantic parsing of natural language questions is transformed into a slot filling task. Based on the content to be filled in each slot, the natural language questions are converted into database query statements; Execute database queries to obtain structured data results, and then convert these results into natural language responses to provide feedback to the user.

[0007] As a further aspect of the present invention: the plurality of slots includes: source node slot, target node slot, relation edge slot, comparison object slot, timestamp slot, slot after, slot before, slot first, slot last, and slot in the middle; The source node slot corresponds to the head node in the temporal knowledge graph quadruple, the target node slot corresponds to the tail node in the temporal knowledge graph quadruple, the relation edge slot corresponds to the edge in the temporal knowledge graph quadruple, the timestamp slot corresponds to the time in the temporal knowledge graph quadruple, and the comparison object slot is used to extract object objects related to the constraints of "after" or "before".

[0008] As a further aspect of the present invention: the classification and recognition of semantic vectors based on multiple predefined slots includes: for each word in the word sequence, calculating the probability score of the word belonging to each slot through a combination of a linear layer and a Sigmoid activation function, the calculation formula is as follows:

[0009] in, For the semantic vector, the first Vector representation of each word For slot type index, and For the first The weight matrix and bias of each classifier It is the Sigmoid activation function. For the first The word belongs to the first The probability score of each type of slot; Each slot is filled with the word that has the highest probability score.

[0010] As a further aspect of the present invention: after extracting the filling content corresponding to each slot, the method further includes: performing semantic expansion matching on entity words in the filling content, using the probability score from the slot recognition stage as a soft attention weight, and performing a weighted average of the semantic vectors to generate entity vectors.

[0011] Calculate the cosine similarity between the entity vector and the word embedding vectors of candidate entities in the knowledge base:

[0012] in, This represents the embedding vector of candidate entity words in the knowledge base; Sort by similarity from highest to lowest, and return a preset number of matching results that are ranked highest in similarity.

[0013] As a further aspect of the present invention: the database query statement is generated based on a predefined SQL template, and the SQL template contains database operations corresponding to the time-series knowledge graph query; When the natural language question contains multiple temporal constraints, the database query statement is a nested query statement.

[0014] As a further aspect of the present invention: the multiple time-series constraints include a first time-series constraint and a second time-series constraint. When generating the nested query statement, a sub-query statement is first generated to obtain the timestamp information corresponding to the first time-series constraint. Then, the query result of the sub-query statement is used as the filtering condition of the external query statement to generate the external query statement. After obtaining the complete time constraint conditions, the answer to the question is obtained through a second query.

[0015] As a further aspect of the present invention: after sorting by similarity and returning a preset number of matching results with the highest similarity, the method further includes: generating corresponding database query statements based on each matching result for each slot, submitting them to the database for execution, merging all query results, deduplicating them, and then returning them to the user.

[0016] As a further aspect of the present invention: the slots after, before, first, last, and in are all temporal constraint condition slots. Each temporal constraint condition slot determines whether the current question contains the corresponding type of temporal constraint through binary classification, and outputs yes or no, without filling in specific words.

[0017] As a further aspect of the present invention: the word vector mapping maps each word in the word sequence into a dense numerical vector through a pre-trained word embedding matrix, and the vocabulary in the word embedding matrix is ​​generated by segmenting and statistically analyzing Chinese corpus in the temporal knowledge graph.

[0018] As a further aspect of the present invention, the method is executed by the following functional units: The question preprocessing unit is used to perform word segmentation and word vector mapping on the natural language questions input by the user, and output the segmented word sequence and the corresponding word vector representation; The question preprocessing unit is used to perform word segmentation and word vector mapping on the natural language questions input by the user, and output the segmented word sequence and the corresponding word vector representation; The semantic representation extraction unit is used to receive the word vector representation of the word sequence and encode it through a deep learning model, and output a semantic vector that integrates the context. The slot identification unit is used to receive the semantic vector and determine the slots of the question context information through a combination of linear layer and Sigmoid function, and output the identification and filling results of each slot; The entity matching unit is used to receive entity words in the slot filling result and match similar entity words through the average pooling plus cosine similarity matching method, and output the expanded matching entity candidate set; The answer generation unit is connected to the slot identification unit and the entity matching unit respectively. It is used to receive the slot filling result and the entity matching result, fill the SQL statement template, and output the SQL query statement and the corresponding question and answer.

[0019] This invention provides a time-series knowledge graph question-answering matching method based on keyword templates. Compared with existing technologies, it has the following advantages: (1) By designing fixed keyword slots, this invention degenerates multi-hop problems into template filling problems, identifies and extracts the main body and temporal keywords of the problem, and fills them into predefined SQL statement templates. This transforms the identification and parsing problem of natural language questions into a template filling problem, avoiding the complex semantic parsing and multi-hop reasoning process in traditional methods. This improves the reasoning efficiency while increasing the accuracy of question answering. (2) The present invention includes a template system with 10 slots, in which the source node, target node, relation edge and comparison object constitute the question entity class slot, and the slots of "after", "before", "first", "last" and "in" constitute the temporal constraint class slots, and the timestamp is a separate class; this slot system corresponds to the quadruple structure of temporal knowledge graph, and can capture the temporal constraints in the question, overcoming the defect of existing static knowledge graph question answering methods that cannot effectively utilize time information; (3) In the slot identification process, the present invention uses a combination of linear layer and Sigmoid function to determine the slot of the question context information, which can identify entity words and temporal constraint keywords in the question; in the entity matching process, the matching method of average pooling plus cosine similarity is used to match similar entity words, which solves the matching accuracy problem caused by synonyms and further improves the recall and precision of question answering. (4) The present invention automatically generates corresponding SQL query statements based on the number and type of constraints. Single-hop problems generate single-level query statements, and multi-hop problems generate nested query statements. It realizes unified processing of questions with different complexities and has good scalability and universality. Attached Figure Description

[0020] Figure 1 This is a unit architecture diagram of the present invention; Figure 2 This is an overall flowchart of the present invention; Figure 3 This is an example diagram of question word segmentation in this invention; Figure 4 This is an example diagram of word vector representation in this invention; Figure 5 This is an illustration of the slot type of the present invention; Figure 6 This is an example diagram of slot template filling according to the present invention; Figure 7 Example diagram of SQL statement filling for this invention. Detailed Implementation

[0021] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0022] Example 1 Please see Figure 2 This application provides a time-series knowledge graph question-answering matching method based on keyword templates, including the following steps: The system obtains natural language questions input by the user, performs word segmentation and word vector mapping on the natural language questions, and obtains a vector representation of the word sequence. The vector representation of the word sequence is encoded through a bidirectional long short-term memory network to obtain a semantic vector that incorporates contextual information; The semantic vector is classified and identified according to multiple predefined slots. The filling content corresponding to each slot is extracted from the word sequence. The multiple slots include at least multiple types of slots corresponding to entities, relations and time constraints in the temporal knowledge graph. The semantic parsing of natural language questions is transformed into a slot filling task. Based on the content to be filled in each slot, the natural language questions are converted into database query statements; Execute database queries to obtain structured data results, and then convert these results into natural language responses to provide feedback to the user.

[0023] Example 2 This invention provides a time-series knowledge graph question-answering matching method based on keyword templates. Please refer to [link / reference]. Figure 1 The method is executed through the following functional units: question preprocessing unit, semantic representation extraction unit, slot identification unit, entity matching unit, and answer generation unit. The temporal knowledge graph is stored in a relational database in the form of quadruples (head, edge, tail, time).

[0024] The question preprocessing unit is used to perform word segmentation and word vector mapping on the natural language questions input by the user, and output the segmented word sequence and the corresponding word vector representation; The semantic representation extraction unit is connected to the question preprocessing unit. It receives word vector representations of word sequences and encodes and transforms them through a deep learning model, outputting a semantic vector that integrates the context. The slot identification unit is connected to the semantic representation extraction unit. It is used to receive semantic vectors and determine the slots of the question context information through a combination of linear layer and Sigmoid function, and output the identification and filling results of each slot. The entity matching unit is connected to the slot recognition unit. It is used to receive entity words in the slot filling results and match similar entity words through the average pooling plus cosine similarity matching method, and output the expanded matching entity candidate set. The answer generation unit is connected to the slot recognition unit and the entity matching unit respectively. It is used to receive the slot filling results and entity matching results, fill the SQL statement template, and output the SQL query statement and the corresponding question and answer. The SQL query statement is sent to the database execution engine to retrieve the structured data results. Finally, the answer generation unit merges the unstructured natural language question with the structured query results, and transforms it into a fluent natural language answer through a predefined response template or generative model and feeds it back to the user.

[0025] In this embodiment, as Figure 1 As shown, the question preprocessing unit performs word segmentation on the natural language question input by the user, splitting the sentence into independent word sequences. Each word is mapped to a pre-trained word vector space to obtain a vector representation of the word; The core process of word vector mapping is maintaining a mapping table (matrix) from Chinese words to numerical vectors. The calculation process is as follows:

[0026] in, For the first in the input sequence One word, For the pre-trained word embedding matrix, For the first Dense vector representation of each word; Each row in the word vector mapping table represents a word in the vocabulary, and all words are represented using a fixed-dimensional numeric vector; A lexicon is a collection of characters, words, and phrases obtained by segmenting and statistically analyzing all Chinese corpora in the current knowledge base. The vector representations of characters, words, and phrases in the lexicon are generated through two methods: corpus pre-training and random initialization, and are continuously iterated and optimized as the subsequent prediction and matching process progresses. Please see Figure 3 Taking the user-input question "Fangshan District suffered from heavy rain; which surrounding rescue teams arrived before July 31, 2025?" as an example, after word segmentation, the resulting word sequence is {"Fangshan District", "suffered", "heavy rain", "surrounding", "which", "rescue teams", "at", "July 31, 2025", "before", "arrive"}. (See also...) Figure 4 Each word is mapped to a corresponding numerical vector representation.

[0027] Based on the word segmentation results, the semantic representation extraction unit extracts the numerical vector corresponding to each word matcher in the current question sequence from the word vector mapping. Then, it obtains a new high-dimensional vector by concatenating all the vector representations in the sequence. , Used to indicate the entire question; Then, a bidirectional long short-term memory recurrent neural network (BiLSTM) is used to extract information from the word vector sequence after the question encoding is transformed. This process considers both forward and backward information from the question sequence to capture more comprehensive contextual information from the question text data. The calculation process is as follows:

[0028]

[0029]

[0030] in This is the hidden state of the forward LSTM (capturing the information above). This is the hidden state of the backward LSTM (capturing information below). The final hidden state vector after concatenation (dimension 1) ),in is the dimension of the LSTM hidden layer. This vector not only contains the meaning of the current word, but also incorporates the context of the entire sentence. For example, for the word "arrive", its vector now contains information about who arrived, when they arrived, and where they arrived.

[0031] In this embodiment, as Figure 5 As shown, the slot identification unit is connected to the semantic representation extraction unit and is used to further extract and identify the question feature information processed by the semantic representation extraction unit. A template containing 10 slots is predefined in the slot identification unit. The question entity class slots include: the source node (src), which corresponds to the head node in the time-series knowledge graph; The target node corresponds to the tail node in the time-series knowledge graph; Relationship edges (edges) correspond to relationship edges in a time-series knowledge graph; The compare_entity contains the object related to the constraint in the after / before question.

[0032] Constraint slots include: after, before, first, last, and isin, used to specify timestamps or specific events.

[0033] Timestamps are classified as a separate category, corresponding to timestamps in time-series knowledge graphs.

[0034] The slot recognition unit uses a combination of linear layer and Sigmoid function to determine the slots based on the context information of the question. It extracts and recognizes the entity words and constraint keywords corresponding to the 10 slots in the template from the word sequence of the question.

[0035] For question entity class slots (src, target, edge, compare_entity), the slot extraction and recognition process requires extracting and filling in the corresponding entity words from the question. The calculation process is as follows:

[0036] in, For the first time from BiLSTM The semantic vector of each word, This is an index for slot type (identified as src / edge / target / compare, a total of 4 types). and For the first The weight matrix and bias of each classifier The Sigmoid activation function compresses the output to the range (0,1) to represent probabilities. For the first The word belongs to the first The probability score of each type of slot.

[0037] For each word in the question word sequence, predict the probability that it belongs to each slot. Each slot is filled with the word that has the highest probability value.

[0038] For constraint-type slots (after, before, first, last, isin), the slot recognition unit only determines whether the current question contains the question type corresponding to the constraint, outputs yes or no, and does not fill in specific content. The timestamp (time) is extracted from the question based on time keywords such as year, month, and day.

[0039] Taking question 1, "Fangshan District suffered from heavy rain. Which surrounding rescue teams arrived before July 31, 2025?", and question 2, "After the arrival of the XX rescue team, which rescue team arrived in Fangshan District first?" as examples, the corresponding slot template extraction and filling results are as follows: In question 1, the source node is "?" (to be queried), the target node is "Fangshan District", the relation edge is "arrived", the comparison object is empty, "before..." is "yes", the timestamp is "July 31, 2025", and all other constraint condition slots are "no"; In question 2, the source node is "?" (to be queried), the target node is "Fangshan District", the relation edge is "arrived", the comparison object is "XX rescue team", "after..." is "yes", "first" is "yes", the timestamp is empty, and all other constraint condition slots are "no".

[0040] Question 1 has the constraint "before July 31, 2025" and the query subject is "arrival in Fangshan District, Beijing", which is a one-hop problem; Question 2 has the constraints "after the XX rescue team" and "first" and the query subject is "arrival in Fangshan District", which is a two-hop problem.

[0041] In this embodiment, as Figure 6 As shown, the entity matching unit is connected to the slot recognition unit and is used to fill the four slots of source node, target node, relation edge, and comparison object by calculating the word with the highest matching probability from the question word sequence.

[0042] In both Chinese and English contexts, there is a phenomenon of polysemy, where some words correspond to multiple semantic expressions and have multiple synonyms. For example, "arrive" and "reach" express the same semantic content in the current context.

[0043] After the entity matching unit completes the entity word filling for the slot, it performs matching of similar entity words for the above 4 slots based on the average pooling plus cosine similarity matching method, and returns the Top-K matching results according to the similarity.

[0044] Considering computational complexity, it is also possible to select which slots need to be matched with similar entity words, while the remaining slots only retain entity words extracted from the question.

[0045] The calculation process is as follows:

[0046] in, The slot probability (as a soft attention weight). This is the output vector of the BiLSTM. This is the entity vector representation after weighted average.

[0047] To obtain a unified representation of the entire entity, the vectors of all words belonging to that entity are aggregated using average pooling, and then semantically similar entity words are matched based on similarity calculation:

[0048] in, The entity vector extracted from the problem. The Score is the embedding vector of candidate entity words in the knowledge base. A higher Score indicates a better match between the entity in the question and the candidate entity words in the knowledge base.

[0049] The final result is the Top-K with the highest Score.

[0050] In this embodiment, as Figure 1 As shown, the answer generation unit is connected to the slot identification unit and the entity matching unit respectively, and is used to fill the SQL statement based on the results of the slot identification unit and the entity matching unit.

[0051] Based on the slot filling results obtained from the slot identification unit, the information corresponding to the five slots—source node, target node, relation edge, comparison object, and timestamp—is filled into the SQL statement, transforming the natural language question into a database query.

[0052] The complexity of the transformed SQL statement depends on the number and type of constraints in the original question. A one-hop question only requires one database query after being transformed into an SQL statement; a multi-hop question requires a compound query, which first needs to be completed to obtain the timestamp information related to the first constraint, and then a second query is used to obtain the answer to the question after obtaining the complete time constraint.

[0053] In addition to using information directly extracted from the question to configure and generate SQL statements, corresponding SQL statements are generated based on the Top-K matching results of the four slot entities obtained from the entity matching unit, and database queries are performed together.

[0054] See Figure 7 Taking question 1 and question 2 as examples, Figure 4 The SQL statement filling results for two questions are shown. After the answer generation unit generates the corresponding SQL statement based on the slot filling and entity matching results, it queries the database and returns the answer corresponding to the question, completing the question-answering matching process of the time-series knowledge graph.

[0055] Example 3 This embodiment further explains the classification and identification method of the 10 slots in the slot identification unit.

[0056] In this embodiment, as Figure 5 As shown, the 10 predefined slots in the slot identification unit are as follows: (1) Source node (src): corresponds to the head node in the time-series knowledge graph quadruple (head, edge, tail, time).

[0057] (2) Target node: Corresponds to the tail node in the time-series knowledge graph quadruple (head, edge, tail, time).

[0058] (3) Edge: Corresponding to the edge in the temporal knowledge graph quadruple (head, edge, tail, time), it represents the relationship / action between the source node and the target node.

[0059] (4) Compare Entity: This includes two types of constraints: "after" and "before," which correspond to the object related to the constraint condition. For example, in the question "After the XX rescue team arrived, which rescue team arrived in Fangshan area first?", "XX rescue team" is the comparison entity corresponding to the constraint condition in the question.

[0060] (5) After: a constraint used to limit the timestamp or specific event.

[0061] (6) Before: a constraint used to limit timestamps or specific events.

[0062] (7) Timestamp (time): Corresponds to the time in the time sequence knowledge graph quadruple (head, edge, tail, time), indicating the specific time node that appears in the question.

[0063] (8) First: Constraints used to limit timestamps or specific events.

[0064] (9) Last: Constraints used to limit timestamps or specific events.

[0065] (10) in: constraints used to limit timestamps or specific events.

[0066] The 10 slots mentioned above are divided into three categories: question entity class (source node, target node, relation edge, comparison object), constraint condition class (after, before, first, last, in), and timestamp (a separate category).

[0067] In the specific implementation process, the slot identification unit predicts the probability of each word in the question word sequence belonging to each slot by using a combination of a linear layer and a Sigmoid function. Each slot is filled with the word that has the highest probability value.

[0068] For constraint-type slots, the slot recognition unit only determines whether the current question contains the question type corresponding to the constraint, outputs yes or no, and does not fill in specific content.

[0069] The timestamp is extracted from the question based on time keywords such as "year, month, day".

[0070] Example 4 This embodiment describes the process of generating SQL statements in the answer generation unit.

[0071] In this embodiment, the answer generation unit fills the information corresponding to each slot into a predefined SQL statement template based on the slot filling result obtained by the slot identification unit.

[0072] The SQL template includes database operations related to knowledge graph queries.

[0073] For one-hop problems, taking the question "Fangshan District was hit by a rainstorm. Which rescue teams arrived before July 31, 2025?" as an example, this question has only one constraint related to the timestamp, making it a one-hop problem. Based on the slot filling results (target node is "Fangshan District", relation edge is "arrive", timestamp is "July 31, 2025", "before..." is "yes"), the SQL statement generated by the answer generation unit is a single-level query statement, and the answer can be obtained by performing a single database query.

[0074] For multi-hop problems, taking the question "After the XX rescue team arrived, which rescue team arrived in Fangshan District first?" as an example, this question contains two constraints ("after the XX rescue team arrived" and "first"), which is a two-hop problem. Based on the slot filling results (target node is "Fangshan District", relation edge is "arrive", comparison object is "XX rescue team", "after" is "yes", "first" is "yes"), the SQL statement generated by the answer generation unit is a compound query statement: First, a subquery needs to be completed to obtain the timestamp information related to "after the XX rescue team arrived", that is, the time when the XX rescue team arrived in Fangshan District; after obtaining the complete time constraint, the answer to the question is obtained through a second query.

[0075] In addition to generating SQL statements using information directly extracted from the questions, the answer generation unit also generates corresponding SQL statements based on the Top-K matching results of the four slot entities (source node, target node, relation edge, and comparison object) obtained by the entity matching unit, and performs database queries accordingly. After generating the corresponding SQL statements based on the slot filling and entity matching results, the answer generation unit queries the database, returns the answer corresponding to the question, and completes the question-answering matching process of the time-series knowledge graph.

[0076] Some of the data in the above formulas are numerical calculations with dimensions removed, and the contents not described in detail in this specification are all prior art known to those skilled in the art.

[0077] The above embodiments are only used to illustrate the technical methods of the present invention and are not intended to limit it. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical methods of the present invention without departing from the spirit and scope of the technical methods of the present invention.

Claims

1. A time-series knowledge graph question-answering matching method based on keyword templates, characterized in that, Includes the following steps: The system obtains natural language questions input by the user, performs word segmentation and word vector mapping on the natural language questions, and obtains a vector representation of the word sequence. The vector representation of the word sequence is encoded through a bidirectional long short-term memory network to obtain a semantic vector that incorporates contextual information; The semantic vector is classified and identified according to multiple predefined slots. The filling content corresponding to each slot is extracted from the word sequence. The multiple slots include at least multiple types of slots corresponding to entities, relations and time constraints in the temporal knowledge graph. The semantic parsing of natural language questions is transformed into a slot filling task. Based on the content to be filled in each slot, the natural language questions are converted into database query statements; Execute database queries to obtain structured data results, and then convert these results into natural language responses to provide feedback to the user.

2. The method for temporal knowledge graph question-answering matching based on keyword templates according to claim 1, characterized in that, The multiple slots include: source node slot, target node slot, relation edge slot, comparison object slot, timestamp slot, slot after, slot before, first slot, last slot, and slot in the middle. The source node slot corresponds to the head node in the temporal knowledge graph quadruple, the target node slot corresponds to the tail node in the temporal knowledge graph quadruple, the relation edge slot corresponds to the edge in the temporal knowledge graph quadruple, the timestamp slot corresponds to the time in the temporal knowledge graph quadruple, and the comparison object slot is used to extract object objects related to the constraints of "after" or "before".

3. The method for temporal knowledge graph question-answering matching based on keyword templates according to claim 1, characterized in that, The step of classifying and recognizing semantic vectors based on multiple predefined slots includes: for each word in the word sequence, calculating the probability score of the word belonging to each slot through a combination of a linear layer and a Sigmoid activation function, using the following formula: , in, For the semantic vector, the first Vector representation of each word For slot type index, and For the first The weight matrix and bias of each classifier It is the Sigmoid activation function. For the first The word belongs to the first The probability score of each type of slot; Each slot is filled with the word that has the highest probability score.

4. The time-series knowledge graph question-answering matching method based on keyword templates according to claim 1, characterized in that, After extracting the filling content corresponding to each slot, the process also includes: semantic expansion matching of entity words in the filling content, using the probability scores from the slot recognition stage as soft attention weights, and generating entity vectors by weighted averaging of the semantic vectors. , Calculate the cosine similarity between the entity vector and the word embedding vectors of candidate entities in the knowledge base: , in, This represents the embedding vector of candidate entity words in the knowledge base; Sort by similarity from highest to lowest, and return a preset number of matching results that are ranked highest in similarity.

5. The time-series knowledge graph question-answering matching method based on keyword templates according to claim 1, characterized in that, The database query statement is generated based on a predefined SQL template, which contains database operations corresponding to the time-series knowledge graph query. When the natural language question contains multiple temporal constraints, the database query statement is a nested query statement.

6. The time-series knowledge graph question-answering matching method based on keyword templates according to claim 5, characterized in that, The multiple time-series constraints include a first time-series constraint and a second time-series constraint. When generating the nested query statement, a subquery statement is first generated to obtain the timestamp information corresponding to the first time-series constraint. Then, the query result of the subquery statement is used as the filtering condition of the outer query statement to generate the outer query statement. After obtaining the complete time constraint conditions, the answer to the question is obtained through a second query.

7. The time-series knowledge graph question-answering matching method based on keyword templates according to claim 4, characterized in that, After sorting the results by similarity and returning a preset number of matching results with the highest similarity, the process further includes: generating corresponding database query statements based on each matching result for each slot, submitting them to the database for execution, merging all query results, deduplicating them, and then returning them to the user.

8. The time-series knowledge graph question-answering matching method based on keyword templates according to claim 2, characterized in that, The slots after, before, first, last, and in are all temporal constraint slots. Each temporal constraint slot uses binary classification to determine whether the current question contains the corresponding type of temporal constraint, outputting yes or no, without filling in specific words.

9. The time-series knowledge graph question-answering matching method based on keyword templates according to claim 1, characterized in that, The word vector mapping maps each word in the word sequence to a dense numerical vector through a pre-trained word embedding matrix. The vocabulary in the word embedding matrix is ​​generated by segmenting and statistically analyzing Chinese corpora in the temporal knowledge graph.

10. The time-series knowledge graph question-answering matching method based on keyword templates according to claim 1, characterized in that, This method is executed through the following functional units: The question preprocessing unit is used to perform word segmentation and word vector mapping on the natural language questions input by the user, and output the segmented word sequence and the corresponding word vector representation; The question preprocessing unit is used to perform word segmentation and word vector mapping on the natural language questions input by the user, and output the segmented word sequence and the corresponding word vector representation; The semantic representation extraction unit is used to receive the word vector representation of the word sequence and encode it through a deep learning model, and output a semantic vector that integrates the context. The slot identification unit is used to receive the semantic vector and determine the slots of the question context information through a combination of linear layer and Sigmoid function, and output the identification and filling results of each slot; The entity matching unit is used to receive entity words in the slot filling result and match similar entity words through the average pooling plus cosine similarity matching method, and output the expanded matching entity candidate set; The answer generation unit is connected to the slot identification unit and the entity matching unit respectively. It is used to receive the slot filling result and the entity matching result, fill the SQL statement template, and output the SQL query statement and the corresponding question and answer.