Electric power financial knowledge question and answer method and device, terminal and storage medium
By performing word segmentation and entity linking on the power finance knowledge graph and matching relationship paths, the problem of unsatisfactory question-answering results in the power finance field was solved, and the accuracy of question answering was improved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- STATE GRID HEBEI ELECTRIC POWER CO LTD
- Filing Date
- 2023-04-14
- Publication Date
- 2026-04-21
AI Technical Summary
Existing knowledge graph question answering methods are not performing well in the field of power finance and are unable to provide accurate answers.
By segmenting and linking the question text, a candidate word set is extracted from the power finance knowledge graph, and relational path matching is performed to select the final relational path to determine the answer.
It improved the accuracy of question-and-answer tasks, reduced the range of relationship matching, and ensured the accuracy of the answers.
Smart Images

Figure CN116881407B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of natural language processing technology, and in particular to a method, apparatus, terminal, and storage medium for answering questions about electricity and financial knowledge. Background Technology
[0002] A knowledge graph (KG), known in library and information science as knowledge domain visualization or knowledge domain mapping, is a series of various graphs that display the development process and structural relationships of knowledge. It uses visualization techniques to describe knowledge resources and their carriers, mining, analyzing, constructing, drawing, and displaying knowledge and their interrelationships. Knowledge graphs are a modern theory that combines theories and methods from applied mathematics, computer graphics, information visualization techniques, and information science with methods such as bibliometric citation analysis and co-occurrence analysis. It uses visualized graphs to vividly display the core structure, development history, cutting-edge fields, and overall knowledge architecture of a discipline, achieving the goal of multidisciplinary integration. Knowledge graphs can provide practical and valuable references for disciplinary research.
[0003] Knowledge graph question answering has been widely applied across various fields, and knowledge graph-based question answering technology has also seen significant development. Knowledge graphs fall under the category of knowledge engineering, a crucial research area in artificial intelligence, and are one of the important applications of using knowledge engineering to build large-scale knowledge resources. Knowledge graph construction requires mining, analyzing, drawing, and displaying knowledge and the relationships between it, making the existing knowledge base more intelligent. Combined with knowledge graph-based intelligent question answering, potential relationships are inferred from the direct connections between entities in the knowledge graph. Compared to traditional search engines, information retrieval based on knowledge graphs no longer simply returns ranked document results, but rather, through intelligent semantic analysis, provides answers that closely match the user's desired answers.
[0004] Knowledge graph-based question answering technology is constantly being combined with technologies in various fields, forming search engines for semantic analysis and knowledge retrieval in different domains. However, in the financial field, especially in the power sector, due to the confidentiality of financial data and the specialized nature of financial texts, existing knowledge graph-based question answering methods struggle to achieve ideal results.
[0005] Therefore, it is necessary to develop and design a question-and-answer method for electricity finance knowledge. Summary of the Invention
[0006] The present invention provides a method, device, terminal and storage medium for answering questions about power finance knowledge, which is used to solve the problem that the existing question-answering technology has not achieved ideal results in the field of power finance.
[0007] In a first aspect, embodiments of the present invention provide a method for answering questions about electricity financial knowledge, including:
[0008] The question text is segmented and entity linked. Multiple candidate word sets corresponding to multiple keywords of the question text are found from the power finance knowledge graph. The power finance knowledge graph includes multiple entities and multiple relationships.
[0009] Based on the multiple candidate word sets, relationship path matching is performed to obtain multiple candidate relationship paths;
[0010] The final relationship path is selected from the multiple candidate relationship paths, and the final answer is determined based on the final relationship path.
[0011] In one possible implementation, the step of segmenting and linking the question text to entities involves identifying multiple candidate word sets from the power finance knowledge graph that correspond to multiple keywords in the question text, including:
[0012] Based on the multiple entities and multiple relationships of the power finance knowledge graph, the question text is segmented to obtain multiple target keywords, wherein the entities and the relationships are formed based on multiple basic word segmentation combinations;
[0013] Based on the multiple target keywords, multiple target word vectors corresponding to the multiple target keywords are extracted from the power finance knowledge graph, wherein the target word vectors are constructed based on the identifiers of multiple basic word segments that constitute the target keywords;
[0014] The multiple target word vectors are sorted according to the question text to obtain a word vector set;
[0015] Extract multiple graph vectors corresponding to multiple entities and multiple relations from the power finance knowledge graph. The graph vectors of entities and relations are constructed based on the identifiers of multiple basic word segments that constitute the entities and relations, respectively.
[0016] Multiple candidate word sets are obtained based on the similarity between the multiple spectral vectors and the word vector set.
[0017] In one possible implementation, obtaining multiple candidate word sets based on the similarity between the multiple spectral vectors and the word vector set includes:
[0018] For each of the plurality of spectral vectors, perform the following steps:
[0019] The similarity of the graph vectors is determined based on the first formula, the graph vectors, and the set of word vectors, wherein the first formula is:
[0020]
[0021] In the formula, The similarity between the graph vectors is... For the word vector set corresponding to the first A vector of keywords, For spectral vectors;
[0022] Based on the similarity of the graph vectors and the similarity threshold, determine whether the graph vector is a candidate word;
[0023] If the graph vector is a candidate word, then the entity or relation corresponding to the graph vector is added to the candidate word set corresponding to the word vector.
[0024] In one possible implementation, the step of performing relation path matching based on the plurality of candidate word sets to obtain a plurality of candidate relation paths includes:
[0025] The multiple candidate word sets are classified to obtain multiple entity candidate word sets and multiple relation candidate word sets;
[0026] Traversal and judgment steps: If the first entity candidate word set has been traversed, then incomplete relation preparation links are deleted, and multiple complete relation preparation links are matched according to the multiple relation candidate word sets to obtain multiple candidate relation paths, wherein the first entity candidate word set is the candidate word set corresponding to the first entity keyword of the question text in the multiple entity candidate word sets, and the number of entities in the incomplete relation preparation links is less than the number of entities in the multiple entity candidate word sets;
[0027] If the first entity candidate word set is not traversed, then an entity is selected from the first entity candidate word set in a preset order as the first candidate entity, and multiple relation link pre-set sets are constructed based on the first candidate entity. The relation link pre-set sets include entities with multiple one-hop relationships, and the multiple entities in the relation link pre-set sets are determined by one-hop relationship judgment based on multiple entity candidate word sets.
[0028] In one possible implementation, the construction of multiple relational link pre-sets based on the first candidate entity includes:
[0029] Initialize the preliminary candidate word set as the second entity candidate word set;
[0030] One-hop relationship determination steps: Determine the one-hop relationship between the first candidate entity and multiple entities in the preliminary candidate word set;
[0031] If there is an entity in the preliminary candidate word set that has a one-hop relationship with the candidate entity, then the first candidate entity is added to the corresponding relationship link preliminary set, the next word set of the preliminary candidate word set is taken as the preliminary candidate word set, the entity with a one-hop relationship with the candidate entity is taken as the first candidate entity, and then the process jumps to the one-hop relationship judgment step.
[0032] Otherwise, proceed to the traversal and judgment step.
[0033] In one possible implementation, the step of matching multiple complete preliminary relation links based on the multiple candidate relation word sets to obtain multiple candidate relation paths includes:
[0034] For each complete relation preparation link in the plurality of complete relation preparation links, perform the following steps:
[0035] The relationships of the multiple candidate word sets are added to the relationship preparation network according to the order of multiple keywords in the question text;
[0036] Select the last set of relation candidate words from the plurality of relation candidate word sets as the target word set;
[0037] For each relation in the target word set, perform the following steps:
[0038] Retrieve the head entity of the relationship;
[0039] Determine whether the head entity exists in the last candidate word set of the plurality of entity candidate word sets;
[0040] If it exists in the last candidate word set of the plurality of relation candidate word sets, then the tail entity of the relation is taken as the candidate answer.
[0041] In one possible implementation, selecting the final relationship path from the plurality of candidate relationship paths includes:
[0042] Based on the multiple entities and multiple relationships of the power finance knowledge graph, the question text is segmented to obtain multiple target keywords, wherein the entities and the relationships are formed based on multiple basic word segmentation combinations;
[0043] Based on the multiple target keywords, multiple target word vectors corresponding to the multiple target keywords are extracted from the power finance knowledge graph, wherein the target word vectors are constructed based on the identifiers of multiple basic word segments that constitute the target keywords;
[0044] The multiple target word vectors are reorganized based on the question text to obtain the question vector;
[0045] Based on the second formula, the multiple candidate relationship paths, and the question vector, multiple scores corresponding to the multiple candidate relationship paths are obtained, wherein the second formula is:
[0046]
[0047] In the formula, For rating, Let be the vector of questions. For the first A vector of relations, For the first A vector of entities;
[0048] The candidate relationship path with the highest score is selected as the final relationship path.
[0049] Secondly, embodiments of the present invention provide a power finance knowledge question-and-answer device for implementing the power finance knowledge question-and-answer method as described in the first aspect or any possible implementation thereof, the power finance knowledge question-and-answer device comprising:
[0050] The word segmentation and linking module is used to perform word segmentation and entity linking processing on the question text, and to find multiple candidate word sets corresponding to multiple keywords of the question text from the power finance knowledge graph, wherein the power finance knowledge graph includes multiple entities and multiple relationships;
[0051] The candidate relation path construction module is used to perform relation path matching based on the multiple candidate word sets to obtain multiple candidate relation paths;
[0052] as well as,
[0053] The path selection and answer determination module is used to select the final relationship path from the multiple candidate relationship paths and determine the final answer based on the final relationship path.
[0054] Thirdly, embodiments of the present invention provide a terminal, including a memory and a processor, wherein the memory stores a computer program executable on the processor, and the processor executes the computer program to implement the steps of the method as described in the first aspect or any possible implementation of the first aspect.
[0055] Fourthly, embodiments of the present invention provide a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the method as described in the first aspect or any possible implementation thereof.
[0056] The beneficial effects of the embodiments of the present invention compared with the prior art are as follows:
[0057] This invention discloses a question-answering method for power finance knowledge. First, it performs word segmentation and entity linking on the question text, identifying multiple candidate word sets corresponding to multiple keywords in the power finance knowledge graph. The power finance knowledge graph includes multiple entities and multiple relationships. Then, it performs relationship path matching based on the multiple candidate word sets to obtain multiple candidate relationship paths. Finally, it selects the final relationship path from the multiple candidate relationship paths and determines the final answer based on the final relationship path. This invention utilizes a power finance knowledge graph, performs keyword segmentation, and determines the most similar link to the question text based on keywords and link-based reasoning, thereby determining the most accurate answer. This reduces the scope of relationship matching, improves the accuracy of relationship path matching, and thus enhances the accuracy of the question-answering task. Attached Figure Description
[0058] To more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0059] Figure 1 This is a flowchart of the power finance knowledge question-and-answer method provided in the embodiments of the present invention;
[0060] Figure 2 This is an architecture diagram of the knowledge graph question answering method provided in the embodiments of the present invention;
[0061] Figure 3 This is an example diagram of the power finance knowledge graph provided in the embodiments of the present invention;
[0062] Figure 4 This is an example diagram of the candidate set of entity connection modules provided in the embodiments of the present invention;
[0063] Figure 5 This is a schematic diagram of a one-hop relationship determination provided by an embodiment of the present invention;
[0064] Figure 6 This is a diagram illustrating the process of determining the final candidate answer provided by an embodiment of the present invention.
[0065] Figure 7 This is a diagram illustrating the path selection and answer determination process provided by an embodiment of the present invention;
[0066] Figure 8 This is a flowchart of the link matching algorithm for the knowledge graph question answering method provided in the embodiments of the present invention;
[0067] Figure 9This is a functional block diagram of the power finance knowledge Q&A device provided in the embodiments of the present invention;
[0068] Figure 10 This is a terminal function block diagram provided by an embodiment of the present invention. Detailed Implementation
[0069] In the following description, specific details such as particular system structures and techniques are set forth for illustrative purposes and not for limitation, so as to provide a thorough understanding of embodiments of the invention. However, those skilled in the art will understand that the invention can be implemented in other embodiments without these specific details. In other instances, detailed descriptions of well-known systems, apparatuses, and methods are omitted so as not to obscure the description of the invention with unnecessary detail.
[0070] To make the objectives, technical solutions, and advantages of the present invention clearer, specific embodiments will be described below in conjunction with the accompanying drawings.
[0071] The embodiments of the present invention will be described in detail below. This example is implemented based on the technical solution of the present invention, and provides detailed implementation methods and specific operation processes. However, the protection scope of the present invention is not limited to the following embodiments.
[0072] Figure 1 A flowchart of a power finance knowledge question-and-answer method provided for an embodiment of the present invention.
[0073] like Figure 1 As shown, a flowchart illustrating the implementation of the power finance knowledge question-and-answer method provided by an embodiment of the present invention is illustrated below:
[0074] In step 101, the question text is segmented and entity linked to find multiple candidate word sets corresponding to multiple keywords of the question text from the power finance knowledge graph, wherein the power finance knowledge graph includes multiple entities and multiple relationships.
[0075] In some embodiments, step 101 includes:
[0076] Based on the multiple entities and multiple relationships of the power finance knowledge graph, the question text is segmented to obtain multiple target keywords, wherein the entities and the relationships are formed based on multiple basic word segmentation combinations;
[0077] Based on the multiple target keywords, multiple target word vectors corresponding to the multiple target keywords are extracted from the power finance knowledge graph, wherein the target word vectors are constructed based on the identifiers of multiple basic word segments that constitute the target keywords;
[0078] The multiple target word vectors are sorted according to the question text to obtain a word vector set;
[0079] Extract multiple graph vectors corresponding to multiple entities and multiple relations from the power finance knowledge graph. The graph vectors of entities and relations are constructed based on the identifiers of multiple basic word segments that constitute the entities and relations, respectively.
[0080] Multiple candidate word sets are obtained based on the similarity between the multiple spectral vectors and the word vector set.
[0081] In some implementations, multiple candidate word sets are obtained based on the similarity between the multiple spectral vectors and the word vector set, including:
[0082] For each of the plurality of spectral vectors, perform the following steps:
[0083] The similarity of the graph vectors is determined based on the first formula, the graph vectors, and the set of word vectors, wherein the first formula is:
[0084]
[0085] In the formula, The similarity between the graph vectors is... For the word vector set corresponding to the first A vector of keywords, For spectral vectors;
[0086] Based on the similarity of the graph vectors and the similarity threshold, determine whether the graph vector is a candidate word;
[0087] If the graph vector is a candidate word, then the entity or relation corresponding to the graph vector is added to the candidate word set corresponding to the word vector.
[0088] For example, the power finance knowledge question-and-answer method of this invention can be divided into four parts based on its functional modules:
[0089] The module includes word segmentation, entity linking, link reasoning, and scoring. Figure 2The framework of the model is presented below. First, a knowledge graph (KG) can be represented as a set of triples, i.e., KG∈E×R×E, where E is the set of all entities in the knowledge graph, and R is the set of all relations in the knowledge graph. For any triple t in the knowledge graph KG, it can be represented as an ordered pair (h, r, t), where h is the head entity of the triple, t is the tail entity, and r is the relationship between the head entity h and the tail entity t, where h, t∈E and r∈R. Second, the knowledge graph question answering task (KGQA) is performed given a knowledge graph KG∈E×R×E and a natural language question q. Through a series of inferences, the correct answer a, where a∈E, is found in the knowledge graph KG for the natural language question q.
[0090] Specifically, the word segmentation module comprises four parts:
[0091] The method used in this paper extracts all possible keywords from the knowledge graph (KG) for the natural language problem q. ,in n This represents the number of keywords contained in the natural language question q. This approach avoids the risk of incorrect keyword extraction while also making full use of the information contained in the question.
[0092] Commonly used Chinese word segmentation tools (such as jieba) cannot accurately segment financial text data. For example, given the question "Who is the person in charge of the cultural innovation project undertaken by the Human Resources Department of Company A?", jieba segmentation results in "A / Company / Human Resources Department / Undertake / The / Culture / Innovation / Project / The / Person in Charge / Is / Who", while the desired segmentation is "A Company / Human Resources Department / Undertake / The / Culture / Innovation / Project / The / Person in Charge / Is / Who". The two results differ significantly, and the segmentation results of general word segmentation tools cannot meet the experimental requirements.
[0093] Through observation and analysis of financial texts, we categorized the keywords that might appear in the questions into four types: company-related, department-related, project-related, and attribute-related (including project and department attributes). Department-related keywords are usually easy to identify. Company-related keywords all have obvious characteristics: keywords related to substations typically contain the combination of "string" + "company" or "limited liability company," making them relatively easy to segment based on these characteristics. Project-related and attribute-related keywords are usually separated by prepositions, verbs, and other similar words.
[0094] Entity Link Module:
[0095] The keyword sequence obtained in the previous step (word segmentation module) , …… Linking to the knowledge graph yields a keyword sequence. , …… candidate word set , …… This paper uses vector matching for entity linking.
[0096] Embedding representations of keyword sequences and knowledge graphs (e.g., using the TransE model) yield a set of vector representations of the keyword sequences. and the set of vector representations of knowledge graphs . Includes a set of node vectors Ej and relation vector set Rl ,in j and l These represent the number of nodes and the number of relationships in the knowledge graph, respectively. For each... respectively with Ej and Rl Each vector in the graph is subjected to an inner product operation, and the result is used as a similarity score between the keyword and the node relationship in the knowledge graph:
[0097]
[0098] In the formula, The similarity between the graph vectors is... For the word vector set corresponding to the first A vector of keywords, This is the spectral vector.
[0099] Pick Above a certain threshold e or r As keywords candidate word set .
[0100] In step 102, relational path matching is performed based on the multiple candidate word sets to obtain multiple candidate relational paths.
[0101] In some embodiments, step 102 includes:
[0102] The multiple candidate word sets are classified to obtain multiple entity candidate word sets and multiple relation candidate word sets;
[0103] Traversal and judgment steps: If the first entity candidate word set has been traversed, then incomplete relation preparation links are deleted, and multiple complete relation preparation links are matched according to the multiple relation candidate word sets to obtain multiple candidate relation paths, wherein the first entity candidate word set is the candidate word set corresponding to the first entity keyword of the question text in the multiple entity candidate word sets, and the number of entities in the incomplete relation preparation links is less than the number of entities in the multiple entity candidate word sets;
[0104] If the first entity candidate word set is not traversed, then an entity is selected from the first entity candidate word set in a preset order as the first candidate entity, and multiple relation link pre-set sets are constructed based on the first candidate entity. The relation link pre-set sets include entities with multiple one-hop relationships, and the multiple entities in the relation link pre-set sets are determined by one-hop relationship judgment based on multiple entity candidate word sets.
[0105] In some implementations, the step of constructing multiple relational link pre-sets based on the first candidate entity includes:
[0106] Initialize the preliminary candidate word set as the second entity candidate word set;
[0107] One-hop relationship determination steps: Determine the one-hop relationship between the first candidate entity and multiple entities in the preliminary candidate word set;
[0108] If there is an entity in the preliminary candidate word set that has a one-hop relationship with the candidate entity, then the first candidate entity is added to the corresponding relationship link preliminary set, the next word set of the preliminary candidate word set is taken as the preliminary candidate word set, the entity with a one-hop relationship with the candidate entity is taken as the first candidate entity, and then the process jumps to the one-hop relationship judgment step.
[0109] Otherwise, proceed to the traversal and judgment step.
[0110] In some implementations, the step of matching multiple complete preliminary relation links based on the multiple candidate relation word sets to obtain multiple candidate relation paths includes:
[0111] For each complete relation preparation link in the plurality of complete relation preparation links, perform the following steps:
[0112] The relationships of the multiple candidate word sets are added to the relationship preparation network according to the order of multiple keywords in the question text;
[0113] Select the last set of relation candidate words from the plurality of relation candidate word sets as the target word set;
[0114] For each relation in the target word set, perform the following steps:
[0115] Retrieve the head entity of the relationship;
[0116] Determine whether the head entity exists in the last candidate word set of the plurality of entity candidate word sets;
[0117] If it exists in the last candidate word set of the plurality of relation candidate word sets, then the tail entity of the relation is taken as the candidate answer.
[0118] For example, the third part of the power finance knowledge question-answering method is the link reasoning module, and the link matching module adopts a link matching algorithm based on intersection. For the candidate set obtained in the previous entity linking step, one candidate set is randomly selected, and the set of entities within one hop range of all entities in the candidate set is sequentially taken, and their intersections are taken with other candidate sets respectively. The above operation is performed on each candidate set, and the finally obtained intersection parts are integrated into a complete relationship link. The specific process of the link matching algorithm is as follows: Figure 8 As shown.
[0119] Assuming there is such Figure 3 The partial knowledge graph shown illustrates the natural language processing problem "Who is the person in charge of the cultural innovation project undertaken by the Human Resources Department of Company A?" Figure 3 Question-answering reasoning is performed using the knowledge graph shown. The specific process is as follows:
[0120] (1) First, obtain the keyword sequence W={W1,W2,W3,W4,W5}={“Company A”,“Human Resources Department”,“Undertake”,“Cultural Innovation Project”,“Person in Charge”} and the candidate set B of the keyword sequence W, such as Figure 3 As shown.
[0121] Keywords W1, W2, and W4 are linked to entities in the knowledge graph, resulting in entity candidate sets B1, B2, and B4, respectively. Entities in these candidate sets are identified by their corresponding IDs in the knowledge graph. Keywords W3 and W5 are linked to relations in the knowledge graph, resulting in relation candidate sets B3 and B5, respectively. Relations in these candidate sets are identified by their corresponding head node IDs and tail node IDs in the knowledge graph.
[0122] (2) Select one of the candidate entity sets B1 (which can be any candidate set), and take one candidate entity B11 = "Company A {id=1}", to obtain the set of all entities within one hop range of this candidate entity in the knowledge graph K11 = {"Human Resources Department {id=2}", "Finance Department {id=5}"}. Take the intersection of entity set K11 with all other candidate entity sets B2 and B4. If entity set K11 has no intersection with candidate entity sets B2 and B4, it means that candidate entity B11 has no relationship with other candidate entity nodes, so discard the node; if entity set K11 has an intersection with candidate entity sets B2 and B4, it means that candidate entity B11 has a relationship with other candidate entity nodes, and the matching of relationship links can continue, such as Figure 5 As shown.
[0123] (3) The intersection operation is performed between entity set K11 and candidate entity sets B2 and B4 respectively. The result shows that K11 has no intersection with B4, but has an intersection with B2 {"Personnel Department {id=2}", "Finance Department {id=5}"}. This indicates that there is a relationship between candidate entity B11 "Company A {id=1}" and entities "Personnel Department {id=2}" and "Finance Department {id=5}", and the relationship link reasoning can be continued based on this.
[0124] (4) Continue to take the intersection of the entity sets within one hop of each of the entities “Personnel Department {id=2}” and “Finance Department {id=5}” with the remaining candidate entity sets B4 that failed to find an intersection. If an intersection can be found, continue to repeat the above operation until all candidate entity sets have successfully found an intersection. Then, add the relation candidate set to the intersection operation, such as... Figure 5 As shown.
[0125] (5) Finally, after all candidate sets have participated and successfully intersected, we find that the head entity B41 = "{id=3}" of the relation B51 = "{id=3} start time {id=4}" exists in the candidate set, while the tail entity "{id=4}" does not. At this point, we take the tail entity "{id=4}" as the candidate answer, and the relationship path between the candidate entity B11 = "Company A {id=1}" and the candidate answer "{id=4}" as the candidate relationship path, as follows: Figure 6 As shown.
[0126] In step 103, a final relationship path is selected from the plurality of candidate relationship paths, and the final answer is determined based on the final relationship path.
[0127] In some embodiments, step 103 includes:
[0128] Based on the multiple entities and multiple relationships of the power finance knowledge graph, the question text is segmented to obtain multiple target keywords, wherein the entities and the relationships are formed based on multiple basic word segmentation combinations;
[0129] Based on the multiple target keywords, multiple target word vectors corresponding to the multiple target keywords are extracted from the power finance knowledge graph, wherein the target word vectors are constructed based on the identifiers of multiple basic word segments that constitute the target keywords;
[0130] The multiple target word vectors are reorganized based on the question text to obtain the question vector;
[0131] Based on the second formula, the multiple candidate relationship paths, and the question vector, multiple scores corresponding to the multiple candidate relationship paths are obtained, wherein the second formula is:
[0132]
[0133] In the formula, For rating, Let be the vector of questions. For the first A vector of relations, For the first A vector of entities;
[0134] The candidate relationship path with the highest score is selected as the final relationship path.
[0135] For example, the fourth part of the power finance knowledge question-and-answer method is the scoring module. Taking the candidate entity B11="Company A {id=1}" as an example, we reasoned the matching process of the relationship link and obtained a relationship link, such as... Figure 7 As shown. Performing the above-described operations on all candidate entities in the entire candidate entity set B will yield multiple complete relation paths, i.e., multiple candidate answers. We will score each candidate path to determine the final answer.
[0136] Embedding the question q yields its vector representation. Take the entity vector representation of each link. , ... Relational vector representation , ... Rate it:
[0137]
[0138] In the formula, For rating, Let be the vector of questions. For the first A vector of relations, For the first A vector of entities.
[0139] Pick The candidate path with the highest value is taken as the final relation path, and the entity ultimately linked by this relation path is the final answer.
[0140] Comparison of the embodiments of the present invention with the prior art:
[0141] Experimental comparison:
[0142] We selected three baseline models for comparison in our experiment:
[0143] (1) Template matching method: A template library was constructed based on the power finance knowledge graph, which included 30 question templates. The questions were matched with the templates in the library according to the rules and converted into corresponding SPARQL query statements for retrieval in the knowledge graph.
[0144] (2) Bilstm+CRF+CNN: Bilstm+CRF is used to identify key entities in the question through named entity recognition, and CNN is used to extract the similarity matrix between the question vector and the relation vector for relation prediction.
[0145] (3) KGEmbedding: Knowledge graphs and questions are embedded separately, question embeddings and answer entity embeddings are learned, and candidate answers are predicted. Finally, the final answer is determined by combining the similarity between the question and the relation. The final experimental results are shown in Table 1.
[0146]
[0147] Table 1 Comparison of Experimental Results
[0148] The experiments conducted on the complete dataset compared our proposed method with template matching, Bilstm+CRF+CNN, and KGEmbedding, as shown in Table 1. As can be seen in the table, our model outperforms the comparison models on one-hop, two-hop, and three-hop datasets. The advantage of our model becomes more pronounced as the number of hops increases, exceeding the KGEmbedding model by 2.8%, fully demonstrating the effectiveness of our model on this dataset.
[0149] The ablation experiments on the proposed model on the three-hop dataset are shown in Table 2. In the entity relationship linking stage, this paper uses both vector matching and character matching methods, achieving final accuracy rates of 92.9% and 93.2% respectively, with no significant difference. Removing the relationship path matching stage from the proposed model and concatenating keyword embeddings, then learning the concatenated embeddings and answer entity embeddings to derive candidate answers, resulted in a final accuracy rate of 89.2%, a 4.1% decrease compared to the proposed model, highlighting the importance of the relationship path matching stage in the proposed model.
[0150]
[0151] Table 2 Ablation Experiment
[0152] This invention discloses a method for answering questions about power finance knowledge. First, it performs word segmentation and entity linking on the question text, identifying multiple candidate word sets corresponding to multiple keywords in the power finance knowledge graph. The power finance knowledge graph includes multiple entities and multiple relationships. Then, it performs relationship path matching based on the multiple candidate word sets to obtain multiple candidate relationship paths. Finally, it selects the final relationship path from the multiple candidate relationship paths and determines the final answer based on the final relationship path. This invention utilizes a power finance knowledge graph, performs keyword segmentation, and determines the most similar link to the question text based on keywords and link-based reasoning, thereby determining the most accurate answer. This reduces the scope of relationship matching, improves the accuracy of relationship path matching, and thus enhances the accuracy of the question-answering task.
[0153] It should be understood that the sequence number of each step in the above embodiments does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.
[0154] The following are embodiments of the apparatus of the present invention. For details not described in detail, please refer to the corresponding method embodiments described above.
[0155] Figure 9 This is a functional block diagram of the power finance knowledge Q&A device provided in an embodiment of the present invention, with reference to... Figure 9 The power finance knowledge question-and-answer device 9 includes: a word segmentation and linking module 901, a candidate relationship path construction module 902, and a path selection and answer determination module 903, wherein:
[0156] The word segmentation and linking module 901 is used to perform word segmentation and entity linking processing on the question text, and to find multiple candidate word sets corresponding to multiple keywords of the question text from the power finance knowledge graph, wherein the power finance knowledge graph includes multiple entities and multiple relationships;
[0157] The candidate relation path construction module 902 is used to perform relation path matching based on the multiple candidate word sets to obtain multiple candidate relation paths;
[0158] as well as,
[0159] The path selection and answer determination module 903 is used to select the final relationship path from the multiple candidate relationship paths and determine the final answer based on the final relationship path.
[0160] Figure 10 This is a functional block diagram of the terminal provided in an embodiment of the present invention. For example... Figure 10 As shown, the terminal 10 in this embodiment includes a processor 1000 and a memory 1001, wherein the memory 1001 stores a computer program 1002 that can run on the processor 1000. When the processor 1000 executes the computer program 1002, it implements the steps of the various power finance knowledge question-and-answer methods and embodiments described above, for example... Figure 1 Steps 101 to 103 are shown.
[0161] For example, the computer program 1002 may be divided into one or more modules / units, which are stored in the memory 1001 and executed by the processor 1000 to complete the present invention.
[0162] The terminal 10 can be a computing device such as a desktop computer, laptop, handheld computer, or cloud server. The terminal 10 may include, but is not limited to, a processor 1000 and a memory 1001. Those skilled in the art will understand that... Figure 10 This is merely an example of terminal 10 and does not constitute a limitation on terminal 10. It may include more or fewer components than shown, or combine certain components, or different components. For example, terminal 10 may also include input / output devices, network access devices, buses, etc.
[0163] The processor 1000 may be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor.
[0164] The memory 1001 can be an internal storage unit of the terminal 10, such as a hard disk or memory of the terminal 10. The memory 1001 can also be an external storage device of the terminal 10, such as a plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, etc., equipped on the terminal 10. Furthermore, the memory 1001 can include both internal storage units and external storage devices of the terminal 10. The memory 1001 is used to store the computer program 1002 and other programs and data required by the terminal 10. The memory 1001 can also be used to temporarily store data that has been output or will be output.
[0165] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is merely an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit. Furthermore, the specific names of the functional units and modules are only for easy differentiation and are not intended to limit the scope of protection of this application. The specific working process of the units and modules in the above system can be referred to the corresponding process in the aforementioned method embodiments, and will not be repeated here.
[0166] In the above embodiments, the descriptions of each embodiment have their own emphasis. For parts that are not described in detail or recorded in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0167] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this invention.
[0168] In the embodiments provided by this invention, it should be understood that the disclosed devices / terminals and methods can be implemented in other ways. For example, the device / terminal embodiments described above are merely illustrative. For instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.
[0169] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment, depending on actual needs.
[0170] Furthermore, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0171] If the integrated module / unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the above-described embodiments can also be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various methods and apparatus embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable medium can include: any entity or device capable of carrying the computer program code, a recording medium, a USB flash drive, a portable hard drive, a magnetic disk, an optical disk, a computer memory, a read-only memory (ROM), a random access memory (RAM), an electrical carrier signal, a telecommunication signal, and a software distribution medium, etc.
[0172] The above-described embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit them. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included within the protection scope of the present invention.
Claims
1. A question-and-answer method for electricity finance knowledge, characterized in that, include: The question text is segmented and entity linked. Multiple candidate word sets corresponding to multiple keywords of the question text are found from the power finance knowledge graph. The power finance knowledge graph includes multiple entities and multiple relationships. Based on the multiple candidate word sets, relational path matching is performed to obtain multiple candidate relational paths, including: The multiple candidate word sets are classified to obtain multiple entity candidate word sets and multiple relation candidate word sets; Traversal and judgment steps: If the first entity candidate word set has been traversed, then incomplete relation preparation links are deleted, and multiple complete relation preparation links are matched according to the multiple relation candidate word sets to obtain multiple candidate relation paths, wherein the first entity candidate word set is the candidate word set corresponding to the first entity keyword of the question text in the multiple entity candidate word sets, and the number of entities in the incomplete relation preparation links is less than the number of entities in the multiple entity candidate word sets; If the first entity candidate word set is not traversed, then an entity is selected from the first entity candidate word set in a preset order as the first candidate entity, and multiple relation link pre-set sets are constructed based on the first candidate entity. The relation link pre-set sets include entities with multiple one-hop relationships, and the multiple entities in the relation link pre-set sets are determined by one-hop relationship judgment based on multiple entity candidate word sets. Select the final relationship path from the multiple candidate relationship paths, and determine the final answer based on the final relationship path; The step of constructing multiple relation link pre-sets based on the first candidate entity includes: Initialize the preliminary candidate word set as the second entity candidate word set; One-hop relationship determination steps: Determine the one-hop relationship between the first candidate entity and multiple entities in the preliminary candidate word set; If there is an entity in the preliminary candidate word set that has a one-hop relationship with the candidate entity, then the first candidate entity is added to the corresponding relationship link preliminary set, the next word set of the preliminary candidate word set is taken as the preliminary candidate word set, the entity with a one-hop relationship with the candidate entity is taken as the first candidate entity, and then the process jumps to the one-hop relationship judgment step. Otherwise, proceed to the traversal and judgment step; The step of matching multiple complete preliminary relationship links based on the multiple candidate relation word sets to obtain multiple candidate relationship paths includes: For each complete relation preparation link in the plurality of complete relation preparation links, perform the following steps: The relationships of the multiple candidate word sets are added to the relationship preparation network according to the order of multiple keywords in the question text; Select the last set of relation candidate words from the plurality of relation candidate word sets as the target word set; For each relation in the target word set, perform the following steps: Retrieve the head entity of the relationship; Determine whether the head entity exists in the last candidate word set of the plurality of entity candidate word sets; If it exists in the last candidate word set of the plurality of relation candidate word sets, then the tail entity of the relation is taken as the candidate answer.
2. The power finance knowledge question-and-answer method according to claim 1, characterized in that, The process of segmenting and linking the question text involves identifying multiple candidate word sets from the power finance knowledge graph that correspond to multiple keywords in the question text, including: Based on the multiple entities and multiple relationships of the power finance knowledge graph, the question text is segmented to obtain multiple target keywords, wherein the entities and the relationships are formed based on multiple basic word segmentation combinations; Based on the multiple target keywords, multiple target word vectors corresponding to the multiple target keywords are extracted from the power finance knowledge graph, wherein the target word vectors are constructed based on the identifiers of multiple basic word segments that constitute the target keywords; The multiple target word vectors are sorted according to the question text to obtain a word vector set; Extract multiple graph vectors corresponding to multiple entities and multiple relations from the power finance knowledge graph. The graph vectors of entities and relations are constructed based on the identifiers of multiple basic word segments that constitute the entities and relations, respectively. Multiple candidate word sets are obtained based on the similarity between the multiple spectral vectors and the word vector set.
3. The power finance knowledge question-and-answer method according to claim 2, characterized in that, The step of obtaining multiple candidate word sets based on the similarity between the multiple spectral vectors and the word vector set includes: For each of the plurality of spectral vectors, perform the following steps: The similarity of the graph vectors is determined based on the first formula, the graph vectors, and the set of word vectors, wherein the first formula is: In the formula, The similarity between the graph vectors is... For the word vector set corresponding to the first A vector of keywords, For spectral vectors; Based on the similarity of the graph vectors and the similarity threshold, determine whether the graph vector is a candidate word; If the graph vector is a candidate word, then the entity or relation corresponding to the graph vector is added to the candidate word set corresponding to the word vector.
4. The electricity finance knowledge question-and-answer method according to any one of claims 1-3, characterized in that, The step of selecting the final relationship path from the plurality of candidate relationship paths includes: Based on the multiple entities and multiple relationships of the power finance knowledge graph, the question text is segmented to obtain multiple target keywords, wherein the entities and the relationships are formed based on multiple basic word segmentation combinations; Based on the multiple target keywords, multiple target word vectors corresponding to the multiple target keywords are extracted from the power finance knowledge graph, wherein the target word vectors are constructed based on the identifiers of multiple basic word segments that constitute the target keywords; The multiple target word vectors are reorganized based on the question text to obtain the question vector; Based on the second formula, the multiple candidate relationship paths, and the question vector, multiple scores corresponding to the multiple candidate relationship paths are obtained, wherein the second formula is: In the formula, For rating, Let be the vector of questions. For the first A vector of relations, For the first A vector of entities; The candidate relationship path with the highest score is selected as the final relationship path.
5. A power finance knowledge question-and-answer device, characterized in that, For implementing the power finance knowledge question-and-answer method as described in any one of claims 1-4, the power finance knowledge question-and-answer device comprises: The word segmentation and linking module is used to perform word segmentation and entity linking processing on the question text, and to find multiple candidate word sets corresponding to multiple keywords of the question text from the power finance knowledge graph, wherein the power finance knowledge graph includes multiple entities and multiple relationships; The candidate relation path construction module is used to perform relation path matching based on the multiple candidate word sets to obtain multiple candidate relation paths; as well as, The path selection and answer determination module is used to select the final relationship path from the multiple candidate relationship paths and determine the final answer based on the final relationship path.
6. A terminal, comprising a memory and a processor, wherein the memory stores a computer program capable of running on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the method as described in any one of claims 1 to 4 above.
7. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method as described in any one of claims 1 to 4 above.
Citation Information
Patent Citations
Question and answer method and device, electronic equipment and storage medium
CN110837550A