CN114399051B - Intelligent food safety question-answer reasoning method and device - Google Patents

Intelligent food safety question-answer reasoning method and device Download PDF

Info

Publication number
CN114399051B
CN114399051B CN202111640639.2A CN202111640639A CN114399051B CN 114399051 B CN114399051 B CN 114399051B CN 202111640639 A CN202111640639 A CN 202111640639A CN 114399051 B CN114399051 B CN 114399051B
Authority
CN
China
Prior art keywords
entity
relationship
node
entity node
relation
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202111640639.2A
Other languages
Chinese (zh)
Other versions
CN114399051A (en
Inventor
史运涛
白一贤
李书钦
刘伟川
王力
董哲
殷翔
周萌
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
North China University of Technology
Original Assignee
North China University of Technology
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by North China University of Technology filed Critical North China University of Technology
Priority to CN202111640639.2A priority Critical patent/CN114399051B/en
Publication of CN114399051A publication Critical patent/CN114399051A/en
Application granted granted Critical
Publication of CN114399051B publication Critical patent/CN114399051B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N5/00Computing arrangements using knowledge-based models
    • G06N5/04Inference or reasoning models
    • G06N5/045Explanation of inference; Explainable artificial intelligence [XAI]; Interpretable artificial intelligence
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/33Querying
    • G06F16/332Query formulation
    • G06F16/3329Natural language query formulation or dialogue systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/36Creation of semantic tools, e.g. ontology or thesauri
    • G06F16/367Ontology
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N5/00Computing arrangements using knowledge-based models
    • G06N5/02Knowledge representation; Symbolic representation
    • G06N5/022Knowledge engineering; Knowledge acquisition
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N5/00Computing arrangements using knowledge-based models
    • G06N5/02Knowledge representation; Symbolic representation
    • G06N5/022Knowledge engineering; Knowledge acquisition
    • G06N5/025Extracting rules from data
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N7/00Computing arrangements based on specific mathematical models
    • G06N7/01Probabilistic graphical models, e.g. probabilistic networks

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Mathematical Physics (AREA)
  • Data Mining & Analysis (AREA)
  • Computational Linguistics (AREA)
  • Artificial Intelligence (AREA)
  • Computing Systems (AREA)
  • Evolutionary Computation (AREA)
  • Software Systems (AREA)
  • Databases & Information Systems (AREA)
  • Computational Mathematics (AREA)
  • Pure & Applied Mathematics (AREA)
  • Mathematical Optimization (AREA)
  • Algebra (AREA)
  • Medical Informatics (AREA)
  • Probability & Statistics with Applications (AREA)
  • Human Computer Interaction (AREA)
  • Mathematical Analysis (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Animal Behavior & Ethology (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention provides an intelligent food safety question-answer reasoning method and device, wherein the method comprises the following steps: acquiring a head entity and a relation of a food safety question; inputting the head entity and the relation into a dual-module iterative inference model to carry out tail entity inference, and acquiring entity nodes and relation edges associated with the head entity and the relation; calculating the score values of the entity nodes according to the entity nodes and the relation edges connected with the entity nodes, and selecting the entity node with the highest score value as a tail entity of a food safety question; the dual-module iterative inference model comprises an extension module and an inference module. According to the invention, through the cyclic iterative reasoning of the extension module and the reasoning module, entity nodes and relationship edges associated with the head entity and the relationship are extended, the entity node with the highest score is selected as the output answer of the tail entity, and the entity nodes and relationship edges between the head entity and the tail entity can be extracted, so that the graphic explanation is provided for the prediction, and the interpretability of the reasoning process is improved.

Description

Intelligent food safety question-answer reasoning method and device
Technical Field
The invention relates to the technical field of food safety, in particular to an intelligent question-answer reasoning method and device for food safety.
Background
In the present day that the total amount of information is exploded and the propagation speed is so fast, the food safety problem is a hot topic of society all the time. Although the food safety big data has a large application value, the food safety big data has the characteristics of large knowledge capacity, various sources, high updating speed, low value density and the like, and the traditional information research and analysis technology is difficult to establish the relevance in mass information and realize intelligent reasoning and decision.
The existing food safety intelligent question-answering method mostly adopts a single-step reasoning method and adopts direct relations, namely fact tuples in a knowledge graph to learn and reason. However, food safety knowledge and food safety problems become more and more complex, deep information of the knowledge map is difficult to learn by single-step reasoning, reasonable explanation for relation prediction among entities is difficult to provide by a reasoning algorithm, and the multi-hop complex problem cannot be effectively solved.
Therefore, it is an urgent technical problem to improve interpretability of reasoning process of intelligent food safety question answering.
Disclosure of Invention
The invention provides a food safety intelligent question-answering reasoning method and device, which are used for solving the defect of poor interpretability of a reasoning process of food safety intelligent question-answering in the prior art.
The invention provides an intelligent food safety question-answer reasoning method, which comprises the following steps:
acquiring head entities and relations of food safety question sentences;
inputting the head entity and the relation into a double-module iterative inference model to carry out tail entity inference, and acquiring entity nodes and relation edges associated with the head entity and the relation;
calculating the score values of the entity nodes according to the entity nodes and the relation edges connected with the entity nodes, and selecting the entity node with the highest score value as a tail entity of the food safety question;
the dual-module iterative inference model comprises an extension module and an inference module, wherein the extension module is used for extending entity nodes and relationship edges associated with the head entity and the relationship; the reasoning module is used for updating the potential representation and the attention probability distribution of the newly expanded entity node and feeding back the updated potential representation and the updated attention probability distribution of the newly expanded entity node to the expansion module.
Optionally, inputting the head entity and the relationship into a dual-module iterative inference model for tail entity inference, and acquiring an entity node and a relationship edge associated with the head entity and the relationship, including:
under the condition that the preset hop count is one hop, determining an entity node and a relation edge of the next hop according to the head entity and the relation;
under the condition that the preset hop count is multi-hop, determining an entity node and a relationship edge of a first hop according to the head entity and the relationship;
and after the first hop, determining the entity node and the relationship edge of the next hop according to the relationship and the entity node of the current hop.
Optionally, determining an entity node and a relationship edge of a next hop according to the relationship and the entity node of the current hop includes:
calculating the probability of the output relationship edge of the entity node of the current hop according to the relationship and the probability of the output relationship edge of the entity node of the current hop, and acquiring the probability value of the output relationship edge of the entity node of the current hop;
and screening the output relation edges according to the probability values of the output relation edges to obtain the relation edges of the next hop and entity nodes connected with the relation edges of the next hop.
Optionally, the obtaining a probability value of the output relationship edge of the entity node of the current hop according to the relationship and the probability of the output relationship edge of the entity node of the current hop by the entity node of the current hop includes:
acquiring a first aggregation matrix according to the embedded vector and the potential expression vector of the entity node connected with the output relationship edge of the entity node of the current hop and the embedded matrix of the output relationship edge of the entity node of the current hop;
acquiring a second aggregation matrix according to the embedding vector and the potential expression vector of the entity node of the current hop and the embedding matrix of the relationship;
and acquiring the probability value of the output relationship edge of the entity node of the current hop according to the first aggregation matrix, the second aggregation matrix and the attention probability distribution of the entity node of the current hop.
Optionally, the screening the output relationship edges according to the probability values of the output relationship edges to obtain relationship edges of a next hop and entity nodes connected to the relationship edges of the next hop, including:
sorting the probability values of the output relationship edges;
and screening a preset number of output relationship edges with the probability value ranking in the front, and taking the screened output relationship edges and entity nodes connected with the screened output relationship edges as the relationship edges of the next hop and the entity nodes connected with the relationship edges of the next hop.
Optionally, inputting the head entity and the relationship into a dual-module iterative inference model for tail entity inference, and obtaining an entity node and a relationship edge associated with the head entity and the relationship, further comprising:
potential representations and attention probability distributions of the newly expanded entity nodes are updated.
Optionally, updating the potential representation and the attention probability distribution of the newly expanded entity node includes:
acquiring the weight of the input relation edge of the newly expanded entity node according to the potential representation of the newly expanded entity node and the potential representation of the last hop entity node connected with the input relation edge of the newly expanded entity node;
and acquiring the updated potential representation of the newly expanded entity node according to the weight of the input relationship edge of the newly expanded entity node and the potential representation of the last hop entity node connected with the input relationship edge of the newly expanded entity node.
Optionally, updating the potential representation and the attention probability distribution of the newly expanded entity node further comprises:
adding the probability values of the input relation edges of the newly expanded entity nodes to obtain a probability value addition result;
and normalizing the sum result of the probability values to obtain the updated attention probability distribution of the newly expanded entity node.
Optionally, calculating the score value of the entity node according to the entity node and the relationship edge connected to the entity node includes:
and determining the score value of the entity node according to the attention probability distribution of the entity node and the sum of the weights of the input relation edges of the entity node.
Optionally, the calculation formula of the score value of the entity node is as follows:
ST(e)=aT(e)∑α(e)
wherein S isT(e) Representing the score value of the entity node e after T steps of jumping; a is aT(e) Representing the attention probability distribution of the entity node e after T steps of jumping; α (e) represents the weight of the input relational edge of the entity node e.
Optionally, before obtaining the head entity and the relationship of the food safety question, the method includes:
extracting entities and relationships by using food safety related data;
and carrying out vector embedding processing on the extracted entities and the relations to construct a food safety knowledge mapping network.
The invention provides an intelligent question-answering reasoning device for food safety, which comprises:
the first acquisition module is used for acquiring the head entity and the relation of the food safety question;
the second acquisition module is used for inputting the head entity and the relation into a dual-module iterative inference model to carry out tail entity inference and acquiring entity nodes and relation edges associated with the head entity and the relation;
the calculation selection module is used for calculating the score values of the entity nodes according to the entity nodes and the relation edges connected with the entity nodes, and selecting the entity node with the highest score value as a tail entity of the food safety question sentence;
the dual-module iterative inference model comprises an extension module and an inference module, wherein the extension module is used for extending entity nodes and relationship edges associated with the head entity and the relationship; the reasoning module is used for updating the potential representation and the attention probability distribution of the newly expanded entity node and feeding the updated potential representation and the updated attention probability distribution of the newly expanded entity node back to the expanding module.
The invention also provides an electronic device, which comprises a memory, a processor and a computer program stored on the memory and capable of running on the processor, wherein the processor executes the computer program to realize the steps of any one of the food safety intelligent question-answering reasoning methods.
The present invention also provides a non-transitory computer readable storage medium having stored thereon a computer program which, when executed by a processor, performs the steps of the food safety intelligent question-answer reasoning method as described in any one of the above.
The invention also provides a computer program product comprising a computer program which, when executed by a processor, implements the steps of the food safety intelligent question-answer reasoning method as described in any one of the above.
According to the food safety intelligent question-answer reasoning method and device, entity nodes and relation edges associated with a head entity and a relation are expanded through the cyclic iterative reasoning of the expansion module and the reasoning module, the entity node with the highest score is selected as a tail entity, the tail entity is output as a question answer, the problem of complex multi-hop food safety query without obvious answers is solved, the entity nodes and the relation edges passing between the head entity and the tail entity can be used for providing graphic explanation for prediction, and the interpretability of the reasoning process is improved.
Drawings
In order to more clearly illustrate the technical solutions of the present invention or the prior art, the drawings needed to be used in the description of the embodiments or the prior art will be briefly introduced below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
FIG. 1 is a schematic flow chart of an intelligent question-answering reasoning method for food safety provided by an embodiment of the invention;
FIG. 2 is a second schematic flow chart of the intelligent question-answering reasoning method for food safety according to the embodiment of the present invention;
FIG. 3 is a schematic diagram of the extraction of entities and relationships provided by an embodiment of the invention;
FIG. 4 is a partial illustration of a food safety knowledge graph provided by an embodiment of the present invention;
FIG. 5 is a schematic diagram of screening a relationship edge to be expanded according to an embodiment of the present invention;
fig. 6 is a schematic diagram of one-hop physical node expansion according to an embodiment of the present invention;
fig. 7 is a schematic diagram of a two-hop entity node extension according to an embodiment of the present invention;
FIG. 8 is an updated schematic diagram of a potential representation of a new extended entity node provided by an embodiment of the present invention;
fig. 9 is a schematic structural diagram of an intelligent food safety question-answering reasoning apparatus provided in an embodiment of the present invention;
fig. 10 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention clearer, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings, and it is obvious that the described embodiments are some, but not all embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Before explaining the embodiments of the present invention in detail, the knowledge graph, the intelligent question-answering technology and the multi-hop reasoning technology related to the embodiments of the present invention are briefly described.
The knowledge graph technology can enable data to have the advantages of high reliability, complete associated information and good visualization effect, the knowledge graph usually establishes a three-component network, mass internet information is expressed into semantic representation recognizable in the objective world in the form of { head entity, relation and tail entity }, the knowledge graph has strong semantic expression, storage and expression capacity, and the knowledge graph is widely concerned and researched and applied in the industrial and academic fields.
The intelligent question-answering system aims at aiming at the complex information requirement provided by the user, allowing the user to ask questions in a natural language question sentence mode, and directly returning accurate answers for the user. The question-answering technology combined with the knowledge graph utilizes rich structural semantic information, can deeply understand the problems of the user, gives accurate answers, provides 24-hour intelligent question-answering service for the user, and has prominent important application value in a plurality of fields such as medical treatment, education, finance and the like.
The essence of multi-hop inference is to use existing knowledge to infer new or unknown knowledge through multiple iterative inferences, establishing new relationships between entities. In recent years, knowledge-graph-oriented multi-hop inference has developed unique inference methods with the prevalence of technologies such as distributed representation, neural networks, and the like, and may include rule-based inference, distributed representation-based inference, neural network-based inference, and hybrid inference, depending on the method division. In the food safety research, the common methods for multi-hop inference in the food safety field mainly include rule-based inference and logic-based inference, such as known (poison a, high risk, food a) and (food a, the same class, food B), which can be inferred (poison a, high risk, food B).
Fig. 1 is one of the flow diagrams of the food safety intelligent question-answer reasoning method provided by the embodiment of the present invention, and as shown in fig. 1, the present invention provides a food safety intelligent question-answer reasoning method, which includes:
step 101, acquiring a head entity and a relation of a food safety question;
specifically, fig. 2 is a second schematic flow chart of the food safety intelligent question-answering reasoning method provided by the embodiment of the present invention, and as shown in fig. 2, the food safety intelligent question-answering reasoning method provided by the embodiment of the present invention includes four parts of knowledge extraction, knowledge embedding, iterative reasoning, and result output.
Optionally, before obtaining the head entity and the relationship of the food safety question, the method includes:
extracting entities and relationships by using food safety related data;
and carrying out vector embedding processing on the extracted entities and the relationship to construct a food safety knowledge graph network.
Specifically, the data related to food safety may be data related to food safety standard or data related to global food safety standard.
The entity and the relation in the food safety related data are extracted, the entity types are collected into { food category, food name, bacterial name, chemical, animal, plant, environment, fungus, virus, food poisoning name, symptom sign, time } and the like, the relation set is { belonging to, causing, infected part, latent period, symptom expression, vomit, treatment medicine, disinfectant, origin, growth temperature } and the like.
Fig. 3 is a schematic diagram of entity and relationship extraction provided by the embodiment of the present invention, and as shown in fig. 3, the specific extraction method relates to technologies of a Bidirectional Encoder Representation network (BERT), a Bidirectional Long Short-Term Memory (Bi-directional Long Short-Term Memory, bilst) and a Conditional Random Field (CRF).
The method comprises the steps of inputting a food safety knowledge text into a BERT module for preprocessing, extracting and converting relevant key knowledge in relevant document data into semantic vectors by the BERT module, performing label prediction and classification on embedded semantic vectors by splicing a forward Short-Term Memory (LSTM) and a backward LSTM by the BilSTM module, generating a prediction label by a pair of forward LSTM and backward LSTM, taking C1, C2, C3, C4 and the like in the figure 3 as prediction labels, adding constraint to the prediction labels by the CRF module, optimizing a loss function, and taking B, I, O and O and the like corresponding to each prediction label in the figure 3 as label information.
A Named Entity Recognition (NER) method is adopted to label BIO labels on a small number of data sets, and recognized words are summarized into a form of { entity, relation and entity } and then are put into a three-element network of the knowledge graph, so that the knowledge graph is constructed.
Fig. 4 is a partial example of a food safety knowledge-graph provided by an embodiment of the present invention, and as shown in fig. 4, entities are connected with each other through relationships, and the relationships have directions, so that a huge food safety knowledge-graph is formed.
For example, proteus vulgaris is associated with proteus vulgaris intoxication through a pathogenic relationship, and proteus vulgaris intoxication is associated with abdominal pain, vomiting, fever through a symptomatic relationship.
After the knowledge extraction is completed, knowledge embedding is required. The three-component network of the food safety knowledge graph and the problem after extraction of the query sentence are both Chinese character form representation, and the Chinese characters need to be subjected to vector embedding processing and converted into a node network so as to facilitate subsequent calculation and reasoning.
Vector embedding is performed by using a DistMult model, the model uses vectors to represent each entity so as to obtain potential semantics, and uses a diagonal matrix to represent each relation so as to model potential relations between entities.
And carrying out vector embedding processing on the entities and the relations in the food safety knowledge graph so as to construct a food safety knowledge graph network.
The food safety related data are subjected to entity and relation extraction, and then vector embedding is carried out on the entities and the relations, so that a food safety knowledge map network is constructed, and a search range is established for follow-up questioning and inquiring.
After the food safety knowledge map network is established, the food safety question is received, and the head entity and the relation in the food safety question are extracted, so that the head entity and the relation of the food safety question are obtained.
For example, a food safety question "how long the latent period of salmonella poisoning is" is received, "salmonella poisoning" is extracted as the head entity, and "latent period" is taken as the relationship.
102, inputting the head entity and the relation into a dual-module iterative inference model to perform tail entity inference, and acquiring entity nodes and relation edges associated with the head entity and the relation;
the dual-module iterative inference model comprises an extension module and an inference module, wherein the extension module is used for extending entity nodes and relationship edges associated with the head entity and the relationship; the reasoning module is used for updating the potential representation and the attention probability distribution of the newly expanded entity node and feeding back the updated potential representation and the updated attention probability distribution of the newly expanded entity node to the expansion module.
Specifically, the question sentence is converted into { esR',? The form of the data is input into a double-module iterative inference model, esRepresents a head entity extracted from a question, r' represents a relationship extracted from a question,? Representing the tail entity to be searched in the question sentence.
The dual-module iterative inference model comprises an extension module and an inference module. The expansion module searches related entity nodes and relationship edges from the food safety knowledge graph network according to the head entities and the relationships, calculates the probability of the relationship edges, and selects part of relationship edges with higher probability and entity nodes connected with the relationship edges with higher probability for expansion; the inference module updates the potential representation and the attention probability distribution of the newly expanded entity node and feeds back the updated potential representation and the updated attention probability distribution to the expansion module, and the expansion module continues to calculate and expand by using the updated potential representation and the updated attention probability distribution of the inference module, so that iteration is performed.
And forming a food safety knowledge graph sub-network by using the searched relation edges and entity nodes which are associated with the head entities and the relations. Before searching is started, only head entities are added into the food safety knowledge graph sub-network, and after a dual-module iterative reasoning model is entered, expanded entity nodes and relationship edges are also added into the food safety knowledge graph sub-network.
The search range and the calculation complexity can be reduced by constructing the food safety knowledge graph sub-network, and the reasoning process is organized by using the food safety knowledge graph sub-network, so that the reasoning capability which is stronger than that of the prior path-based method and gradient-based end-to-end training is realized.
Optionally, inputting the head entity and the relationship into a dual-module iterative inference model for tail entity inference, and acquiring an entity node and a relationship edge associated with the head entity and the relationship, including:
under the condition that the preset hop count is one hop, determining an entity node and a relation edge of the next hop according to the head entity and the relation;
under the condition that the preset hop count is multi-hop, determining an entity node and a relationship edge of a first hop according to the head entity and the relationship;
and after the first hop, determining the entity node and the relationship edge of the next hop according to the relationship and the entity node of the current hop.
Specifically, before the expansion module starts to expand, the preset hop count is set according to the complexity of the question and/or the size of the food safety knowledge graph. The preset hop count can be set to one hop or multiple hops, and the multiple hops are greater than or equal to two hops.
And under the condition that the preset hop count is one hop, namely, the relation r 'exists in the relation edge connected with the head entity, searching the relation r' in the relation edge connected with the head entity, and directly outputting the tail entity connected with the relation r 'after searching the relation r'.
And directly determining the entity node and the relation edge of the next hop according to the head entity and the relation, and outputting the entity node of the next hop as a tail entity.
Under the condition that the preset hop count is multi-hop, namely, the relation r 'does not exist in the relation edge connected with the head entity, multiple iterative reasoning needs to be carried out to find the relation edge associated with the relation r'.
And determining the entity node and the relationship edge of the first hop according to the head entity and the relationship, and determining the entity node and the relationship edge of the next hop by the relationship and the entity node of the current hop.
Except that the first hop is related to the head entity, the subsequent next hop is determined by the relationship and the entity node of the current hop, thereby effectively reducing the complexity of reasoning.
Optionally, determining an entity node and a relationship edge of a next hop according to the relationship and the entity node of the current hop includes:
calculating the probability of the output relationship edge of the entity node of the current hop according to the relationship and the probability of the output relationship edge of the entity node of the current hop, and acquiring the probability value of the output relationship edge of the entity node of the current hop; and screening the output relation edges according to the probability values of the output relation edges to obtain the relation edges of the next hop and the entity nodes connected with the relation edges of the next hop.
Specifically, complex semantic information under different multi-hop paths is involved in food safety questions and answers, for a specific food safety problem, semantic information contained under different relationship paths of each pair of entity nodes and relationship edges is different, and the importance degree of reasoning correct answers is also different. Therefore, attention needs to be drawn to the output relationship of the next hop, weights need to be assigned to the food problem inference paths of different output relationship sides, and all path sequences need to be arranged and screened.
Optionally, the obtaining a probability value of the output relationship edge of the entity node of the current hop according to the relationship and the probability of the output relationship edge of the entity node of the current hop by the entity node of the current hop includes:
acquiring a first aggregation matrix according to the embedded vector and the potential expression vector of the entity node connected with the output relationship edge of the entity node of the current hop and the embedded matrix of the output relationship edge of the entity node of the current hop;
acquiring a second aggregation matrix according to the embedding vector and the potential expression vector of the entity node of the current hop and the embedding matrix of the relationship;
and acquiring the probability value of the output relationship edge of the entity node of the current hop according to the first aggregation matrix, the second aggregation matrix and the attention probability distribution of the entity node of the current hop.
Specifically, fig. 5 is a schematic diagram of screening a relationship edge to be expanded according to an embodiment of the present invention, for exampleAs shown in fig. 5, in the t-th hop, the current entity node is entity node ekEntity node ekThe output relation edge of (1) has i pieces, each output relation edge riConnecting a physical node ei
According to eiAnd the embedded vectors and the potential representation vectors and the embedded matrix of the relationship edge i form a first aggregation matrix Ek
First aggregation matrix EkThe expression of (a) is as follows:
Figure GDA0003831647260000121
in the formula, EkA first aggregation matrix is represented that is,
Figure GDA0003831647260000122
d is the dimension of the embedding vector and,
Figure GDA0003831647260000123
representing a physical node eiIs used to represent the vector of the potential representation of,
Figure GDA0003831647260000124
representing a physical node eiThe embedded vector of (a) is embedded,
Figure GDA0003831647260000125
representing a relational edge riThe embedded matrix of (1), where | represents the concatenation of vectors.
According to entity node ekAnd the embedded vectors and the potential representation vectors and the embedded matrix of the relationship form a second aggregation matrix Dk
Second polymerization matrix DkThe expression of (a) is as follows:
Figure GDA0003831647260000126
in the formula, DkA second aggregation matrix is represented that is,
Figure GDA0003831647260000127
d is the dimension of the embedding vector and,
Figure GDA0003831647260000128
representing a physical node ekIs used to represent the vector of the potential representation of,
Figure GDA0003831647260000129
representing a physical node ekEmbedded vector of vr′An embedded matrix representing the relation r', with | | representing the concatenation of vectors.
According to a first aggregation matrix EkA second polymerization matrix DkAnd a physical node ekComputing entity node e for attention probability distributionkThe probability value distribution of the output relation edge, and the entity node e is determined according to the probability value distributionkEach of which outputs a probability value for the relationship edge.
Entity node ekThe expression of the probability value distribution of the output relational edge of (1) is as follows:
Pk=at(ek)softmax[relu(EkW1)·relu(W2Dk)]
in the formula, PkRepresenting an entity node ekOutput of the relational edge, PkIs a column vector of i dimensions, each dimension size representing the correlation size of each output relational edge and question, at(ek) Representing a physical node ekThe attention probability distribution of (1), softmax () is a function, the softmax function carries out multi-layer probability calculation, relu () is an activation function, the relu function carries out linearization, EkIs a first aggregation matrix, W1And W2As the parameter(s) is (are),
Figure GDA0003831647260000131
Figure GDA0003831647260000132
Dkis a second polymerization matrix.
Further, calculate the t hopEstablishing a set P by the probability value of the output relation edge of the entity nodet,PtIs the set of probability values of the output relationship edges of all the entity nodes in the t-th hop.
The method for calculating the probability value of the output relationship edge of the entity node of the current hop is clear, and the method is beneficial to screening the relationship edge subsequently.
Under the condition that the preset hop number is multiple hops, the difference between the first hop and the subsequent hop in the determination of the entity node and the relationship edge is that a second aggregation matrix in the probability value calculation of the relationship edge is different, and the second aggregation matrix in the first hop is formed by connecting a potential representation vector of a head entity, an embedded vector of the head entity and an embedded matrix of a relationship r' in series.
Optionally, the screening the output relationship edges according to the probability values of the output relationship edges to obtain relationship edges of a next hop and entity nodes connected to the relationship edges of the next hop, including:
sorting the probability values of the output relationship edges;
and screening a preset number of output relationship edges with the probability value ranking in the front, and taking the screened output relationship edges and entity nodes connected with the screened output relationship edges as the relationship edges of the next hop and the entity nodes connected with the relationship edges of the next hop.
Specifically, in the t-th hop, a plurality of entity nodes are provided, each entity node is provided with a plurality of output relationship edges to be expanded, the probability values of all the output relationship edges to be screened in each hop are sequenced from large to small, after the sequencing is completed, a preset number of output relationship edges with the probability values ranked at the top are screened out, the preset number can be preset according to the computing capacity of a question-answering system, and the screened output relationship edges and the entity nodes connected with the screened output relationship edges are used as newly expanded relationship edges and newly expanded entity nodes. And adding the newly expanded relation edges and the newly expanded entity nodes into the food safety knowledge graph sub-network to complete the expansion of the food safety knowledge graph sub-network.
Fig. 6 is a schematic diagram of one-hop entity node extension according to an embodiment of the present invention, and as shown in fig. 6, a head entity esThere are 6 output relationship edges to be expanded in the first hop, and the probability value of each output relationship edge to be expanded is P in sequence11、P12、P13、P14、P15And P16Sorting the probability values, setting the preset number n to 4, and screening out 4 probability values P ranked ahead12、P13、P15And P16Then extend the probability value P12、P13、P15And P16Corresponding output relation edges and entity nodes connected with the output relation edges.
Fig. 7 is a schematic diagram of two-hop entity node expansion provided in the embodiment of the present invention, and as shown in fig. 7, four entity nodes in the second hop have 10 output relationship edges to be expanded, and the probability value of each output relationship edge to be expanded is P in sequence20、P21、P22、P23、P24、P25、P26、P27、P28And P29Sorting the probability values, wherein the preset number n is still 4, and screening out 4 probability values P ranked in the front21、P22、P24And P27Then extend the probability value P21、P22、P24And P27Corresponding output relation edges and entity nodes connected with the output relation edges.
The screening process of the relationship edges is clarified, and the determination of the newly expanded relationship edges and the entity nodes is completed.
For the multi-hop inference method, to complete a query esR',? And since the embedding-based method needs to enumerate the whole entity set, each query needs O (| ε |). For large knowledgegraph networks containing millions of entities, this is very costly, especially in combination with complex scoring functions. The invention utilizes the local structure of the food safety knowledge map sub-network to reduce the time complexity.
For the expansion module, in each step, a maximum of n entities are accessed, and for each entity, a maximum of η scores of output relational edges need to be computed. At a given iterationUnder the condition of the times T, only O (T) is needed to complete the expansion of the food safety knowledge graph subnetwork for one time) Time.
Optionally, inputting the head entity and the relationship into a dual-module iterative inference model for tail entity inference, and obtaining an entity node and a relationship edge associated with the head entity and the relationship, further comprising:
potential representations and attention probability distributions of the newly expanded entity nodes are updated.
Specifically, for the nodes of the food safety knowledge graph, different weights should be given to different connections in information aggregation according to the problem.
In order to better discover the correlation in the food safety knowledge Graph and complete the information transfer learning of the knowledge Graph of the current multi-hop step, the inference module selects a Graph Attention network (GAT), combines a multi-head Attention mechanism, obtains the neighborhood characteristics of each node through stacking network layers, and allocates different weights to different nodes in the neighborhood of the food safety multi-hop nodes. This has the advantage that no costly matrix operations are required, nor is the information on the structure of the object diagram known in advance. By the method, the GAT can solve the problem that different neighborhood node weights are distributed differently in different problems, the relevance of subsequent reasoning and specific food safety problems is enhanced, and meanwhile, the GAT can also be applied to inductive learning and direct-push learning.
The reasoning module has the main functions of combining with a GAT network model, calculating the weight of the node message during transmission, integrating a multi-head attention mechanism according to the weight and the characteristic embedding of a neighborhood input entity node, updating the potential representation of a newly expanded entity node, and updating the attention distribution of the newly expanded entity according to the probability distribution of an input edge.
Optionally, updating the potential representation and the attention probability distribution of the newly expanded entity node includes:
acquiring the weight of the input relation edge of the newly expanded entity node according to the potential representation of the newly expanded entity node and the potential representation of the last hop entity node connected with the input relation edge of the newly expanded entity node;
and acquiring the updated potential representation of the newly expanded entity node according to the weight of the input relationship edge of the newly expanded entity node and the potential representation of the last hop entity node connected with the input relationship edge of the newly expanded entity node.
Specifically, fig. 8 is a schematic diagram of an update of a potential representation of a new extended entity node provided in an embodiment of the present invention, as shown in fig. 8, an entity node e of a previous hopiBy entering relational edges with newly expanded entity nodes emConnecting, inputting the weight of the relation edge as alphai
Inputting the weight alpha of the relational edgeiThe expression of (a) is as follows:
Figure GDA0003831647260000161
in the formula, alphaiRepresenting the weight of the ith input relation edge, leakyRelu () is an activation function, beta is a parameter vector to be learned, W is a parameter matrix,
Figure GDA0003831647260000162
representing an entity node emIs used to represent the vector of the potential representation of,
Figure GDA0003831647260000163
entity node e representing last hopiIs potentially represented by a vector, NiIndicating that there are i physical nodes in the last hop to transmit messages to the current physical node,
Figure GDA0003831647260000164
a potential representation vector representing the kth physical node in the last hop.
The node message aggregation is delivered from the previous layer, all representations are computed sequentially in the same layer, and the network shares the same two parameters β and W across layers.
According to the weight alpha of the input relation edgeiWith the last hop entity node eiCan obtain the updated entity node emPotential representation of (a).
Updated entity node emThe expression of (a) is as follows:
Figure GDA0003831647260000165
in the formula (I), the compound is shown in the specification,
Figure GDA0003831647260000166
representing updated entity node emRepresents a vector, σ () represents an activation function, G represents the G-th level of multi-head attention, G represents the total number of levels of multi-head attention, αi gRepresents the weight of the ith relational edge in the g-th layer, WgA parameter matrix representing the g-th layer,
Figure GDA0003831647260000167
entity node e representing last hopiRepresents a vector.
Considering that message aggregation of nodes has different correlations to different food safety questions, different weight calculation methods need to be considered in calculation, and a multi-head attention mechanism needs to be introduced. The reasoning module defines G pairs of different learning parameters beta and W, each pair of different learning parameters is used for calculating respectively, adding and summing are carried out, then the average number of the parameters is calculated, and the final entity node e is obtained after the function is activatedmUpdated potential representation
Figure GDA0003831647260000171
The updating method of the potential representation of the newly expanded entity node is clear, and the subsequent expansion module can be continued to expand based on the new potential representation.
Optionally, updating the potential representation and the attention probability distribution of the newly expanded entity node further comprises:
adding the probability values of the input relation edges of the newly expanded entity nodes to obtain a probability value addition result;
and normalizing the sum result of the probability values to obtain the updated attention probability distribution of the newly expanded entity node.
In particular, by entity node emThe probability values of the input relationship edges are added and calculated to obtain an entity node emAttention probability distribution of (1).
Entity node emThe expression of the attention probability distribution of (1) is as follows:
at(em)=∑Pt(eim)
in the formula, at(em) Representing a physical node emAttention probability distribution of (1), Pt(eim) Representing a physical node emThe ith entry of (1) inputs a probability value for the relational edge.
Because the relation edges are screened, only the relation edges of the target number strips with the probability values ranked at the top are selected and added into the food safety knowledge map sub-network, and the sum of the probability values is probably less than 1, the attention distribution needs to be normalized, and the entity node e is obtainedmAn updated attention probability distribution.
Entity node emThe expression of the updated attention probability distribution is as follows:
Figure GDA0003831647260000172
in formula (II), a't(em) Representing a physical node emUpdated attention probability distribution, at(em) Representing an entity node emE' represents each entity node in the sub-network of the food safety knowledge-graph, epsilon represents all entity nodes in the sub-network of the food safety knowledge-graph, g represents the g-th layer of multi-head attention, at(e′)gRepresenting the attention probability distribution of the entity node e' in the g-th level.
By grading the importance among the relationship edges in the inference path, important path vectors are selectively gathered, and meanwhile, a multi-head attention mechanism is combined in the probability calculation of the entity nodes, so that the inference result is more convincing.
And the inference module returns the updated potential representation and entity attention distribution of the newly expanded entity nodes to the expansion module, the expansion module expands the next hop according to the new parameters, and adds the newly expanded entity nodes and the relationship edges of the next hop to the food safety knowledge graph sub-network, so that iteration is carried out, and the screening of the entity nodes in the food safety knowledge graph network and the inference of the entity nodes in the food safety knowledge graph sub-network are completed step by step according to the food safety problem.
The updating of the attention probability distribution of the newly expanded entity node is made clear, and the subsequent expansion module can continue to expand based on the new attention probability distribution.
And (3) carrying out random gradient descent method training on parameters in the dual-module iterative inference model by using a cross entropy loss function.
For the inference module, at most the potential representations of the n nodes are updated in each step. To update each entity, at most, aggregation from | E | input edges is needed. Therefore, O (T) is needed for potential representation calculationn| E |). Because in each step the subgraph adds n edges at most, the | E | < Tn. Overall, the food safety knowledgebase sub-network requires at most O (T)+T2n2) Time. Given the predefined T, n and η, the maximum time is a constant, independent of the number of entities in the graph, and therefore a large food safety knowledge graph network can be processed.
And 103, calculating the score values of the entity nodes according to the entity nodes and the relation edges connected with the entity nodes, and selecting the entity node with the highest score value as a tail entity of the food safety question.
Specifically, the food safety question answer outputs the final target entity, i.e. deduces the extracted es,r′,?}And the tail entity in the system is subjected to a double-module iterative reasoning process of an expansion module and a reasoning module until a food safety knowledge graph sub-network forms a closed directed graph, or the food safety knowledge graph sub-network is expanded to be large enough after T-step jumping, then final answer probability prediction is carried out on entity nodes in the food safety knowledge graph sub-network, the entity node with the highest score is selected as the tail entity, and the tail entity is output as a final target entity.
Optionally, calculating the score value of the entity node according to the entity node and the relationship edge connected to the entity node includes:
and determining the score value of the entity node according to the attention probability distribution of the entity node and the sum of the weights of the input relation edges of the entity node.
Specifically, the score value of an entity node in a food safety knowledge graph sub-network is jointly determined by the weight of the input relation edge of the entity node and the attention probability distribution of the entity node.
Optionally, the calculation formula of the score value of the entity node is as follows:
ST(e)=aT(e)∑α(e)
wherein S isT(e) Representing the score value of the entity node e after T steps of jumping; a isT(e) Representing the attention probability distribution of the entity node e after T-step jumping; α (e) represents the weight of the input relational edge of the entity node e.
The final score value is calculated by combining the relation edge probability in the problem through the expansion module, and the head entity in the reasoning module is jointly determined through information transmission and aggregation of the weight value step by step. The relevance of the problem is guaranteed on the reasoning result.
The calculation of the score values of the entity nodes in the food safety knowledge graph sub-network is determined, and the selection of the tail entities from a plurality of entity nodes is facilitated.
According to the food safety intelligent question-answer reasoning method provided by the embodiment of the invention, through the cyclic iterative reasoning of the expansion module and the reasoning module, entity nodes and relationship edges associated with the head entity and the relationship are expanded, the entity node with the highest score is selected as the tail entity, and the tail entity is output as the answer to the question, so that the problem of complex multi-hop food safety query without obvious answers is solved, the entity nodes and relationship edges passing between the head entity and the tail entity can be used for providing graphic explanation for prediction, and the interpretability of the reasoning process is improved.
Fig. 9 is a schematic structural diagram of the intelligent food safety question-answer reasoning apparatus provided in the embodiment of the present invention, and as shown in fig. 9, the present invention further provides an intelligent food safety question-answer reasoning apparatus, including: a first obtaining module 901, a second obtaining module 902, and a calculating and selecting module 903, wherein:
the first obtaining module 901 is used for obtaining the head entity and the relationship of the food safety question;
the second obtaining module 902 is configured to input the head entity and the relationship into a dual-module iterative inference model for tail entity inference, and obtain an entity node and a relationship edge associated with the head entity and the relationship;
the calculation selection module 903 is configured to calculate score values of the entity nodes according to the entity nodes and relationship edges connected with the entity nodes, and select an entity node with a highest score value as a tail entity of the food safety question;
the dual-module iterative inference model comprises an extension module and an inference module, wherein the extension module is used for extending entity nodes and relationship edges associated with the head entity and the relationship; the reasoning module is used for updating the potential representation and the attention probability distribution of the newly expanded entity node and feeding back the updated potential representation and the updated attention probability distribution of the newly expanded entity node to the expansion module.
Specifically, the intelligent food safety question-answering reasoning apparatus provided in the embodiment of the present application can implement all the method steps implemented by the above method embodiment, and can achieve the same technical effects, and details of the same parts and beneficial effects as those of the method embodiment in this embodiment are not described herein again.
Fig. 10 is a schematic structural diagram of an electronic device according to an embodiment of the present invention, and as shown in fig. 10, the electronic device may include: a processor (processor) 1010, a communication Interface (Communications Interface) 1020, a memory (memory) 1030, and a communication bus 1040, wherein the processor 1010, the communication Interface 1020, and the memory 1030 are in communication with each other via the communication bus 1040. Processor 1010 may invoke logic instructions in memory 1030 to perform a food safety intelligent question-answer reasoning method comprising: acquiring a head entity and a relation of a food safety question; inputting the head entity and the relation into a dual-module iterative inference model to carry out tail entity inference, and acquiring entity nodes and relation edges associated with the head entity and the relation; calculating the score values of the entity nodes according to the entity nodes and the relation edges connected with the entity nodes, and selecting the entity node with the highest score value as a tail entity of the food safety question; the dual-module iterative inference model comprises an extension module and an inference module, wherein the extension module is used for extending entity nodes and relationship edges associated with the head entity and the relationship; the reasoning module is used for updating the potential representation and the attention probability distribution of the newly expanded entity node and feeding back the updated potential representation and the updated attention probability distribution of the newly expanded entity node to the expansion module.
Furthermore, the logic instructions in the memory 1030 can be implemented in software functional units and stored in a computer readable storage medium when the logic instructions are sold or used as independent products. Based on such understanding, the technical solution of the present invention or a part thereof which substantially contributes to the prior art may be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
In another aspect, the present invention also provides a computer program product, which includes a computer program stored on a non-transitory computer readable storage medium, the computer program including program instructions, when the program instructions are executed by a computer, the computer can execute the food safety intelligent question-answer reasoning method provided by the above methods, the method including: acquiring a head entity and a relation of a food safety question; inputting the head entity and the relation into a dual-module iterative inference model to carry out tail entity inference, and acquiring entity nodes and relation edges associated with the head entity and the relation; calculating the score values of the entity nodes according to the entity nodes and the relation edges connected with the entity nodes, and selecting the entity node with the highest score value as a tail entity of the food safety question; the dual-module iterative inference model comprises an extension module and an inference module, wherein the extension module is used for extending entity nodes and relationship edges associated with the head entity and the relationship; the reasoning module is used for updating the potential representation and the attention probability distribution of the newly expanded entity node and feeding back the updated potential representation and the updated attention probability distribution of the newly expanded entity node to the expansion module.
In still another aspect, the present invention also provides a non-transitory computer readable storage medium, on which a computer program is stored, the computer program being implemented by a processor to perform the food safety intelligent question-answer reasoning method provided by the above methods, the method including: acquiring a head entity and a relation of a food safety question; inputting the head entity and the relation into a dual-module iterative inference model to carry out tail entity inference, and acquiring entity nodes and relation edges associated with the head entity and the relation; calculating the score values of the entity nodes according to the entity nodes and the relation edges connected with the entity nodes, and selecting the entity node with the highest score value as a tail entity of the food safety question; the dual-module iterative inference model comprises an extension module and an inference module, wherein the extension module is used for extending entity nodes and relationship edges associated with the head entity and the relationship; the reasoning module is used for updating the potential representation and the attention probability distribution of the newly expanded entity node and feeding the updated potential representation and the updated attention probability distribution of the newly expanded entity node back to the expanding module.
The above-described embodiments of the apparatus are merely illustrative, and the units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment. One of ordinary skill in the art can understand and implement it without inventive effort.
Through the above description of the embodiments, those skilled in the art will clearly understand that each embodiment can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware. With this understanding in mind, the above-described technical solutions may be embodied in the form of a software product, which can be stored in a computer-readable storage medium such as ROM/RAM, magnetic disk, optical disk, etc., and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the methods described in the embodiments or some parts of the embodiments.
The terms "first," "second," and the like in the embodiments of the present application are used for distinguishing between similar elements and not for describing a particular sequential or chronological order. It is to be understood that the terms so used are interchangeable under appropriate circumstances such that the embodiments of the application are capable of operation in other sequences than those illustrated or otherwise described herein, and that the terms "first" and "second" used herein generally refer to a class and do not limit the number of objects, for example, a first object can be one or more.
Finally, it should be noted that: the above examples are only intended to illustrate the technical solution of the present invention, but not to limit it; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present invention.

