Business database dialogue method and device, electronic equipment and medium

Through cleaning and blocking original knowledge data, large -scale language models are used to build diagram structure data and conduct community testing, solve the problem of complex data processing generated by IoT devices, and achieve efficient business database dialogue and data extraction.

CN119378676APending Publication Date: 2025-01-28E SURFING IOT CO LTD
View PDF 0 Cites 4 Cited by

Patent Information

Application Number
CN202411260173.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-10
Publication Date
2025-01-28

AI Technical Summary

Technical Problem

The prior art is difficult to efficiently process complex data generated by IoT devices, especially in the creation and management of database query views, which requires a lot of time and resources.

Method used

A business database dialogue method is proposed to clean and separate the original knowledge data, use large language models to build diagram structure data, and divide the community through community detection algorithms to generate community abstracts and answers.

Benefits of technology

Realize the efficient business database dialogue, simplify the database query process, improve the efficiency and accuracy of data extraction, and reduce the technical threshold.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119378676A_ABST
    Figure CN119378676A_ABST
Patent Text Reader

Abstract

The invention discloses a service database dialogue method and device, electronic equipment and a medium, and the method comprises the steps: carrying out the cleaning and partitioning of original knowledge data, and obtaining text blocks; carrying out data extraction and construction by utilizing a large language model to obtain graph structure data; detecting and dividing the graph structure data through a community detection algorithm to obtain a plurality of communities; generating a corresponding community abstract for each community through a large language model; performing embedding processing on the community abstract to obtain a first vector; in response to an input question of the target object, performing similarity matching on the first vector to obtain candidate communities, generating an intermediate answer for each candidate community, and obtaining a correlation score of each intermediate answer and the input question; taking the candidate community with the highest correlation score as a target community; and based on the node attribute information corresponding to the target community, generating a target answer by using a large language model. Business database dialogues can be efficiently achieved, and the method can be widely applied to the technical field of data processing.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of data processing technology, and in particular to a business database dialogue method, device, electronic equipment and medium. Background Art

[0002] With the exponential growth of IoT devices, data is pouring into databases every day, and real-time insights into business trends have become the key to guiding strategic planning and development. Although existing data platforms and business intelligence (BI) solutions can handle diverse data sets and build structured reporting frameworks, the dimension hierarchy of IoT data is relatively complex. According to many topics such as products, accounts, events, perception, and operations, it can be divided into interface layer, integration layer, middle layer, summary layer, application layer, etc. This not only requires developers to have a deep understanding of the database architecture, but also means that each new query view requires a lot of time and resources. Summary of the invention

[0003] The present invention proposes a business database dialogue method, device, electronic device and medium, aiming to solve one of the technical problems in the related art at least to a certain extent. The embodiments of the present invention can efficiently conduct business database dialogue.

[0004] On the one hand, an embodiment of the present invention provides a business database dialogue method, including:

[0005] Obtain the original knowledge data, clean and divide it into blocks, and obtain multiple text blocks; the original knowledge data includes metadata and query log data of all business tables; a single text block is associated with the data of a business table;

[0006] Based on the text block, the preset first large language model is used to extract data and construct graph structure data;

[0007] The graph structure data is detected and divided by a community detection algorithm to obtain multiple communities; a corresponding community summary is generated for each community by a preset second large language model; each community includes node attribute information of its corresponding part in the graph structure data;

[0008] Embedding the community summary to obtain the first vector corresponding to the community summary of each community;

[0009] In response to the input question of the target object, similarity matching is performed on the first vector to obtain a preset number of candidate communities with the highest similarity; an intermediate answer is generated for each candidate community through a preset third large language model, and a relevance score of each intermediate answer to the input question is obtained;

[0010] The candidate community with the highest relevance score is taken as the target community; based on the node attribute information corresponding to the target community, the preset fourth large language model is used to generate the target answer.

[0011] Optionally, obtaining original knowledge data, cleaning and dividing the original knowledge data into blocks to obtain multiple text blocks includes the following steps:

[0012] Extract the table creation statement and dimension attribute identifier of each business table in turn to obtain the metadata corresponding to each business table;

[0013] Retrieve the query records corresponding to each business table from the query log, and extract the query log data corresponding to each business table based on the query records;

[0014] Clear the execution log in the query log data, and then perform token cleaning on the query statements in the query log data to obtain the target query data;

[0015] Based on the dimensions of the business table, the metadata and target query data corresponding to the same business table are organized into text blocks corresponding to the business table.

[0016] Optionally, based on the text block, using a preset first large language model to extract data to construct graph structure data includes the following steps:

[0017] Iteratively send the text block to the first large language model according to the dimensions of the business table to extract data, and obtain the nodes, edges and node attribute information corresponding to each node;

[0018] Import the nodes, edges and node attribute information into the graph database to construct the graph structure data.

[0019] Optionally, the graph structure data is detected and divided by a community detection algorithm to obtain multiple communities, including the following steps:

[0020] Use graph structure data as the target graph structure;

[0021] Get the edge weights and number of connections between each node in the target graph structure;

[0022] Performing an initial partition on the target graph structure to obtain a first partition result; in the first partition result, each node in the target graph structure is regarded as a separate community;

[0023] Based on the edge weight and the number of connections, the quality of community division is measured for the adjacent communities in the first division result to obtain the modularity of all adjacent communities; based on the modularity, the target adjacent community is moved to the domain;

[0024] Perform community aggregation based on the results of domain movement, and update the target graph structure according to the results of community aggregation; wherein the aggregated community serves as a separate node in the updated target graph structure;

[0025] Return to execute the step of obtaining the edge weights and the number of connections between each node in the target graph structure until the preset iteration condition is reached, and multiple communities are output according to the target graph structure obtained in the last iteration.

[0026] Optionally, embedding the community summary to obtain a first vector corresponding to the community summary of each community includes the following steps:

[0027] Using a preset embedding model, the community summary of each community is represented by a vector in turn, so as to obtain a first vector corresponding to the community summary of each community;

[0028] The first vectors corresponding to all community summaries are stored in a preset vector knowledge base.

[0029] Optionally, in response to an input question of the target object, performing similarity matching on the first vector comprises the following steps:

[0030] Vectorize the input problem of the target object to obtain a second vector;

[0031] The cosine similarity algorithm is used to calculate the similarity between the second vector and the first vector corresponding to each community summary in turn, so as to obtain the similarity between the second vector and each first vector.

