Multi-source isomorphic data NL2SQL method and device based on retrieval enhancement, equipment and medium

By constructing cross-source metadata mapping and a global index table, and combining vector models and large language models, the problems of low efficiency and insufficient accuracy of NL2SQL queries under multiple isomorphic data sources are solved, and efficient and accurate cross-source data location and visualization are achieved.

CN121743350APending Publication Date: 2026-03-27SHANDONG LANGCHAO YUNTOU INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-22
Publication Date
2026-03-27

AI Technical Summary

Technical Problem

Existing technologies suffer from low NL2SQL query efficiency, difficulty in cross-source processing, and insufficient accuracy in scenarios with multiple homogeneous data sources. Traditional methods rely on specialized SQL knowledge and are prone to introducing errors. Existing RAG frameworks are designed for single data sources and have poor flexibility in cross-source SQL generation.

Method used

By constructing cross-source metadata mapping tables and global index mapping tables, and utilizing preset vector models and large language models, keyword matching and intent vector conversion for cross-source data queries are achieved, generating target database search statements and displaying them visually.

Benefits of technology

It improves the efficiency and accuracy of cross-source data queries, simplifies the multi-database retrieval process, enhances user experience, and ensures the accuracy and intuitiveness of data processing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121743350A_ABST
    Figure CN121743350A_ABST
Patent Text Reader

Abstract

The invention discloses a multi-source isomorphic data NL2SQL method, device and equipment based on retrieval enhancement and a medium, and relates to the technical field of natural language process.The method comprises the steps that query keywords are extracted, and a cross-source metadata mapping table is matched to determine a candidate database set from a plurality of isomorphic databases; the cross-source metadata mapping table is used for storing a global mapping relationship among metadata information of a database; generating a query intention object, and determining database retrieval configuration information from the global index mapping table; the global index mapping table is used for storing a vector database address and a database index structure; the database index structure is used for storing a mapping relation between a document keyword vector and a document original text; determining a target database information set based on the intention object vector according to database retrieval configuration information; and generating a target database retrieval statement based on the preset retrieval statement generation large model, and executing the target database retrieval statement so as to visually display a database retrieval result.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of natural language processing technology, and in particular to a method, apparatus, device, and medium for NL2SQL based on retrieval enhancement for multi-source isomorphic data. Background Technology

[0002] In today's digital age, enterprise data is growing explosively, and the scenario of enterprise data being distributed and stored across multiple homogeneous enterprise databases is becoming increasingly common. Traditional database queries rely on specialized SQL (Structured Query Language) knowledge, making it difficult to meet the efficient access needs of non-technical personnel for multi-source data. Existing technologies face significant challenges in processing multi-source data: the dispersion of multi-source data necessitates manual database switching for queries, and cross-source data integration relies on complex syntax such as UNION (an operator in SQL), which is not only cumbersome but also prone to errors due to human intervention, severely restricting data processing efficiency. Retrieval-Augmented Generation (RAG) technology, by combining retrieval with Large Language Model (LLM), provides a new solution for NL2SQL (Natural Language to SQL). However, most existing RAG frameworks are designed for single data sources, and a large amount of irrelevant data interferes with retrieval accuracy, leading to data source confusion when generating SQL using LLM; cross-source SQL generation relies on manually preset rules, resulting in poor flexibility.

[0003] In summary, how to solve the problems of low query efficiency, difficulty in cross-source processing, and insufficient accuracy of NL2SQL in scenarios with multiple homogeneous data sources is a technical problem that urgently needs to be solved. Summary of the Invention

[0004] In view of this, the purpose of this invention is to provide a NL2SQL method, apparatus, device, and medium based on retrieval enhancement for multi-source isomorphic data, which can solve the problems of low query efficiency, difficulty in cross-source processing, and insufficient accuracy of NL2SQL in scenarios with multiple isomorphic data sources. The specific solution is as follows:

[0005] Firstly, this application provides a NL2SQL method for multi-source isomorphic data based on retrieval enhancement, including:

[0006] Upon receiving a target data query request, the query keywords corresponding to the target data query request are extracted, and a pre-built cross-source metadata mapping table is matched based on the query keywords to determine a set of relevant candidate databases from several homogeneous databases; the cross-source metadata mapping table is used to store the global mapping relationship between the metadata information of the several homogeneous databases.

[0007] A query intent object is generated based on the candidate database set and the query keywords. Database retrieval configuration information is determined from a pre-built global index mapping table based on the query intent object. The global index mapping table stores the vector database addresses and database index structures corresponding to the several isomorphic databases. The vector database address is the address of a preset vector database, which stores the document keyword vectors corresponding to the document keywords of the several isomorphic databases. The database index structure stores the mapping relationship between the document keyword vectors and the original document text.

[0008] The query intent object is converted into an intent object vector using a preset vector model, and the database retrieval configuration information is used to determine the target database information set related to the target data query request based on the intent object vector and the preset vector database.

[0009] A large model is generated based on a preset search statement. A target database search statement is generated based on the target database information set, and the target database search statement is executed to visualize the obtained database search results.

[0010] Optionally, before extracting the query keywords corresponding to the target data query request after receiving the target data query request, the method further includes:

[0011] After establishing a connection with the several homogeneous databases through a preset driver protocol, the data definition language files and database schema files of the several homogeneous databases are parsed to extract the corresponding metadata information;

[0012] Based on the metadata information, the homogeneity of the several homogeneous databases is verified according to preset verification rules, so that after the verification is passed, the homogeneous databases are assigned corresponding data source identifiers.

[0013] The metadata information is analyzed to determine the global mapping relationship between the metadata information, and the cross-source metadata mapping table is constructed based on the global mapping relationship, the metadata information, and the data source identifier.

[0014] Optionally, before extracting the query keywords corresponding to the target data query request after receiving the target data query request, the method further includes:

[0015] Text processing is performed on the database documents in the metadata information to extract the corresponding document keywords through component syntactic analysis and preset named entity recognition tools;

[0016] The document keywords are converted into document keyword vectors using a preset vector model, and the document keywords and document keyword vectors are used as first-level indexes, with the corresponding original document text as a second-level index, to construct the corresponding database index structure for the several isomorphic databases.