Claims (12)

1. A food safety intelligent question-answering reasoning method is characterized by comprising the following steps:
acquiring a head entity and a relation of a food safety question;
inputting the head entity and the relation into a dual-module iterative inference model to carry out tail entity inference, and acquiring entity nodes and relation edges associated with the head entity and the relation;
calculating the score values of the entity nodes according to the entity nodes and the relation edges connected with the entity nodes, and selecting the entity node with the highest score value as a tail entity of the food safety question;
the dual-module iterative inference model comprises an extension module and an inference module, wherein the extension module is used for extending entity nodes and relationship edges associated with the head entity and the relationship; the reasoning module is used for updating the potential representation and the attention probability distribution of the newly expanded entity node and feeding back the updated potential representation and the updated attention probability distribution of the newly expanded entity node to the expansion module;
inputting the head entity and the relationship into a dual-module iterative inference model to perform tail entity inference, and acquiring entity nodes and relationship edges associated with the head entity and the relationship, including:
under the condition that the preset hop count is one hop, determining an entity node and a relation edge of the next hop according to the head entity and the relation;
under the condition that the preset hop count is multi-hop, determining an entity node and a relationship edge of a first hop according to the head entity and the relationship;
after the first hop, determining the entity node and the relationship edge of the next hop according to the relationship and the entity node of the current hop;
inputting the head entity and the relationship into a dual-module iterative inference model for tail entity inference to obtain entity nodes and relationship edges associated with the head entity and the relationship, and further comprising:
acquiring the weight of the input relation edge of the newly expanded entity node according to the potential representation of the newly expanded entity node and the potential representation of the last hop entity node connected with the input relation edge of the newly expanded entity node;
and acquiring the updated potential representation of the newly expanded entity node according to the weight of the input relationship edge of the newly expanded entity node and the potential representation of the last hop entity node connected with the input relationship edge of the newly expanded entity node.
2. The food safety intelligent question-answer reasoning method of claim 1, wherein determining the entity node and the relation edge of the next hop according to the relation and the entity node of the current hop comprises:
calculating the probability of the output relationship edge of the entity node of the current hop according to the relationship and the entity node of the current hop, and acquiring the probability value of the output relationship edge of the entity node of the current hop;
and screening the output relation edges according to the probability values of the output relation edges to obtain the relation edges of the next hop and entity nodes connected with the relation edges of the next hop.
3. The food safety intelligent question-answering reasoning method of claim 2, wherein the obtaining of the probability value of the output relationship edge of the entity node of the current hop by calculating the relationship and the probability of the output relationship edge of the entity node of the current hop by the entity node of the current hop comprises:
acquiring a first aggregation matrix according to the embedded vector and the potential expression vector of the entity node connected with the output relationship edge of the entity node of the current hop and the embedded matrix of the output relationship edge of the entity node of the current hop;
acquiring a second aggregation matrix according to the embedding vector and the potential expression vector of the entity node of the current hop and the embedding matrix of the relationship;
and acquiring the probability value of the output relationship edge of the entity node of the current hop according to the first aggregation matrix, the second aggregation matrix and the attention probability distribution of the entity node of the current hop.
4. The food safety intelligent question-answer reasoning method of claim 2, wherein the output relationship edges are screened according to the probability values of the output relationship edges to obtain relationship edges of a next hop and entity nodes connected with the relationship edges of the next hop, comprising:
sorting the probability values of the output relationship edges;
and screening a preset number of output relationship edges with the probability value ranking in the front, and taking the screened output relationship edges and entity nodes connected with the screened output relationship edges as the relationship edges of the next hop and the entity nodes connected with the relationship edges of the next hop.
5. The food safety intelligent question-answer reasoning method of claim 1, wherein the head entity and the relationship are input into a dual module iterative reasoning model for tail entity reasoning to obtain entity nodes and relationship edges associated with the head entity and the relationship, further comprising:
adding the probability values of the input relationship edges of the newly expanded entity nodes to obtain a probability value addition result;
and normalizing the sum result of the probability values to obtain the updated attention probability distribution of the newly expanded entity node.
6. The food safety intelligent question-answer reasoning method of claim 5, wherein the calculating of the score value of the entity node according to the entity node and the relation edge connected with the entity node comprises:
acquiring the weight of the input relation edge of the entity node according to the updated potential representation of the entity node and the updated potential representation of the last hop entity node connected with the input relation edge of the entity node;
and determining the score value of the entity node according to the sum of the weights of the input relation edges of the entity node and the updated attention probability distribution of the entity node.
7. The food safety intelligent question-answering reasoning method of claim 6, wherein the calculation formula of the score values of the entity nodes is as follows:
ST(e)=aT(e)∑α(e)
wherein S isT(e) Representing the score value of the entity node e after T steps of jumping; a isT(e) Representing the attention probability distribution of the entity node e after T steps of jumping; α (e) represents the weight of the input relational edge of the entity node e.
8. The food safety intelligent question-answer reasoning method of claim 1, wherein before obtaining the head entity and the relationship of the food safety question sentence, the method comprises the following steps:
extracting entities and relationships by using food safety related data;
and carrying out vector embedding processing on the extracted entities and the relations to construct a food safety knowledge mapping network.
9. An intelligent food safety question-answering reasoning device is characterized by comprising:
the first acquisition module is used for acquiring the head entity and the relation of the food safety question;
the second acquisition module is used for inputting the head entity and the relation into a dual-module iterative inference model to carry out tail entity inference and acquiring entity nodes and relation edges associated with the head entity and the relation;
the calculation selection module is used for calculating the score values of the entity nodes according to the entity nodes and the relation edges connected with the entity nodes, and selecting the entity node with the highest score value as a tail entity of the food safety question sentence;
the dual-module iterative inference model comprises an extension module and an inference module, wherein the extension module is used for extending entity nodes and relationship edges associated with the head entity and the relationship; the reasoning module is used for updating the potential representation and the attention probability distribution of the newly expanded entity node and feeding back the updated potential representation and the updated attention probability distribution of the newly expanded entity node to the expansion module;
inputting the head entity and the relationship into a dual-module iterative inference model for tail entity inference, and acquiring entity nodes and relationship edges associated with the head entity and the relationship, wherein the method comprises the following steps:
under the condition that the preset hop count is one hop, determining an entity node and a relation edge of the next hop according to the head entity and the relation;
under the condition that the preset hop count is multi-hop, determining an entity node and a relationship edge of a first hop according to the head entity and the relationship;
after the first hop, determining the entity node and the relationship edge of the next hop according to the relationship and the entity node of the current hop;
inputting the head entity and the relationship into a dual-module iterative inference model to perform tail entity inference, and acquiring entity nodes and relationship edges associated with the head entity and the relationship, further comprising:
acquiring the weight of the input relation edge of the newly expanded entity node according to the potential representation of the newly expanded entity node and the potential representation of the last hop entity node connected with the input relation edge of the newly expanded entity node;
and acquiring the updated potential representation of the newly expanded entity node according to the weight of the input relationship edge of the newly expanded entity node and the potential representation of the last hop entity node connected with the input relationship edge of the newly expanded entity node.
10. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor when executing the computer program implements the steps of the food safety intelligent question-answer reasoning method according to any one of claims 1 to 8.
11. A non-transitory computer readable storage medium having stored thereon a computer program, wherein the computer program when executed by a processor implements the steps of the food safety intelligent question-answering reasoning method according to any one of claims 1 to 8.
12. A computer program product comprising a computer program, characterized in that the computer program, when being executed by a processor, carries out the steps of the food safety intelligent question-answering reasoning method according to any one of claims 1 to 8.
CN202111640639.2A 2021-12-29 2021-12-29 Intelligent food safety question-answer reasoning method and device Active CN114399051B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111640639.2A CN114399051B (en) 2021-12-29 2021-12-29 Intelligent food safety question-answer reasoning method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111640639.2A CN114399051B (en) 2021-12-29 2021-12-29 Intelligent food safety question-answer reasoning method and device