[0032] Optionally, based on the node attribute information corresponding to the target community, a preset fourth large language model is used to generate a target answer, including the following steps:

[0033] The node attribute information and community summary corresponding to the target community are sent to the context window of the fourth large language model, and the target answer is generated in combination with the preset output template.

[0034] On the other hand, an embodiment of the present invention provides a service database dialogue device, including:

[0035] The first module is used to obtain original knowledge data, clean and divide the original knowledge data into blocks, and obtain multiple text blocks; the original knowledge data includes metadata and query log data of all business tables; a single text block is associated with the data of a business table;

[0036] The second module is used to extract data based on the text block using a preset first large language model to obtain graph structure data;

[0037] The third module is used to detect and divide the graph structure data through a community detection algorithm to obtain multiple communities; generate a corresponding community summary for each community through a preset second large language model; each community includes node attribute information of its corresponding part in the graph structure data;

[0038] The fourth module is used to embed the community summary to obtain a first vector corresponding to the community summary of each community;

[0039] The fifth module is used to perform similarity matching on the first vector in response to the input question of the target object, and obtain a preset number of candidate communities with the highest similarity; generate an intermediate answer for each candidate community through a preset third large language model, and obtain a relevance score between each intermediate answer and the input question;

[0040] The sixth module is used to select the candidate community with the highest relevance score as the target community; based on the node attribute information corresponding to the target community, the preset fourth large language model is used to generate the target answer.

[0041] On the other hand, an embodiment of the present invention provides an electronic device, including: a processor and a memory; the memory is used to store programs; the processor executes the program to implement the above-mentioned business database dialogue method.

[0042] On the other hand, an embodiment of the present invention provides a computer storage medium, in which a program executable by a processor is stored. When the program executable by the processor is executed by the processor, it is used to implement the above-mentioned business database dialogue method.

[0043] The embodiment of the present invention obtains original knowledge data, cleans and divides the original knowledge data into blocks, and obtains multiple text blocks; the original knowledge data includes metadata and query log data of all business tables; a single text block is associated with data of a business table; based on the text block, a preset first large language model is used to extract data and construct graph structure data; the graph structure data is detected and divided by a community detection algorithm to obtain multiple communities; a corresponding community summary is generated for each community by a preset second large language model; each community includes node attribute information of its corresponding part in the graph structure data; the community summary is embedded to obtain a first vector corresponding to the community summary of each community; in response to an input question of a target object, the first vector is matched with similarity to obtain a preset number of candidate communities with the highest similarity; an intermediate answer is generated for each candidate community by a preset third large language model, and a relevance score of each intermediate answer to the input question is obtained; the candidate community with the highest relevance score is used as a target community; based on the node attribute information corresponding to the target community, a target answer is generated by a preset fourth large language model. The embodiment of the present invention can use a large model to store a huge database structure in the form of a graph to obtain the relationship between the fields of the library table, and then extract relevant information through multi-level retrieval, ultimately improving the accuracy of the large model's answers and improving the efficiency of viewing and using numbers. BRIEF DESCRIPTION OF THE DRAWINGS

[0044] The accompanying drawings are used to provide a further understanding of the technical solution of the present invention and constitute a part of the specification. Together with the embodiments of the present invention, they are used to explain the technical solution of the present invention and do not constitute a limitation on the technical solution of the present invention.

[0045] Figure 1 A schematic diagram of an implementation environment for conducting a business database dialogue provided by an embodiment of the present invention;

[0046] Figure 2 A flowchart of a business database dialogue method provided by an embodiment of the present invention;

[0047] Figure 3 A schematic diagram of an example of an entity extraction prompt word template provided by an embodiment of the present invention;

[0048] Figure 4 A schematic diagram of an example of a prompt word template for generating a graph summary provided by an embodiment of the present invention;

[0049] Figure 5 A schematic diagram of an example of generating intermediate answer prompt word templates for multiple communities provided in an embodiment of the present invention;

[0050] Figure 6 A schematic diagram of an example of a SQL generation prompt word template provided by an embodiment of the present invention;

[0051] Figure 7 A schematic diagram of the overall process principle of the business database dialogue method provided by an embodiment of the present invention;

[0052] Figure 8 A schematic diagram of an example of table metadata information provided by an embodiment of the present invention;

[0053] Fig. 9 A schematic diagram of an example of querying log information provided by an embodiment of the present invention;

[0054] Fig.10 A schematic diagram of an example of table information after filtering provided by an embodiment of the present invention;

[0055] Fig.11 A schematic diagram of an example of model generation table information provided in an embodiment of the present invention;

[0056] Fig.12 A schematic diagram of an example of a single table and graph structure data provided by an embodiment of the present invention;

[0057] Fig.13 A schematic diagram of an example of a community graph visualization result provided by an embodiment of the present invention;

[0058] Fig.14 A schematic diagram of an example of forming a community summary provided by an embodiment of the present invention;

[0059] Fig.15 A schematic diagram of an example of generating SQL provided by an embodiment of the present invention;

[0060] Fig.16 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0061] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.

[0062] It should be noted that, although the functional modules are divided in the system schematic diagram and the logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in a different order than the module division in the system or the order in the flowchart. The terms "first / S100", "second / S200", etc. in the specification, claims and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.

[0063] Reference to "embodiments" in the present invention means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present invention. The appearance of the phrase in various places in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described in the present invention may be combined with other embodiments.

[0064] To facilitate the understanding of the technical solution of the present invention, the technical feature terms that may appear in the embodiments of the present invention are first explained:

[0065] The LLM model, or Large Language Model, is a large neural network model trained using deep learning algorithms, designed to understand and generate natural language text. The LLM model is trained with a large amount of text data, and is able to capture the complexity and nuances of language, thereby performing various natural language processing tasks such as text generation, question-answering systems, semantic understanding, and reasoning. This model is designed to improve the model's expressiveness and predictive performance, and is able to handle more complex tasks and data, demonstrating human-like intelligence.

[0066] like Figure 1 FIG. 1 is a schematic diagram of an implementation environment provided by an embodiment of the present invention. Figure 1 The implementation environment includes at least one terminal 102 and a server 101. The terminal 102 and the server 101 can be connected to a network wirelessly or wired to complete data transmission and exchange.

[0067] Server 101 can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers. It can also be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network), as well as big data and artificial intelligence platforms.