[0017] For each of the isomorphic databases, a corresponding independent vector library is created in the preset vector database to obtain the address of the vector database, and the document keyword vector is saved to the independent vector library;

[0018] Construct a global index mapping table that includes the data source identifier, the database index structure, and the vector database address.

[0019] Optionally, before extracting the query keywords corresponding to the target data query request after receiving the target data query request, the method further includes:

[0020] The metadata information is used to analyze the several homogeneous databases, and corresponding multi-source metadata documents are generated based on the analysis results.

[0021] Using prompting engineering techniques, a preset semantic expansion model is controlled to semantically expand the historical sentence cases in the multi-source metadata documents to obtain an initial case dataset;

[0022] The initial case dataset is validated for correctness, and after the validation is passed, the initial case dataset is divided into a training dataset and a test dataset according to a preset partitioning ratio.

[0023] The target initial model is iteratively trained using the training dataset and the test dataset to control the target initial model to learn the semantic mapping rules of cross-source queries, thereby obtaining the large model generated by the preset retrieval statement.

[0024] Optionally, the step of determining a set of target database information related to the target data query request based on the database retrieval configuration information, the intent object vector, and the preset vector database includes:

[0025] Based on the vector database address in the database retrieval configuration information, a search is performed in the preset vector database based on the intent object vector to determine candidate document keyword vectors through vector similarity;

[0026] The original text of the document is determined by the database index structure in the database retrieval configuration information, and the query keywords are matched with the original text of the document to obtain a set of target database information related to the target data query request.

[0027] Optionally, the step of generating a large model based on a preset search statement, and generating a target database search statement based on the target database information set, includes:

[0028] The target database information set is integrated based on a preset prompt word template to obtain target prompt words that include the data source identifier;

[0029] The target prompt words are input into a preset search statement to generate a large model, so that the preset search statement generation large model can determine the database query type based on the data source identifier and generate a database search statement based on the database query type;

[0030] The statement format of the database retrieval statement is verified using a preset syntax validator, and the database retrieval statement is determined as the target database retrieval statement after the verification is passed.

[0031] Optionally, executing the target database retrieval statement to visualize the obtained database retrieval results includes:

[0032] The target database retrieval statement is executed on each of the candidate isomorphic databases in the candidate database set to obtain the corresponding database retrieval results;

[0033] The database search results are merged and format converted to obtain the processed search results;

[0034] The aggregated index and corresponding contribution ratio of the candidate isomorphic database are calculated based on the processed retrieval results, and the processed retrieval results are visualized based on the aggregated index and the contribution ratio.

[0035] During the visualization process, a preset multi-source differentiation strategy is used to differentiate and display the relevant data of each candidate isomorphic database in the processed retrieval results.

[0036] Secondly, this application provides a retrieval-enhanced multi-source isomorphic data NL2SQL apparatus, comprising:

[0037] The mapping table matching module is used to extract the query keywords corresponding to the target data query request after receiving the target data query request, and match the query keywords with a pre-built cross-source metadata mapping table to determine a set of relevant candidate databases from several homogeneous databases; the cross-source metadata mapping table is used to store the global mapping relationship between the metadata information of the several homogeneous databases.

[0038] The information determination module is used to generate a query intent object based on the candidate database set and the query keywords, and to determine database retrieval configuration information from a pre-built global index mapping table according to the query intent object; the global index mapping table is used to store the vector database addresses and database index structures corresponding to the plurality of isomorphic databases; the vector database address is the address of a preset vector database, and the preset vector database is used to store the document keyword vectors corresponding to the document keywords of the plurality of isomorphic databases; the database index structure is used to store the mapping relationship between the document keyword vectors and the original document text;

[0039] The set determination module is used to convert the query intent object into an intent object vector using a preset vector model, and determine the target database information set related to the target data query request based on the database retrieval configuration information, the intent object vector, and the preset vector database.

[0040] The statement execution module is used to generate a large model based on a preset search statement, generate a target database search statement based on the target database information set, and execute the target database search statement to visualize the obtained database search results.

[0041] Thirdly, this application provides an electronic device, comprising:

[0042] Memory, used to store computer programs;

[0043] A processor is configured to execute the computer program to implement the aforementioned NL2SQL method for multi-source isomorphic data based on retrieval enhancement.

[0044] Fourthly, this application provides a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, it implements the aforementioned NL2SQL method for multi-source isomorphic data based on retrieval enhancement.

[0045] In this application, upon receiving a target data query request, the query keywords corresponding to the target data query request are extracted, and a pre-built cross-source metadata mapping table is matched based on the query keywords to determine a relevant set of candidate databases from several homogeneous databases. The cross-source metadata mapping table is used to store the global mapping relationship between the metadata information of the several homogeneous databases. A query intent object is generated based on the candidate database set and the query keywords, and database retrieval configuration information is determined from a pre-built global index mapping table based on the query intent object. The global index mapping table is used to store the vector database addresses and database index structures corresponding to the several homogeneous databases. The vector database addresses are preset. The address of the vector database, wherein the preset vector database is used to store the document keyword vectors corresponding to the document keywords of the plurality of isomorphic databases; the database index structure is used to store the mapping relationship between the document keyword vectors and the original document text; the query intent object is converted into an intent object vector using a preset vector model, and based on the database retrieval configuration information, a set of target database information related to the target data query request is determined based on the intent object vector and the preset vector database; a large model is generated based on a preset retrieval statement, a target database retrieval statement is generated based on the target database information set, and the target database retrieval statement is executed to visualize the obtained database retrieval results. As can be seen from the above, after receiving a target data query request, this application first extracts the corresponding query keywords, determines the relevant candidate database set by matching the pre-built cross-source metadata mapping table used to store the global mapping relationship of several isomorphic database metadata information, and then generates a query intent object based on the candidate database set and the query keywords. Based on this object, it obtains the database retrieval configuration information from the pre-built global index mapping table used to store the address of the preset vector database (storing document keyword vectors) corresponding to the isomorphic database and the database index structure (storing the mapping relationship between document keyword vectors and original document text). Then, it uses a preset vector model to convert the query intent object into an intent object vector, and combines the database retrieval configuration information with the preset vector database to determine the target database information set. Finally, it generates the target database retrieval statement based on the set by a preset retrieval statement generation model, and visualizes the retrieval results after execution.In this way, through the process described above in this application, relying on the retrieval architecture of cross-source metadata mapping and global index, and through the collaboration of keyword matching, intent vector conversion and vector database retrieval, accurate cross-source data positioning between homogeneous databases is achieved. This simplifies the complex process of multi-database retrieval by leveraging global mapping relationships, improves the matching accuracy between query intent and database content through vector models, and makes the retrieval results more intuitive and easy to understand through visualization. This effectively improves the efficiency, accuracy and user experience of cross-source data query, thereby solving the problems of low NL2SQL query efficiency, difficulty in cross-source processing and insufficient accuracy in scenarios with multiple homogeneous data sources. Attached Figure Description

