An artificial intelligence question answering system based on a knowledge graph and a method thereof
Patent Information
- Application Number
- CN202610467268.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-04-10
- Publication Date
- 2026-10-23
AI Technical Summary
[0004]本发明的目的在于提供一种基于知识图谱的人工智能问答系统及其方法,以解决上述背景中问题
(1)本发明通过构建包含员工、岗位、技能、流程节点及其语义关联的人资知识图谱,并结合用户画像与上下文语境进行实体消歧和路径推理,显著提升了对复杂人资查询的语义理解能力。当用户输入包含多义词或不完整信息的自然语言查询时,系统能够利用知识图谱的拓扑结构和实体间的共现频率,准确识别用户意图,避免歧义匹配,从而在招聘、转岗、培训规划等场景中提供更精准的答案,减少了人工二次澄清的需求。
Smart Images

Figure CN122964205A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of natural language processing and knowledge engineering technology, specifically to an artificial intelligence question-answering system and method based on knowledge graphs. Background Technology
[0002] In the current field of human resource management, intelligent question-answering systems typically rely on keyword matching or preset rule templates to mechanically compare user-input natural language queries with fields or documents in the database. This human-computer interaction method struggles to parse polysemous words, industry terms, or abbreviations contained in the query. When users ask complex questions involving multi-source data such as employee information, job requirements, and business processes, the system cannot semantically correlate and integrate information scattered across heterogeneous data sources, often returning only partial or even incorrect answers.
[0003] In existing technologies, due to the lack of structured modeling and semantic understanding capabilities for knowledge in the human resources field, it is impossible to accurately interpret user intent when faced with natural language queries containing complex contexts and implicit relationships. It is also difficult to correlate and reason across cross-source data such as employee information, job skills, and business processes, resulting in one-sided answers and low accuracy. Furthermore, the system cannot dynamically evolve based on users' personalized habits and real-time feedback, thus failing to meet the comprehensive needs of human resource management for accurate question answering, process operation, and adaptive optimization. Summary of the Invention
[0004] The purpose of this invention is to provide an artificial intelligence question-answering system and method based on knowledge graphs to solve the problems mentioned above.
[0005] The objective of this invention can be achieved through the following technical solutions: An AI question-answering method based on knowledge graphs includes the following steps: S1: Based on multi-source human resources data, including employee information, job descriptions, business process documents and historical Q&A records, a human resources knowledge graph containing employees, positions, skills, process nodes and their semantic associations is constructed through entity extraction and relationship mining. The entities and relationships in the graph are vectorized and a structured knowledge graph is output. S2: Receives user natural language queries, combines pre-built user profiles and contextual information, maps the queries to entities and relationships in the knowledge graph through semantic parsing, generates graph query statements or retrieval conditions containing query intent, and outputs intent parsing results; S3: Receive the intent parsing results, and based on the topological structure of the knowledge graph, retrieve candidate entities, relationships, or subgraphs related to the query through graph traversal, path reasoning, or similarity calculation. Then, sort the retrieval results by combining vector similarity and output candidate knowledge fragments. S4: Input candidate knowledge fragments as context into the large language model, combine them with the retrieval enhancement generation component to generate answers or executable business process operation instructions that conform to natural language habits, and filter the output content according to permission rules to generate the final response; S5: Collect user feedback on the final response, including clicks, ratings, or subsequent actions, and dynamically update entity attributes, relationship strength, and user profiles in the knowledge graph based on the feedback to optimize the accuracy and personalization of subsequent question and answer, forming a closed loop.
[0006] As a further aspect of the present invention: the output structured knowledge graph specifically includes: By using pre-defined dictionary matching and dependency parsing, the system extracts employee, job, skill, and process node entities from multi-source human resources data and merges entities with the same name. Based on the co-occurrence window of entities in the text and the syntactic dependency path, an initial relation graph is constructed. Isolated edges are removed by graph connectivity component analysis, and relation types are sorted by confidence through relation path counting to filter out core relations. Entities and relations are constructed into a heterogeneous graph. A random walk based on metapaths is used to generate an entity sequence. The sequence is then input into a context prediction algorithm to learn the vector representation of each entity. At the same time, the relation vector is calculated based on the difference between the entity vectors at both ends of the relation. Entity vectors, relation vectors, and knowledge graph structure data are integrated to form a structured knowledge graph.
[0007] As a further aspect of the present invention: the output intent parsing result specifically includes: It receives natural language queries from users, performs dependency parsing on the queries, extracts the core words and their dependencies, and assigns different weights to the core words based on the historical query entity preferences stored in the user profile. The core words are matched with entities in the knowledge graph. For core words that match multiple candidate entities, the entity that best matches the current context is selected by using the entities already identified in the context and the co-occurrence frequency between entities. Based on the dependency structure of the query and the mapped entity pairs, the path connecting these entities is searched in the knowledge graph, and the relationship with the shortest path length and matching the query intent is selected as the query relationship. Combine the identified entities and relationships to generate graph retrieval criteria that contain the query intent.
[0008] As a further aspect of the present invention: the selection of the entity that best matches the current context specifically includes: Candidate entities are retrieved from the knowledge graph based on literal matching of core words, and the set of associations of each candidate entity in the knowledge graph is recorded. Starting with the identified entities, expand outwards two layers along the relation edges to extract all adjacent entities and relations, forming a context subgraph; Iterate through each candidate entity, calculate the shortest path length between the candidate entity and each determined entity in the context subgraph, and sum the reciprocals of all path lengths as the contextual closeness of the candidate entity. The candidate entity with the highest contextual closeness is selected as the entity that matches the core word.
[0009] As a further aspect of the present invention: the output candidate knowledge fragment specifically includes: Based on the identified entities contained in the intent parsing results, locate the corresponding nodes in the knowledge graph as a set of seed nodes; Starting from each node in the seed node set, traverse one layer outward along the relation edges, collect all adjacent nodes and relation edges, and merge the newly collected nodes with the seed nodes to form a candidate subgraph. Perform a dot product operation between the query semantic vector contained in the intent parsing result and the vector of each node in the candidate subgraph, and select the nodes with the top 1 / 3 of the dot product values and their associated paths to form a condensed subgraph. The condensed subgraph is transformed into candidate knowledge fragments composed of continuous text segments.
[0010] As a further aspect of the present invention: the construction of candidate sub-graphs specifically includes: Iterate through each node in the seed node set, obtain all outgoing and incoming edges of the node, and if the number of adjacent nodes of a node exceeds a preset threshold, randomly select 1 / 3 of the adjacent nodes to participate in the subsequent expansion. For each seed node, traverse one layer outward along the preserved relation edges, collect adjacent nodes and relation edges, and record the depth value of each traversal path, discarding paths with a depth value exceeding one. Merge all adjacent nodes and relation edges obtained by expanding different seed nodes. If the same node is expanded by multiple seed nodes, retain the node and increase its reference count. The seed node is combined with its adjacent nodes and their relation edges that are retained after overlapping and merging to form a candidate subgraph.
[0011] As a further aspect of the present invention: the generation of the final response specifically includes: The entity names and relation types in the candidate knowledge fragments are arranged in order of appearance to form a text sequence, and the text sequence is filled into a preset prompt template to form a generated prompt containing contextual information; The generated prompts are concatenated with the user's original query and input into the large language model. The original response text output by the large language model is obtained, and regular expressions are used to extract the answer body or operation instruction field from the original response text. Based on the list of entity identifiers that the current user can access stored in the permission rules, iterate through all entity names that appear in the answer body, remove statements involving inaccessible entities, and generate filtered answer content. Each entity name appearing in the filtered response content is associated with the source node in the candidate knowledge fragment, and a corresponding reference mark is added to the end of the response content to form the final response.
[0012] As a further aspect of the present invention: the feedback-driven dynamic updating of the knowledge graph specifically includes: Collect user clickstream, rating values, and subsequent query text for the final response; map the clickstream to the incremental number of visits to the corresponding entity; convert the rating values into the corresponding entity satisfaction scores; and associate and bind keywords in the subsequent query text with the entity being queried. The satisfaction scores are weighted and accumulated into the historical rating attributes of the corresponding entity. The incremental number of visits is added to the popularity attribute of the entity. The popularity attribute is then subjected to time decay calculation, and the visit records within the most recent preset period are retained. Traverse all adjacent entity pairs on the current query path, extract the corresponding relationship edges, add a temporary co-occurrence count value for each relationship edge, and dynamically adjust the weight value of the relationship edge based on the ratio of the count value to the historical co-occurrence count. The core entity names and relationship types involved in this query, along with the bound keywords, are merged and added to the historical preference entity list and preference relationship list of the user profile. Outdated records that have exceeded the preset time limit are removed, and the updated user profile is output to S1.
[0013] An AI question-answering system based on knowledge graphs, comprising: Knowledge Graph Construction Module: Based on multi-source human resources data, including employee information, job descriptions, business process documents and historical Q&A records, it constructs a human resources knowledge graph containing employees, positions, skills, process nodes and their semantic associations through entity extraction and relationship mining. It also vectorizes the entities and relationships in the graph and outputs a structured knowledge graph. User intent understanding module: It receives users' natural language queries, combines them with pre-built user profiles and contextual information, maps the queries to entities and relationships in the knowledge graph through semantic parsing, generates graph query statements or retrieval conditions containing the query intent, and outputs the intent parsing results; Knowledge Reasoning and Retrieval Module: This module receives the intent parsing results, retrieves candidate entities, relationships, or subgraphs related to the query based on the topological structure of the knowledge graph through graph traversal, path reasoning, or similarity calculation, and sorts the retrieval results by combining vector similarity, outputting candidate knowledge fragments. Answer generation and instruction synthesis module: It is used to input candidate knowledge fragments as context into the large language model, combine them with the retrieval enhancement generation component, generate answers or executable business process operation instructions that conform to natural language habits, and filter the output content according to the permission rules to generate the final response; Feedback and Update Module: This module collects user feedback on the final response, including clicks, ratings, or subsequent actions. Based on this feedback, it dynamically updates entity attributes, relationship strength, and user profiles in the knowledge graph, optimizing the accuracy and personalization of subsequent question-and-answer sessions to form a closed loop.
[0014] The beneficial effects of this invention are: (1) This invention significantly improves the semantic understanding of complex HR queries by constructing an HR knowledge graph containing employees, positions, skills, process nodes and their semantic relationships, and combining user profiles and contextual information for entity disambiguation and path reasoning. When users input natural language queries containing polysemous words or incomplete information, the system can accurately identify user intent by utilizing the topological structure of the knowledge graph and the co-occurrence frequency between entities, avoiding ambiguous matching, thereby providing more accurate answers in scenarios such as recruitment, job transfer, and training planning, and reducing the need for manual secondary clarification.
[0015] (2) This invention introduces a dynamic update mechanism based on user feedback. By collecting clickstreams, ratings, and subsequent query texts, it adjusts the entity popularity, relationship strength, and user profile preference records in the knowledge graph in real time. After multiple interactions, the system can gradually learn the personalized query habits of different users, making the weight allocation of entity mappings and the ranking results of candidate fragments more in line with individual needs. At the same time, time decay calculation ensures the timeliness of hot information, enabling the question-answering system to maintain adaptive optimization capabilities in long-term operation and continuously improve the personalization level of knowledge services. Attached Figure Description
[0016] The invention will now be further described with reference to the accompanying drawings.
[0017] Figure 1 This is a flowchart of the method of the present invention; Figure 2 This is a system block diagram of the present invention. Detailed Implementation
[0018] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0019] Please see Figure 1 As shown, this invention is an artificial intelligence question-answering method based on knowledge graphs, comprising the following steps: S1: Based on multi-source human resources data, including employee information, job descriptions, business process documents and historical Q&A records, a human resources knowledge graph containing employees, positions, skills, process nodes and their semantic associations is constructed through entity extraction and relationship mining. The entities and relationships in the graph are vectorized and a structured knowledge graph is output. S2: Receives user natural language queries, combines pre-built user profiles and contextual information, maps the queries to entities and relationships in the knowledge graph through semantic parsing, generates graph query statements or retrieval conditions containing query intent, and outputs intent parsing results; S3: Receive the intent parsing results, and based on the topological structure of the knowledge graph, retrieve candidate entities, relationships, or subgraphs related to the query through graph traversal, path reasoning, or similarity calculation. Then, sort the retrieval results by combining vector similarity and output candidate knowledge fragments. S4: Input candidate knowledge fragments as context into the large language model, combine them with the retrieval enhancement generation component to generate answers or executable business process operation instructions that conform to natural language habits, and filter the output content according to permission rules to generate the final response; S5: Collect user feedback on the final response, including clicks, ratings, or subsequent actions, and dynamically update entity attributes, relationship strength, and user profiles in the knowledge graph based on the feedback to optimize the accuracy and personalization of subsequent question and answer, forming a closed loop.
[0020] In S1, based on multi-source HR data, including employee information, job descriptions, business process documents, and historical Q&A records, an HR knowledge graph containing employees, positions, skills, process nodes, and their semantic relationships is constructed through entity extraction and relation mining. The entities and relationships in the graph are then vectorized to output a structured knowledge graph, specifically including: First, employee information tables are collected from the human resources information system, including fields such as employee number, name, department, job title, and date of employment. Job description documents are retrieved from the enterprise document library, recording the responsibilities, qualifications, and reporting relationships of each position in text format. Business process documents are exported from the process management platform, describing the node names, node order, and approver roles of processes such as recruitment, probation, and transfer in flowchart or text format. Historical question-and-answer records are extracted from the question-and-answer log database, containing user questions, system answers, and corresponding entity annotations. After aggregating the above multi-source HR data, a dictionary-based maximum forward matching algorithm is used for entity extraction. The dictionary pre-sets entries such as employee name, job title, skill keywords (e.g., "Java development," "project management"), and process node names (e.g., "submit application," "department approval"). Dependency parsing analysis is also used to identify subject-verb-object structures in sentences, extracting four types of entities: employees, positions, skills, and process nodes. Entities with the same name belonging to the same department or the same document context are grouped together as a single entity.
[0021] Secondly, based on the entity extraction results, each sentence or each table row is used as an analysis unit. A sliding window is set with a length of five sentences or ten entities, and the number of times each pair of entities co-occurs within the window is counted as the co-occurrence frequency. Simultaneously, dependency parsing is performed on each sentence to extract entity pairs with subject-verb, verb-object, or coordinate relationships as syntactic dependency paths. Entity pairs with a co-occurrence frequency higher than three or with existing syntactic dependency paths are connected to construct an initial relation graph. Then, graph connectivity analysis is performed on the initial relation graph to identify all connected components. Edges in isolated connected components with fewer than three nodes and no core entities are deleted, removing isolated edges. Next, each remaining relation edge is traversed, and the number of paths through which the two entities connected by that edge co-occur in all historical Q&A records and business process documents is counted. This number of paths is defined as the total number of all possible paths connecting the two entities via other intermediate entities. Relationship edges are sorted from largest to smallest based on the number of paths, and the top 80% of relation edges are selected as core relations and retained in the relation set, while the remaining relation edges are discarded.
[0022] Next, the filtered and retained entities and relationships are combined to form a heterogeneous graph containing four types of nodes: employees, positions, skills, and process nodes, as well as various relational edges between nodes. For this heterogeneous graph, a meta-path-based random walk strategy is used to generate entity sequences. A meta-path is defined as a path that visits different types of nodes sequentially according to a preset pattern such as "employee-position-skill-process node" or "employee-position-employee". During the random walk, starting from each entity node, the next node is selected according to the constraints of the meta-path, repeating this process until the path length reaches 20 nodes, thus obtaining a large number of entity sequences. These sequences are input into a context prediction algorithm, which uses a continuous bag-of-words model for training. Each entity is treated as a center word, and the five entities before and after it are treated as context words. The algorithm learns the vector representation of each entity by maximizing the probability of the context entities appearing, ultimately obtaining 128-dimensional entity vectors. For each relational edge, the vectors of the entities at both ends are subtracted to obtain a difference vector, which is then used as the vector representation of the relation.
[0023] Finally, all entity vectors and relation vectors generated in the above steps, along with the knowledge graph structure data such as entity names, entity types, relation types, and connections between entities, are integrated according to a unified storage format. During integration, entities are used as record units. Each record contains the entity's unique identifier, entity name, entity type, entity vector, and a list of adjacent entities connected to that entity through each relation edge, along with their relation types and relation vectors. After all records are collected, a structured knowledge graph containing vectorized information is formed. This graph is stored in file format and serves as input data for subsequent steps.
[0024] In S2, the system receives natural language queries from users, combines them with pre-built user profiles and contextual information, and maps the queries to entities and relationships in the knowledge graph through semantic parsing. This generates graph query statements or search conditions containing the query intent, and outputs the intent parsing results, specifically including: First, the system receives natural language query text submitted by the user via input device. Dependency parsing is then performed on this text using a transition-based dependency parsing algorithm. This algorithm iterates through each word in the query text, identifying dependency arcs such as subject-verb, verb-object, and noun-head relationships to extract the core words and their corresponding dependency relationships. Core words are typically nouns or verbs, such as "employee," "transfer," and "skill." Simultaneously, the system retrieves the user's historical query entity preference list from a pre-built user profile. This list records the entity types and specific entity names frequently encountered by the user in past queries. For each core word, different weights are assigned based on its part of speech and its role in the dependency relationship, combined with historical query entity preferences: if the core word is a noun and matches an entity type in the preference list, its weight is set to 1.5; if the core word is a verb but related to a relationship type in the preference list, its weight is set to 1.2; the weights of other core words remain at 1.0.
[0025] Next, the core words mentioned above are matched with the entities in the structured knowledge graph output in step S1. During matching, a literal inclusion matching method is first used to recall all entities whose names contain the text of the core word as candidate entities. All relational edges associated with each candidate entity in the knowledge graph and its adjacent entities are recorded, forming a set of association relationships for that candidate entity. For core words that match multiple candidate entities, disambiguation is performed using the currently identified entities and the context. Specifically, starting with the entities that have already been mapped in the current query (i.e., identified entities), two layers are expanded outward along the relational edges in the knowledge graph: the first layer collects all adjacent entities and relational edges directly connected to the identified entities; the second layer, starting from these adjacent entities, collects the entities and relational edges directly connected to them. All entities and relational edges collected by the two layers are merged to form a contextual subgraph. Subsequently, for each candidate entity, a breadth-first search algorithm is used to calculate the shortest path length between the candidate entity and each identified entity in the context subgraph. This path length is defined as the number of edges required to reach the identified entity from the candidate entity along the relation edges. For each identified entity, the reciprocal of this path length (or 1 if the path length is 0) is calculated. Then, the reciprocals for all identified entities are summed, and the resulting value is used as the contextual closeness of the candidate entity. The candidate entity with the highest contextual closeness is selected as the entity that ultimately matches the core word; if multiple candidate entities have the same highest contextual closeness, the entity that appears more frequently in the historical question-and-answer records is selected.
[0026] Next, based on the dependency structure of the query and the mapped entity pairs, the relation corresponding to the query intent is determined. Specifically, the subject-verb, verb-object, and other relation pairs obtained from dependency parsing are transformed into the expected relation type between entities. For example, if the subject is "employee" and the verb is "transfer," the expected relation is "participate in transfer." Then, using the mapped entities as endpoints, all paths connecting these entities are searched in the knowledge graph. Each path consists of a series of relation edges. For each path, its total length (i.e., the number of relation edges it contains) is calculated, and the shortest path is selected. If multiple paths of equal length exist, the semantic similarity between the relation type name in each path and the verb or preposition in the query is compared. Dictionary-based semantic matching (such as WordNet thesaurus) is used to select the path with the highest similarity, and the relation contained in that path is taken as the query relation.
[0027] Finally, all entities and query relationships identified in the above steps are combined to form a graph retrieval condition. This graph retrieval condition is represented in a structured form, including a list of entities, relationship types, and the connection methods between entities. For example, "Employee A" is connected to "Position B" through the relationship "Holds Position". This graph retrieval condition, as the intent parsing result, is output to the subsequent knowledge reasoning and retrieval modules.
[0028] The specific implementation of selecting the entity that best matches the current context as described in the above steps is as follows: First, candidate entities are retrieved from the knowledge graph based on literal matching of core keywords. Literal matching employs a combination of exact and fuzzy matching: exact matching is performed first; if fewer than three entities are returned, fuzzy matching with an edit distance of less than or equal to 2 is used to supplement the retrieval. For each retrieved candidate entity, all outgoing and incoming edges of that entity are read from the knowledge graph, and the entity at the other end of each relation edge and the relation type are recorded, forming a set of associations for that candidate entity.
[0029] Second, starting with the identified entities, construct a context subgraph by expanding outwards two layers along the relational edges. During expansion, starting from each identified entity, first collect all directly adjacent entities (first layer), then for each entity collected in the first layer, collect all its directly adjacent entities again (second layer), but exclude entities that already appear in the identified entity set or the first layer to avoid duplication. Combine the identified entities, the first-layer entities, the second-layer entities, and all relational edges between them to form the context subgraph.
[0030] Third, traverse each candidate entity and calculate the shortest path length between it and each identified entity in the context subgraph. A breadth-first search algorithm is used, starting with a candidate entity and exploring outwards layer by layer in the knowledge graph until the target identified entity is reached. The number of edges traversed is recorded as the path length. For each identified entity, if the candidate entity is the same as it (i.e., the path length is 0), the affinity contribution value is recorded as 1; if the path length is greater than 0, the contribution value is recorded as the reciprocal of the path length (e.g., the reciprocal is 1 / 2 when the path length is 2). The contribution values of all identified entities are summed to obtain the context affinity of the candidate entity.
[0031] Fourth, compare the contextual closeness scores of all candidate entities and select the candidate entity with the highest score as the entity that matches the core word. If multiple candidate entities have the same highest contextual closeness score, further compare the frequency of these candidate entities in the user profile's historical preference entity list and select the entity with the most frequent occurrences; if they are still the same, randomly select one. This matching result is output to the relationship inference step as the identified entity.
[0032] In S3, the intent parsing results are received. Based on the topological structure of the knowledge graph, candidate entities, relationships, or subgraphs related to the query are retrieved through graph traversal, path reasoning, or similarity calculation. The retrieval results are then sorted based on vector similarity, and candidate knowledge fragments are output, specifically including: First, based on the identified entities contained in the intent parsing results, the nodes corresponding to these entities are located in the structured knowledge graph, and these nodes are used as a set of seed nodes. Each seed node has a unique identifier generated in step S1 and a 128-dimensional node vector.
[0033] Secondly, starting from each node in the seed node set, traverse one layer outwards along the relation edges, collecting all adjacent nodes and relation edges, and then merge the newly collected nodes with the seed nodes to form a candidate subgraph. This process specifically includes the following operations: First, fan-out suppression. For each node in the seed node set, iterate through all its outgoing and incoming edges and count the number of its neighboring nodes. A preset fan-out threshold of 30 is used. If a node has more than 30 neighboring nodes, randomly select 1 / 3 (10) of its neighbors for subsequent expansion, ignoring the rest. If the number of neighboring nodes is less than or equal to 30, all neighbors are retained. A uniformly distributed random number generator is used for random selection to ensure that each neighboring node has an equal probability of being selected.
[0034] Second, path pruning. For each seed node, traverse one level outward along the relationship edges preserved in the previous step, collecting all directly adjacent nodes and their corresponding relationship edges. Record the depth value of each traversal path. Since only one level is traversed outward, the depth value is always 1, but it must be ensured that no path backtracks to the seed node itself through relationship edges (i.e., excluding self-loops). If a path with a depth value exceeding 1 appears during the traversal (e.g., a loop caused by relationship edges pointing to already visited nodes), then that path is removed.
[0035] Third, overlap merging. All adjacent nodes obtained from expanding different seed nodes are merged with the relation edges. A temporary mapping table is constructed, where the key is the node identifier and the value is the count of how many seed nodes the node was expanded from (i.e., the number of references). If the same node is expanded from multiple seed nodes, only one copy of the node is retained, and its reference count is incremented accordingly. For relation edges, if multiple relation edges connect the same pair of nodes and have the same relation type, only one is retained, and its occurrence count is recorded as a weight, but the reference count is primarily used in subsequent steps.
[0036] Fourth, subgraph construction. The seed node set is combined with the set of neighboring nodes retained after overlapping and merging, along with their relational edges, to form a candidate subgraph. Each node in the candidate subgraph carries its original 128-dimensional node vector and a reference count obtained from the overlapping and merging step. This candidate subgraph contains first-order neighborhood information directly related to the initial entity queried by the user.
[0037] Next, the query semantic vector contained in the intent parsing result is multiplied by the vector of each node in the candidate subgraph, and the overall score of each node is calculated by combining the node's reference count. The query semantic vector is denoted as Q, with a dimension of 128, and each node... The node vector is denoted as It is also 128-dimensional. First, calculate the dot product value. The calculation formula is as follows: ;in, The query semantic vector is represented in the th order. Values in each dimension Represents a node The vector in the th The values in each of the 128 dimensions are summed using the summation symbol, which represents the summation of the products over all 128 dimensions to obtain the dot product value. The dot product value reflects the semantic similarity between the node and the user query.
[0038] Then, the number of times the node is referenced. Normalization is performed to obtain the normalized number of citations. The normalization method uses min-max normalization, which involves traversing all nodes in the candidate subgraph and finding the maximum number of references. and minimum value For each node Its normalized citation count is calculated as Divide by .like equal Therefore, the normalized reference count for all nodes is set to 0.5. Next, the overall score for each node is calculated. The calculation formula is as follows: ;in, This is a balancing coefficient used to adjust the weight of the number of citations in the overall score. In this embodiment... Set to 0.2. Overall score. It also considers the semantic similarity between the node and the query, as well as the importance of the node in the candidate subgraph (i.e., the degree to which it is referenced by multiple seed nodes).
[0039] Based on the overall score of each node All nodes are sorted in descending order, and the top 1 / 3 of nodes and their associated paths are selected to form a condensed subgraph. Specifically, if the total number of nodes in the candidate subgraph is N, then the top floor(N / 3) nodes with the highest scores are selected. floor(N / 3) represents rounding down the result of N divided by 3, i.e., taking the largest integer not greater than the quotient, and retaining all relational edges of these nodes in the candidate subgraph and the paths connected by these relational edges (i.e., direct connections between these nodes and between them and the seed node). If N is not divisible by 3, it is rounded down. These selected nodes and their associated paths together form the condensed subgraph. The condensed subgraph focuses on the knowledge fragments that are most relevant to the user query and have high contextual importance.
[0040] Finally, the condensed subgraph is transformed into candidate knowledge fragments composed of continuous text segments. During the transformation, each node and each relation edge in the condensed subgraph is traversed, and corresponding text descriptions are extracted from the original multi-source HR data based on the node's entity type (e.g., employee, position, skill, process node) and relation type. For example, for employee nodes, information such as name, department, and position is extracted; for position nodes, the position name and job description are extracted; and for relation edges, the relation type name (e.g., "employed in" or "possesses skills") is extracted. All extracted text is then concatenated into natural language sentences in the form of "node-relation-node" triples. Multiple sentences are arranged in order of node importance to form a continuous text segment, which is the candidate knowledge fragment.
[0041] In S4, candidate knowledge fragments are input into the large language model as context. Combined with the retrieval enhancement generation component, answers or executable business process operation instructions conforming to natural language habits are generated. The output content is then filtered according to permission rules to generate the final response, specifically including: First, all entity names and relation types appearing in the candidate knowledge fragments are extracted in the order of their appearance in the fragments and arranged sequentially to form a text sequence. This text sequence, together with the original text of the candidate knowledge fragments, constitutes the input material. Then, this text sequence is filled into a preset prompt template, which adopts a three-part structure. The first part is the system role definition, fixed as "You are a professional human resources assistant"; the second part is the context filling area, used to insert the above text sequence; and the third part is the instruction area, fixed as "Please answer the user's question or perform the corresponding operation based on the above context." After filling the second part with the text sequence, a generated prompt containing contextual information is formed.
[0042] Next, the generated prompt is concatenated with the original query text entered by the user in step S2, with the generated prompt first and the original query second, separated by a newline character. The concatenated complete text is then input into the large language model. This large language model is built using a decoder-only Transformer architecture, which internally contains a tokenizer, an embedding layer, a 24-layer Transformer decoder stack, and an output layer connected in sequence. The word segmenter uses a byte-pair encoding algorithm to split the input text into a sequence of tokens and map each token to a corresponding numerical code. The embedding layer converts each numerical code into a 128-dimensional initial vector and superimposes a positional code calculated based on a sine function onto each vector. Each layer in the 24-layer Transformer decoder stack contains a multi-head self-attention sublayer and a feedforward neural network sublayer. The multi-head self-attention sublayer uses eight attention heads to compute the association weights between the input vectors in parallel, and the feedforward neural network sublayer contains two linear transformations and expands the intermediate dimension to 512 dimensions. The output layer maps the vector output by the last decoder layer to a probability distribution of the vocabulary size through a linear transformation and uses an autoregressive approach to predict the next token one by one until the complete original response text is generated. After obtaining the original response text, regular expressions are used to extract fields. The regular expression is defined as the pattern "Answer body: (.?) Operation instruction: (.?)". If the match is successful, the answer body field and the operation instruction field are extracted respectively. If the match fails, a punctuation-based segmentation method is used to segment the original response text into sentences by period. The first sentence is taken as the answer body, and the remaining part is taken as the operation instruction field.
[0043] Next, the entity identifier list of the current user is read from the permission database. This list pre-stores all employee IDs, job titles, skill names, and process node names that the user has access to. Each word in the answer body is iterated through, and a maximum forward matching algorithm is used to identify the entity names contained within them. For each identified entity name, it is checked whether it exists in the current user's entity identifier list. If it exists, the word is retained; otherwise, the entire sentence containing that word is marked as inaccessible. After the iteration is complete, all sentences marked as inaccessible are removed from the answer body, and the remaining sentences are reassembled to form the filtered response content.
[0044] Finally, each entity name appearing in the filtered response is compared with the entity names of each node in the candidate knowledge fragments output in step S3. If the names match, an association is established between the entity name and the unique identifier of the corresponding node in the knowledge graph. A citation is added to the end of the filtered response, with the format being a list of all associated entity names within square brackets, separated by commas. The response with the added citation is then output to the user interface as the final response.
[0045] In S5, user feedback on the final response is collected, including clicks, ratings, or subsequent actions. Based on this feedback, entity attributes, relationship strength, and user profiles in the knowledge graph are dynamically updated to optimize the accuracy and personalization of subsequent question-and-answer sessions, forming a closed loop. Specifically, this includes: First, user feedback data on the final response is collected, including clickstream records generated by users clicking on entity links in the final response, user-submitted ratings (ranging from 1 to 5 points), and subsequent query text entered by the user immediately after this query. The number of times each entity appears in the clickstream is accumulated as the increment of the number of times that entity is accessed. The ratings are converted into entity satisfaction scores using a linear mapping, with the following mapping rules: 1 point corresponds to 0.2 points, 2 points to 0.4 points, 3 points to 0.6 points, 4 points to 0.8 points, and 5 points to 1.0 points. For subsequent query text, the dependency parsing method described in step S2 is used to extract keywords, and these keywords are associated with and bound to the core entities involved in this query, that is, a co-occurrence relationship between the keyword and the entity is recorded in the user profile.
[0046] Secondly, the entity satisfaction scores obtained in the above steps are weighted and accumulated into the historical rating attribute of the corresponding entity in the knowledge graph. The weighting coefficient is determined based on the number of times the entity is referenced in this query; for each additional reference, the weighting coefficient increases by 0.1, but not exceeding 1.0. The increment in the number of visits is directly added to the entity's popularity attribute, and then a time decay calculation is performed on this popularity attribute. The decay period is set to 30 days, and the decay occurs daily at a decay coefficient of 0.97. That is, the popularity value on day t is equal to the original popularity value multiplied by 0.97 raised to the power of t, where t represents the number of days since the current date. After the decay calculation, only the visit records within the last 30 days are retained; records older than 30 days are removed from the popularity attribute.
[0047] Next, traverse all paths traversed in the knowledge graph during this query, extracting the relationship edges between adjacent entity pairs on each path. For each relationship edge, add a temporary co-occurrence count, initially 0, increasing by 1 with each traversal. Then, add this temporary co-occurrence count to the historical co-occurrence count stored for that relationship edge to obtain a new total co-occurrence count. Next, calculate the ratio of this total co-occurrence count to the historical co-occurrence count. If the ratio is greater than 1.2, increase the weight of the relationship edge by 0.1; if the ratio is less than 0.8, decrease the weight by 0.1; if the ratio is between 0.8 and 1.2, leave the weight unchanged. The adjustment range for the weight is limited to between 0.1 and 1.0; values outside this range are used as boundary values.
[0048] Finally, the core entity names and relationship types involved in this query, along with the keywords bound in the previous steps, are merged and added to the historical preference entity list and preference relationship list of the user profile. For the historical preference entity list, each entity records the date of its most recent query; for the preference relationship list, each relationship records the date of its most recent use. Subsequently, the entire user profile is traversed, and all outdated entries with records older than 90 days from the current date are removed to ensure that the user profile retains only recent preference information. The updated user profile is output to step S1 to guide the entity mapping and weight allocation for subsequent queries, thus forming a complete closed-loop optimization process.
[0049] Please see Figure 2 As shown, an AI question-answering system based on knowledge graphs includes: Knowledge Graph Construction Module: Based on multi-source human resources data, including employee information, job descriptions, business process documents and historical Q&A records, it constructs a human resources knowledge graph containing employees, positions, skills, process nodes and their semantic associations through entity extraction and relationship mining. It also vectorizes the entities and relationships in the graph and outputs a structured knowledge graph. User intent understanding module: It receives users' natural language queries, combines them with pre-built user profiles and contextual information, maps the queries to entities and relationships in the knowledge graph through semantic parsing, generates graph query statements or retrieval conditions containing the query intent, and outputs the intent parsing results; Knowledge Reasoning and Retrieval Module: This module receives the intent parsing results, retrieves candidate entities, relationships, or subgraphs related to the query based on the topological structure of the knowledge graph through graph traversal, path reasoning, or similarity calculation, and sorts the retrieval results by combining vector similarity, outputting candidate knowledge fragments. Answer generation and instruction synthesis module: It is used to input candidate knowledge fragments as context into the large language model, combine them with the retrieval enhancement generation component, generate answers or executable business process operation instructions that conform to natural language habits, and filter the output content according to the permission rules to generate the final response; Feedback and Update Module: This module collects user feedback on the final response, including clicks, ratings, or subsequent actions. Based on this feedback, it dynamically updates entity attributes, relationship strength, and user profiles in the knowledge graph, optimizing the accuracy and personalization of subsequent question-and-answer sessions to form a closed loop.
[0050] The working principle of this invention is as follows: First, based on multi-source human resources data, an HR knowledge graph containing employees, positions, skills, process nodes, and their semantic associations is constructed through entity extraction and relationship mining. Entities and relationships in the graph are then vectorized to output a structured knowledge graph. Second, natural language queries from users are received, and semantic parsing is performed using pre-built user profiles and contextual information. The queries are mapped to entities and relationships in the knowledge graph, generating graph retrieval conditions containing the query intent. Then, using the identified entities from the intent parsing results as seed nodes, graph traversal and path reasoning are performed in the knowledge graph. The retrieval results are sorted using vector similarity calculations, and candidate knowledge fragments most relevant to the query are selected. Next, these candidate knowledge fragments are used as context input to a large language model to generate answers conforming to natural language habits or executable business process operation instructions. The output content is filtered according to permission rules, and citation annotations are added to form the final response. Finally, user feedback information, such as clicks, evaluations, and subsequent queries, is collected. Based on this feedback, the entity attributes, relationship strength, and user profiles in the knowledge graph are dynamically updated. The updated user profiles are used to guide subsequent queries, forming a closed-loop optimization.
[0051] The foregoing has provided a detailed description of one embodiment of the present invention, but this description is merely a preferred embodiment and should not be construed as limiting the scope of the invention. All equivalent variations and modifications made within the scope of the claims of this invention should still fall within the patent coverage of this invention.
Claims
1. A knowledge graph-based artificial intelligence question-answering method, characterized in that, Includes the following steps: S1: Based on multi-source human resources data, including employee information, job descriptions, business process documents and historical Q&A records, a human resources knowledge graph containing employees, positions, skills, process nodes and their semantic associations is constructed through entity extraction and relationship mining. The entities and relationships in the graph are vectorized and a structured knowledge graph is output. S2: Receives user natural language queries, combines pre-built user profiles and contextual information, maps the queries to entities and relationships in the knowledge graph through semantic parsing, generates graph query statements or retrieval conditions containing query intent, and outputs intent parsing results; S3: Receive the intent parsing results, and based on the topological structure of the knowledge graph, retrieve candidate entities, relationships, or subgraphs related to the query through graph traversal, path reasoning, or similarity calculation. Then, sort the retrieval results by combining vector similarity and output candidate knowledge fragments. S4: Input candidate knowledge fragments as context into the large language model, combine them with the retrieval enhancement generation component to generate answers or executable business process operation instructions that conform to natural language habits, and filter the output content according to permission rules to generate the final response; S5: Collect user feedback on the final response, including clicks, ratings, or subsequent actions, and dynamically update entity attributes, relationship strength, and user profiles in the knowledge graph based on the feedback to optimize the accuracy and personalization of subsequent question and answer, forming a closed loop.
2. The knowledge graph-based artificial intelligence question-answering method according to claim 1, characterized in that, The output structured knowledge graph specifically includes: By using pre-defined dictionary matching and dependency parsing, the system extracts employee, job, skill, and process node entities from multi-source human resources data and merges entities with the same name. Based on the co-occurrence window of entities in the text and the syntactic dependency path, an initial relation graph is constructed. Isolated edges are removed by graph connectivity component analysis, and relation types are sorted by confidence through relation path counting to filter out core relations. Entities and relations are constructed into a heterogeneous graph. A random walk based on metapaths is used to generate an entity sequence. The sequence is then input into a context prediction algorithm to learn the vector representation of each entity. At the same time, the relation vector is calculated based on the difference between the entity vectors at both ends of the relation. Entity vectors, relation vectors, and knowledge graph structure data are integrated to form a structured knowledge graph.
3. The knowledge graph-based artificial intelligence question-answering method according to claim 1, characterized in that, The output intent parsing results specifically include: It receives natural language queries from users, performs dependency parsing on the queries, extracts the core words and their dependencies, and assigns different weights to the core words based on the historical query entity preferences stored in the user profile. The core words are matched with entities in the knowledge graph. For core words that match multiple candidate entities, the entity that best matches the current context is selected by using the entities already identified in the context and the co-occurrence frequency between entities. Based on the dependency structure of the query and the mapped entity pairs, the path connecting these entities is searched in the knowledge graph, and the relationship with the shortest path length and matching the query intent is selected as the query relationship. Combine the identified entities and relationships to generate graph retrieval criteria that contain the query intent.
4. The knowledge graph-based artificial intelligence question-answering method according to claim 3, characterized in that, The selection of the entity that best matches the current context specifically includes: Candidate entities are retrieved from the knowledge graph based on literal matching of core words, and the set of associations of each candidate entity in the knowledge graph is recorded. Starting with the identified entities, expand outwards two layers along the relation edges to extract all adjacent entities and relations, forming a context subgraph; Iterate through each candidate entity, calculate the shortest path length between the candidate entity and each determined entity in the context subgraph, and sum the reciprocals of all path lengths as the contextual closeness of the candidate entity. The candidate entity with the highest contextual closeness is selected as the entity that matches the core word.
5. The knowledge graph-based artificial intelligence question-answering method according to claim 1, characterized in that, The output candidate knowledge fragments specifically include: Based on the identified entities contained in the intent parsing results, locate the corresponding nodes in the knowledge graph as a set of seed nodes; Starting from each node in the seed node set, traverse one layer outward along the relation edges, collect all adjacent nodes and relation edges, and merge the newly collected nodes with the seed nodes to form a candidate subgraph. Perform a dot product operation between the query semantic vector contained in the intent parsing result and the vector of each node in the candidate subgraph, and select the nodes with the top 1 / 3 of the dot product values and their associated paths to form a condensed subgraph; The condensed subgraph is transformed into candidate knowledge fragments composed of continuous text segments.
6. The knowledge graph-based artificial intelligence question-answering method according to claim 5, characterized in that, The formation of candidate subgraphs specifically includes: Iterate through each node in the seed node set, obtain all outgoing and incoming edges of the node, and if the number of adjacent nodes of a node exceeds a preset threshold, randomly select 1 / 3 of the adjacent nodes to participate in the subsequent expansion. For each seed node, traverse one layer outward along the preserved relation edges, collect adjacent nodes and relation edges, and record the depth value of each traversal path, discarding paths with a depth value exceeding one. Merge all adjacent nodes and relation edges obtained by expanding different seed nodes. If the same node is expanded by multiple seed nodes, retain the node and increase its reference count. The seed node is combined with its adjacent nodes and their relation edges that are retained after overlapping and merging to form a candidate subgraph.
7. The knowledge graph-based artificial intelligence question-answering method according to claim 1, characterized in that, The generation of the final response specifically includes: The entity names and relation types in the candidate knowledge fragments are arranged in order of appearance to form a text sequence, and the text sequence is filled into a preset prompt template to form a generated prompt containing contextual information; The generated prompts are concatenated with the user's original query and input into the large language model. The original response text output by the large language model is obtained, and regular expressions are used to extract the answer body or operation instruction field from the original response text. Based on the list of entity identifiers that the current user can access stored in the permission rules, iterate through all entity names that appear in the answer body, remove statements involving inaccessible entities, and generate filtered answer content. Each entity name appearing in the filtered response content is associated with the source node in the candidate knowledge fragment, and a corresponding reference mark is added to the end of the response content to form the final response.
8. The knowledge graph-based artificial intelligence question-answering method according to claim 1, characterized in that, The feedback mechanism dynamically updates the knowledge graph, specifically including: Collect user clickstream, rating values, and subsequent query text for the final response; map the clickstream to the incremental number of visits to the corresponding entity; convert the rating values into the corresponding entity satisfaction scores; and associate and bind keywords in the subsequent query text with the entity being queried. The satisfaction scores are weighted and accumulated into the historical rating attributes of the corresponding entity. The incremental number of visits is added to the popularity attribute of the entity. The popularity attribute is then subjected to time decay calculation, and the visit records within the most recent preset period are retained. Traverse all adjacent entity pairs on the current query path, extract the corresponding relationship edges, add a temporary co-occurrence count value for each relationship edge, and dynamically adjust the weight value of the relationship edge based on the ratio of the count value to the historical co-occurrence count. The core entity names and relationship types involved in this query, along with the bound keywords, are merged and added to the historical preference entity list and preference relationship list of the user profile. Outdated records that have exceeded the preset time limit are removed, and the updated user profile is output to S1.
9. A knowledge graph-based artificial intelligence question-answering system, characterized in that, An artificial intelligence question-answering method based on a knowledge graph, as described in any one of claims 1-8, comprises: Knowledge Graph Construction Module: Based on multi-source human resources data, including employee information, job descriptions, business process documents and historical Q&A records, it constructs a human resources knowledge graph containing employees, positions, skills, process nodes and their semantic associations through entity extraction and relationship mining. It also vectorizes the entities and relationships in the graph and outputs a structured knowledge graph. User intent understanding module: It receives users' natural language queries, combines them with pre-built user profiles and contextual information, maps the queries to entities and relationships in the knowledge graph through semantic parsing, generates graph query statements or retrieval conditions containing the query intent, and outputs the intent parsing results; Knowledge Reasoning and Retrieval Module: This module receives the intent parsing results, retrieves candidate entities, relationships, or subgraphs related to the query based on the topological structure of the knowledge graph through graph traversal, path reasoning, or similarity calculation, and sorts the retrieval results by combining vector similarity, outputting candidate knowledge fragments. Answer generation and instruction synthesis module: It is used to input candidate knowledge fragments as context into the large language model, combine them with the retrieval enhancement generation component, generate answers or executable business process operation instructions that conform to natural language habits, and filter the output content according to the permission rules to generate the final response; Feedback and Update Module: This module collects user feedback on the final response, including clicks, ratings, or subsequent actions. Based on this feedback, it dynamically updates entity attributes, relationship strength, and user profiles in the knowledge graph, optimizing the accuracy and personalization of subsequent question-and-answer sessions to form a closed loop.