[0068] In addition, the server 101 can also be a node server in the blockchain network. Blockchain is a new application model of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, and encryption algorithm.

[0069] The terminal 102 may be a smart phone, a tablet computer, a laptop computer, a desktop computer, a smart speaker, a smart watch, etc., but is not limited thereto. The terminal 102 and the server 101 may be directly or indirectly connected via wired or wireless communication, which is not limited in the embodiment of the present invention.

[0070] Based on the example Figure 1 In the implementation environment shown, an embodiment of the present invention provides a business database dialogue method. The following is an example of the business database dialogue method being applied in the terminal 102. It can be understood that the business database dialogue method can also be applied in the server 101.

[0071] Reference Figure 2 , Figure 2 The flowchart of the business database dialogue method applied to the terminal provided by the embodiment of the present invention, the execution subject of the business database dialogue method can be any of the aforementioned computer devices (including servers or terminals). Figure 2 , the method comprises the following steps:

[0072] S100, obtaining original knowledge data, cleaning and dividing the original knowledge data into blocks, and obtaining multiple text blocks;

[0073] Among them, the original knowledge data includes metadata and query log data of all business tables; a single text block is associated with the data of a business table;

[0074] It should be noted that, in some embodiments, step S100 may include the following steps: extracting the table creation statements and the dimension attribute identifiers of each business table in turn to obtain the metadata corresponding to each business table; retrieving the query records corresponding to each business table from the query log, and extracting the query log data corresponding to each business table based on the query records; clearing the execution logs in the query log data, and then performing token cleaning on the query statements in the query log data to obtain the target query data; based on the dimensions of the business table, organizing the metadata and target query data corresponding to the same business table into text blocks corresponding to the business table.

[0075] For example, in some specific implementations, this step requires knowledge extraction and integration of metadata information of all business tables and historical query SQL logs, aiming to form standardized node, edge and node attribute information for graph data.

[0076] 1. Extraction of table metadata information: First, you need to extract the table creation statement, including table column name, data type, constraints, field comments, table Chinese name, etc. This is important information for understanding the table structure; secondly, you need to extract the dimension attribute identifier to which the table belongs. You need to perform statistics on the business dimensions associated with the table, such as products, finance, events, perception, operations, tenants, etc., to clarify the position and role of the table in the business logic, which is crucial for the subsequent community division of the graph database.

[0077] 2. User historical query behavior log information: According to the query log, retrieve the query records of the specified table, extract the query SQL and result summary information, and record the tables involved in the associated query as neighbor nodes.

[0078] S200, based on the text block, using a preset first large language model to extract data and construct graph structure data;

[0079] It should be noted that, in some embodiments, step S200 may include the following steps: iteratively sending the text block into the first large language model according to the dimension of the business table to extract data, and obtain the nodes, edges and node attribute information corresponding to each node; importing the nodes, edges and node attribute information into the graph database to construct graph structure data.

[0080] For example, in some specific implementations, the text in step 1 is first cleaned, the query log of the select type is retained, and the execution logs of show and desc are removed. The word cleaning may include: replacing the line breaks in the query statement with spaces, and removing stop words and special symbols. Then, the cleaned text is divided into blocks according to the dimension of the table, that is, the metadata information of the same table and the query log with the table as the main target are taken as a single text block.

[0081] S300, detecting and dividing the graph structure data by a community detection algorithm to obtain multiple communities; generating a corresponding community summary for each community by a preset second large language model;

[0082] Among them, each community includes the node attribute information of its corresponding part in the graph structure data;

[0083] It should be noted that, in some embodiments, the graph structure data is detected and divided by a community detection algorithm to obtain multiple communities, including the following steps: using the graph structure data as the target graph structure; obtaining the edge weights and the number of connections between each node in the target graph structure; performing an initial division on the target graph structure to obtain a first division result; each node in the target graph structure in the first division result is regarded as a separate community; based on the edge weights and the number of connections, the community division quality of adjacent communities in the first division result is measured to obtain the modularity of all adjacent communities; based on the modularity, the target adjacent communities are moved in the domain; based on the results of the domain movement, communities are aggregated, and the target graph structure is updated according to the results of the community aggregation; wherein the aggregated community is regarded as a separate node in the updated target graph structure; returning to execute the step of obtaining the edge weights and the number of connections between each node in the target graph structure until the preset iteration condition is reached, and multiple communities are obtained according to the target graph structure output obtained in the last iteration.

[0084] Exemplarily, in some specific implementations, the prepared text block is iteratively sent to the LLM context according to the table dimension to extract entities (corresponding nodes), edges and attributes. In the extraction process, a multi-part LLM prompt project is used to first identify all entities (tables) in the text, including naming, library name, type and description information, and then extract the relationship between all entities in the query log that have associated queries, including source entities and target entities and relationship description information, and finally output in a standardized format. The entity extraction prompt word template is as follows: Figure 3 As shown, in order to ensure the quality of entity extraction, multiple rounds of extraction can be used to prevent the loss of certain key entities and relationships.

[0085] Then, the information of nodes and edges generated in step three is imported into the graph database to form graph structure data. Among them, the nodes of the graph represent table entities, the edges of the graph are determined by the association of query logs and the table inheritance relationship in the table creation statement, and the weights are quantified by the number of relationship entities detected. After the graph structure is constructed, the Leiden community detection algorithm is used to detect the structure of the graph. Leiden is an algorithm for identifying node groups in graph data. The connection density within the node group is higher than the connection density with the outside, which means that the tables in the agreed community are more correlated, the number of edge connections is more, and it is more likely to represent the same type of data. The calculation steps of the Leiden community detection algorithm are as follows:

[0086] (1) Initial partitioning: each node is considered as a separate community.

[0087] (2) Neighborhood movement: Consider each node one by one and try to move it to the neighboring community to maximize modularity. Modularity is an indicator to measure the quality of community division and is defined as follows:

[0088]

[0089] Among them, A ij is the weight of the edge between nodes i and j in the graph; k i and k j is the degree (i.e., number of connections) of nodes i and j; m is the total number of edges in the graph; δ(c i ,c j ) is an indicator function, which is 1 when i and j belong to the same community, otherwise it is 0. The modularity value range is between [-1, 1], and the higher the value, the better the community division.

[0090] (3) Community aggregation: After the neighborhood movement is completed, each community is treated as a separate node and the graph is reconstructed. In the new graph, each node represents a community and the edge weight is the total edge weight between the original communities.