[0046] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.

[0047] Figure 1 This application discloses a flowchart of an NL2SQL method for multi-source isomorphic data based on retrieval enhancement.

[0048] Figure 2 This is a schematic diagram of the NL2SQL device structure for multi-source isomorphic data based on retrieval enhancement disclosed in this application;

[0049] Figure 3 This is a structural diagram of an electronic device disclosed in this application. Detailed Implementation

[0050] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0051] Traditional enterprise database queries rely on specialized SQL knowledge, making it difficult to meet the efficient access needs of non-technical personnel for multi-source data. Existing technologies face significant challenges when processing multi-source data: the dispersed nature of multi-source data necessitates manual database switching for queries, and cross-source data integration relies on complex syntax such as UNION, which is not only cumbersome but also prone to errors due to human intervention, severely hindering data processing efficiency. Retrieval Augmentation (RAG) technology, by combining retrieval with Large Language Model (LLM), provides a new solution for NL2SQL. However, most existing RAG frameworks are designed for single data sources, with a large amount of irrelevant data interfering with retrieval accuracy, leading to data source confusion when generating SQL using LLM; cross-source SQL generation relies on manually preset rules, resulting in poor flexibility.

[0052] To overcome the aforementioned technical problems, this application provides a NL2SQL method for multi-source isomorphic data based on retrieval enhancement, which can solve the problems of low query efficiency, difficulty in cross-source processing, and insufficient accuracy of NL2SQL in multi-isomorphic data source scenarios.

[0053] See Figure 1 As shown, this embodiment of the invention discloses a multi-source isomorphic data NL2SQL method based on retrieval enhancement, including:

[0054] Step S11: After receiving the target data query request, extract the query keywords corresponding to the target data query request, and match the query keywords with a pre-built cross-source metadata mapping table to determine a set of relevant candidate databases from several homogeneous databases; the cross-source metadata mapping table is used to store the global mapping relationship between the metadata information of the several homogeneous databases.

[0055] In this embodiment, the aforementioned homogeneous databases specifically refer to several homogeneous enterprise databases.

[0056] In this embodiment, after receiving a user's target data query request involving multi-source data (e.g., querying the total number of orders with a value greater than 1000 in databases A and B) submitted in natural language, the system removes stop words, standardizes the time format (e.g., converting last year to xxxx year), and identifies entity types (table name, field name, filter conditions) to extract query keywords. These keywords are then matched against a pre-built cross-source metadata mapping table that stores global mapping relationships between metadata information of several isomorphic databases, such as a MySQL cluster and PostgreSQL shards. For example, database A corresponds to db_a, and database B corresponds to db_b. This identifies and locates potentially involved data sources, and relevant candidate database sets (e.g., db_a and db_b) are selected from the isomorphic databases. The metadata information includes, but is not limited to, table structure, field comments, constraints, historical SQL cases, field types, and primary / foreign key relationships. It is understood that when no specific data source is found in the cross-source metadata mapping table using the query keywords, this embodiment can predict potential data sources (such as order queries defaulting to db_primary and db_secondary) based on historical question-answer pairs and metadata relevance.

[0057] It should be noted that before receiving the target data query request, this embodiment needs to first construct the cross-source metadata mapping table. The processing flow is as follows: After establishing a connection with the several homogeneous databases through a preset driver protocol, the data definition language files and database schema files of the several homogeneous databases are parsed to extract the corresponding metadata information; based on the metadata information, the homogeneity of the several homogeneous databases is verified according to preset verification rules, so that after the verification is passed, the corresponding data source identifier is assigned to the homogeneous database; the metadata information is analyzed to determine the global mapping relationship between the metadata information, and the cross-source metadata mapping table is constructed according to the global mapping relationship, the metadata information, and the data source identifier. That is, after establishing a connection with the several homogeneous databases through a preset driver protocol, such as JDBC (an application programming interface for database connections) or ODBC (Open Database Connectivity), the data definition language (DDL) files and database schema files of the several homogeneous databases are parsed to extract the metadata information. Then, the homogeneity of the several homogeneous databases is verified according to preset verification rules. The field names, data types, and constraints of the target tables in each database are compared to see if they are consistent (e.g., the orders table contains the same fields such as order_id and customer_id in both db1 and db2). If there are differences, an alarm is triggered and access is rejected. After the verification is passed, a unique data source identifier is assigned to each of the homogeneous databases (e.g., source_id: db_primary). Then, the metadata information is analyzed to determine the global mapping relationship between them. Finally, the cross-source metadata mapping table is constructed by combining the global mapping relationship, the metadata information, and the data source identifier to record the correspondence of homogeneous tables in different data sources (e.g., the mapping between db_primary.orders and db_secondary.orders). In addition, this embodiment also supports manually supplementing non-standard data sources (such as Excel (spreadsheet) files), converting their structure into a virtual table consistent with the target database through template matching, ensuring the structural uniformity of multi-source data. In this way, relying on the cross-source metadata global mapping filtering method, this embodiment can quickly establish the association between query keywords and multiple isomorphic databases, avoiding the inefficient operation of searching all databases one by one, and improving the accuracy and efficiency of candidate database location. Verifying isomorphism before constructing the global mapping ensures that the databases included in the mapping table have a consistent data structure, avoiding matching failures due to structural differences during cross-source queries. Simultaneously, by binding the data source identifier with the global mapping relationship, unified association and management of metadata from multiple isomorphic databases is achieved, providing a mapping basis for subsequent candidate database location.

