Search

CN-121328707-B - Knowledge reasoning method and system

CN121328707BCN 121328707 BCN121328707 BCN 121328707BCN-121328707-B

Abstract

The invention relates to the technical field of knowledge graph reasoning, in particular to a knowledge reasoning method and a system, comprising the steps of receiving a user inquiry statement containing a reasoning rule identifier, identifying the reasoning rule identifier according to a preset rule, and calling rule definition information containing reasoning condition information and top rule types from a rule database based on the reasoning rule identifier if the user inquiry statement exists; if the reasoning condition information contains nested reasoning rule identifications, the reasoning condition information is converted into a basic triplet mode set layer by layer through recursion analysis, then the set is structured according to the top rule type to obtain intermediate query elements, a query sentence is generated by combining with an original query sentence of a user, and a reasoning result is obtained after the execution. The method solves the problems that the fixed architecture of the traditional reasoning engine is difficult to adapt to the dynamic property, so that the reasoning logic needs to be modified when the engine is required to be redeployed after the rule is updated and the data structure is changed, and the application flexibility and the expansion capability of the reasoning engine are limited. The invention has the effect of improving the flexibility and expansibility of knowledge reasoning.

Inventors

  • ZHANG YU
  • MENG CHAO
  • LIU KAI
  • QU YINGYING

Assignees

  • 途普智能科技(北京)有限公司

Dates

Publication Date
20260508
Application Date
20250923

Claims (8)

  1. 1. A method of knowledge reasoning, comprising: Responding to the query request, and receiving a query statement input by a user; Judging whether an inference rule identifier exists in the query statement input by the user or not based on a preset recognition rule, wherein the inference rule identifier refers to a unique mark associated with the preset inference rule; If the inference rule identification exists, acquiring corresponding rule definition information from a preset rule database based on the inference rule identification, wherein the rule definition information comprises inference condition information and a top rule type; analyzing the reasoning condition information, if the reasoning condition information contains nested reasoning rule identifications, recursively acquiring and analyzing rule definition information corresponding to the nested reasoning rule identifications until all the reasoning condition information is converted into a basic triplet mode set, wherein the basic triplet mode set is a result finally output by the recursion analysis and only contains an array of basic triples and filtering conditions, and all the nested rule identifications are completely expanded and replaced; Carrying out corresponding structuring processing on the basic triplet mode set based on a top-level rule type to obtain an intermediate query element, wherein the top-level rule type is the type of the reasoning rule originally called by the user, and comprises a relationship type and an attribute type; obtaining a target query sentence based on the intermediate query element and the query sentence input by the user, including: Performing query fusion processing on the query statement input by the user and the intermediate query element to generate an intermediate query statement; Performing variable validity check on the intermediate query statement; if the verification is passed, determining the intermediate query statement as a target query statement; executing the target query statement to obtain an inference result; performing query fusion processing on the query statement input by the user and the intermediate query element to generate an intermediate query statement, including: Analyzing the query statement input by the user to obtain an original graph mode; traversing each triplet pattern in the original graph pattern to obtain a target triplet pattern containing an inference rule identifier; Replacing the reasoning rule identification in the target triplet mode with the intermediate query element to obtain a replaced graph mode; And combining the replaced graph mode with the rest of the original graph modes to generate an intermediate query statement.
  2. 2. The knowledge reasoning method of claim 1, wherein identifying whether a query statement has a reasoning rule identification based on a preset recognition rule comprises: extracting semantic information of a query sentence; and matching the semantic information with a preset identification rule, and judging that an inference rule identifier exists if the matching is successful.
  3. 3. The knowledge reasoning method of claim 1, wherein the reasoning rule identification includes rule name information; if the inference rule identification exists, acquiring corresponding rule definition information from a preset rule database based on the inference rule identification, wherein the method comprises the following steps: Acquiring a rule configuration table of a preset database; inputting rule name information into a rule configuration table for inquiring to obtain corresponding rule configuration information; And extracting rule configuration information to obtain rule definition information.
  4. 4. The knowledge reasoning method of claim 1, wherein, The rule definition information also comprises return definition information and filtering information; performing corresponding structuring processing on the basic triplet mode set based on the top rule type to obtain an intermediate query element, wherein the method comprises the following steps: If the top rule type is a relation type, extracting a logic operator among all the triplet modes in the basic triplet mode set; Combining based on the returned definition information, the basic triplet mode set and the logic operator to obtain an initial query element; converting the filtering information to obtain a constraint expression; An intermediate query element is derived based on the constraint expression and the initial query element.
  5. 5. The knowledge reasoning method of claim 4, wherein, And carrying out corresponding structuring treatment on the basic triplet mode set based on the top rule type to obtain an intermediate query element, and further comprising: If the top rule type is an attribute type, extracting a logic operator among all the triplet modes in the basic triplet mode set; Combining triples related by shared variables in a basic triplet mode set to obtain a basic graph mode, wherein the shared variable related finger triplet modes are connected together through the same variables; logically combining the basic graph modes based on a logic operator to form a first graph mode; converting the filtering information to obtain a constraint expression; combining the constraint expression with the first graph mode to generate a target graph mode; an intermediate query element is determined based on the target graph schema and the returned definition information.
  6. 6. A knowledge reasoning system, characterized in that a knowledge reasoning method as claimed in claim 1 is performed, the system comprising: the receiving module is used for responding to the query request and receiving a query statement input by a user; the judging module is used for judging whether the query statement input by the user has an inference rule mark or not based on a preset recognition rule; the acquisition module is used for acquiring corresponding rule definition information from a preset rule database based on the inference rule identification if the inference rule identification exists, wherein the rule definition information comprises inference condition information and top rule types; the first analysis module is used for analyzing the reasoning condition information, and if the reasoning condition information contains nested reasoning rule identifiers, rule definition information corresponding to the nested reasoning rule identifiers is recursively acquired and analyzed until all the reasoning condition information is converted into a basic triplet mode set; The second analysis module is used for carrying out corresponding structuring treatment on the basic triplet mode set based on the top rule type to obtain an intermediate query element; the query construction module is used for obtaining a target query statement based on the intermediate query element and the query statement input by the user; And the execution engine module is used for executing the target query statement to obtain an inference result.
  7. 7. An apparatus comprising a memory and a processor, the memory having stored thereon a computer program capable of being loaded by the processor and performing the knowledge reasoning method of any of claims 1 to 5.
  8. 8. A computer readable storage medium, characterized in that a computer program is stored which can be loaded by a processor and which performs the knowledge reasoning method as claimed in any of the claims 1 to 5.

Description

Knowledge reasoning method and system Technical Field The invention relates to the technical field of knowledge graph reasoning, in particular to a knowledge reasoning method and system. Background Under the background of the high-speed development of information technology, the knowledge graph is used as a core carrier of structured knowledge, and the systematic storage and efficient associated query of massive knowledge are realized through the accurate modeling of entities and relations, so that the knowledge graph becomes a key technical support in the fields of intelligent question-answering, recommendation systems, decision support and the like. Along with the expansion of the application scene of the knowledge graph, the complexity of the user on the reasoning requirement is continuously improved. In the prior art, an inference engine is mostly constructed based on a fixed rule set or a specific logic programming language, and performs logic deduction on data in a knowledge graph through a preset static rule to obtain unknown entity relationship or attribute information. However, in practical application, the data structure of the knowledge graph can be dynamically changed along with the updating of the business scene, the inference rule needs to be adjusted according to new knowledge logic or business requirements, and the fixed architecture of the traditional inference engine is difficult to adapt to the dynamics, so that the inference logic needs to be greatly modified when the engine is required to be redeployed after the rule is updated and the data structure is changed, and the application flexibility and the expansion capability of the inference engine are greatly limited. Disclosure of Invention The invention aims to provide a knowledge reasoning method which has the characteristics of improving the flexibility and expansibility of knowledge reasoning. The first object of the present invention is achieved by the following technical solutions: a knowledge reasoning method, comprising: Responding to the query request, and receiving a query statement input by a user; judging whether an inference rule mark exists in the query statement or not based on a preset recognition rule; If the inference rule identification exists, acquiring corresponding rule definition information from a preset rule database based on the inference rule identification, wherein the rule definition information comprises inference condition information and a top rule type; Analyzing the reasoning condition information, and recursively acquiring and analyzing rule definition information corresponding to the nested reasoning rule identifications if the reasoning condition information contains the nested reasoning rule identifications until all the reasoning condition information is converted into a basic triplet mode set; carrying out corresponding structuring treatment on the basic triplet mode set based on the top rule type to obtain an intermediate query element; obtaining a query sentence based on the intermediate query element and the query sentence input by the user; and executing the query statement to obtain an inference result. By adopting the technical scheme, firstly, the query statement input by the user is judged based on the preset identification rule, when the inference rule identification exists, the corresponding rule definition information is called from the rule database based on the inference rule identification, and the nested rule possibly existing is converted into the basic triplet mode set layer by layer through the recursion analysis mechanism, so that the problem of logic fracture in a complex inference scene is effectively avoided, then, the structuring processing is carried out according to the top rule type, the query statement is reconstructed by combining with the original query statement, finally, the output of the inference result is carried out based on the query statement, different inference requirements are dynamically adapted, the completeness and the accuracy of knowledge inference are guaranteed, and the flexibility and the expansibility of the knowledge inference are greatly improved. The present invention may be further configured in a preferred example to: Identifying whether the query statement has an inference rule identification based on a preset identification rule comprises the following steps: extracting semantic information of a query sentence; and matching the semantic information with a preset identification rule, and judging that an inference rule identifier exists if the matching is successful. By adopting the technical scheme, when the semantic information of the query statement is successfully matched with the preset recognition rule, the existence of the inference rule identification is judged, the accuracy of inference triggering is effectively improved, and the knowledge inference can be adapted to different business scenes. The present invention may be further config