[0091] (4) Iterative process: Repeat the neighborhood movement and community aggregation process on the new graph until the modularity no longer increases significantly.

[0092] Finally, LLM is used to generate a summary for each community, which mainly includes the relevance and main features of the tables in the community. The prompt word template for graph summary generation is as follows: Figure 4 If there are large communities, you may need to iteratively generate summaries and split the community into subcommunities and generate summaries for each subcommunity.

[0093] S400, embedding the community summary to obtain a first vector corresponding to the community summary of each community;

[0094] It should be noted that, in some embodiments, step S400 may include the following steps: using a preset embedding model to vectorize the community summary of each community in turn to obtain a first vector corresponding to the community summary of each community; wherein the first vectors corresponding to all community summaries are stored in a preset vector knowledge base.

[0095] Exemplarily, in some specific implementations, the node attributes obtained in the above steps and the generated community summary text are represented by vectors using the m3e-base embedding model and stored in the faiss vector knowledge base. An embedding model is a type of model that maps high-dimensional discrete data such as text, images, or videos to a low-dimensional continuous vector space, while still retaining the semantic relevance of the original data, so that the semantics and contextual relationships of the text can be captured through mathematical calculations. The main steps are as follows:

[0096] 1. Input preprocessing: For any text sequence, firstly segment it and remove stop words, then construct a word sequence w=[w 1 ,w 2 ,w 3 ,……w n ], assuming the sequence length is n, where w i Represents the i-th word.

[0097] 2. Embedding layer: Since the index dimension generated by the vocabulary is too high, it needs to be mapped to a low-dimensional space through an intermediate layer. Therefore, the sequence w needs to be transformed into a low-dimensional sequence of dimension d through an embedding layer. The matrix dimension of the entire embedding layer is V×d. The transformed embedded sequence is e=[e 1 ,e 2 ,e 3 ,……e d ]. Its formula is:

[0098] e=w*E w

[0099] Where E = R V×d .

[0100] S500, in response to the input question of the target object, performing similarity matching on the first vector to obtain a preset number of candidate communities with the highest similarity; generating an intermediate answer for each candidate community through a preset third large language model, and obtaining a relevance score between each intermediate answer and the input question;

[0101] It should be noted that, in some embodiments, in response to an input question of a target object, performing similarity matching on a first vector may include the following steps: vectorizing the input question of the target object to obtain a second vector; and calculating the similarity of the second vector with the first vector corresponding to each community summary in turn through a cosine similarity algorithm to obtain the similarity between the second vector and each first vector.

[0102] For example, in some specific implementations, after a user inputs a question, the user's question needs to be converted into a vector representation, the similarity between the user's question and all community summary vectors is calculated, and the most relevant community summaries are found. An intermediate answer is generated for each community answer (multiple LLM prompts can also be used to generate them separately, and multiple community intermediate answer prompt word templates are generated, such as Figure 5 ) and are scored based on their relevance to the user's question.

[0103] Among them, the similarity matching retrieval of vectors can be implemented as follows:

[0104] The questions raised by the user are vectorized using the same Embedding model, and the similarity is calculated with the vectors in the Faiss vector library. The similarity is measured using cosine similarity, which evaluates the similarity between two non-zero vectors a and b by calculating the cosine value of the angle between them. The formula is as follows:

[0105]

[0106] Where a·b represents the dot product of a and b; ‖a‖‖b‖ represents the product of the moduli of vectors a and b; and n represents the dimension of the vector. The lower the similarity, the lower the angle between the two vectors, and the higher the semantic relevance.

[0107] After retrieving the n vectors with the highest similarity in the vector knowledge base, the table information corresponding to the n vectors is returned according to the degree of semantic similarity, so that the table information that may be needed is obtained according to the user's input.

[0108] S600: taking the candidate community with the highest relevance score as the target community; and generating a target answer using a preset fourth large language model based on the node attribute information corresponding to the target community.

[0109] It should be noted that, in some embodiments, generating a target answer based on the node attribute information corresponding to the target community using a preset fourth large language model may include the following steps: sending the node attribute information corresponding to the target community and the community summary into the context window of the fourth large language model, and generating the target answer in combination with a preset output template.

[0110] For example, in some specific implementations, the relevant community summary and table information are selected according to the scores corresponding to the community intermediate answers, and are sent to the context window of the large language model for SQL generation. The SQL generation prompt word template is as follows: Figure 6 shown.

[0111] According to the intermediate answers of multiple communities in the previous steps and the user's questions, specify the required SQL syntax and output json content that can be effectively recognized according to certain requirements.

[0112] In order to explain the principle of the technical solution of the present invention in detail, the overall process of the present invention is described below in combination with some specific embodiments. It is easy to understand that the following is an explanation of the technical principle of the present invention and cannot be regarded as a limitation of the present invention.

[0113] First of all, it should be noted that, in view of the current status of the prior art, the present invention combines the characteristics of the large language generation model, uses the model to learn the development experience of report developers, and dynamically generates and executes SQL according to user interaction. At the same time, SQL can be continuously optimized through multiple rounds of dialogue to achieve the final needs of users, which greatly simplifies the data acquisition process, improves the convenience and efficiency of data use, and reduces technical barriers. In addition, this method also combines a GraphRAG technology. Compared with the traditional RAG technology, it breaks the limitation that RAG technology cannot understand the inherent association of documents, and constructs a map of databases of various dimensions, subjects, and departments, and mines the deep connection between libraries and tables, so that the large model can obtain library table association information, capture more accurate data structures, and thus generate more accurate answers. Based on this, the present invention proposes a database dialogue method based on Graph RAG technology, which can store the huge database structure in the form of a map through a large model, and obtain the relationship between library table fields, and extract relevant information through multi-level retrieval, and finally improve the accuracy of the large model answer and improve the efficiency of seeing and using numbers.

[0114] Specifically, the present invention is tested on all mainstream databases and corresponding database languages, and the present invention uses MYSQL database as an example. Figure 7 , the overall process of the present invention can be implemented as follows:

[0115] Step 1: Table metadata information / query log data:

[0116] In this step, it is necessary to extract and integrate knowledge from the metadata information of all business tables and the historical query SQL logs, aiming to form standardized node, edge, and node attribute information for the graph data.