[0058] Step S12: Generate a query intent object based on the candidate database set and the query keywords, and determine the database retrieval configuration information from a pre-built global index mapping table according to the query intent object; the global index mapping table is used to store the vector database addresses and database index structures corresponding to the several isomorphic databases; the vector database address is the address of a preset vector database, and the preset vector database is used to store the document keyword vectors corresponding to the document keywords of the several isomorphic databases; the database index structure is used to store the mapping relationship between the document keyword vectors and the original document text.

[0059] In this embodiment, a structured query intent object is generated based on the candidate database set and the query keywords, such as {entities: ['orders', 'amount'], conditions: ['>1000'], sources: ['db_a', 'db_b']}, providing clear guidance for subsequent multi-source retrieval. Then, database retrieval configuration information is obtained from a pre-built global index mapping table based on the query intent object. The global index mapping table stores the addresses and database index structures of preset vector databases corresponding to the several isomorphic databases; the preset vector databases store document keyword vectors corresponding to the document keywords of each isomorphic database; the database index structure stores the mapping relationship between the document keyword vectors and the original document text; each dimension of the document keyword vector corresponds to its semantic features (such as field type, table relationship).

[0060] It should be noted that before receiving the target data query request, this embodiment needs to first construct the global index mapping table and the database index structure. The processing flow is as follows: Text processing is performed on the database documents in the metadata information to extract the corresponding document keywords using component syntax analysis and a preset named entity recognition tool; the document keywords are converted into document keyword vectors using a preset vector model, and the document keywords and document keyword vectors are used as a first-level index, with the corresponding original document text as a second-level index, to construct the corresponding database index structure for the several isomorphic databases; for each isomorphic database, a corresponding independent vector library is created in the preset vector database to obtain the vector database address, and the document keyword vector is saved to the independent vector library; the global index mapping table, including the data source identifier, the database index structure, and the vector database address, is constructed. The database documents include, but are not limited to, DDL documents, table documents, table comments, historical SQL cases, etc. In other words, the database documents in the metadata information are first grouped and independently segmented and merged according to the data source identifier. NLP (Natural Language Processing) discourse analysis tools are used to identify the hierarchical relationships between paragraphs (such as the descriptions of the main table and sub-tables), merging related paragraphs to preserve complete semantics. The documents are then segmented according to preset rules (single paragraph length no more than 500 characters, adjacent paragraphs overlapping by 50 characters) to ensure that each text block is semantically independent. Subsequently, document keywords are extracted using component syntactic analysis and preset named entity recognition tools. Specifically, component syntactic analysis extracts core predicates and objects (such as the order amount in a query for order amount), and named entity recognition locates table names, field names, and other entities (such as the orders table and the amount field), forming a mapping pair between keywords and the data source (such as orders|db_primary).Finally, using a preset vector model, such as Sentence-BERT (a sentence embedding model), the document keywords are converted into high-dimensional (e.g., 768-dimensional) document keyword vectors. The document keywords and their vectors are used as a first-level index, and the corresponding original document text as a second-level index to construct a database index structure for the several isomorphic databases. A corresponding field (source_id) is added to the database index structure to associate with the data source, realizing a three-level mapping of keyword retrieval, data source location, and original text acquisition. For each isomorphic database, an independent vector library (e.g., faiss_db_primary, faiss_db_secondary) is created in the preset vector database, such as the Faiss vector database, to obtain the address of the vector database. The document keyword vectors are indexed and stored in the independent vector library according to L2 distance (Euclidean distance). Faiss's GPU (Graphics Processing Unit) acceleration algorithm (e.g., IVF (Inverted File) + PQ (Product Index)) is used. Quantization (product quantization) improves retrieval speed and ultimately constructs a global index mapping table, global_index_map, which contains the data source identifier, the database index structure, and the vector database address. This table records the correspondence between the data source identifier, vector library ID, and database index structure (db_primary corresponds to the IVF1024_PQ16 index of fax_db_primary), supporting fast location of multi-source vector data.

[0061] Understandably, to avoid cross-source vector interference, this embodiment adds a `source_tag` to the metadata when storing the document keyword vectors to mark the data source, ensuring that matching is performed only in the vector library of the target data source during retrieval. In this way, this embodiment associates the query intent with the global index mapping table, quickly locating the core configuration information required for retrieval, clarifying the storage location of keyword vectors and text mapping rules, avoiding configuration confusion and path redundancy during the retrieval process, and helping to improve the targeting and response speed of cross-source data queries. The combination of hierarchical index construction and independent vector library storage ensures the accuracy of document keyword extraction through syntactic analysis and entity recognition, and achieves structured representation of keywords through vector models. Simultaneously, the index structure clarifies the relationship between vectors and original text, while the global index mapping table integrates the core configuration information required for cross-source retrieval, improving the accuracy and response efficiency of cross-source data retrieval.

[0062] Step S13: Convert the query intent object into an intent object vector using a preset vector model, and determine the target database information set related to the target data query request based on the database retrieval configuration information, the intent object vector, and the preset vector database.

[0063] In this embodiment, the query intent object is converted into an intent object vector using the preset vector model. Then, based on the database retrieval configuration information, for each database in the candidate database set, the intent object vector is combined with the preset vector database for independent parallel matching to retrieve documents with the Top-K similarity (such as Top-5 vector matching results). Finally, the target database information set related to the target data query request is determined, including the relevant index entries of each database (including data source identifier, document keywords, and original document text).

