Method and system for quickly adapting different knowledge graphs
By using intent recognition and graph query template configuration, combined with JSON data structures and regular expressions, the problem of low parsing efficiency of intelligent assistants in adapting to different knowledge graphs has been solved, achieving fast and flexible data parsing and adaptation.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-31
- Publication Date
- 2026-03-31
AI Technical Summary
Existing technologies require significant time and resources for data parsing when accessing knowledge graphs from different domains, resulting in low adaptation efficiency for intelligent assistants.
The intent recognition module processes the natural language query statements input by the user, configures the graph query statement template, and uses the knowledge graph entity parsing module to replace the query entity slots with query words to form an executable graph query statement. It combines JSON data structure and regular expressions for parsing, avoiding the need to repeatedly write parsing annotations at the code level.
It enables rapid data parsing for the intelligent assistant when accessing different knowledge graphs, reducing development time and costs and improving adaptation efficiency.
Smart Images

Figure CN114881021B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of artificial intelligence and relates to a data parsing implementation method for intelligent assistants to quickly connect to knowledge graphs in different fields; specifically, it is a method and system for quickly adapting to different knowledge graphs. Background Technology
[0002] Since Google announced the use of knowledge graph technology in its search engine in 2012, it has gained popularity in academia and industry, and has been widely applied in AI assistants and question-answering systems to assist in deep understanding of human language, support reasoning, and improve the user experience of human-computer question answering. As the value of knowledge graphs is increasingly discovered and utilized by various enterprises and organizations, its scale has grown significantly. However, its fragmentation has also increased. This has led to a significant time commitment for upper-level intelligent assistants and other applications to parse different graph queries when accessing the underlying graph. This is because the intent recognition and the types of entities and relationships involved in graph queries differ across different domains, resulting in different data parsing models required. Figure 1 As shown, the original business of the intelligent assistant was to call content from knowledge graph A. Now, it needs to access content from knowledge graph B. Because the entity types and corresponding attribute keys in the two graphs are different, it is necessary to continuously write corresponding model parsing statements in the code. For ease of understanding, this example uses the interaction between the Java programming language and the graph database Neo4j.
[0003] Example 1: Query the list information of a certain series of products in graph A. The corresponding model data parsing method in Java code is generally:
[0004] @Query("match(n:Product)where n.prdname contains{prdname}return n")
[0005] List <product>getProductList(@Param("prdname")String prdname)
[0006] Example 2: Query the contact information for a specific scheme in map B. The corresponding model data parsing method in Java code is generally:
[0007] @Query("match(n:Contacter)-[:inchargeof]-(m)where m.solname contains{solname}return n")
[0008] List <contacter>getProductContacters(@Param("solname")String solname)
[0009] The above method requires writing a Java statement to match each graph query statement for parsing, and then repackaging it into a JAR or WAR file for deployment to the server environment. This process is very slow and requires a lot of cost to adapt to knowledge graphs in different domains. Summary of the Invention
[0010] To address the aforementioned shortcomings of existing technologies, the present invention aims to provide a method and system for rapidly adapting to different knowledge graphs; the present invention enables rapid data parsing when connecting to knowledge graphs from different domains via an intelligent assistant. The technical solution adopted by the present invention to solve its technical problem is as follows:
[0011] A method for quickly adapting to different knowledge graphs includes the following steps:
[0012] 1) The intent recognition module processes the natural language query statement input by the user to obtain named entities and parts of speech, and outputs the user intent and slot of the current query statement.
[0013] 2) The graph query statement configuration module configures graph query statement templates with different answers based on the user's intent;
[0014] 3) For each graph query statement template, a specified graph is determined according to the graph query statement template; the knowledge graph entity parsing module filters out the query entity slot field in the graph query statement template, replaces the query entity slot field with the input or selected query words, forms a graph query statement that can be executed completely, and retrieves the corresponding result object from the specified graph according to the graph query statement.
[0015] Furthermore, the information in the graph query statement template includes: intent category, slot, and graph query statement.
[0016] Furthermore, the information in the graph query statement template also includes the response type.
[0017] Furthermore, the response types include template answers and graph-based answers.
[0018] Furthermore, the knowledge graph entity parsing module parses the basic objects from the graph query statement template, replaces the basic objects with the input or selected query terms, performs graph queries, and obtains the corresponding key value and associated Node object data.
[0019] A system for rapidly adapting to different knowledge graphs, characterized by comprising an intent recognition module, a graph query statement configuration module, and a knowledge graph entity parsing module; wherein,
[0020] The intent recognition module is used to process the natural language query statement input by the user, obtain named entities and parts of speech, and output the user intent and slot of the current query statement.
[0021] The graph query statement configuration module is used to configure graph query statement templates with different answers according to the user's intent;
[0022] The knowledge graph entity parsing module is used to determine a specified graph based on the graph query statement template; filter out the query entity slot field in the graph query statement template, replace the query entity slot field with the input or selected query terms, form a complete executable graph query statement, and retrieve the corresponding result object from the specified graph based on the graph query statement.
[0023] A computer device, characterized in that it includes a memory and a processor, the memory storing a computer program configured to be executed by the processor, the computer program including instructions for performing the steps of the above-described method.
[0024] A computer-readable storage medium having a computer program stored thereon, characterized in that the computer program, when executed by a processor, implements the steps of the above-described method.
[0025] This invention constructs a parsing system under multiple knowledge graphs, which includes an intent recognition module, a graph query statement configuration module, and a knowledge graph entity parsing module.
[0026] The intent recognition module processes the natural language content input by the user, performs NER (Named Entity Recognition), word segmentation, and part-of-speech analysis, and outputs the intent and slots of the current query statement. For related implementation methods, please refer to "Big Talk on Knowledge Graphs - Intent Recognition and Slot Filling" (source address: https: / / zhuanlan.zhihu.com / p / 165963264).
[0027] The graph query configuration module is used to configure different graph query templates for different answers based on different user intents. Currently, most implementations of graph queries in Java applications involve importing the "spring-data-neo4j library" and writing corresponding parsing annotations at the code level, such as "@Query("match(n:Product)wheren.prdname contains{prdname}return n")". The drawback of this approach is that it requires multiple modifications to the code for different types of graphs and multiple operations on parsing entity class data for different graphs. This solution innovatively separates the graph query statement from directly writing code, eliminating the need to write Java annotation code. Instead, it designs an API based on the intent recognition module. This API can configure intent categories, response types (template answers, graph answers), and graph query statement configurations, using a JSON data structure. An example is shown below:
[0028] {
[0029] "questions": "A collection of similar questions"
[0030] "intentClass": "intent category",
[0031] "intentName": "intent name",
[0032] "slots": "slot set",
[0033] "actionType": "Response type",
[0034] "actions": "Graph query statements"
[0035] "graphLink": The graph to be connected
[0036] }
[0037] With the above JSON interface data design, different question sets, as well as corresponding intents and graph query templates, can be dynamically added without having to be written in the code.
[0038] The knowledge graph entity parsing module is used to connect to the specified graph through the `graphLink` field in the aforementioned JSON when different graph query statements are input. It designs a set of regular expressions to filter out the corresponding query entity slot fields in the "graph query statement." Then, using the key-value mapping relationship of the dictionary, it maps the NLP (Natural Language Processing) word segmentation and corresponding part-of-speech tags to values in the dictionary table. These values are the aforementioned slot fields. The entity slot fields are replaced with the corresponding results after word segmentation of the user-input query statement, forming a complete executable graph query statement. By connecting to the specified graph database through code and using methods provided by the neo4j-java library, the corresponding result objects can be directly queried from the graph database / graph. It maps entities of different types of graphs into several common representation forms, parsing layer by layer, resolving and storing the specified entities and corresponding attributes in the result objects, and converting them into the JSON data format required by the upper-layer application.
[0039] The content after successful parsing is returned to the upper-layer application.
[0040] The beneficial effects of this invention are as follows:
[0041] This invention completely decouples the intent recognition, graph query statement, and specific graph query parsing operations of the intelligent assistant. By associating intent and graph query in the configuration file and designing relevant regular expressions and general parsing methods, flexible configuration and use can be achieved without intrusive code. When the user's input question is received and understood by the intent recognition module of the intelligent assistant, the corresponding graph query statement will be allocated according to the corresponding graph query statement configuration module, and subsequent graph entity data parsing and structured data will be returned to the intelligent assistant. Attached Figure Description
[0042] Figure 1 This invention relates to a graph illustrating the access requirements of fragmented knowledge graphs of different types.
[0043] Figure 2 This is the overall flowchart of the present invention. Detailed Implementation
[0044] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, a clear and complete description will be provided below in conjunction with the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative effort are within the protection scope of the present invention.
[0045] Figure 2 This is the overall business process diagram, where steps 4 and 5 are the objects requiring key protection. The complete process description is as follows:
[0046] Step 1: The end user inputs text through the AI assistant page;
[0047] Step 2: The intelligent assistant performs NER (Named Entity Recognition) and word segmentation and part-of-speech analysis on the input text, identifying entity slots based on the feature dictionary. First, it calls full-text / partial matching to determine the text's matching degree. If the matching rate reaches 70% or higher, it falls under the normal QA question pair query process, proceeding to Step 3's template question-and-answer process. Otherwise, it judges the sentence's classification feature keywords. If the classification matching reaches 70% or higher, it falls under the knowledge graph query process, proceeding to Step 4's knowledge graph query configuration module. Finally, if the evaluation criteria are not met, it directly enters the fallback answer response process and ends the entire process.
[0048] Step 3, Template Q&A Process: This part directly configures the corresponding set of similar questions and related text answers. If a question in the current question set is matched, the corresponding answer will be sent to the end user.
[0049] Step 4: Using the `graphLink` field in the example JSON above, the desired graph is connected. After accurately identifying the corresponding intent using NLP (Natural Language Processing) technology, the process proceeds to the graph query configuration module. This module allows manual configuration via a web interface from the management backend, specifying different question sets, slot sets, and corresponding graph query templates. The data type is JSON, primarily containing the intent categories, slot sets, and graph query templates mentioned in point 3 of the invention. This configuration, combined with the new mode parsing and general processing method in Step 5, resolves parsing issues when connecting to different graphs.
[0050] Step 5: This module will parse different graph query statements into JSON object data, which contains different keys and corresponding Node node data. Combining with the configured graph statement template above, the following is an example: User A wants to query the person in charge of a certain solution. By inputting "Who is the person in charge of the intelligent medical solution?" through the AI assistant, after the above NLP processing, the word segmentation and词性标注 results of "请问 / v智慧 / nm医疗 / nm方案 / n的 / ude1负责人 / n是 / vshi谁 / ry" will be output. Combining with the question set configured in the field of "question" in the above JSON, Bayesian classifier clustering analysis will be carried out to determine that the query statement input by this user belongs to the template question of "querying solution contacts". The corresponding graph query statement is: match(n:Contacter)-[:inchargeof]-(m)where m.solnamecontains{solname}return n. Design a set of regular expressions, and配合槽位定义里nm字段, analyze the above segmented statement, filter out the keyword "intelligent medical", and replace it in the graph query statement to form a complete statement as follows: match(n:Contacter)-[:inchargeof]-(m)where m.solname contains‘intelligent medical’return n, perform the query of the graph, and parse the corresponding JSON object data result. Each key represents the corresponding key value and the associated Node node object data. The Node node data is essentially also a JSON object. In the above example, by combining the nm field defined in the slot, traverse the Node object, and store the corresponding key-value in a custom general class; if there are multiple Node node data parsed, then form a general class set of List list, and finally provide it to the upper-level intelligent assistant for use.
[0051] Step 6: The intelligent assistant receives the parsed data and puts the corresponding content to be displayed to the user on the interface.
[0052] Through the above key design methods, the present invention realizes the high decoupling of the corresponding intent configuration, graph query configuration and graph entity parsing when the intelligent assistant accesses different knowledge graphs, speeds up the development progress of the data interface when developing the intelligent assistant, and is flexible and configurable.< / contacter> < / product>
Claims
1. A method for quickly adapting different knowledge graphs, comprising the steps of: 1) processing a natural language query sentence input by a user using an intent recognition module to obtain named entities and parts of speech, and simultaneously outputting the user's intent and slots of the current query sentence; 2) configuring a graph query sentence template for different answers according to the user's intent by a graph query sentence configuration module; 3) for each graph query sentence template, determining a specified graph according to the graph query sentence template, filtering out the query entity slot field in the graph query sentence template by a knowledge graph entity analysis module, and corresponding the segmented words and corresponding parts of speech after natural language processing to the values in a dictionary table by means of the key-value correspondence of the dictionary table, the values in the dictionary table being defined slot fields, replacing the entity slot field with the corresponding results of the segmented words after processing the query sentence input by the user, forming a complete graph query sentence that can be executed, and querying the corresponding result object from the specified graph according to the graph query sentence. The information in the graph query sentence template further includes a reply type. The reply type includes template answers and graph answers.
2. The method of claim 1, wherein, The knowledge graph entity analysis module analyzes the basic object from the graph query sentence template, replaces the input or selected query words with the basic object, queries the graph, and obtains the corresponding key value key and associated Node node object data.
3. The method of claim 2, wherein, The method comprises an intent recognition module, a graph query sentence configuration module, and a knowledge graph entity analysis module, wherein:
4. The method according to any one of claims 1 to 3, characterized in that, The intent recognition module is configured to process a natural language query sentence input by a user to obtain named entities and parts of speech, and simultaneously output the user's intent and slots of the current query sentence; 5.A system for fast adapting different knowledge graphs, characterized in that, The graph query sentence configuration module is configured to configure a graph query sentence template for different answers according to the user's intent; the information in the graph query sentence template includes intent categories, slots, and graph query sentences; The knowledge graph entity analysis module is configured to determine a specified graph according to the graph query sentence template; filter out the query entity slot field in the graph query sentence template, and correspond the segmented words and corresponding parts of speech after natural language processing to the values in a dictionary table by means of the key-value correspondence of the dictionary table, the values in the dictionary table being defined slot fields, replace the entity slot field with the corresponding results of the segmented words after processing the query sentence input by the user, form a complete graph query sentence that can be executed, and query the corresponding result object from the specified graph according to the graph query sentence. The computer program is configured to be executed by the processor, and the computer program comprises instructions for executing each step of the method of any one of claims 1 to 4. The computer program is configured to be executed by the processor, and the computer program comprises instructions for executing each step of the method of any one of claims 1 to 4.
6. A computer device, comprising: 7. A computer readable storage medium having stored thereon a computer program, characterized in that,
Citation Information
Patent Citations
Visual knowledge graph query template construction method, device and system and storage medium
CN112507135A