[0117] 1. Extraction of table metadata information: First, you need to extract the table creation statement, including table column name, data type, constraints, field comments, table Chinese name, etc. This is important information for understanding the table structure; secondly, you need to extract the dimension attribute identifier to which the table belongs. You need to perform statistics on the business dimensions associated with the table, such as products, finance, events, perception, operations, tenants, etc., to clarify the position and role of the table in the business logic, which is crucial for the subsequent community division of the graph database.

[0118] 2. User historical query behavior log information: According to the query log, retrieve the query records of the specified table, extract the query SQL and result summary information, and record the tables involved in the associated query as neighbor nodes.

[0119] Step 2: Text cleaning and segmentation:

[0120] First, clean the text in step 1, keep the query logs of the select type, and remove the execution logs of show and desc. Word cleaning can include: replacing the line breaks in the query statement with spaces, removing stop words and special symbols. Then, divide the cleaned text into blocks according to the table dimension, that is, the metadata information of the same table and the query log with the table as the main target are taken as a single text block.

[0121] Step 3: Extract the nodes, edges and node attribute information of the graph:

[0122] The text block prepared in step 2 is iteratively sent to the LLM context according to the table dimension to extract entities (corresponding nodes), edges and attributes. In the extraction process, a multi-part LLM prompting project is used to first identify all entities (tables) in the text, including naming, library name, type and description information, and then extract the relationship between all entities in the query log that have associated queries, including source entities and target entities and relationship description information, and finally output them in a standardized format.

[0123] First, the entity extraction prompt word template is as follows Figure 3 As shown, in order to ensure the quality of entity extraction, multiple rounds of extraction are adopted to prevent the loss of certain key entities and relationships.

[0124] Step 4: Build graphs and communities:

[0125] The node and edge information generated in step three is imported into the graph database to form graph structure data. Among them, the nodes of the graph represent table entities, the edges of the graph are determined by the association of the query log and the table inheritance relationship in the table creation statement, and the weight is quantified by the number of relationship entities detected. After the graph structure is constructed, the Leiden community detection algorithm is used to detect the structure of the graph. Leiden is an algorithm for identifying node groups in graph data. The connection density within the node group is higher than the connection density with the outside, which means that the tables in the agreed community are more correlated, the number of edge connections is more, and it is more likely to represent the same type of data. The calculation steps of the Leiden community detection algorithm are as follows:

[0126] (1) Initial partitioning: each node is considered as a separate community.

[0127] (2) Neighborhood movement: Consider each node one by one and try to move it to the neighboring community to maximize modularity. Modularity is an indicator to measure the quality of community division and is defined as follows:

[0128]

[0129] Among them, A ij is the weight of the edge between nodes i and j in the graph; k i and k j is the degree (i.e., number of connections) of nodes i and j; m is the total number of edges in the graph; δ(c i ,c j ) is an indicator function, which is 1 when i and j belong to the same community, otherwise it is 0. The modularity value range is between [-1, 1], and the higher the value, the better the community division.

[0130] (3) Community aggregation: After the neighborhood movement is completed, each community is treated as a separate node and the graph is reconstructed. In the new graph, each node represents a community and the edge weight is the total edge weight between the original communities.

[0131] (4) Iterative process: Repeat the neighborhood movement and community aggregation process on the new graph until the modularity no longer increases significantly.

[0132] Step 5: Generate graph community summary:

[0133] LLM is used to generate a summary for each community, which mainly includes the association and main features of the tables in the community. If there are large communities, it may be necessary to generate summaries iteratively and split the community into subcommunities and generate summaries for each subcommunity. Figure 4 shown.

[0134] Step 6: Node attributes and community summary embedding:

[0135] The node attributes obtained in the previous steps and the generated community summary text are represented by vectors using the m3e-base embedding model and stored in the faiss vector knowledge base. An embedding model is a type of model that maps high-dimensional discrete data such as text, images, or videos to a low-dimensional continuous vector space, while still retaining the semantic relevance of the original data. This allows the semantics and context of the text to be captured through mathematical calculations. The main steps are as follows:

[0136] 1. Input preprocessing: For any text sequence, firstly segment it and remove stop words, then construct a word sequence w=[w 1 ,w 2 ,w 3 ,……w n ], assuming the sequence length is n, where w i Represents the i-th word.

[0137] 2. Embedding layer: Since the index dimension generated by the vocabulary is too high, it needs to be mapped to a low-dimensional space through an intermediate layer. Therefore, the sequence w needs to be transformed into a low-dimensional sequence of dimension d through an embedding layer. The matrix dimension of the entire embedding layer is V×d. The transformed embedded sequence is e=[e 1 ,e 2 ,e 3 ,……e d ]. Its formula is:

[0138] e=w*E w

[0139] Where E = R V×d .

[0140] 3. Vector retrieval: The questions raised by the user are vectorized using the same Embedding model, and the similarity is calculated with the vectors in the Faiss vector library. The similarity is measured using cosine similarity, which evaluates the similarity between two non-zero vectors a and b by calculating the cosine value of the angle between them. The formula is as follows:

[0141]

[0142] Where a·b represents the dot product of a and b; ‖a‖‖b‖ represents the product of the moduli of vectors a and b; and n represents the dimension of the vector. The lower the similarity, the lower the angle between the two vectors, and the higher the semantic relevance.

[0143] After retrieving the n vectors with the highest similarity in the vector knowledge base, the table information corresponding to the n vectors is returned according to the degree of semantic similarity, so that the table information that may be needed is obtained according to the user's input.

[0144] Step 7: Similarity retrieval and generation of community answers:

[0145] When the user enters a question, the user's question needs to be converted into a vector representation, the similarity between the user's question and all community summary vectors is calculated, and the most relevant community summaries are found. An intermediate answer is generated for each community answer (the multi-part LLM prompt project can also be used to generate prompt word templates for multiple communities to generate intermediate answers, such as Figure 5 ) and are scored based on their relevance to the user's question.

[0146] Step 8: Merge and generate answer SQL and optimize multiple times:

[0147] In this step, the relevant community summary and table information are selected according to the community answer score in step 7, and sent to the context window of the large language model for SQL generation. The prompt word template in this step is as follows: Figure 6 shown.

[0148] According to the intermediate answers of multiple communities in the previous steps and the user's questions, specify the required SQL syntax and output json content that can be effectively recognized according to certain requirements.