[0064] It should be noted that the processing flow for determining the target database information set related to the target data query request is as follows: Based on the vector database address in the database retrieval configuration information, a search is performed in the preset vector database based on the intent object vector to determine candidate document keyword vectors through vector similarity; the original document text of the candidate document keyword vectors is determined through the database index structure in the database retrieval configuration information, and the query keywords are matched with the original document text to obtain the target database information set related to the target data query request. That is, based on the vector database address in the database retrieval configuration information and the intent object vector, a search is performed in the preset vector database, and candidate document keyword vectors are filtered out through vector similarity. Then, with the help of the database index structure in the database retrieval configuration information, the original document text corresponding to the candidate document keyword vectors is located, and the query keywords are matched with the original document text, such as matching the amount field name, to filter irrelevant content. The correct data source is ensured through the data source identifier. When merging the retrieval results of each database, they are sorted by similarity score, and a source_rank field is added to indicate the confidence level of each source result. If a data source returns no results, the search scope can be automatically expanded (e.g., if a query for db_beijing.orders returns no results, search for the metadata of db_beijing.all_tables), avoiding the omission of related information in multi-source data, and ultimately obtaining a set of target database information related to the target data query request. In this way, this embodiment achieves precise matching between query intent and database keyword vectors through vector transformation, breaking through the limitations of traditional literal keyword matching. It can deeply capture the core semantics of the query intent and quickly locate the target database with the highest relevance by combining search configuration information, improving the accuracy and efficiency of database location in cross-source data queries. Through a two-layer matching mechanism of initial screening by vector similarity and fine-tuning by text keywords, it not only overcomes the limitations of literal matching through vector semantic matching, accurately capturing core related information, but also ensures the accuracy of matching through secondary verification of text keywords, effectively filtering irrelevant databases, improving the accuracy and reliability of target database location, and facilitating subsequent efficient data retrieval and rapid acquisition of target results.

[0065] Step S14: Generate a large model based on a preset search statement. Generate a target database search statement based on the target database information set and execute the target database search statement to visualize the obtained database search results.

[0066] In this embodiment, a large model is generated based on a preset search statement. The target database search statement is automatically generated according to the target database information set. After the target database search statement is executed, the obtained database search results are presented in a visual manner.

[0067] It should be noted that before receiving the target data query request, this embodiment needs to first obtain the preset retrieval statement generation model. The processing flow is as follows: Analyze the several homogeneous databases based on the metadata information to generate corresponding multi-source metadata documents according to the analysis results; use prompting engineering technology to control the preset semantic expansion model to semantically expand the historical statement cases in the multi-source metadata documents to obtain an initial case dataset; verify the correctness of the initial case dataset, and after verification, divide the initial case dataset into a training dataset and a test dataset according to a preset partitioning ratio; iteratively train the target initial model using the training dataset and the test dataset to control the target initial model to learn the semantic mapping rules of cross-source queries, thereby obtaining the preset retrieval statement generation model. That is, based on the metadata information of the aforementioned homogeneous databases, structural analysis is performed. Based on the analysis results, multi-source metadata documents are generated (e.g., joint annotations of the orders tables in db_primary and db_secondary). Using hinting engineering techniques, a pre-defined semantic expansion model, such as GPT-4 (a pre-trained language model), is driven to semantically expand historical statement examples in the multi-source metadata documents, generating synonym queries (e.g., obtaining the total of all orders in year xxxx, including primary and secondary databases) and queries at different granularities (e.g., statistics by regional database partitioning). Corresponding cross-source SQL is generated for each expansion question, resulting in an initial... The case dataset consists of a natural language question (e.g., querying the total number of orders in two databases over a year) and a target SQL statement (e.g., a cross-source UNION statement). The initial case dataset is validated for correctness by executing the SQL in each data source and comparing the results. Only samples whose execution results match expectations (e.g., the UNION query result matches the sum of a single-source query) are retained. After validation, the dataset is split into a training dataset and a test dataset according to a preset ratio, for example, 8:2. These two datasets are used to iteratively train the initial target model, enabling the model to learn the semantic mapping rules of cross-source queries, ultimately generating a large model based on the preset retrieval statement.