Publications (2)

Publication Number Publication Date
CN114399051A CN114399051A (en) 2022-04-26
CN114399051B true CN114399051B (en) 2022-11-01

Family

ID=81229550

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111640639.2A Active CN114399051B (en) 2021-12-29 2021-12-29 Intelligent food safety question-answer reasoning method and device

Country Status (1)

Country Link
CN (1) CN114399051B (en)

Family Cites Families (14)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7685141B2 (en) * 2007-06-06 2010-03-23 Yahoo! Inc. Connection sub-graphs in entity relationship graphs
US20140108321A1 (en) * 2012-10-12 2014-04-17 International Business Machines Corporation Text-based inference chaining
WO2015009682A1 (en) * 2013-07-15 2015-01-22 De, Piali Systems and methods for semantic reasoning
US10482139B2 (en) * 2013-11-05 2019-11-19 Google Llc Structured user graph to support querying and predictions
CN112119412A (en) * 2018-05-18 2020-12-22 伯耐沃伦人工智能科技有限公司 Neural network of map with attention
US11514498B2 (en) * 2019-03-07 2022-11-29 Beijing Jingdong Shangke Information Technology Co., Ltd. System and method for intelligent guided shopping
CN110929047B (en) * 2019-12-11 2023-04-28 中国人民解放军国防科技大学 Knowledge graph reasoning method and device for focusing on neighbor entity
EP3920048A1 (en) * 2020-06-02 2021-12-08 Siemens Aktiengesellschaft Method and system for automated visual question answering
CN111832922B (en) * 2020-06-30 2021-10-01 北方工业大学 Food safety event risk studying and judging method and device based on knowledge graph reasoning
CN112487168B (en) * 2020-12-11 2024-03-08 华润数字科技有限公司 Semantic question-answering method and device of knowledge graph, computer equipment and storage medium
CN112905762A (en) * 2021-02-05 2021-06-04 南京航空航天大学 Visual question-answering method based on equal attention-deficit-diagram network
CN113010663A (en) * 2021-04-26 2021-06-22 东华大学 Adaptive reasoning question-answering method and system based on industrial cognitive map
CN113779220B (en) * 2021-09-13 2023-06-23 内蒙古工业大学 Mongolian multi-hop question-answering method based on three-channel cognitive map and graph annotating semantic network
CN113849613B (en) * 2021-09-15 2023-04-18 北方工业大学 Food safety question-answering reasoning method, system and electronic equipment