[0149] The core goal of this invention is to realize the function of natural language dialogue with database by integrating Graph RAG technology and advanced Large Language Model (LLM) technology, and to pioneer the automatic generation of SQL driven by natural language, aiming to completely eliminate the technical barriers to database operations, accelerate the data extraction process, and enable business personnel with non-technical backgrounds to easily and accurately obtain the required information.

[0150] The text2sql method in the present invention is different from the traditional database dialogue system. It does not simply connect the large language model (LLM) directly to the database table, but adopts the advanced Graph RAG technology to generate SQL. In the production business environment, the structure of the database table is usually very complex. A single database may contain hundreds of tables, and the required data may span multiple tables. Users are often not clear about which specific table data they need. The present invention introduces an intelligent Graph RAG method in the database table identification stage. This method not only utilizes the powerful semantic understanding ability of LLM, but also constructs a graph database index, takes the database table as the node in the graph, and the relationship between the tables as the edge, effectively mapping the complex structure of the database. Through this graph structure, the present invention can identify clusters and hierarchies in the database, that is, a collection of tables that are closely related in business logic.

[0151] Furthermore, the present invention uses the experience and knowledge of technicians to guide the model to accurately lock the target data table through the graph cluster summary generated by LLM. When facing complex and changing database architectures, Graph RAG technology can significantly improve the accuracy and efficiency of SQL query generation. This method not only simplifies the interaction process between users and databases, but also enables non-technical users to quickly obtain the data they need through natural language queries.

[0152] Through Graph RAG technology, the present invention realizes a highly intelligent database query method, which can understand the user's query intention, automatically retrieve and integrate the required information from the entire database, and generate accurate SQL query statements, thereby providing users with an intuitive, efficient and easy-to-use data access solution.

[0153] For example, in some specific application scenarios, the present invention can be implemented as follows:

[0154] This method integrates database structured query language with human natural language through the technology of big model, summarizes and generates table summaries using the big model technology, then quickly retrieves related tables through GraphRAG technology, and combines the big model again to achieve question rewriting and table screening, and finally generates the SQL statement required by the user.

[0155] 1. Extract metadata information of 684 tables stored in the data center database (data information examples are as follows Figure 8 As shown) and query log information (information examples as Fig. 9 shown).

[0156] Filter the table query log by table name, and filter out SQL statements starting with Desc and Show, focusing on query statements starting with Select. The table information after filtering is as follows: Fig.10 shown.

[0157] The text block prepared in the previous step is iterated into the LLM context according to the table dimension to extract entities, edges and attributes. During the extraction process, a multi-part LLM prompting project is used to first identify all entities (tables) in the text, including naming, library name, type and description information, and then extract the relationship between all entities in the query log that have associated queries, including source entities and target entities and relationship description information, and finally output in a standardized format. The output result of a single extraction is as follows: Fig.11 shown.

[0158] 2. Import the node and edge information generated in the previous step into the graph database to form graph structure data. The nodes of the graph represent table entities, the edges of the graph are determined by the association of the query log and the table inheritance relationship in the table creation statement, and the weight is quantified by the number of relationship entities detected. The sample graph structure data generated by generating a single table and connection conditions in the previous step is as follows: Fig.12 shown.

[0159] After the complete graph structure data is established, the Leiden community detection algorithm is used to detect the graph structure. The community visualization graph obtained by the Leiden community detection algorithm is as follows: Fig.13 shown.

[0160] 3. After the graph structure data is constructed and the community is detected by Leiden algorithm, a community summary is formed for each community table. An example of forming a community summary is as follows: Fig.14 shown.

[0161] 4. Based on the summary information and node attribute information of each community obtained in the previous steps, the m3e-base model is used to embed the vectors and store them in the vector database. When the user enters a question, the user question is embedded in the vector of the same m3e-base model and then searched in the vector database to obtain the community summary with the highest similarity. The relevant node attribute information in the community is iteratively input into the context information of the LLM, and finally the large model outputs the corresponding SQL syntax. The generated SQL example is as follows: Fig.15 shown.

[0162] In summary, the present invention proposes an IoT business database dialogue (text2sql) method based on enhanced retrieval generation. Users do not need to understand too much professional SQL syntax and can interact with the database only through natural language, which reduces the threshold for database operators. Furthermore, this method innovatively combines GraphRAG with text2sql, using the characteristics of graph data structure and the timeliness of vector library search to effectively query table information related to users in complex databases in seconds, and users do not even need to understand detailed business data.

[0163] The present invention innovatively defines the table information of the database into the data structure of the graph structure, by defining the table as a node, defining the table metadata and other information as node attributes, and defining the inheritance information and association information of the table as the connection and weight information of the edge. After completing the mapping of the data table to the graph data, the community detection algorithm is used to divide thousands of tables into unconnected communities, representing different business types and application scenarios, and generate community summaries. The summary information of multiple communities can be retained in the context added to the large model, retaining the relationship between the tables, solving the problem that the traditional RAG only focuses on the single structure of some tables, and improving the accuracy of database dialogue.

[0164] Compared with the prior art, the present invention has at least the following beneficial effects:

[0165] 1. First, the present invention provides a method for generating specified SQL according to user questions by means of a large language model through natural dialogue with users, which can lower the usage threshold of SQL users, while improving the efficiency of users and helping people who do not understand data to quickly view and use data.

[0166] 2. Different from the more common text2sql method, the present invention adopts GraphRAG technology, so that the context of LLM is no longer limited to a number of table metadata, but can focus on table information within multiple communities with a broader perspective and capture the relationship between tables, so that LLM can understand the flow process of business data and improve the accuracy of SQL generation.

[0167] 3. In the process of generating SQL using a large model, it is difficult to generate SQL that meets user needs in one go. However, by recording historical questions and answers and supporting multiple rounds of questions and answers, the SQL hit rate can be continuously optimized.

[0168] On the other hand, an embodiment of the present invention provides a service database dialogue device, including:

[0169] The first module is used to obtain original knowledge data, clean and divide the original knowledge data into blocks, and obtain multiple text blocks; the original knowledge data includes metadata and query log data of all business tables; a single text block is associated with the data of a business table;

[0170] The second module is used to extract data based on the text block using a preset first large language model to obtain graph structure data;

[0171] The third module is used to detect and divide the graph structure data through a community detection algorithm to obtain multiple communities; generate a corresponding community summary for each community through a preset second large language model; each community includes node attribute information of its corresponding part in the graph structure data;

[0172] The fourth module is used to embed the community summary to obtain a first vector corresponding to the community summary of each community;