[0068] It should be noted that the processing flow for generating the target database retrieval statement is as follows: The target database information set is integrated based on a preset prompt word template to obtain target prompt words including the data source identifier; the target prompt words are input into a preset retrieval statement generation model, so that the preset retrieval statement generation model determines the database query type based on the data source identifier and generates a database retrieval statement based on the database query type; the statement format of the database retrieval statement is verified using a preset syntax validator, and after successful verification, the database retrieval statement is determined as the target database retrieval statement. That is, based on the preset prompt word template, the target database information set is integrated to generate target prompt words containing the data source identifier (e.g., #db_a #db_b Query orders with amount > 1000: {Search result 1}, {Search result 2}). The target prompt words are input into the preset search statement to generate a large model. The model determines the database query type based on the data source identifier and generates a database search statement based on the type: if it is a single-source query (e.g., only involving db_a), standard SQL is generated, such as SELECT * FROM db_beijing.orders WHEREamount > 1000; if it is a multi-source isomorphic table query, a UNION ALL cross-source statement is generated, for example:

[0069] (SELECT * FROM db_beijing.orders WHERE amount > 1000)

[0070] UNION ALL

[0071] (SELECT * FROM db_shanghai.orders WHERE amount > 1000). Understandably, if the database supports distributed queries (such as MySQL ShardingSphere), a merge query instruction routed to each shard will be generated. After generating the database retrieval statement, a preset syntax validator, such as ANTLR (Another Tool for Language Recognition, a syntax parser generation tool), is used to verify the correctness of the database retrieval statement's format. The correctness of table names and field names is also checked based on the metadata information (e.g., whether the `orders` table exists in `db_a`), avoiding syntax errors caused by differences in data sources. Once verified, it is determined as the target database retrieval statement.

[0072] It should be further noted that the process of executing the target database retrieval statement to visualize the obtained database retrieval results is as follows: The target database retrieval statement is executed on each candidate isomorphic database in the candidate database set to obtain corresponding database retrieval results; the database retrieval results are merged and format converted to obtain processed retrieval results; the summary index and corresponding index contribution ratio of the candidate isomorphic databases are calculated based on the processed retrieval results, and the processed retrieval results are visualized based on the summary index and the index contribution ratio; during the visualization process, a preset multi-source differentiation strategy is used to differentiate and display the relevant data of each candidate isomorphic database in the processed retrieval results. That is, the target database retrieval statement is executed on each candidate isomorphic database in the candidate database set to obtain the corresponding database retrieval results. The database retrieval results returned by each data source are distinguished according to the data source identifier. The database retrieval results are then merged and format-converted, uniformly converting the format to JSON (a lightweight text data exchange format) or CSV (a plain text file format) to obtain uniformly standardized retrieval results. For example, if the result fields are identical and deduplication is required, UNION is used for merging; if all data needs to be retained, UNION is used. The system adds a `source_tag` column (e.g., labeling the data source column as `db_a` or `db_b`), and then provides a result summary function. It calculates the summary indicators (e.g., total number of orders, average amount) and the corresponding contribution ratio of each candidate isomorphic database (e.g., `db_a` accounts for 60%, `db_b` accounts for 40%) to improve the readability of multi-source data. Based on these data, the processed retrieval results are visualized. During the visualization process, a preset multi-source differentiation strategy is adopted to present the relevant data of different candidate isomorphic databases in a differentiated manner. For example, it generates charts with source legends using tools such as ECharts (a data visualization chart library) (e.g., different colors in a bar chart represent the order volume of different data sources), or it uses group headers in the table to distinguish multi-source data (e.g., the `db_a` order amount column and the `db_b` order amount column).

[0073] It is understandable that this embodiment can also continuously improve multi-source processing capabilities through a source-based feedback mechanism. Users can annotate database retrieval results: if the SQL generation of a certain data source is incorrect (e.g., db_a returns an empty result but data actually exists), the user can choose to update only the index of 'a', and store the feedback along with the corresponding source_id (data source identifier), query statement, and correct SQL in the source-based feedback database. During feedback processing, only the relevant indexes of that data source are reprocessed: keywords in the correct SQL (e.g., db_a.orders) are extracted, their vector representations are updated, and they are re-indexed into the Faiss database to avoid cross-source interference caused by global model adjustments. At the same time, a new cross-source question-answering pair storage mechanism is added: correct cases of multi-source queries (e.g., UNION statement syntax) are recorded, grouped by source_id, and stored in the training set. The next time a similar query is performed, this type of case is retrieved first, forming a closed-loop iteration of "feedback-optimization-retrieval". In addition, the feedback frequency of each data source can be analyzed periodically, and deep optimization can be triggered for high-frequency error sources (e.g., regenerating the vector index of the source, supplementing the metadata document of the source) to achieve differentiated improvement of multi-source processing capabilities. In this way, this embodiment automatically generates search statements using a large model and combines them with visualization, avoiding the tediousness and errors of manually writing search statements, improving the execution efficiency of cross-source data retrieval. At the same time, the intuitive visualization makes the search results easier to understand and analyze, effectively lowering the threshold for data interpretation. The training method of building a high-quality dataset based on metadata and semantic expansion ensures a high degree of adaptability between the training data and the cross-source query scenario. The accuracy of semantic expansion is improved through prompting engineering, and iterative training allows the model to deeply master the semantic mapping logic of cross-source retrieval, enabling the final search statement generation model to have the ability to generate search statements adapted to multiple source databases. The process of multi-database parallel retrieval, result standardization processing, visualization of quantitative indicators, and differentiation of multi-source data not only achieves efficient integration and unified presentation of cross-source data, but also makes the value of each data source clear at a glance through summary indicators and contribution ratios. The multi-source differentiation strategy avoids confusion between data from different databases, allowing users to intuitively perceive the data source and distribution characteristics, improving the readability and analysis efficiency of cross-source search results.

[0074] As can be seen from the above, after receiving a target data query request, this embodiment first extracts the corresponding query keywords, determines the relevant candidate database set by matching a pre-built cross-source metadata mapping table that stores global mapping relationships for several isomorphic database metadata information, and then generates a query intent object based on the candidate database set and the query keywords. Based on this object, it obtains database retrieval configuration information from a pre-built global index mapping table that stores the address of a preset vector database (storing document keyword vectors) corresponding to isomorphic databases and the database index structure (storing the mapping relationship between document keyword vectors and original document text). Subsequently, it uses a preset vector model to convert the query intent object into an intent object vector, and combines the database retrieval configuration information with the preset vector database to determine the target database information set. Finally, it uses a preset retrieval statement generation model to generate a target database retrieval statement based on this set, and then visualizes the retrieval results after execution. In this way, through the above process of the embodiments of this application, relying on the retrieval architecture of cross-source metadata mapping and global index, and through the synergy of keyword matching, intent vector conversion and vector database retrieval, accurate cross-source data positioning between homogeneous databases is achieved. It simplifies the complex process of multi-database retrieval by leveraging global mapping relationships, improves the matching accuracy between query intent and database content through vector models, and makes the retrieval results more intuitive and easy to understand through visualization. This effectively improves the efficiency, accuracy and user experience of cross-source data query, thereby solving the problems of low NL2SQL query efficiency, difficulty in cross-source processing and insufficient accuracy in multi-homogeneous data source scenarios.

[0075] Accordingly, see Figure 2 As shown in the embodiments of this application, a multi-source isomorphic data NL2SQL device based on retrieval enhancement is also provided, including:

[0076] The mapping table matching module 11 is used to extract the query keywords corresponding to the target data query request after receiving the target data query request, and match the query keywords with a pre-built cross-source metadata mapping table to determine the relevant candidate database set from several homogeneous databases; the cross-source metadata mapping table is used to store the global mapping relationship between the metadata information of the several homogeneous databases.

[0077] The information determination module 12 is used to generate a query intent object based on the candidate database set and the query keywords, and to determine database retrieval configuration information from a pre-built global index mapping table according to the query intent object; the global index mapping table is used to store the vector database addresses and database index structures corresponding to the plurality of isomorphic databases; the vector database address is the address of a preset vector database, and the preset vector database is used to store the document keyword vectors corresponding to the document keywords of the plurality of isomorphic databases; the database index structure is used to store the mapping relationship between the document keyword vectors and the original document text;

[0078] The set determination module 13 is used to convert the query intent object into an intent object vector using a preset vector model, and determine the target database information set related to the target data query request based on the database retrieval configuration information, the intent object vector, and the preset vector database.

[0079] The statement execution module 14 is used to generate a large model based on a preset search statement, generate a target database search statement according to the target database information set, and execute the target database search statement to visualize the obtained database search results.

[0080] In some specific embodiments, the NL2SQL device based on retrieval enhancement for multi-source isomorphic data may further include:

[0081] The file parsing unit is used to establish a connection with the plurality of homogeneous databases through a preset driver protocol, and then parse the data definition language files and database schema files of the plurality of homogeneous databases to extract the corresponding metadata information.

[0082] The database verification unit is used to verify the homogeneity of the plurality of homogeneous databases based on the metadata information and according to preset verification rules, so as to assign a corresponding data source identifier to the homogeneous database after the verification is passed.

[0083] An information analysis unit is used to analyze the metadata information to determine the global mapping relationship between the metadata information, and to construct the cross-source metadata mapping table based on the global mapping relationship, the metadata information and the data source identifier.

[0084] In some specific embodiments, the NL2SQL device based on retrieval enhancement for multi-source isomorphic data may further include:

[0085] The text processing unit is used to perform text processing on the database documents in the metadata information respectively, so as to extract the corresponding document keywords through component syntactic analysis and preset named entity recognition tools;

[0086] The structural building unit is used to convert the document keywords into document keyword vectors through a preset vector model, and to construct the corresponding database index structure for the several homogeneous databases, using the document keywords and document keyword vectors as first-level indexes and the corresponding original document text as second-level indexes.

[0087] The vector library creation unit is used to create a corresponding independent vector library in the preset vector database for each homogeneous database, so as to obtain the address of the vector database and save the document keyword vector to the independent vector library;

[0088] The mapping table construction unit is used to construct the global index mapping table, which includes the data source identifier, the database index structure, and the vector database address.

[0089] In some specific embodiments, the NL2SQL device based on retrieval enhancement for multi-source isomorphic data may further include:

[0090] The database analysis unit is used to analyze the plurality of homogeneous databases based on the metadata information, so as to generate corresponding multi-source metadata documents according to the analysis results.

[0091] The semantic augmentation unit is used to utilize prompting engineering techniques to control a preset semantic augmentation model to semantically augment historical sentence cases in the multi-source metadata document in order to obtain an initial case dataset.

[0092] The dataset partitioning unit is used to verify the correctness of the initial case dataset, and after the verification is passed, to partition the initial case dataset into a training dataset and a test dataset according to a preset partitioning ratio.

[0093] The iterative training unit is used to iteratively train the target initial model using the training dataset and the test dataset, so as to control the target initial model to learn the semantic mapping rules of cross-source queries and obtain the preset retrieval statement to generate a large model.

[0094] In some specific embodiments, the set determination module 13 may specifically include:

[0095] The database retrieval unit is used to perform a retrieval in the preset vector database based on the vector database address in the database retrieval configuration information and the intent object vector, so as to determine the candidate document keyword vector through vector similarity.

[0096] The text determination unit is used to determine the original text of the document containing the candidate document keyword vector through the database index structure in the database retrieval configuration information, so as to match the query keywords with the original text of the document to obtain a set of target database information related to the target data query request.

[0097] In some specific embodiments, the statement execution module 14 may specifically include:

[0098] The collection and integration unit is used to integrate the target database information collection based on the preset prompt word template to obtain target prompt words including the data source identifier;

[0099] The prompt word input unit is used to input the target prompt word into the preset search statement generation model, so that the preset search statement generation model can determine the database query type based on the data source identifier and generate a database search statement based on the database query type;

[0100] The format verification unit is used to verify the statement format of the database retrieval statement using a preset syntax validator, and to determine the database retrieval statement as the target database retrieval statement after the verification is passed.

[0101] In some specific embodiments, the statement execution module 14 may specifically include:

[0102] The statement execution unit is used to execute the target database retrieval statement on the candidate isomorphic databases in the candidate database set respectively, so as to obtain the corresponding database retrieval results;

[0103] The result processing unit is used to merge and convert the database retrieval results to obtain the processed retrieval results.

[0104] A visualization unit is used to calculate the summary index and corresponding index contribution ratio of the candidate isomorphic database for the processed retrieval results, and to visualize the processed retrieval results based on the summary index and the index contribution ratio.

[0105] The data display unit is used to differentiate and display the relevant data of each candidate isomorphic database in the processed retrieval results during the visualization process using a preset multi-source differentiation strategy.

[0106] Furthermore, embodiments of this application also disclose an electronic device, Figure 3This is a structural diagram of an electronic device 20 according to an exemplary embodiment. The content of the diagram should not be construed as limiting the scope of this application. The electronic device 20 may specifically include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. The memory 22 stores a computer program, which is loaded and executed by the processor 21 to implement the relevant steps in the NL2SQL method for multi-source homogeneous data based on retrieval enhancement disclosed in any of the foregoing embodiments. Furthermore, the electronic device 20 in this embodiment may specifically be a computer.

[0107] In this embodiment, the power supply 23 is used to provide operating voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and external devices, and the communication protocol it follows can be any communication protocol applicable to the technical solution of this application, and is not specifically limited here; the input / output interface 25 is used to acquire external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs, and is not specifically limited here.

[0108] In addition, the memory 22, as a carrier for resource storage, can be a read-only memory, random access memory, disk or optical disk, etc. The resources stored thereon can include operating system 221, computer program 222, etc., and the storage method can be temporary storage or permanent storage.

[0109] The operating system 221 is used to manage and control the various hardware devices on the electronic device 20 and the computer program 222, which may be Windows Server, Netware, Unix, Linux, etc. In addition to including a computer program capable of performing the NL2SQL method based on retrieval enhancement for multi-source homogeneous data disclosed in any of the foregoing embodiments, the computer program 222 may further include computer programs capable of performing other specific tasks.

[0110] Furthermore, this application also discloses a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, it implements the aforementioned disclosed NL2SQL method for multi-source isomorphic data based on retrieval enhancement. Specific steps of this method can be found in the corresponding content disclosed in the foregoing embodiments, and will not be repeated here.

[0111] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatus disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple; relevant parts can be referred to in the method section.

[0112] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0113] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein can be implemented directly by hardware, a software module executed by a processor, or a combination of both. The software module can be located in random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium known in the art.

