Knowledge-based question-and-answer methods, devices, equipment, storage media, and program products
By performing node and hierarchical clustering on the knowledge graph and fine-tuning the large model, the shortcomings of question-answering systems in understanding complex semantic relationships are addressed, thereby improving the accuracy and relevance of answers.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- CHINA UNITED NETWORK COMM GRP CO LTD
- Filing Date
- 2025-01-22
- Publication Date
- 2026-07-31
AI Technical Summary
Existing question-answering systems suffer from inaccuracies in understanding and processing complex semantic relationships, especially when dealing with complex queries involving multiple entities and relationships. The lack of a deep understanding of the relationships between entities leads to inaccurate or incomplete answers.
By performing node clustering on the knowledge graph, multiple topic clusters are generated, and hierarchical clustering is performed. The large model is then fine-tuned using topic- and hierarchical knowledge graphs to improve its text understanding capabilities.
This enhances the semantic understanding capabilities of the question-and-answer system, improves the accuracy and relevance of answers, and meets users' demand for high-quality information services.
Smart Images

Figure CN122489685A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of large model technology, and in particular to a knowledge question answering method, apparatus, device, storage medium and program product. Background Technology
[0002] In modern information retrieval and human-computer interaction systems, users typically ask questions in natural language and expect machines to provide accurate and relevant answers. However, existing question-answering systems face significant challenges in generating answers, particularly in understanding and processing complex semantic relationships. Traditional document retrieval techniques primarily rely on keyword matching and statistical methods, which result in a relatively flat knowledge representation and lack of understanding of the deep semantic structure within the text.
[0003] Therefore, existing question-answering systems have technical problems with inaccuracy in the process of understanding text. Summary of the Invention
[0004] This application provides a knowledge question answering method, apparatus, device, storage medium, and program product to solve the technical problem of inaccurate text understanding in question answering systems.
[0005] Firstly, this application provides a knowledge question-answering method, including:
[0006] Obtain a data source, wherein the data source includes multiple sample data;
[0007] The sample data is subjected to data extraction processing to obtain the entities, attributes and relationships corresponding to the sample data;
[0008] A knowledge graph is generated based on the entities, attributes, and relationships corresponding to the sample data, and the knowledge graph is saved to the database.
[0009] The knowledge graph is subjected to node clustering to obtain multiple topic clusters;
[0010] Hierarchical clustering is performed on the multiple topic clusters to obtain multiple hierarchical clusters;
[0011] Based on the multiple topic clusters and the multiple hierarchical clusters, the large model to be fine-tuned is processed to obtain the target large model, wherein the target large model is used to perform intent recognition and entity recognition on the user input question.
[0012] Optionally, in the method described above, the node clustering process of the knowledge graph to obtain multiple topic clusters includes:
[0013] Obtain a pre-built autoencoder model;
[0014] A clustering distribution is introduced into the autoencoder model to obtain an autoencoder model for clustering;
[0015] Based on the autoencoder model used for clustering, the knowledge graph is subjected to node clustering processing to obtain multiple topic clusters.
[0016] Optionally, in the method described above, the hierarchical clustering process of the plurality of topic clusters to obtain a plurality of hierarchical clusters includes:
[0017] Calculate the distance metric between any two topic clusters;
[0018] Based on the distance metric, hierarchical clustering is performed on the multiple topic clusters to obtain multiple hierarchical clusters.
[0019] Optionally, in the method described above, calculating the distance metric between any two topic clusters includes:
[0020] Calculate the average distance between all point pairs in any two topic clusters;
[0021] Based on the average distance, determine the distance metric between any two topic clusters.
[0022] Optionally, in the method described above, the step of fine-tuning the large model to be fine-tuned based on the plurality of topic clusters and the plurality of hierarchical clusters to obtain the target large model includes:
[0023] Key information extraction processing is performed on the multiple topic clusters and the multiple hierarchical clusters to obtain index content, wherein the index content includes a node list, node attributes and connection relationships;
[0024] Based on the index content, the large model to be fine-tuned is processed to obtain the target large model.
[0025] Optionally, the method described above, after fine-tuning the large model to be fine-tuned based on the plurality of topic clusters and the plurality of hierarchical clusters to obtain the target large model, further includes:
[0026] The problem of obtaining user input;
[0027] Based on the target large model, intent recognition and entity recognition are performed on the question to obtain the knowledge subgraph corresponding to the question;
[0028] The answer to the question is determined based on the pre-configured prompts in the large model and the knowledge subgraph.
[0029] Optionally, the method described above further includes:
[0030] The configuration interface displays multiple functional components;
[0031] In response to the user's configuration operation on the configuration interface for the functional components, the large model to be fine-tuned is fine-tuned to obtain the target large model.
[0032] Secondly, this application provides a knowledge question-answering device, comprising:
[0033] An acquisition module is used to acquire a data source, wherein the data source contains multiple sample data.
[0034] The first processing module is used to perform data extraction processing on the sample data to obtain the entities, attributes and relationships corresponding to the sample data;
[0035] The generation module is used to generate a knowledge graph based on the entities, attributes and relationships corresponding to the sample data, and save the knowledge graph to the database;
[0036] The first clustering module is used to perform node clustering processing on the knowledge graph to obtain multiple topic clusters;
[0037] The second clustering module is used to perform hierarchical clustering on the multiple topic clusters to obtain multiple hierarchical clusters;
[0038] The second processing module is used to fine-tune the large model to be fine-tuned based on the multiple topic clusters and the multiple hierarchical clusters to obtain the target large model, wherein the fine-tuned large model is used to perform intent recognition and entity recognition on the user input question.
[0039] Optionally, the first clustering module described above, when performing node clustering processing on the knowledge graph to obtain multiple topic clusters, is used to:
[0040] Obtain a pre-built autoencoder model;
[0041] A clustering distribution is introduced into the autoencoder model to obtain an autoencoder model for clustering;
[0042] Based on the autoencoder model used for clustering, the knowledge graph is subjected to node clustering processing to obtain multiple topic clusters.
[0043] Optionally, the second clustering module described above, when performing hierarchical clustering processing on the multiple topic clusters to obtain multiple hierarchical clusters, is used to:
[0044] Calculate the distance metric between any two topic clusters;
[0045] Based on the distance metric, hierarchical clustering is performed on the multiple topic clusters to obtain multiple hierarchical clusters.
[0046] Optionally, the second clustering module described above, when performing the calculation of the distance metric between any two topic clusters, is used to:
[0047] Calculate the average distance between all point pairs in any two topic clusters;
[0048] Based on the average distance, determine the distance metric between any two topic clusters.
[0049] Optionally, the second processing module described above, when performing the fine-tuning process based on the multiple topic clusters and the multiple hierarchical clusters to obtain the target large model, is used to:
[0050] Key information extraction processing is performed on the multiple topic clusters and the multiple hierarchical clusters to obtain index content, wherein the index content includes a node list, node attributes and connection relationships;
[0051] Based on the index content, the large model to be fine-tuned is processed to obtain the target large model.
[0052] Optionally, the above-mentioned device further includes:
[0053] The answer generation module is used for:
[0054] The problem of obtaining user input;
[0055] Based on the target large model, intent recognition and entity recognition are performed on the question to obtain the knowledge subgraph corresponding to the question;
[0056] The answer to the question is determined based on the pre-configured prompts in the large model and the knowledge subgraph.
[0057] Optionally, the above-mentioned device further includes:
[0058] The response module is used for:
[0059] The configuration interface displays multiple functional components;
[0060] In response to the user's configuration operation on the configuration interface for the functional components, the large model to be fine-tuned is fine-tuned to obtain the target large model.
[0061] Thirdly, this application provides an electronic device, including: a processor, and a memory communicatively connected to the processor;
[0062] The memory stores computer-executed instructions;
[0063] The processor executes computer execution instructions stored in the memory to implement the knowledge question-answering method as described in any of the first aspects.
[0064] Fourthly, this application provides a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, are used to implement the knowledge question-answering method as described in any of the first aspects.
[0065] Fifthly, this application provides a computer program product, including a computer program that, when executed by a processor, implements the knowledge question-answering method as described in any of the first aspects.
[0066] The knowledge question answering method, apparatus, device, storage medium, and program product provided in this application obtain sample data by acquiring a data source; perform data extraction processing on the sample data to obtain the entities, attributes, and relationships corresponding to the sample data; generate a knowledge graph based on the above entities, attributes, and relationships to determine the relationships between entities, and then save the knowledge graph to a database; perform node clustering processing on the knowledge graph to obtain multiple topic clusters to group the knowledge graph by topic; perform hierarchical clustering processing on the grouped topic clusters to arrange the topic clusters within the group hierarchically to obtain hierarchical clusters of different topics; and use hierarchical clusters and topic clusters to fine-tune the large model to be fine-tuned to improve the large model's ability to understand text, thereby achieving the beneficial effect of improving the text understanding ability of the question answering system. Attached Figure Description
[0067] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0068] Figure 1 This application provides a schematic diagram of the architecture of a question-answering system.
[0069] Figure 2 This is a schematic diagram illustrating an application scenario of a question-and-answer system provided in an embodiment of this application;
[0070] Figure 3 A flowchart illustrating a knowledge question-answering method provided in an embodiment of this application;
[0071] Figure 4 This application provides a schematic diagram of the construction process of an index database.
[0072] Figure 5 This is a schematic diagram illustrating an application scenario of a large model provided in an embodiment of this application;
[0073] Figure 6 This is a schematic diagram of the structure of a knowledge question-answering device provided in an embodiment of this application;
[0074] Figure 7This is a schematic diagram of the structure of an electronic device provided in this application.
[0075] The accompanying drawings have illustrated specific embodiments of this application, which will be described in more detail below. These drawings and descriptions are not intended to limit the scope of the concept in any way, but rather to illustrate the concept of this application to those skilled in the art through reference to specific embodiments. Detailed Implementation
[0076] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.
[0077] First, let me explain the terms used in this application:
[0078] Knowledge graphs are structured data models used in question-answering systems to represent and organize information. They describe entities and their relationships through nodes and edges, thereby capturing complex semantic associations. By utilizing knowledge graphs, question-answering systems can understand the entities and relationships in user queries, perform semantic reasoning and information integration, and provide more accurate and relevant answers. This graph structure not only improves the efficiency of information retrieval but also enhances the system's semantic understanding and reasoning capabilities, enabling it to handle complex queries and dynamically update the knowledge base to maintain the timeliness of information.
[0079] A cluster is a set of data points or objects that are similar to each other in some sense. The goal of clustering is to divide a dataset into several clusters, such that data points within the same cluster have high similarity in the feature space, while data points in different clusters have significant differences. The definition of a cluster depends on the similarity metric used, such as Euclidean distance or cosine similarity, and the chosen clustering algorithm, such as K-means, hierarchical clustering, or DBSCAN. Cluster analysis can reveal the inherent structure and patterns of data, aiding in data understanding and application.
[0080] The knowledge-based question-and-answer method provided in this application can be applied to... Figure 1 The question-and-answer system shown. (For example...) Figure 1 As shown, the question-answering system includes: a user input processing module, a natural language understanding (NLU) module, an information retrieval (IR) module, a knowledge graph module, a reasoning and answer generation module, a natural language generation (NLG) module, a user feedback and learning module, and a dialogue management module.
[0081] The Natural Language Generation (NLG) module and the User Feedback and Learning module work by first receiving and preprocessing the user's query through the User Input Processing module. Then, the NLG module parses the input natural language to identify intent and extract key entities. The Information Relationship (IR) module retrieves relevant information from a knowledge base or document collection, while the knowledge base / knowledge graph module provides structured knowledge support. The Reasoning and Response Generation module generates an answer using the retrieved information and knowledge base content, and the NLG module converts the answer into fluent natural language text. Finally, the User Feedback and Learning module collects feedback to continuously optimize system performance. Through the collaborative work of these modules, the question-answering system can understand queries, retrieve information, and generate accurate answers.
[0082] Figure 2 This is a schematic diagram illustrating the application scenario of the question-answering system provided in this application, such as... Figure 2 As shown, one application scenario of the existing technology is as follows: S101, the user input processing module receives and preprocesses the user's query; S102, the NLU module parses the input natural language to identify intent and extract key entities; S103, the IR module retrieves relevant information from a knowledge base or document collection, wherein the knowledge base / knowledge graph module provides structured knowledge support; S104, the reasoning and answer generation module generates an answer using the retrieved information and knowledge base content; S105, the NLG module converts the answer into fluent natural language text. Through the collaborative work of these modules, the question-answering system can understand the query, retrieve information, and generate accurate answers.
[0083] Specifically, when dealing with relationships between entities, related technologies often fail to effectively capture and represent causal relationships, temporal sequences, and other complex semantic connections within text. This deficiency makes it difficult for question-answering systems to generate accurate answers when faced with questions that require comprehensive consideration of relationships between multiple entities. For example, in question-answering scenarios involving causal relationships between events, the system may be unable to identify the sequence of events or causal chains, thus providing inaccurate or incomplete answers.
[0084] Furthermore, when handling complex queries involving multiple entities and relationships, related technologies often lack a deep understanding of the relationships between entities, which limits the application capabilities of question-answering systems in specific domains or professional knowledge contexts. As users' demands for information accuracy and relevance continue to increase, there is an urgent need for a technology that can better understand and represent the complex relationships between entities to improve the performance and user experience of question-answering systems.
[0085] Therefore, developing a technology that can effectively consider entity relationships during question-and-answer processes can not only enhance the system's semantic understanding capabilities but also improve the accuracy and relevance of answers, meeting users' demands for high-quality information services. The realization of this technology will provide crucial support for the intelligent development of human-computer interaction systems.
[0086] Based on the above scenarios, it can be seen that when dealing with text understanding involving multiple entities, the relevant technologies have unclear technical issues regarding entity domain division and entity relationships within the same domain.
[0087] The knowledge question answering method provided in this application solves the technical problem of low text understanding ability of large models by first dividing entities into topics through clustering, then dividing entities in each topic into levels, and then using the technical means of fine-tuning large models with topic-based and hierarchical knowledge graphs.
[0088] This application provides a knowledge question answering method aimed at solving the above-mentioned technical problems in the prior art. It is executed by the knowledge graph module in the question answering system, wherein the knowledge graph module can be an electronic device, and the electronic device can be a server or a terminal device.
[0089] The aforementioned terminal devices can be either wireless or wired. A wireless terminal can be a device that provides voice and / or other service data connectivity to a user, a handheld device with wireless connectivity, or other processing devices connected to a wireless modem. The wireless terminal can communicate with one or more core network devices via a Radio Access Network (RAN). The wireless terminal can be a mobile terminal, such as a mobile phone (or "cellular" phone) or a computer with a mobile terminal, for example, a portable, pocket-sized, handheld, computer-embedded, or vehicle-mounted mobile device, which exchanges voice and / or data with the RAN. Furthermore, a wireless terminal can also be a Personal Communication Service (PCS) phone, a cordless phone, a Session Initiation Protocol (SIP) phone, a Wireless Local Loop (WLL) station, a Personal Digital Assistant (PDA), or other similar devices. A wireless terminal can also be referred to as a system, subscriber unit, subscriber station, mobile station, mobile station, remote station, remote terminal, access terminal, user terminal, user agent, user device, or user equipment; no specific terminology is used here. Optionally, the aforementioned terminal devices can also be smartwatches, tablets, or other similar devices.
[0090] The technical solution of this application and how the technical solution of this application solves the above-mentioned technical problems are described in detail below with specific embodiments. These specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments. The embodiments of this application will now be described with reference to the accompanying drawings.
[0091] Figure 3 This is a flowchart illustrating a knowledge question-answering method provided in an embodiment of this application, such as... Figure 3 As shown, the knowledge question-answering method provided in this application may specifically include steps S201 to S206, wherein:
[0092] S201. Obtain the data source, which includes multiple sample data.
[0093] The sample data includes structured data, semi-structured data, and unstructured data.
[0094] S202. Perform data extraction processing on the sample data to obtain the entities, attributes and relationships corresponding to the sample data.
[0095] The above extraction process can be achieved based on named entity recognition (NER), relation extraction, and co-occurrence analysis.
[0096] The same sample data corresponds to multiple entities, and each of these entities has its own attributes, and there are relationships between different entities.
[0097] For example, when the entity is a person, the attributes include information such as name, occupation, and age; when the entity is a product, the attributes include information such as geographical coordinates, city name, and population. When the entities are person 1 and person 2, the relationship between person 1 and person 2 can be that of relatives, friends, or colleagues.
[0098] S203. Generate a knowledge graph based on the entities, attributes, and relationships corresponding to the sample data, and save the knowledge graph to the database.
[0099] Specifically, entities are used as nodes, attributes as node attributes, and relationships as node relationships to construct a knowledge graph. Then, the knowledge graph corresponding to the sample data is stored in a knowledge graph library (database).
[0100] S204. Perform node clustering on the knowledge graph to obtain multiple topic clusters.
[0101] Each topic cluster corresponds to a unique technical field or historical problem topic. Node clustering can be performed based on graph autoencoder (GAE) and k-means clustering.
[0102] For example, based on preset topic keywords, the knowledge graph is grouped to obtain topic clusters corresponding to different preset topic keywords, so as to realize the knowledge graph. Among them, the topic cluster includes multiple knowledge graphs.
[0103] S205. Perform hierarchical clustering on multiple topic clusters to obtain multiple hierarchical clusters.
[0104] Specifically, the degree of difference between each pair of topic clusters is obtained. This degree of difference can be a parameter that can characterize the difference between topic clusters, such as distance metric or number of node differences. For the same topic cluster, a target cluster is determined based on the multiple degrees of difference corresponding to that topic cluster. The degree of difference corresponding to the target cluster is the smallest among the multiple degrees of difference. The topic cluster and the target cluster are combined to obtain a new topic cluster. For the same new topic cluster, the process of obtaining the degree of difference between each pair of topic clusters is repeated until the number of new topic clusters reaches the preset number of clusters. At this point, the new topic cluster is regarded as a hierarchical cluster.
[0105] S206. Based on multiple topic clusters and multiple hierarchical clusters, fine-tune the large model to be fine-tuned to obtain the target large model, wherein the target large model is used to perform intent recognition and entity recognition on the user input question.
[0106] Fine-tuning refers to constructing index information for each cluster based on hierarchical clusters and topic clusters, and then constructing an index database based on the index information and its corresponding clusters; the index database is used to replace the database in the knowledge graph module of related technologies.
[0107] The index information includes the content summary corresponding to the cluster, the cluster nodes (entities), and the relationships and attributes of each entity.
[0108] The knowledge question answering method provided in this application obtains data sources to obtain sample data; performs data extraction processing on the sample data to obtain the entities, attributes, and relationships corresponding to the sample data; generates a knowledge graph based on the above entities, attributes, and relationships to determine the relationships between entities, and then saves the knowledge graph to a database; performs node clustering processing on the knowledge graph to obtain multiple topic clusters to group the knowledge graph by topic; performs hierarchical clustering processing on the grouped topic clusters to arrange the topic clusters within the group hierarchically to obtain hierarchical clusters of different topics; and uses hierarchical clusters and topic clusters to fine-tune the large model to be fine-tuned, so as to improve the large model's ability to understand text, thereby achieving the beneficial effect of improving the text understanding ability of the question answering system.
[0109] In one possible implementation, S204 above performs node clustering processing on the knowledge graph to obtain multiple topic clusters, specifically including S204-1 to S204-3, wherein:
[0110] S204-1. Obtain the pre-established autoencoder model.
[0111] The autoencoder model can be a GAE, consisting of a decoder and an encoder. The encoder maps nodes in the knowledge graph to a low-dimensional latent space, denoted as Z. iThe decoder then attempts to reconstruct the structure of the knowledge graph from the low-dimensional latent space. The cross-entropy loss function is used to measure the reconstruction error, and the formula is:
[0112]
[0113] Among them, L Rec For the reconstruction error, A represents the true adjacency matrix. Let represent the predicted adjacency matrix, and the difference between the two is the reconstruction error. ij These are elements in the adjacency matrix A. Predicted adjacency matrix The purpose of this step is to accurately represent the features of the nodes in the graph for subsequent node clustering processing.
[0114] S204-2. Introduce a clustering distribution into the autoencoder model to obtain an autoencoder model for clustering.
[0115] This clustering distribution can be graph clustering, denoted by Q. The autoencoder model used for clustering is represented by P, as follows:
[0116] P = softmax(Q, Z) i )
[0117] Where Q represents the graph clustering model, Z i Let P represent the i-th knowledge graph, and let P represent the graph clustering result of the i-th knowledge graph.
[0118] S204-3. Based on the autoencoder model used for clustering, perform node clustering on the knowledge graph to obtain multiple topic clusters.
[0119] When the degree of dissimilarity is the clustering loss, the clustering loss L of k-means clustering is... C The calculation formula is as follows:
[0120]
[0121] x i U represents the center of the i-th topic cluster. k C represents the position of the k-th node in this topic cluster. k Let represent the set of k centers.
[0122] At this point, it is important to note that, in addition to ensuring the number of new topic clusters reaches the preset number, the node clustering process should also meet the following conditions to reduce the accuracy of node clustering in the autoencoder model during training:
[0123] L = L Rec +αL C
[0124] Here, α is a balance parameter.
[0125] In one possible implementation, the above-described S205 involves hierarchical clustering of multiple topic clusters to obtain multiple hierarchical clusters, specifically including S205-1 and S205-2, wherein:
[0126] S205-1 Calculate the distance metric between any two topic clusters.
[0127] Let there be two clusters Ci and Cj, where Ci = {ei1, ei2, ..., ein} and Cj = {ej1, ej2, ..., ejm}. The distance between pairs of points can be calculated using methods such as Euclidean distance. Then, the average link distance D(Ci, Cjm) between the two clusters is... i C j )for:
[0128]
[0129] Wherein d(e ik ,e jl ) represents e 2 ik +e 2 jl The arithmetic square root; e ik Let e represent the average distance between any two knowledge graphs among the above n knowledge graphs, i,k∈[1,n], where e jl Let j represent the average distance between any two knowledge graphs among the above m knowledge graphs, where j, l∈[1,m].
[0130] S205-2. Based on the distance metric, perform hierarchical clustering on multiple topic clusters to obtain multiple hierarchical clusters.
[0131] In one possible implementation, S205-1 calculates the distance metric between any two topic clusters, which may specifically include S205-1-1 and S205-1-2, wherein:
[0132] S205-1-1 Calculate the average distance between all point pairs in any two topic clusters.
[0133] Let there be two clusters Ci and Cj, where Ci = {ei1, ei2, ..., ein} and Cj = {ej1, ej2, ..., ejm}. Cluster Ci contains n knowledge graphs, and cluster Cj contains m knowledge graphs. Let the average distance be e. in and e jm , where e ik Let e represent the average distance between any two knowledge graphs among the above n knowledge graphs, i,k∈[1,n], where e jlLet j represent the average distance between any two knowledge graphs among the above m knowledge graphs, where j, l∈[1,m].
[0134] S205-1-2. Determine the distance metric between any two subject clusters based on the average distance.
[0135] The calculation formula for the distance metric is detailed in S205-1, and will not be repeated in this embodiment.
[0136] In one possible implementation, S206 above performs fine-tuning on the large model to be fine-tuned based on multiple topic clusters and multiple hierarchical clusters to obtain the target large model. Specifically, it may include S206-1 and S206-2, wherein:
[0137] S206-1. Extract key information from multiple topic clusters and multiple hierarchical clusters to obtain index content, which includes a list of nodes, node attributes, and connection relationships.
[0138] S206-2. Based on the index content, perform fine-tuning on the large model to be fine-tuned to obtain the target large model.
[0139] For details of the specific implementation process, please refer to S206. This embodiment will not repeat the details.
[0140] In one possible implementation, after fine-tuning the large model to be fine-tuned based on multiple topic clusters and multiple hierarchical clusters in S206 to obtain the target large model, the implementation further includes S207 to S209, wherein:
[0141] S207, Problem of obtaining user input.
[0142] S208. Based on the target big model, perform intent recognition and entity recognition on the question to obtain the knowledge subgraph corresponding to the question.
[0143] Specifically, the above problems are decomposed into entity entities to obtain problem entities; based on the above problems, the problem entities are analyzed to obtain the corresponding problem entity relationships and problem entity attributes; the problem entities, problem entity relationships, and problem entity attributes are used as problem index parameters; the index information with the highest overlap with the above problem index parameters is determined in the index database and used as the target index information; the hierarchical cluster corresponding to the target index information is retrieved, and then the nodes related to the problem entities are screened out in the hierarchical cluster corresponding to the target index information, while the nodes unrelated to the problem entities are removed, in order to construct a knowledge subgraph.
[0144] S209. Determine the answer to the question based on the pre-configured prompts and knowledge subgraphs in the large model.
[0145] Pre-configured prompts can be implemented based on prompts.
[0146] In one possible implementation, the knowledge question-answering method provided in this application further includes S211 and S212, wherein:
[0147] S211. Multiple functional components are displayed on the configuration interface.
[0148] The functional components include input components, output components, database components, etc.
[0149] S212. In response to the user's configuration operation on the configuration interface for the functional components, perform fine-tuning on the large model to be fine-tuned to obtain the target large model.
[0150] Users can drag and drop input components, output components, database components, etc. onto the canvas, and then connect the various components according to the workflow. The whole process does not require writing code and is visual.
[0151] In addition, this embodiment supports user-defined working components. Custom components are implemented by creating Python classes, which define the component's input, output, and functionality. An example is shown below: Class: Input = []; Output = []; function(). Here, Input represents the data entering the component; function is the function that indicates how to process the data; and Output represents the data output by the component.
[0152] In addition, the defined workflows can be shared via API, allowing users to directly call the API for use, and developers to test them.
[0153] The following example illustrates the knowledge question-answering method provided in the above embodiments, including: S301-S303 aim to generate an index database offline; S304 aims to analyze user questions online and generate answers using the index database; and S305 aims to define workflows in a low-code manner.
[0154] The specific implementation process is as follows:
[0155] S301. Construct a knowledge graph based on data sources.
[0156] Data is retrieved from the data source, entities, attributes, and relationships are extracted from the collected data, a knowledge graph is generated, and the generated knowledge graph is stored in the database.
[0157] S302. Use graph clustering to cluster entity nodes in the knowledge graph into topic clusters, and then construct hierarchical clusters by performing hierarchical clustering on the topic clusters.
[0158] Node clustering: To improve query efficiency and provide more accurate answers, graph clustering is used to divide the knowledge graph into different topic clusters. Relevant clusters can be identified based on the topic of the question, and then searches and reasoning can be performed within those clusters.
[0159] Hierarchical clustering: In order to better understand the different entities and the relationships between entities in the knowledge graph, hierarchical clustering is performed on the multiple topic clusters obtained in the above steps to build a hierarchical knowledge structure. When a user asks a relatively broad question, the question answering system first searches in the higher-level clusters to quickly locate the relevant topic.
[0160] S303. Extract cluster information: Based on the user's input question, find the smallest cluster that includes all entities in the question, and obtain the index information of the cluster to build an index database.
[0161] Figure 4 This is a schematic diagram illustrating the construction process of an index database provided in an embodiment of this application, such as... Figure 4 As shown, a knowledge graph is extracted from the knowledge base. For each knowledge graph, the corresponding entity nodes, node relationships, and node attributes are extracted, and a graph database is constructed using these entities, relationships, and attributes. Graph clustering is used to cluster the nodes of the knowledge graph to obtain topic clusters, and then hierarchical clustering is performed on the topic clusters to obtain hierarchical clusters. Then, the content summaries, clustering nodes, and relationship descriptions corresponding to the topic clusters and hierarchical clusters are extracted to construct an index database. The index database is then used to replace the knowledge graph database in the large language model (referred to as the large model) to complete the fine-tuning of the large language model.
[0162] Furthermore, when there are too many knowledge subgraphs, they will occupy storage space in the index database, necessitating optimization of the knowledge subgraphs within the index database. Optimization processes include, but are not limited to, merging knowledge subgraphs.
[0163] Integrating knowledge subgraphs involves multiple aspects, including entity alignment, relation mapping, and conflict resolution. When cross-domain differences arise during entity alignment, the problem of the same word having different meanings can occur. Furthermore, over time, even the same word within the same domain may develop different meanings.
[0164] Therefore, how to solve the problem of different meanings of the same word across time and domain is very important for the integration of knowledge subgraphs.
[0165] This embodiment provides a knowledge subgraph fusion method, applied to S303.
[0166] The above-mentioned S303 involves constructing an index database based on the index information, which may specifically include:
[0167] For each index in the index database, identify the same entity that the index information shares with every other index information;
[0168] The number of identical entities is counted as the number of similar entities. Based on the number of similar entities, the entity similarity between the entities in this index information and the entities in other index information is calculated. Entity similarity = number of similar entities ÷ total number of entities contained in this index information. Based on the entity similarity threshold and the above entity similarity, the entity similarity result is determined. If the entity similarity is not less than the entity similarity threshold, the entity similarity result is determined to be entity similar; otherwise, the entity similarity result is determined to be entity different.
[0169] When the entity similarity result is entity similarity, based on hierarchical clusters and topic clusters, the first entity relation group corresponding to the same entity in the index information is determined, and the second entity relation group corresponding to the same entity in other index information is determined; the number of the same entity relations in the first entity relation and the second entity relation is counted as the number of similar relations; the relation similarity corresponding to the first entity relation group is calculated, relation similarity = number of similar relations ÷ total number of entity relations corresponding to the first entity relation group; based on the relation similarity threshold and the above relation similarity, the relation similarity result is determined, wherein if the relation similarity is not less than the relation similarity threshold, the relation similarity result is determined to be relation similar, otherwise, the relation similarity result is determined to be relation different;
[0170] When the relation similarity result is that the relations are similar, a new knowledge subgraph is obtained based on the knowledge subgraphs corresponding to the two index information, so as to complete the memory optimization of the index database.
[0171] Furthermore, to avoid the same knowledge subgraph being merged by different knowledge subgraphs, the above-mentioned method of obtaining a new knowledge subgraph based on the knowledge subgraphs corresponding to the two index information can specifically include: taking the two index information as a similar index group, then counting multiple similar index groups corresponding to the index database, merging the similar index groups that have intersections as the target index group, and merging the knowledge subgraphs corresponding to the index information in the target index group to obtain a new knowledge subgraph.
[0172] S304, such as Figure 5 As shown, the user's question and the knowledge subgraph generated based on the question are input into the large model, and the large model generates the answer to the question based on the knowledge subgraph.
[0173] S304-1. Generate a knowledge subgraph: Obtain the user-input question, perform entity recognition on the question, find the smallest cluster (matching cluster) that includes all entities in the question, and obtain the target index information of the cluster.
[0174] The target index information is described in natural language. For example, the content summary (content digest) is "The personnel in the technical department are XXXX, and their common characteristics are XXXX", and the relationship description (entity relationship) is "source node 1 - node relationship - target node 1", "source node 2 - node relationship - target node 2", ..., "source node n - node relationship - target node n".
[0175] S304-2, Generating Answers to Questions: Input the question and the generated knowledge subgraph into the large model, and use predefined appropriate prompts to allow the large model to answer the user's question based on the knowledge subgraph to generate an answer.
[0176] S305. Define a knowledge-based question-and-answer workflow in a low-code platform and debug and use it via API.
[0177] To further reduce development difficulty and allow non-technical business personnel to participate in the development process, this invention proposes defining a knowledge-based question-and-answer workflow within a low-code platform. Users drag and drop input components, output components, database components, etc., onto the canvas, and then connect the various components according to the workflow. The entire process requires no coding and is visually intuitive. Furthermore, this invention supports user-defined workflow components, implemented by creating Python classes. These classes define the component's input, output, and functionality, as shown in the following example: Class: Input = []; Output = []; function(). Here, Input represents the number of inputs to the component; function is the function that specifies how to process the data; and Output represents the data output by the component.
[0178] In addition, the defined workflows can be shared via API, allowing users to directly call the API for use, and developers to test them.
[0179] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that this application is not limited to the described order of actions, as some steps may be performed in other orders or simultaneously according to this application. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are all optional embodiments, and the actions and modules involved are not necessarily essential to this application.
[0180] It should be further noted that although the steps in the flowchart are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowchart may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the sub-steps or stages of other steps.
[0181] Figure 6 This is a schematic diagram of the structure of a knowledge question-answering device provided in an embodiment of this application, as shown below. Figure 6 As shown, the knowledge question-answering device 40 provided in this application embodiment includes:
[0182] The acquisition module 401 is used to acquire a data source, which contains multiple sample data.
[0183] The first processing module 402 is used to perform data extraction processing on the sample data to obtain the entities, attributes and relationships corresponding to the sample data;
[0184] The generation module 403 is used to generate a knowledge graph based on the entities, attributes and relationships corresponding to the sample data, and save the knowledge graph to the database;
[0185] The first clustering module 404 is used to perform node clustering processing on the knowledge graph to obtain multiple topic clusters;
[0186] The second clustering module 405 is used to perform hierarchical clustering on multiple topic clusters to obtain multiple hierarchical clusters;
[0187] The second processing module 406 is used to fine-tune the large model to be fine-tuned based on multiple topic clusters and multiple hierarchical clusters to obtain the target large model. The fine-tuned large model is used to perform intent recognition and entity recognition on the user input question.
[0188] Optionally, the first clustering module 404 described above, when performing node clustering processing on the knowledge graph to obtain multiple topic clusters, is used to:
[0189] Obtain a pre-built autoencoder model;
[0190] Introducing a clustering distribution into the autoencoder model yields an autoencoder model for clustering.
[0191] Based on the autoencoder model used for clustering, the knowledge graph is subjected to node clustering to obtain multiple topic clusters.
[0192] Optionally, the second clustering module 405 described above, when performing hierarchical clustering processing on multiple topic clusters to obtain multiple hierarchical clusters, is used to:
[0193] Calculate the distance metric between any two topic clusters;
[0194] Based on the distance metric, hierarchical clustering is performed on multiple topic clusters to obtain multiple hierarchical clusters.
[0195] Optionally, the second clustering module 405 described above, when performing the calculation of the distance metric between any two topic clusters, is used to:
[0196] Calculate the average distance between all point pairs in any two topic clusters;
[0197] Determine the distance metric between any two topic clusters based on the average distance.
[0198] Optionally, the second processing module 406, when performing fine-tuning processing on the large model to be fine-tuned based on multiple topic clusters and multiple hierarchical clusters to obtain the target large model, is used to:
[0199] Key information is extracted from multiple topic clusters and multiple hierarchical clusters to obtain index content, which includes a list of nodes, node attributes, and connection relationships.
[0200] Based on the index content, the large model to be fine-tuned is fine-tuned to obtain the target large model.
[0201] Optionally, the aforementioned device 40 further includes:
[0202] Answer generation module 403 is used for:
[0203] The problem of obtaining user input;
[0204] Based on the target big model, intent recognition and entity recognition are performed on the question to obtain the knowledge subgraph corresponding to the question;
[0205] The answer to the question is determined based on the pre-configured prompts and knowledge subgraphs in the large model.
[0206] Optionally, the aforementioned device 40 further includes:
[0207] The response module is used for:
[0208] The configuration interface displays multiple functional components;
[0209] In response to the user's configuration operations for functional components on the configuration interface, the large model to be fine-tuned is fine-tuned to obtain the target large model.
[0210] The knowledge question-answering device provided in this embodiment can execute the methods provided in the above method embodiments. Its implementation principle and technical effect are similar, and will not be described in detail here.
[0211] It should be understood that the above-described device embodiments are merely illustrative, and the device of this application can also be implemented in other ways. For example, the division of units / modules in the above embodiments is only a logical functional division, and there may be other division methods in actual implementation. For example, multiple units, modules, or components may be combined, or integrated into another system, or some features may be ignored or not executed.
[0212] Furthermore, unless otherwise specified, the functional units / modules in the various embodiments of this application can be integrated into one unit / module, or each unit / module can exist physically separately, or two or more units / modules can be integrated together. The integrated units / modules described above can be implemented in hardware or as software program modules.
[0213] When an integrated unit / module is implemented in hardware, that hardware can be digital circuits, analog circuits, etc. The physical implementation of the hardware structure includes, but is not limited to, transistors, memristors, etc.
[0214] Figure 7 A schematic diagram of the structure of the electronic device provided in this application. Figure 7 As shown, the electronic device 50 provided in this embodiment includes at least one processor 501 and a memory 502. Optionally, the electronic device 50 further includes a communication component 503. The processor 501, memory 502, and communication component 503 are connected via a bus 504.
[0215] In a specific implementation, at least one processor 501 executes computer execution instructions stored in memory 502, causing at least one processor 501 to perform the above-described method.
[0216] The specific implementation process of processor 501 can be found in the above method embodiments, and its implementation principle and technical effect are similar. It will not be repeated here.
[0217] Unless otherwise specified, processor 501 can be any suitable hardware processor, such as CPU, GPU, FPGA, DSP, and ASIC. Unless otherwise specified, memory 502 can be any suitable magnetic or magneto-optical storage medium, such as resistive random access memory (RRAM), dynamic random access memory (DRAM), static random access memory (SRAM), enhanced dynamic random access memory (EDRAM), high-bandwidth memory (HBM), hybrid memory cube (HMC), etc.
[0218] If the integrated unit / module is implemented as a software program module and sold or used as an independent product, it can be stored in a computer-readable storage device (CMD). Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a memory and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this application. The aforementioned memory includes various media capable of storing program code, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard drive, magnetic disk, or optical disk.
[0219] This application also provides a computer-readable storage medium storing computer-executable instructions. When a processor executes the computer-executable instructions, it implements the above-described method for updating redundant fields in a distributed system.
[0220] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the above-described method for updating redundant fields in a distributed system.
[0221] In the above embodiments, the descriptions of each embodiment have their own emphasis. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments. The technical features of the above embodiments can be combined arbitrarily. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as these combinations of technical features do not contradict each other, they should be considered within the scope of this specification.
[0222] Other embodiments of this application will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of this application that follow the general principles of this application and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this application are indicated by the following claims.
[0223] It should be understood that this application is not limited to the precise structure described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this application is limited only by the appended claims.
Claims
1. A knowledge-based question-and-answer method, characterized in that, include: Obtain a data source, wherein the data source includes multiple sample data; The sample data is subjected to data extraction processing to obtain the entities, attributes and relationships corresponding to the sample data; A knowledge graph is generated based on the entities, attributes, and relationships corresponding to the sample data, and the knowledge graph is saved to the database. The knowledge graph is subjected to node clustering to obtain multiple topic clusters; Hierarchical clustering is performed on the multiple topic clusters to obtain multiple hierarchical clusters; Based on the multiple topic clusters and the multiple hierarchical clusters, the large model to be fine-tuned is processed to obtain the target large model, wherein the target large model is used to perform intent recognition and entity recognition on the user input question.
2. The method according to claim 1, characterized in that, The knowledge graph is subjected to node clustering to obtain multiple topic clusters, including: Obtain a pre-built autoencoder model; A clustering distribution is introduced into the autoencoder model to obtain an autoencoder model for clustering; Based on the autoencoder model used for clustering, the knowledge graph is subjected to node clustering processing to obtain multiple topic clusters.
3. The method according to claim 1, characterized in that, The hierarchical clustering process performed on the multiple topic clusters to obtain multiple hierarchical clusters includes: Calculate the distance metric between any two topic clusters; Based on the distance metric, hierarchical clustering is performed on the multiple topic clusters to obtain multiple hierarchical clusters.
4. The method according to claim 3, characterized in that, The calculation of the distance metric between any two topic clusters includes: Calculate the average distance between all point pairs in any two topic clusters; Based on the average distance, determine the distance metric between any two topic clusters.
5. The method according to any one of claims 1 to 4, characterized in that, The step of fine-tuning the large model to be fine-tuned based on the multiple topic clusters and the multiple hierarchical clusters to obtain the target large model includes: Key information extraction processing is performed on the multiple topic clusters and the multiple hierarchical clusters to obtain index content, wherein the index content includes a node list, node attributes and connection relationships; Based on the index content, the large model to be fine-tuned is processed to obtain the target large model.
6. The method according to any one of claims 1 to 4, characterized in that, After fine-tuning the large model to be fine-tuned based on the multiple topic clusters and the multiple hierarchical clusters to obtain the target large model, the process further includes: The problem of obtaining user input; Based on the target large model, intent recognition and entity recognition are performed on the question to obtain the knowledge subgraph corresponding to the question; The answer to the question is determined based on the pre-configured prompts in the large model and the knowledge subgraph.
7. The method according to any one of claims 1 to 4, characterized in that, Also includes: The configuration interface displays multiple functional components; In response to the user's configuration operation on the configuration interface for the functional components, the large model to be fine-tuned is fine-tuned to obtain the target large model.
8. A knowledge-based question-and-answer device, characterized in that, include: An acquisition module is used to acquire a data source, wherein the data source contains multiple sample data. The first processing module is used to perform data extraction processing on the sample data to obtain the entities, attributes and relationships corresponding to the sample data; The generation module is used to generate a knowledge graph based on the entities, attributes and relationships corresponding to the sample data, and save the knowledge graph to the database; The first clustering module is used to perform node clustering processing on the knowledge graph to obtain multiple topic clusters; The second clustering module is used to perform hierarchical clustering on the multiple topic clusters to obtain multiple hierarchical clusters; The second processing module is used to fine-tune the large model to be fine-tuned based on the multiple topic clusters and the multiple hierarchical clusters to obtain the target large model, wherein the fine-tuned large model is used to perform intent recognition and entity recognition on the user input question.
9. An electronic device, characterized in that, include: At least one processor; as well as A memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor to enable the at least one processor to perform the knowledge question-answering method as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions, which, when executed by a processor, are used to implement the knowledge question-answering method as described in any one of claims 1 to 7.
11. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the knowledge question-answering method as described in any one of claims 1 to 7.