[0173] The fifth module is used to perform similarity matching on the first vector in response to the input question of the target object, and obtain a preset number of candidate communities with the highest similarity; generate an intermediate answer for each candidate community through a preset third large language model, and obtain a relevance score between each intermediate answer and the input question;

[0174] The sixth module is used to select the candidate community with the highest relevance score as the target community; based on the node attribute information corresponding to the target community, the preset fourth large language model is used to generate the target answer.

[0175] The contents of the method embodiments of the present invention are all applicable to the device embodiments. The functions specifically implemented by the device embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.

[0176] On the other hand, an embodiment of the present invention further provides an electronic device, the electronic device includes a memory and a processor, the memory stores a computer program, and the processor implements the above sensitive information method when executing the computer program. The electronic device can be any intelligent terminal including a tablet computer, a car computer, etc.

[0177] It can be understood that the contents of the above method embodiments are all applicable to the present device embodiments, the functions specifically implemented by the present device embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.

[0178] like Fig.16 As shown, Fig.16 A specific example of the hardware structure of an electronic device 1000 according to an embodiment is shown. The electronic device 1000 includes:

[0179] The processor 1001 may be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of the present invention.

[0180] The memory 1002 can be implemented in the form of a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 1002 can store an operating system and other application programs. When the technical solution provided in the embodiment of this specification is implemented by software or firmware, the relevant program code is stored in the memory 1002, and the processor 1001 calls and executes the network node population optimization method of the embodiment of the present invention;

[0181] Input / output interface 1003, used to implement information input and output;

[0182] The communication interface 1004 is used to realize the communication interaction between the device and other devices. The communication can be realized through a wired manner (such as USB, network cable, etc.) or a wireless manner (such as mobile network, WIFI, Bluetooth, etc.);

[0183] A bus 1005 , which transmits information between various components of the device (e.g., the processor 1001 , the memory 1002 , the input / output interface 1003 , and the communication interface 1004 );

[0184] The processor 1001 , the memory 1002 , the input / output interface 1003 and the communication interface 1004 are connected to each other in communication within the device via the bus 1005 .

[0185] The electronic device embodiments described above are merely illustrative, and the units described as separate components may or may not be physically separated, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0186] The contents of the method embodiments of the present invention are all applicable to the electronic device embodiments. The functions specifically implemented by the electronic device embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.

[0187] Another aspect of an embodiment of the present invention further provides a computer-readable storage medium, wherein the storage medium stores a program, and the program is executed by a processor to implement the above method.

[0188] It should be noted that the computer-readable medium shown in the embodiment of the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM), a flash memory, an optical fiber, a portable compact disk read-only memory (Compact Disc Read to Only Memory, CD to ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, device or device. In the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer readable signal media may also be any computer readable medium other than computer readable storage media, which may send, propagate, or transmit programs for use by or in conjunction with an instruction execution system, apparatus, or device. The program code contained on the computer readable medium may be transmitted using any suitable medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.

[0189] The contents of the method embodiments of the present invention are all applicable to the computer-readable storage medium embodiments. The functions specifically implemented by the computer-readable storage medium embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.

[0190] The embodiment of the present invention also discloses a computer program product or a computer program, which includes a computer instruction stored in a computer-readable storage medium. A processor of a computer device can read the computer instruction from the computer-readable storage medium, and the processor executes the computer instruction, so that the computer device executes the above method.

[0191] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0192] It should be noted that, although several modules of the device for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to an embodiment of the present invention, the features and functions of two or more modules or units described above can be embodied in one module or unit. On the contrary, the features and functions of one module or unit described above can be further divided into being embodied by multiple modules or units.

[0193] Through the description of the above implementation, it is easy for those skilled in the art to understand that the example implementation described here can be implemented by software, or by software combined with necessary hardware. Therefore, the technical solution according to the implementation of the present invention can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD to ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, including several instructions to enable a computing device (which can be a personal computer, a server, a touch terminal, or a network device, etc.) to execute the method according to the implementation of the present invention.

[0194] In some selectable embodiments, the function / operation mentioned in the block diagram may not occur in the order mentioned in the operation diagram. For example, depending on the function / operation involved, the two boxes shown in succession can actually be executed substantially simultaneously or the boxes can sometimes be executed in reverse order. In addition, the embodiment presented and described in the flow chart of the present invention is provided by way of example, for the purpose of providing a more comprehensive understanding of the technology. The disclosed method is not limited to the operation and logic flow presented by the present invention. Selectable embodiments are expected, wherein the order of various operations is changed and the sub-operation of a part described as a larger operation is performed independently.

[0195] In addition, although the present invention is described in the context of functional modules, it should be understood that, unless otherwise specified, one or more of the functions and / or features can be integrated into a single physical device and / or software module, or one or more functions and / or features can be implemented in separate physical devices or software modules. It is also understood that a detailed discussion of the actual implementation of each module is unnecessary for understanding the present invention. More specifically, in view of the properties, functions and internal relationships of various functional modules in the device disclosed in the present invention, the actual implementation of the module will be understood within the conventional skills of engineers. Therefore, those skilled in the art can implement the present invention set forth in the claims without excessive experimentation using ordinary techniques. It is also understood that the specific concepts disclosed are merely illustrative and are not intended to limit the scope of the present invention, which is determined by the full scope of the appended claims and their equivalents.

[0196] If the function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the methods of each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.

[0197] The logic and / or steps represented in the flowchart or otherwise described herein, for example, may be considered as an ordered list of executable instructions for implementing logical functions, and may be embodied in any computer-readable medium for use by an instruction execution device, apparatus or device (such as a computer-based device, a device including a processor, or other device that can fetch instructions from an instruction execution device, apparatus or device and execute the instructions), or in conjunction with such instruction execution device, apparatus or device. For purposes of this specification, "computer-readable medium" may be any device that can contain, store, communicate, propagate or transmit a program for use by an instruction execution device, apparatus or device, or in conjunction with such instruction execution device, apparatus or device.

[0198] More specific examples of computer-readable media (a non-exhaustive list) include the following: an electrical connection with one or more wires (electronic device), a portable computer disk case (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and programmable read-only memory (EPROM or flash memory), a fiber optic device, and a portable compact disk read-only memory (CDROM). In addition, the computer-readable medium may even be a paper or other suitable medium on which the program is printed, since the program may be obtained electronically, for example, by optically scanning the paper or other medium, followed by editing, deciphering or, if necessary, processing in another suitable manner, and then stored in a computer memory.

[0199] It should be understood that the various parts of the present invention can be implemented by hardware, software, firmware or a combination thereof. In the above-mentioned embodiments, a plurality of steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution device. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.

[0200] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "examples", "specific examples", or "some examples" means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner.

[0201] Although the embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present invention, and that the scope of the present invention is defined by the claims and their equivalents.

[0202] The above is a specific description of the preferred implementation of the present invention, but the present invention is not limited to the embodiments. Those skilled in the art can make various equivalent modifications or substitutions without violating the spirit of the present invention. These equivalent modifications or substitutions are all included in the scope defined by the claims of the present invention.

Claims

1. A business database dialogue method, characterized in that: The following steps are involved: Acquire original knowledge data, clean and divide the original knowledge data into blocks, and obtain multiple text blocks; The original knowledge data includes metadata and query log data of all business tables; A single text block is associated with data of a business table; Based on the text block, a preset first large language model is used to extract data and construct graph structure data; Detect and divide the graph structure data using a community detection algorithm to obtain multiple communities; Generate a corresponding community summary for each of the communities through a preset second large language model; each of the communities includes node attribute information of a corresponding part in the graph structure data; Performing embedding processing on the community summary to obtain a first vector corresponding to the community summary of each community; In response to an input question of the target object, performing similarity matching on the first vector to obtain a preset number of candidate communities with the highest similarity; Generate an intermediate answer for each candidate community by using a preset third large language model, and obtain a relevance score between each intermediate answer and the input question; Taking the candidate community with the highest relevance score as the target community; Based on the node attribute information corresponding to the target community, a target answer is generated using a preset fourth large language model.

2. The business database dialogue method according to claim 1, characterized in that: The step of obtaining original knowledge data and cleaning and dividing the original knowledge data into blocks to obtain multiple text blocks includes the following steps: Extracting the table creation statement and the dimension attribute identifier of each business table in turn to obtain the metadata corresponding to each business table; Retrieving the query record corresponding to each of the business tables from the query log, and extracting the query log data corresponding to each of the business tables based on the query record; Clearing the execution log in the query log data, and then cleaning the query statements in the query log data to obtain target query data; Based on the dimension of the business table, the metadata and the target query data corresponding to the same business table are sorted into the text block corresponding to the business table.

3. The business database dialogue method according to claim 1, characterized in that: The method of extracting data based on the text block using a preset first large language model to construct graph structure data includes the following steps: Iteratively sending the text block into the first large language model according to the dimension of the business table to extract data, and obtaining nodes, edges and the node attribute information corresponding to each node; The nodes, the edges and the node attribute information are imported into a graph database to construct the graph structure data.

4. The business database dialogue method according to claim 1, characterized in that: The detecting and dividing the graph structure data by using a community detection algorithm to obtain a plurality of communities includes the following steps: Using the graph structure data as a target graph structure; Obtaining edge weights and number of connections between nodes in the target graph structure; Performing an initial partition on the target graph structure to obtain a first partition result; each node in the target graph structure in the first partition result is regarded as a separate community; Based on the edge weights and the number of connections, the community division quality of the adjacent communities in the first division result is measured to obtain the modularity of all the adjacent communities; and the target adjacent community is moved to a domain based on the modularity; Performing community aggregation based on the result of the domain movement, and updating the target graph structure according to the result of the community aggregation; wherein the aggregated community serves as a separate node in the updated target graph structure; Return to the step of obtaining the edge weights and the number of connections between the nodes in the target graph structure until a preset iteration condition is reached, and output a plurality of the communities according to the target graph structure obtained in the last iteration.

5. The business database dialogue method according to claim 1, characterized in that: The embedding process is performed on the community summary to obtain a first vector corresponding to the community summary of each community, including the following steps: Using a preset embedding model to sequentially represent the community summary of each of the communities as a vector, to obtain the first vector corresponding to the community summary of each of the communities; The first vectors corresponding to all the community summaries are stored in a preset vector knowledge base.

6. The business database dialogue method according to claim 1, characterized in that: The step of performing similarity matching on the first vector in response to an input question of the target object comprises the following steps: Vectorizing the input question of the target object to obtain a second vector; The second vector is sequentially calculated for similarity with the first vector corresponding to each of the community summaries by using a cosine similarity algorithm to obtain a similarity between the second vector and each of the first vectors.

7. The business database dialogue method according to claim 1, characterized in that: The step of generating a target answer based on the node attribute information corresponding to the target community using a preset fourth large language model comprises the following steps: The node attribute information and the community summary corresponding to the target community are sent to the context window of the fourth large language model, and the target answer is generated in combination with a preset output template.

8. A business database dialogue device, characterized in that: include: The first module is used to obtain original knowledge data, clean and block the original knowledge data, and obtain multiple text blocks; The original knowledge data includes metadata and query log data of all business tables; A single text block is associated with data of a business table; The second module is used to extract data based on the text block using a preset first large language model to obtain graph structure data; The third module is used to detect and divide the graph structure data through a community detection algorithm to obtain multiple communities; Generate a corresponding community summary for each of the communities through a preset second large language model; each of the communities includes node attribute information of a corresponding part in the graph structure data; A fourth module is used to perform embedding processing on the community summary to obtain a first vector corresponding to the community summary of each community; A fifth module is used to perform similarity matching on the first vector in response to an input question of the target object, and obtain a preset number of candidate communities with the highest similarity; Generate an intermediate answer for each candidate community by using a preset third large language model, and obtain a relevance score between each intermediate answer and the input question; A sixth module is used to select the candidate community with the highest relevance score as the target community; Based on the node attribute information corresponding to the target community, a target answer is generated using a preset fourth large language model.

9. An electronic device, characterized in that: including a processor and a memory; The memory is used to store programs; The processor executes the program to implement the method according to any one of claims 1 to 7.

10. A computer storage medium storing a program executable by a processor, characterized in that: The program executable by the processor is used to implement the method according to any one of claims 1 to 7 when executed by the processor.

Citation Information

Cited By

  • Video frame determination method and apparatus, and electronic device

    CN120726548A

  • Method, apparatus and electronic device for determining video frame

    CN120726548B

  • Data processing method, question and answer method, electronic equipment, storage medium and product

    CN121681734A

  • Data processing method, question and answer method, electronic device, storage medium and product

    CN121681734B