[0114] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0115] The technical solutions provided in this application have been described in detail above. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the methods and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.

Claims

1. A multi-source isomorphic data NL2SQL method based on retrieval enhancement, characterized in that, include: Upon receiving a target data query request, the query keywords corresponding to the target data query request are extracted, and a pre-built cross-source metadata mapping table is matched based on the query keywords to determine a set of relevant candidate databases from several homogeneous databases; the cross-source metadata mapping table is used to store the global mapping relationship between the metadata information of the several homogeneous databases. A query intent object is generated based on the candidate database set and the query keywords. Database retrieval configuration information is determined from a pre-built global index mapping table based on the query intent object. The global index mapping table stores the vector database addresses and database index structures corresponding to the several isomorphic databases. The vector database address is the address of a preset vector database, which stores the document keyword vectors corresponding to the document keywords of the several isomorphic databases. The database index structure stores the mapping relationship between the document keyword vectors and the original document text. The query intent object is converted into an intent object vector using a preset vector model, and the database retrieval configuration information is used to determine the target database information set related to the target data query request based on the intent object vector and the preset vector database. A large model is generated based on a preset search statement. A target database search statement is generated based on the target database information set, and the target database search statement is executed to visualize the obtained database search results.

2. The NL2SQL method for multi-source isomorphic data based on retrieval enhancement according to claim 1, characterized in that, The step of receiving a target data query request and extracting the query keywords corresponding to the target data query request also includes: After establishing a connection with the several homogeneous databases through a preset driver protocol, the data definition language files and database schema files of the several homogeneous databases are parsed to extract the corresponding metadata information; Based on the metadata information, the homogeneity of the several homogeneous databases is verified according to preset verification rules, so that after the verification is passed, the homogeneous databases are assigned corresponding data source identifiers. The metadata information is analyzed to determine the global mapping relationship between the metadata information, and the cross-source metadata mapping table is constructed based on the global mapping relationship, the metadata information, and the data source identifier.

3. The NL2SQL method for multi-source isomorphic data based on retrieval enhancement according to claim 2, characterized in that, The step of receiving a target data query request and extracting the query keywords corresponding to the target data query request also includes: Text processing is performed on the database documents in the metadata information to extract the corresponding document keywords through component syntactic analysis and preset named entity recognition tools; The document keywords are converted into document keyword vectors using a preset vector model, and the document keywords and document keyword vectors are used as first-level indexes, with the corresponding original document text as a second-level index, to construct the corresponding database index structure for the several isomorphic databases. For each of the isomorphic databases, a corresponding independent vector library is created in the preset vector database to obtain the address of the vector database, and the document keyword vector is saved to the independent vector library; Construct a global index mapping table that includes the data source identifier, the database index structure, and the vector database address.

4. The NL2SQL method for multi-source isomorphic data based on retrieval enhancement according to claim 1, characterized in that, The step of receiving a target data query request and extracting the query keywords corresponding to the target data query request also includes: The metadata information is used to analyze the several homogeneous databases, and corresponding multi-source metadata documents are generated based on the analysis results. Using prompting engineering techniques, a preset semantic expansion model is controlled to semantically expand the historical sentence cases in the multi-source metadata documents to obtain an initial case dataset; The initial case dataset is validated for correctness, and after the validation is passed, the initial case dataset is divided into a training dataset and a test dataset according to a preset partitioning ratio. The target initial model is iteratively trained using the training dataset and the test dataset to control the target initial model to learn the semantic mapping rules of cross-source queries, thereby obtaining the large model generated by the preset retrieval statement.

5. The NL2SQL method for multi-source isomorphic data based on retrieval enhancement according to claim 1, characterized in that, The step of determining the target database information set related to the target data query request based on the database retrieval configuration information, the intent object vector, and the preset vector database includes: Based on the vector database address in the database retrieval configuration information, a search is performed in the preset vector database based on the intent object vector to determine candidate document keyword vectors through vector similarity; The original text of the document is determined by the database index structure in the database retrieval configuration information, and the query keywords are matched with the original text of the document to obtain a set of target database information related to the target data query request.

6. The NL2SQL method for multi-source isomorphic data based on retrieval enhancement according to claim 3, characterized in that, The process of generating a large model based on a preset search statement, which generates a target database search statement based on the target database information set, includes: The target database information set is integrated based on a preset prompt word template to obtain target prompt words that include the data source identifier; The target prompt words are input into a preset search statement to generate a large model, so that the preset search statement generation large model can determine the database query type based on the data source identifier and generate a database search statement based on the database query type; The statement format of the database retrieval statement is verified using a preset syntax validator, and the database retrieval statement is determined as the target database retrieval statement after the verification is passed.

7. The NL2SQL method for multi-source isomorphic data based on retrieval enhancement according to any one of claims 1 to 6, characterized in that, The execution of the target database retrieval statement to visualize the obtained database retrieval results includes: The target database retrieval statement is executed on each of the candidate isomorphic databases in the candidate database set to obtain the corresponding database retrieval results; The database search results are merged and format converted to obtain the processed search results; The aggregated index and corresponding contribution ratio of the candidate isomorphic database are calculated based on the processed retrieval results, and the processed retrieval results are visualized based on the aggregated index and the contribution ratio. During the visualization process, a preset multi-source differentiation strategy is used to differentiate and display the relevant data of each candidate isomorphic database in the processed retrieval results.

8. A multi-source isomorphic data NL2SQL device based on retrieval enhancement, characterized in that, include: The mapping table matching module is used to extract the query keywords corresponding to the target data query request after receiving the target data query request, and match the query keywords with a pre-built cross-source metadata mapping table to determine a set of relevant candidate databases from several homogeneous databases; the cross-source metadata mapping table is used to store the global mapping relationship between the metadata information of the several homogeneous databases. The information determination module is used to generate a query intent object based on the candidate database set and the query keywords, and to determine database retrieval configuration information from a pre-built global index mapping table according to the query intent object; the global index mapping table is used to store the vector database addresses and database index structures corresponding to the plurality of isomorphic databases; the vector database address is the address of a preset vector database, and the preset vector database is used to store the document keyword vectors corresponding to the document keywords of the plurality of isomorphic databases; the database index structure is used to store the mapping relationship between the document keyword vectors and the original document text; The set determination module is used to convert the query intent object into an intent object vector using a preset vector model, and determine the target database information set related to the target data query request based on the database retrieval configuration information, the intent object vector, and the preset vector database. The statement execution module is used to generate a large model based on a preset search statement, generate a target database search statement based on the target database information set, and execute the target database search statement to visualize the obtained database search results.

9. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor for executing the computer program to implement the NL2SQL method for multi-source isomorphic data based on retrieval enhancement as described in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, Used to store computer programs; wherein, when the computer programs are executed by a processor, they implement the NL2SQL method for multi-source isomorphic data based on retrieval enhancement as described in any one of claims 1 to 7.