Also Published As

Publication number Publication date
CN114399051A (en) 2022-04-26

Similar Documents

Publication Publication Date Title
CN110837602B (en) User recommendation method based on representation learning and multi-mode convolutional neural network
CN111339313A (en) Knowledge base construction method based on multi-mode fusion
Wu et al. Automatic knowledge graph construction: A report on the 2019 icdm/icbk contest
CN110046262A (en) A kind of Context Reasoning method based on law expert&#39;s knowledge base
CN115640410B (en) Knowledge map multi-hop question-answering method based on reinforcement learning path reasoning
CN111563192B (en) Entity alignment method, device, electronic equipment and storage medium
US11775594B2 (en) Method for disambiguating between authors with same name on basis of network representation and semantic representation
CN113780002B (en) Knowledge reasoning method and device based on graph representation learning and deep reinforcement learning
CN113360604B (en) Knowledge graph multi-hop question-answering method and model based on cognitive reasoning
Arora et al. Agribot: a natural language generative neural networks engine for agricultural applications
CN104484433B (en) A kind of books Ontology Matching method based on machine learning
CN112597316A (en) Interpretable reasoning question-answering method and device
CN115599899B (en) Intelligent question-answering method, system, equipment and medium based on aircraft knowledge graph
CN111639254A (en) System and method for generating SPARQL query statement in medical field
CN114254093A (en) Multi-space knowledge enhanced knowledge graph question-answering method and system
CN111274794A (en) Synonym expansion method based on transmission
CN110322959A (en) A kind of Knowledge based engineering depth medical care problem method for routing and system
Thayaparan et al. Explanationlp: Abductive reasoning for explainable science question answering
CN114399051B (en) Intelligent food safety question-answer reasoning method and device
CN110909174B (en) Knowledge graph-based method for improving entity link in simple question answering
CN117131933A (en) Multi-mode knowledge graph establishing method and application
Breskvar et al. Multi-target regression rules with Random Output Selections
CN115587192A (en) Relationship information extraction method, device and computer readable storage medium
CN106991432A (en) The feature selection approach of forest optimized algorithm based on scoring
CN106960064B (en) Geometric auxiliary line adding method based on self-learning

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant