Knowledge graph query method, device and system, electronic equipment and storage medium
Patent Information
- Application Number
- CN202380099915.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-30
- Publication Date
- 2026-02-13
AI Technical Summary
The prior art is difficult to fully utilize the respective advantages of the tagged attribute graph (LPG) and resource description framework (RDF) when querying knowledge graphs, resulting in low query efficiency.
Take advantage of their respective advantages by obtaining the query request and matching it with a rule base containing at least one rule, identifying the query intent, selecting the appropriate knowledge graph (LPG or RDF).
The query efficiency is improved. By identifying the query intention and selecting the appropriate knowledge graph, the effective utilization of LPG and RDF is achieved, and the accuracy and efficiency of query results are improved.
Smart Images

Figure CN121532759A_ABST
Abstract
Description
Method, device, system, electronic device and storage medium for querying knowledge graph Technical Field
[0001] The present invention relates to the field of knowledge graph technology, and in particular to methods, devices, systems, electronic devices, and storage media for querying knowledge graphs. Background Art
[0002] A knowledge graph is a network of data entities and their relationships, illustrated in a graphical format. Essentially, a knowledge graph is a knowledge base that represents a semantic network—a knowledge base with a directed graph structure. Knowledge graphs can be used to contextualize data (structured and unstructured) into a meaningful information network.
[0003] Labeled Property Graph (LPG) and Resource Description Framework (RDF) are two common approaches to building knowledge graphs. LPG focuses on efficient deep data traversal, path analysis, and storage of arbitrary graph data. RDF emphasizes atomic decomposition of data suitable for ontology creation and data exchange.
[0004] Summary of the Invention
[0005] The embodiments of the present invention provide a method, device, system, electronic device and storage medium for querying a knowledge graph.
[0006] A method for querying a knowledge graph, comprising:
[0007] Get query request;
[0008] Matching the query request with a rule base comprising at least one rule;
[0009] When a rule associated with the query request is matched from the rule base, the query request and the rule associated with the query request are sent to a first knowledge graph of the domain, so that the first knowledge graph determines a first output based on the query request and the rule associated with the query request; otherwise, the query request is sent to a second knowledge graph of the domain, so that the second knowledge graph determines a second output based on the query request, wherein the first knowledge graph is established in RDF format and the second knowledge graph is established in LPG format.
[0010] Therefore, based on the matching judgment between the query request and the rules, the query intent can be identified, and the first knowledge graph or the second knowledge graph can be selected to execute the query based on the intent, thereby making full use of the respective advantages of LPG and RDF and improving query efficiency.
[0011] In one embodiment, matching the query request with a rule base comprising at least one rule includes:
[0012] Extracting entities and relationships between entities from the query request;
[0013] Matching the entity and the relationship with each rule in the rule base, each rule including a respective entity term and a respective relationship term;
[0014] When the entity is identical to the entity item of the rule in the rule base, and / or the relationship is identical to the relationship item of the rule, it is determined that the match with the rule is successful; when the entity is different from the entity item of the rule in the rule base and the relationship is different from the relationship item of the rule, it is determined that the match with the rule is unsuccessful.
[0015] Therefore, whether the query request matches the rule is determined by comparing the results of entities and relationships, which improves the accuracy of intent judgment.
[0016] In one embodiment, it includes:
[0017] determining a language format of the query request;
[0018] When the language format of the query request does not match the first knowledge graph, before sending the query request and the rule associated with the query request to the first knowledge graph of the domain, the language format of the query request is converted into a language format that matches the first knowledge graph.
[0019] Therefore, through language format conversion, users who do not understand the query language format of the first knowledge graph can also query the first knowledge graph normally, realizing a user-friendly query method and lowering the usage threshold.
[0020] In one embodiment, it includes:
[0021] determining a language format of the query request;
[0022] When the language format of the query request does not match the second knowledge graph, before sending the query request to the second knowledge graph of the domain, the language format of the query request is converted into a language format that matches the second knowledge graph.
[0023] Therefore, through language format conversion, users who do not understand the query language format of the second knowledge graph can also query the second knowledge graph normally, realizing a user-friendly query method and lowering the usage threshold.
[0024] In one embodiment, the entity includes at least one of the following:
[0025] A specific object with a unique identifier;
[0026] A non-specific object that does not have a unique identifier.
[0027] It can be seen that entities can have multiple forms of expression, which enriches the matching methods and improves applicability.
[0028] A device for querying a knowledge graph, comprising:
[0029] The acquisition module is used to obtain the query request;
[0030] a matching module, configured to match the query request with a rule base comprising at least one rule;
[0031] A sending module is used to send the query request and the rules associated with the query request to a first knowledge graph of the domain when a rule associated with the query request is matched from the rule base, so that the first knowledge graph determines a first output based on the query request and the rules associated with the query request; otherwise, send the query request to a second knowledge graph of the domain, so that the second knowledge graph determines a second output based on the query request, wherein the first knowledge graph is established in RDF mode and the second knowledge graph is established in LPG mode.
[0032] Therefore, based on the matching judgment between the query request and the rules, the query intent can be identified, and the first knowledge graph or the second knowledge graph can be selected to execute the query based on the intent, thereby making full use of the respective advantages of LPG and RDF and improving query efficiency.
[0033] In one embodiment, the matching module is used to extract entities and the relationships between entities from the query request; match the entities and the relationships with each rule in the rule base, each rule containing its own entity item and its own relationship item; wherein when the entity is the same as the entity item of the rule in the rule base, and / or the relationship is the same as the relationship item of the rule, it is determined that the match with the rule is successful; when the entity is different from the entity item of the rule in the rule base and the relationship is different from the relationship item of the rule, it is determined that the match with the rule is unsuccessful.
[0034] Therefore, whether the query request matches the rule is determined by comparing the results of entities and relationships, which improves the accuracy of intent judgment.
[0035] In one embodiment, a conversion module is included for determining the language format of the query request; when the language format of the query request does not match the first knowledge graph, before sending the query request and the rules associated with the query request to the first knowledge graph of the domain, the language format of the query request is converted into a language format that matches the first knowledge graph.
[0036] Therefore, through language format conversion, users who do not understand the language format of the first knowledge graph can also query the first knowledge graph normally, realizing a user-friendly query method and lowering the usage threshold.
[0037] In one embodiment, a conversion module is included for determining the language format of the query request; when the language format of the query request does not match the second knowledge graph, the language format of the query request is converted into a language format that matches the second knowledge graph before sending the query request to the second knowledge graph of the field.
[0038] Therefore, through language format conversion, users who do not understand the language format of the second knowledge graph can also query the second knowledge graph normally, realizing a user-friendly query method and lowering the usage threshold.
[0039] A system for querying a knowledge graph, comprising:
[0040] The first knowledge graph in the field is built in the form of a resource description framework;
[0041] A second knowledge graph of the domain is established in the form of a labeled attribute graph;
[0042] A rule base, used to store at least one rule;
[0043] A device for querying a knowledge graph, configured to obtain a query request; match the query request with the rule base; when a rule associated with the query request is matched from the rule base, send the query request and the rule associated with the query request to the first knowledge graph, so that the first knowledge graph determines a first output based on the query request and the rule associated with the query request; otherwise, send the query request to the second knowledge graph, so that the second knowledge graph determines a second output based on the query request.
[0044] Therefore, based on the matching judgment between the query request and the rules, the query intent can be identified and the first or second knowledge graph can be selected to execute the query, thereby fully utilizing the respective advantages of LPG and RDF and improving query efficiency.
[0045] An electronic device, comprising:
[0046] processor;
[0047] a memory for storing executable instructions of the processor;
[0048] The processor is used to read the executable instructions from the memory and execute the executable instructions to query the knowledge graph method as described in any one of the above items.
[0049] A computer-readable storage medium having computer instructions stored thereon, wherein the computer instructions, when executed by a processor, implement the method for querying a knowledge graph as described in any of the above items.
[0050] A computer program product comprises a computer program, wherein when the computer program is executed by a processor, the method for querying a knowledge graph as described in any one of the above items is implemented. BRIEF DESCRIPTION OF THE DRAWINGS
[0051] The preferred embodiments of the present invention will be described in detail below with reference to the accompanying drawings, so that those skilled in the art will understand the above and other features and advantages of the present invention more clearly. In the accompanying drawings:
[0052] FIG1 is an exemplary flowchart of a method for querying a knowledge graph according to an embodiment of the present invention.
[0053] FIG2 is an exemplary structural diagram of a system for querying a knowledge graph according to an embodiment of the present invention.
[0054] FIG3 is a schematic diagram of an exemplary process of querying a knowledge graph according to an embodiment of the present invention.
[0055] FIG4 is an exemplary schematic diagram of querying a knowledge graph in an industrial scenario according to an embodiment of the present invention.
[0056] FIG5 is an exemplary structural diagram of an apparatus for querying a knowledge graph according to an embodiment of the present invention.
[0057] FIG6 is an exemplary structural diagram of an electronic device according to an embodiment of the present invention.
[0058] The accompanying drawings are numerals as follows: DETAILED DESCRIPTION
[0059] In order to make the purpose, technical solutions and advantages of the present invention more clear, the present invention is further described in detail with reference to the following examples.
[0060] For the sake of brevity and intuitiveness in description, the solution of the present invention is explained below by describing several representative implementations. A large number of details in the implementations are only used to help understand the solution of the present invention. However, it is obvious that the technical solution of the present invention may not be limited to these details when implemented. In order to avoid unnecessarily obscuring the solution of the present invention, some implementations are not described in detail, but only a framework is given. Hereinafter, "including" means "including but not limited to", and "according to..." means "at least according to..., but not limited to only according to...". Due to the language habits of Chinese, when the number of a component is not specifically specified below, it means that the component can be one or more, or can be understood as at least one.
[0061] First, let's provide an illustrative explanation of concepts related to knowledge graphs. Knowledge graphs describe objective things in the form of graphs, where graphs specifically include nodes and edges. Nodes in a knowledge graph can represent concepts and entities, where concepts are abstract and entities are concrete. Edges represent the relationships and attributes of things or concepts. Attributes represent the internal characteristics of things or concepts, while relationships represent external connections. Often, people simplify the description of knowledge graphs, collectively referring to entities and concepts as entities and relationships and attributes as relationships. In this way, knowledge graphs describe entities and the relationships between them. Entities can be people, places, organizations, concepts, and so on. Relationships can be relationships between people, relationships between people and organizations, relationships between concepts and objects, and so on.
[0062] Considering that LPG has the advantage of efficient query and RDF has powerful modeling and reasoning capabilities, the embodiment of the present invention combines the respective advantages of LPG and RDF and proposes a new knowledge graph query solution based on identifying query intent.
[0063] Figure 1 is an exemplary flow chart of a method for querying a knowledge graph according to an embodiment of the present invention. As shown in Figure 1, the method includes:
[0064] Step 101: Get a query request.
[0065] Here, user input including a query request can be received from various user interfaces. For example, the query request can be: "Query the status of the resource named Motor1." Specifically, the query request can be expressed using various query languages. For example, the query language can be Cypher or SPARQL, etc.
[0066] The above exemplary descriptions are typical examples of query languages. Those skilled in the art will appreciate that such descriptions are merely exemplary and are not intended to limit the scope of protection of the embodiments of the present invention.
[0067] Step 102: Match the query request with a rule base containing at least one rule.
[0068] Here, the rule base can be obtained in various ways such as user editing, remote downloading, and third-party calling. The rule base contains at least one rule. Each rule contains its own reasoning logic. Exemplarily, each rule contains its own entity item and its own relationship item, wherein the reasoning logic can be characterized based on the combination of the entity item and the relationship item. Using the reasoning logic, the conclusion of the rule can be inferred. For example, the reasoning method can be specifically implemented as follows: when all Ys of X are healthy, the state of X is healthy (wherein the relationship between Y and X is: X has Y), where: X and Y are entity items, and the relationship item is X has Y. X and Y can be instantiated as specific entities (for example, X is instantiated as a sports device, and Y is instantiated as a motor), or X and Y are non-instantiated concepts.
[0069] In one embodiment, matching the query request with a rule base containing at least one rule in step 102 includes:
[0070] (1) Extract entities and relationships between entities from query requests;
[0071] (2) Matching entities and relationships with each rule in the rule base, where each rule contains its own entity item and its own relationship item; when the entity item of the entity is the same as that of the rule in the rule base, and / or the relationship item is the same as that of the rule, it is determined that the match with the rule is successful; when the entity item of the entity is different from that of the rule in the rule base and the relationship item is different from that of the rule, it is determined that the match with the rule is unsuccessful.
[0072] Preferably, an entity includes at least one of the following: a specific object with a unique identifier; a non-specific object without a unique identifier. For example, a non-specific object without a unique identifier may be "name," and its attributes may be specific names such as Zhang San or Li Si. A specific object with a unique identifier may be a specific object such as "Zhang San" or "Li Si."
[0073] For example, assume that the rule base contains three rules: Rule 1, Rule 2, and Rule 3. Rule 1 contains entity item a, entity item c, and relationship item b; Rule 2 contains entity item d, entity item e, and relationship item f; and Rule 3 contains entity item e, entity item f, and relationship item b. The entity extracted from the query request is a, and the relationship between the entities is b. Entity a in the query request is the same as entity item a in Rule 1, so the query request matches Rule 1. The query request has no overlapping content with Rule 2, so it does not match Rule 2. Relationship b in the query request is the same as relationship item b in Rule 1, so it matches Rule 3. Therefore, the rules that match the query request are determined to be: Rule 1 and Rule 3.
[0074] When a rule associated with the query request is matched from the rule base (corresponding to the "Y" branch), step 103 is executed and the process ends; otherwise (that is, when a rule associated with the query request cannot be matched from the rule base, corresponding to the "N" branch), step 104 is executed and the process ends.
[0075] Step 103: Send the query request and the rules associated with the query request to the first knowledge graph of the domain, so that the first knowledge graph determines a first output based on the query request and the rules associated with the query request.
[0076] Here, a query request and rules associated with the query request are sent to a first knowledge graph of the domain, so that the first knowledge graph determines a first output based on the query request and the rules associated with the query request. For example, the first output includes: (1) a hit result based on the query request; (2) an inference conclusion determined based on the rules associated with the query request.
[0077] Step 104: Send the query request to the second knowledge graph of the domain, so that the second knowledge graph determines a second output based on the query request, where the first knowledge graph is established in RDF format and the second knowledge graph is established in LPG format. For example, the second output includes: hit results based on the query request.
[0078] Specifically, RDF comes from the concept of the semantic web. The semantic web is considered an extension of the standard web, retaining HTTP as a protocol for data exchange and adding RDF-type schemas for information storage and retrieval, and uniquely identifying relationships between documents. The goal of this standard is to enable the representation, storage, and exchange of resources, especially metadata in a graph-native manner on the web. The main use of LPG is to achieve efficient storage, fast query, and fast traversal of graph data; it is also used to extend data nodes with arbitrary properties and fields to obtain valuable information about the data. LPG and RDF are considered to be two opposite graph modeling approaches, the latter emphasizes atomic decomposition of data suitable for ontology creation and data exchange, and the former focuses on efficient deep data traversal, path analysis, and storage of arbitrary graph data.
[0079] Here, the domain includes not only industries such as finance, industry, and corporate management, but also organizations, units, or workflows within the industry, etc. For example, the domain can be specifically the industrial domain, or it can be a group, factory, plant, production line, equipment, and workpiece within the industrial domain, etc. The first knowledge graph and the second knowledge graph belong to the same domain and have the same domain knowledge. For example, the domain can be implemented as an automobile assembly industrial production line. Then, the first knowledge graph and the second knowledge graph are two types of knowledge graphs, established using RDF and LPG respectively, and contain various knowledge in the automobile assembly industrial production line.
[0080] Knowledge synchronization can be achieved between the first knowledge graph and the second knowledge graph on a regular basis. Preferably, the query request in step 101 is a query request for the fields of the first knowledge graph and the second knowledge graph.
[0081] In one embodiment, the method includes: determining a language format of a query request; and when the language format of the query request does not match a first knowledge graph, converting the language format of the query request to a language format that matches the first knowledge graph before sending the query request and rules associated with the query request to the first knowledge graph of the domain. Preferably, the language format that matches the first knowledge graph is SPARQL.
[0082] In one embodiment, the method includes: determining a language format of a query request; and when the language format of the query request does not match the second knowledge graph, converting the language format of the query request to a language format that matches the second knowledge graph before sending the query request to the second knowledge graph of the domain. Preferably, the language format that matches the second knowledge graph is Cypher.
[0083] Figure 2 is an exemplary structural diagram of a system for querying a knowledge graph according to an embodiment of the present invention. As shown in Figure 2, the system for querying a knowledge graph includes: a first knowledge graph 13 of a domain, established in RDF format; a second knowledge graph 14 of a domain, established in LPG format; a rule base 12 for storing at least one rule; a device 11 for querying a knowledge graph, for obtaining a query request; matching the query request with the rule base 12; when a rule associated with the query request is matched from the rule base 12, the query request and the rule associated with the query request are sent to the first knowledge graph 13, so that the first knowledge graph 13 determines a first output based on the query request and the rule associated with the query request; otherwise, the query request is sent to the second knowledge graph 14, so that the second knowledge graph 14 determines a second output based on the query request.
[0084] The device 11 for querying the knowledge graph is also used to determine the language format of the query request; when the language format of the query request does not match the first knowledge graph 13, before sending the query request and the rules associated with the query request to the first knowledge graph 13, the language format of the query request is converted into a language format that matches the first knowledge graph 13; when the language format of the query request does not match the second knowledge graph 14, before sending the query request to the second knowledge graph 14, the language format of the query request is converted into a language format that matches the second knowledge graph 14.
[0085] Preferably, the system for querying the knowledge graph also includes: a data synchronization mechanism 15, which is used to realize synchronous update of knowledge between the first knowledge graph 13 and the second knowledge graph 14.
[0086] Based on the system structure shown in Figure 2, when a user inputs a query request in his or her customary query language, the device 11 for querying the knowledge graph will formulate a strategy pattern for the user's query statement. Here, the strategy pattern attempts to identify the user's query intention and convert it into a query statement that can be recognized by the corresponding knowledge graph. Then, the corresponding knowledge graph uses the query request after format conversion to respond to the user's needs. Throughout the execution process of the user's needs, the solution can automatically identify the user's purpose and return the required data with high efficiency. It can be seen that the embodiment of the present invention combines the respective advantages of LPG and RDF, but adopts a dynamic recognition method to determine the user's intention and then provide an effective response.
[0087] The following describes an exemplary process of querying a knowledge graph. Figure 3 is a schematic diagram of an exemplary process of querying a knowledge graph according to an embodiment of the present invention.
[0088] In the workflow of Figure 3 , a query request 20 is first received. Then, an extraction process 20 is performed on query request 20 to extract an entity list containing all entities in query request 20 and a relationship list containing all relationships in query request 20. Next, the entity list and relationship list are compared against each rule in the rule base. When at least one entity in the entity list is identical to an entity term in a rule, and / or at least one relationship in the relationship list is identical to a relationship term in a rule, the entity list is considered to match the rule. Then, based on the matching results 23, a decision is made to send the query request to the LPG knowledge graph 26 or the RDF knowledge graph 27 to execute the specific query. When the matching results 23 contain a matching rule (i.e., a rule matching the query request is found in the rule base), the matching rule (which can be one or more) and the query request are sent to the RDF knowledge graph 27. When the matching results 23 do not contain a matching rule (i.e., no rule matching the query request is found in the rule base), the query request is sent to the LPG knowledge graph 26.
[0089] When the language format of the query request sent to the LPG knowledge graph 26 does not conform to the LPG knowledge graph 26, a first language format conversion 24 is performed on the query request to convert it into a query language format that conforms to the LPG knowledge graph 26. When the language format of the query request sent to the RDF knowledge graph 27 does not conform to the RDF knowledge graph 27, a second language format conversion 25 is performed on the query request to convert it into a query language format that conforms to the RDF knowledge graph 27.
[0090] In the LPG knowledge graph 26, a search is performed based on a query request, and the search results are output. In the RDF knowledge graph 27, a search is performed based on a query request, and reasoning is performed based on matching rules to generate reasoning results, and the search results and reasoning results are output.
[0091] The following describes an embodiment of the present invention using an industrial scenario as an example. FIG4 is an exemplary schematic diagram of querying a knowledge graph in an industrial scenario according to an embodiment of the present invention.
[0092] Sports equipment has multiple motors, each with its own health status. While the health status of each motor can be queried and obtained at any time, there is currently a lack of direct, on-site data to tell users whether the sports equipment is healthy at the current time.
[0093] Some inference rules can be configured to tell the system that when all motors of the motion device are healthy, the user can be directly told that the current motion device is healthy. In Figure 4, the motion device 41, the first motor 42, and the second motor 45 belong to the resource node 30. The state parameters of the motion device belong to the state node 31. The specific parameters 47 of the parameter set belong to the parameter set node 32. The motion device 41 has a relationship 51 with the first motor 42 and the second motor 45: has a motor (hasMotor); the motion device 41 has a relationship 50 with the state 46 of the motion device: has a status (hasStatus); the first motor 42 has a relationship 50 with the state 43 of the first motor: has a status (hasStatus); the first motor 42 has a relationship 52 with the parameter 47 of the parameter set: has a parameter set (hasParameterSet).
[0094] Exemplarily: the known inference rules of this scenario are: String updateRules = “[rule1: (?motionDevice NS: hasMotor?motor), (?motor NS: hasStatus?status), ((?status NS: hasProperty NS: value / OK)-> (?x NS: hasMotor?motor;
[0095] In this example, the entity is a non-specific object that does not have a unique identifier. Therefore, the entity list is [NS:value] and the relationship is ['hasMotor', 'hasStatus', 'hasProperty'].
[0096] Alternatively, the inference rules can be characterized as: [rule1:(Resource:motionDevice NS:hasMotor?motor),(?motor NS:hasStatus?status),(?status NS:hasProperty NS:value / OK)->(Resource:motionDevice NS:hasMotor?motor),noValue(Resource:motionDevice,NS:hasMotor,?y),(Resource:motionDevice,NS:hasStatus,?status),(?status,NS:hasProperty,NS:value / OK)];
[0097] In this example, the entity uses both a non-specific object that does not have a unique identifier and a specific object that has a unique identifier.
[0098] At this point, the entity list is [motionDevice, NS:value], and the relationship is ['hasMotor', 'hasStatus', 'hasProperty']. Among them, motionDevice is a specific object, and value is a non-specific object.
[0099] When the user's query request is: "MATCH(:Resource{browseName:'Motor1'})-[r:hasStatus]->(status) RETURN status;"
[0100] Analyzing this query, we automatically identify the entity [Resource:Motor1'] and the relationship ['hasStatus']. Comparison reveals that the entity and relationship the user is interested in overlap with the corresponding rule, with the overlapping portion being ['hasStatus']. Therefore, the query is related to the inference rule. Therefore, both the query and the inference rule are sent to the RDF knowledge graph for processing.
[0101] In order to ensure the comprehensiveness of the final response data, the query request can be converted into a sparql statement: sparql: "SELECT? status Where<http: / / opcfoundation.org / UA / Robotics / Motor / Motor1 / ><http: / / opcfoundation.org / UA / hasStatus / > ? status".
[0102] Similarly, when the user's query request is:
[0103] When using "MATCH(:Resource{browseName:'Motor1'})-[r:hasParameterSet]->(ParameterSet)RETURN ParameterSet;", the entity list is ['Resource:Motor1'] and the relationship list is ['hasParameterSet']. This comparison reveals that the entities and relationships the user is interested in do not overlap with the rule list. Therefore, to leverage LPG's fast query capabilities, the user's query request is directly pushed to the LPG knowledge graph for response processing.
[0104] The above describes how to handle queries written in Cypher. Next, we'll explain how to handle queries written in Sparql.
[0105] When the user's query request is: "SELECT? status Where<http: / / opcfoundation.org / UA / Robotics / MotionDevice / ><http: / / opcfoundation.org / UA / hasStatus> ? status'";
[0106] The entity and relationship are ['Resource:MotionDevice'] and ['hasStatus'], respectively. After comparison, the overlap with the rule is ['hasStatus']. Therefore, the RDF knowledge graph is directly used to query the query request and output the inference results of the rule.
[0107] When the user's query request is: "SELECT? ParameterSet Where<http: / / opcfoundation.org / UA / Robotics / Motor / Motor1 / ><http: / / opcfoundation.org / UA / hasParameterSet / > ? ParameterSet”,
[0108] As you can see, the entity and relationship are ['Resource:Motor1'] and ['hasParameterSet'] respectively. After comparison, it is found that there is no overlap. Therefore, the query request is converted to:
[0109] “MATCH(:Resource{browseName:'Motor1'})-[r:hasParameterSet]->(ParameterSet)RETURN ParameterSet;” and use LPG knowledge graph for processing.
[0110] It can be seen that while the industry is researching converters for converting LPG knowledge graphs and RDF knowledge graphs to each other, the embodiments of the present invention provide a new automatic solution from a novel perspective. This solution fully utilizes the respective advantages of LPG and RDF to effectively respond to users' different purposes. In addition, the embodiments of the present invention lower the user's usage threshold. Users no longer need to master two query languages at the same time, nor do they need to understand the underlying data storage. In addition, the embodiments of the present invention do not focus on the mapping of the data structure itself, but transfer the mapping to the query statement. With structured query statements, the difficulty of conversion is significantly reduced, which has greater reference significance for actual production practice.
[0111] FIG5 is an exemplary structural diagram of an apparatus for querying a knowledge graph according to an embodiment of the present invention. As shown in FIG5 , the apparatus 500 for querying a knowledge graph includes:
[0112] An acquisition module 501 is used to acquire a query request; a matching module 502 is used to match the query request with a rule base containing at least one rule; a sending module 503 is used to send the query request and the rules associated with the query request to a first knowledge graph of the domain when a rule associated with the query request is matched from the rule base, so that the first knowledge graph determines a first output based on the query request and the rules associated with the query request; otherwise, the query request is sent to a second knowledge graph of the domain, so that the second knowledge graph determines a second output based on the query request, wherein the first knowledge graph is established in a resource description framework manner and the second knowledge graph is established in a labeled attribute graph manner.
[0113] In one embodiment, the matching module 502 is used to extract entities and relationships between entities from a query request; match the entities and relationships with each rule in the rule base, each rule containing its own entity item and its own relationship item; when the entity is the same as the entity item of the rule in the rule base, and / or the relationship is the same as the relationship item of the rule, it is determined that the match with the rule is successful; when the entity is different from the entity item of the rule in the rule base and the relationship is different from the relationship item of the rule, it is determined that the match with the rule is unsuccessful.
[0114] In one embodiment, a conversion module 504 is included for determining the language format of the query request; when the language format of the query request does not match the first knowledge graph, the language format of the query request is converted into a language format that matches the first knowledge graph before the query request and the rules associated with the query request are sent to the first knowledge graph of the domain.
[0115] In one embodiment, a conversion module 504 is included for determining the language format of the query request; when the language format of the query request does not match the second knowledge graph, the language format of the query request is converted into a language format that matches the second knowledge graph before sending the query request to the second knowledge graph of the domain.
[0116] The embodiment of the present invention also proposes an electronic device with a processor-memory architecture. Figure 6 is a structural diagram of an electronic device according to an embodiment of the present invention. As shown in Figure 6, the electronic device 600 includes a processor 601, a memory 602, and a computer program stored on the memory 602 and runnable on the processor 601. When the computer program is executed by the processor 601, it implements any of the above methods for querying the knowledge graph. Among them, the memory 602 can be specifically implemented as a variety of storage media such as an electrically erasable programmable read-only memory (EEPROM), a flash memory (Flash memory), and a programmable program read-only memory (PROM). The processor 601 can be implemented to include one or more central processing units or one or more field programmable gate arrays, wherein the field programmable gate array integrates one or more central processing unit cores. Specifically, the central processing unit or the central processing unit core can be implemented as a CPU, an MCU or a DSP, and so on.
[0117] It should be noted that not all steps and modules in the above processes and structure diagrams are required, and certain steps or modules can be omitted based on actual needs. The execution order of the steps is not fixed and can be adjusted as needed. The division of the modules is merely for the convenience of describing the functional division adopted. In actual implementation, a module can be implemented by multiple modules, and the functions of multiple modules can be implemented by the same module. These modules can be located in the same device or in different devices.
[0118] The hardware modules in each embodiment can be implemented mechanically or electronically. For example, a hardware module may include a specially designed permanent circuit or logic device (such as a dedicated processor, such as an FPGA or ASIC) for performing a specific operation. The hardware module may also include a programmable logic device or circuit (such as a general-purpose processor or other programmable processor) temporarily configured by software to perform a specific operation. As for whether to implement the hardware module mechanically, or using a dedicated permanent circuit, or using a temporarily configured circuit (such as configured by software), it can be decided based on cost and time considerations.
[0119] The above are only preferred embodiments of the present invention and are not intended to limit the scope of protection of the present invention. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. A method for querying a knowledge graph, characterized in that: include: Get (101) query request; Matching the query request with a rule base containing at least one rule (102); When a rule associated with the query request is matched from the rule base, the query request and the rule associated with the query request are sent (103) to a first knowledge graph of the domain, so that the first knowledge graph determines a first output based on the query request and the rule associated with the query request; Otherwise, the query request is sent (104) to a second knowledge graph of the domain so that the second knowledge graph determines a second output based on the query request, wherein the first knowledge graph is established in a resource description framework manner and the second knowledge graph is established in a labeled property graph manner.
2. The method according to claim 1, characterized in that The matching of the query request with a rule base containing at least one rule (102) includes: Extracting entities and relationships between entities from the query request; Matching the entity and the relationship with each rule in the rule base, each rule comprising a respective entity term and a respective relationship term; When the entity is identical to the entity item of the rule in the rule base, and / or the relationship is identical to the relationship item of the rule, it is determined that the match with the rule is successful; when the entity is different from the entity item of the rule in the rule base and the relationship is different from the relationship item of the rule, it is determined that the match with the rule is unsuccessful.
3. The method according to claim 1, characterized in that include: Determining a language format of the query request; When the language format of the query request does not match the first knowledge graph, before sending (103) the query request and the rule associated with the query request to the first knowledge graph of the domain, the language format of the query request is converted into a language format that matches the first knowledge graph.
4. The method according to claim 1, characterized in that: include: Determining a language format of the query request; When the language format of the query request does not match the second knowledge graph, before sending (104) the query request to the second knowledge graph of the field, the language format of the query request is converted into a language format that matches the second knowledge graph.
5. The method according to claim 2, characterized in that: The entity includes at least one of the following: A specific object with a unique identifier; A non-specific object that has no unique identifier.
6. A device for querying a knowledge graph, characterized in that: include: An acquisition module (501), used to acquire a query request; A matching module (502), configured to match the query request with a rule base comprising at least one rule; A sending module (503), configured to send the query request and the rule associated with the query request to a first knowledge graph of the domain when a rule associated with the query request is matched from the rule base, so that the first knowledge graph determines a first output based on the query request and the rule associated with the query request; Otherwise, the query request is sent to a second knowledge graph of the field, so that the second knowledge graph determines a second output based on the query request, wherein the first knowledge graph is established in a resource description framework manner, and the second knowledge graph is established in a labeled property graph manner.
7. The device according to claim 6, characterized in that The matching module (502) is used to extract entities and relationships between entities from the query request; match the entities and the relationships with each rule in the rule base, each rule including respective entity items and respective relationship items; When the entity is identical to the entity item of the rule in the rule base, and / or the relationship is identical to the relationship item of the rule, it is determined that the match with the rule is successful; when the entity is different from the entity item of the rule in the rule base and the relationship is different from the relationship item of the rule, it is determined that the match with the rule is unsuccessful.
8. The device according to claim 6, characterized in that include: A conversion module (504) is used to determine the language format of the query request; when the language format of the query request does not match the first knowledge graph, before sending the query request and the rule associated with the query request to the first knowledge graph of the domain, converting the language format of the query request into a language format that matches the first knowledge graph.
9. The device according to claim 6, characterized in that include: A conversion module (504) is used to determine the language format of the query request; when the language format of the query request does not match the second knowledge graph, before sending the query request to the second knowledge graph of the field, convert the language format of the query request into a language format that matches the second knowledge graph.
10. A system for querying a knowledge graph, characterized in that: include: The first knowledge graph in the field (13) is established in the form of a resource description framework; A second knowledge graph (14) of the domain is established in the form of a labeled attribute graph; A rule base (12), used to store at least one rule; A device (11) for querying a knowledge graph, for obtaining a query request; matching the query request with the rule base (12); when a rule associated with the query request is matched from the rule base (12), sending the query request and the rule associated with the query request to the first knowledge graph (13), so that the first knowledge graph (13) determines a first output based on the query request and the rule associated with the query request; Otherwise, the query request is sent to the second knowledge graph (14) so that the second knowledge graph (14) determines a second output based on the query request.
11. An electronic device, characterized in that: include: Processor (601); A memory (602), configured to store executable instructions of the processor (601); The processor (601) is used to read the executable instructions from the memory (602) and execute the executable instructions to implement the method for querying the knowledge graph described in any one of claims 1-5.
12. A computer-readable storage medium having computer instructions stored thereon, characterized in that: When the computer instructions are executed by a processor, the method for querying a knowledge graph described in any one of claims 1-5 is implemented.
13. A computer program product, characterized in that It includes a computer program, which, when executed by a processor, implements the method for querying a knowledge graph as described in any one of claims 1 to 5.