Complex database question answering system based on large language model

Through a complex database question and answer system based on a large language model, users' natural language instructions are converted into vectors, database tables are matched and SQL query instructions are generated, which solves the problem of high user instructions requirements in the existing technology, and improves the flexibility of database operations and efficiency.

CN118964395AInactive Publication Date: 2024-11-15BEIJING ZHONGKE STRON CLOUD INTELLIGENT TECH CO LTD

Patent Information

Application Number
CN202411441708.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-16
Publication Date
2024-11-15
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

The existing database question and answer system has too high requirements for user instructions, resulting in unprofessional users being less flexible and efficient when querying or operating databases.

Method used

Using a complex database question and answer system based on a large language model, the natural language instructions input by the user are converted into vectors through a text embedding model, matched to the relevant database tables, and generated SQL query instructions. The large language model is used to generate corresponding SQL query instructions. Execute and feedback the results.

Benefits of technology

Improve the accuracy and efficiency of multi-table query or operation, ensure the pertinence of query or operation instructions, and fine-tune the text embedding model through historical data sets, enhancing the accuracy of database table recall and instruction matching.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118964395A_ABST
    Figure CN118964395A_ABST
Patent Text Reader

Abstract

The invention discloses a complex database question-answering system based on a large language model, which relates to the technical field of large language models and comprises an instruction receiving module, a question-answering matching module, a statement generating module and a question-answering processing module. The instruction receiving module is used for receiving a natural language instruction input by a user; the question and answer matching module is used for converting and matching the natural language instruction to obtain a related database table; the statement generation module is used for forming the natural language instruction and the related database table description into prompt, and sending the prompt to a large language model to generate a corresponding SQL query instruction; the question and answer processing module is used for executing the SQL query instruction and feeding back a query result to the user; the method and the device are used for solving the problem that the flexibility and the efficiency are not high when a non-professional user queries or operates a database due to the fact that the requirement for a user instruction is too high in the query process of an existing database question-answering system.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of large language models, and in particular to a complex database question-answering system based on a large language model. Background Art

[0002] Complex database question answering system is an advanced information retrieval and processing system, which is specially designed to handle questions related to complex databases. Such systems combine multiple technologies such as natural language processing, information retrieval, knowledge graphs and deep learning to achieve accurate understanding and efficient answers to users' natural language questions.

[0003] In the prior art, when querying or operating a database, users are often required to master specific query or operation languages, such as SQL commands, which greatly limits the operation capabilities of non-professional users; although there are graphical interface tools to simplify queries or operations, the flexibility and efficiency of non-professional users are still limited when processing complex queries or operations. Therefore, a complex database question-answering system based on a large language model is needed to solve the above problems. Summary of the invention

[0004] The present invention aims to solve at least one of the technical problems in the prior art to a certain extent, by converting the natural language instructions input by the user into vectors by using a text embedding model, and then matching the database most relevant to the user instructions from the vector library, and then sending the user instructions and related database descriptions to form a prompt and sending it to a large language model to generate corresponding SQL query instructions, which are sent to the database management system for execution. Finally, the system feeds back the query results to the user, so as to solve the problem that the existing database question and answer system has too high requirements for user instructions during the query process, resulting in low flexibility and efficiency for non-professional users when querying or operating the database.

[0005] To achieve the above objectives, the present application provides a complex database question-answering system based on a large language model, including an instruction receiving module, a question-answering matching module, a sentence generating module, and a question-answering processing module; The instruction receiving module is used to receive natural language instructions input by a user; The question-answer matching module is used to convert and match natural language instructions to obtain relevant database tables; The statement generation module is used to combine natural language instructions and related database table descriptions into a prompt, and send it to the large language model to generate corresponding SQL query instructions; The question-answer processing module is used to execute SQL query instructions and feed back query results to the user.

[0006] Furthermore, the question-answer matching module includes a database table description unit, which is configured with a database table description strategy, which includes: for any database table, obtaining the table name, field name and data type of the database table; setting the table name, field name and data type of the database table as the description of the database table.

[0007] Further, the question-answer matching module further includes a vector conversion unit, the vector conversion unit is configured with a vector conversion strategy, the vector conversion strategy includes: when a user inputs a natural language instruction, preprocessing the natural language instruction to obtain an instruction text; Establish a text embedding model, and fine-tune the text embedding model to obtain a fine-tuned text embedding model; The instruction text obtained after preprocessing is input into the fine-tuned text embedding model, the fine-tuned text embedding model converts the instruction text into a high-dimensional vector, and the obtained high-dimensional vector representation is set as the user instruction vector; Build a vector library to collect and preprocess the description of database tables; The description of each database table is converted into a high-dimensional vector using the fine-tuned text embedding model and the high-dimensional vector is stored in the vector library.

[0008] Further, the preprocessing includes obtaining natural language instructions, and performing text cleaning on the natural language instructions, wherein the text cleaning includes removing useless characters, removing or replacing numbers, and removing spaces and tabs; The natural language instructions that have been cleaned are segmented, including: dividing the text into several small units based on spaces to obtain the instruction text.

[0009] Furthermore, the fine-tuning of the text embedding model includes: acquiring a large amount of natural languages ​​related to natural voice instructions input by historical users from a database, segmenting and tokenizing each natural language, and obtaining a fine-tuning dataset; Use the fine-tuning dataset to train the text embedding model; obtain the fine-tuned text embedding model.

[0010] Furthermore, the high-dimensional vector conversion includes: for any text, using the word segmenter of the text embedding model to perform word segmentation on the text to obtain a text sequence; Add special marks, fill and truncate the text sequence obtained after word segmentation, and convert the text sequence obtained after word segmentation into an integer ID sequence; Pass the obtained integer ID sequence to the text embedding model, and obtain the embedding vector by querying the index of the text embedding model; Output the embedded vector to obtain a high-dimensional vector.

[0011] Furthermore, the question-answer matching module further includes a vector matching unit, and the vector matching unit is configured with a vector matching strategy. The vector matching strategy includes comparing the instruction vector with the high-dimensional vector in the vector library when the instruction vector is obtained, using a cosine similarity algorithm, and the formula is: , A i and B i Represent the components of vectors A and B respectively; The similarity ranges from -1 to 1; -1 indicates that the instruction vector and any high-dimensional vector in the vector library point in opposite directions, 1 indicates that the instruction vector and any high-dimensional vector in the vector library point in exactly the same direction, and 0 indicates that the instruction vector and any high-dimensional vector in the vector library are independent of each other; obtain the database table corresponding to the high-dimensional vector in the vector library whose cosine similarity with the instruction vector is closest to 1, and set it as the database table corresponding to the instruction vector.

[0012] Furthermore, the statement generation module includes a statement generation unit, the statement generation unit is configured with a statement generation strategy, the statement generation strategy includes obtaining a database table corresponding to the pointing vector, setting it as an instruction database table, and constructing a Prompt containing a precise context based on the instruction database table; sending the Prompt to a large language model, and the large language model generates precise SQL query instructions based on the content of the Prompt.

[0013] Beneficial effects of the present invention: The present invention describes each database table, uses text embedding technology to compare the high-dimensional vector features of user query or operation instructions with the vectorized features of these table descriptions, and uses cosine similarity or other advanced similarity algorithms to quickly determine a group of database tables that best match the user query or operation instructions, thereby improving the accuracy of multi-table query or operation and ensuring the pertinence of query or operation instructions; The present invention collects historical data and uses the historical data set to fine-tune the text embedding model, thereby improving the accuracy of database table recall of the text embedding model in user business scenarios; The present invention also constructs a vector library, collects and preprocesses the metadata of the database table, including the table name, field information, etc., summarizes all the information into a complete table description, converts each table description into a high-dimensional vector using a text embedding model, and stores these vectors in an efficient index structure, supporting fast retrieval and dynamic update, ensuring the precise matching of instructions with the database table, and improving the accuracy and efficiency of instruction matching. BRIEF DESCRIPTION OF THE DRAWINGS

[0014] Figure 1 is a functional block diagram of the system of the present invention; Figure 2It is a schematic diagram of the question-answering process flow of the present invention; Figure 3 It is a schematic structural diagram of the electronic device of the present invention. DETAILED DESCRIPTION

[0015] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0016] Example 1, please refer to Figure 1 As shown, the present application provides a complex database question-answering system based on a large language model, including an instruction receiving module, a question-answering matching module, a sentence generating module and a question-answering processing module; The instruction receiving module is used to receive natural language instructions input by users. In the specific implementation process, users submit queries or operation requests through a friendly interface, such as "statistical geographical distribution of new users in the past year", and the system immediately captures and prepares to process this natural language instruction; The question-answer matching module is used to convert and match natural language instructions to obtain relevant database tables; The question-answer matching module includes a database table description unit, which is configured with a database table description strategy. The database table description strategy includes: for any database table, obtaining the table name, field name and data type of the database table; setting the table name, field name and data type of the database table as the description of the database table; in a specific implementation process, for example, there are multiple database tables in the system, one of which is "Users" (user information table), and the other is "UserRegistrations" (user registration record table); The string descriptions of the two database tables are as follows: Users = '''Table name Users, this table stores detailed information of all users on the platform and is the core storage location for user identity and attribute data. Each user has a corresponding unique record in the system, which facilitates tracking of user behavior, preference settings, and provision of personalized services. Fields: - `UserID` (integer, primary key): An ID that uniquely identifies each user, automatically incremented.

[0017] - `Username` (string): User's login name, must be unique.

[0018] - `Email` (string): The user's email address, used for communication and account verification.

[0019] - `FullName` (string): The user's real full name.

[0020] - `Region` (string): The geographical region or country where the user is located.

[0021] - `RegistrationDate` (datetime): The date and time when the user account was created.

[0022] - `IsActive` (boolean): Indicates whether the user account is currently active.

[0023] ''' UserRegistrations = ''' Table name UserRegistration, this table specifically records the details of user registration events, including specific information and process logs during registration, which helps analyze registration trends, monitor potential fraud, and provide data support for user behavior research. Fields: - `RegistrationID` (integer, primary key): A unique identifier for each registration record.

[0024] - `UserID` (integer, foreign key): References the UserID of the Users table to establish an association between the two.

[0025] - `IP_Address` (string): The IP address used when the user registered, used for geolocation analysis and security auditing.

[0026] - `DeviceType` (string): The type of device the user is signing up with (e.g. PC, mobile device).

[0027] - `BrowserInfo` (string): Information about the browser used by the user when registering, which may include browser name and version.

[0028] - `RegistrationDate` (datetime): The specific date and time when the registration event occurred.

[0029] - `Referrer` (string, nullable): The source that led the user to the signup page (e.g. URL, advertising ID).

[0030] - `Successful` (boolean): Indicates whether the registration attempt was successful. ''' See also Figure 2 As shown, the question-answer matching module further includes a vector conversion unit, the vector conversion unit is configured with a vector conversion strategy, the vector conversion strategy includes: when a user inputs a natural language instruction, preprocessing the natural language instruction to obtain an instruction text; Preprocessing includes obtaining natural language instructions and performing text cleaning on the natural language instructions. Text cleaning includes removing useless characters, removing or replacing numbers, and removing spaces and tabs. In the specific implementation process, useless characters include HTML tags, special symbols, and emoticons, such as: @, #, ,%,……,&and etc. Useless characters may interfere with the processing and therefore need to be removed; Removing or replacing numbers includes replacing numbers with specific placeholders or removing them completely; removing spaces and tabs includes standardizing the use of spaces and tabs to avoid problems caused by format differences between different source texts; Segment the natural language instructions that have been cleaned, including: segmenting the text into several small units based on spaces to obtain instruction text; in the specific implementation process, the small units include words, punctuation marks, and numbers, etc., and the text is segmented to facilitate subsequent processing. For example, when the natural language instruction is "How many people are there in thatarea", the text is segmented based on spaces to obtain the instruction texts "How", "many", "people", "are", "there", "in", "that", and "area"; Establish a text embedding model, and fine-tune the text embedding model to obtain a fine-tuned text embedding model; The instruction text obtained after preprocessing is input into the fine-tuned text embedding model, the fine-tuned text embedding model converts the instruction text into a high-dimensional vector, and the obtained high-dimensional vector representation is set as the user instruction vector; in the specific implementation process, the prepared fine-tuning dataset is used to fine-tune the selected pre-trained model; fine-tuning enables the text embedding model to generate high-quality embedding vectors for business-related user natural language instructions and database table description texts; Build a vector library to collect and preprocess the description of database tables; The description of each database table is converted into a high-dimensional vector using the fine-tuned text embedding model and the high-dimensional vector is stored in the vector library.

[0031] Fine-tuning the text embedding model includes: obtaining a large amount of natural language related to natural voice commands input by historical users from a database, segmenting and tokenizing each natural language, and obtaining a fine-tuning dataset; Use the fine-tuning dataset to train the text embedding model; obtain the fine-tuned text embedding model. In the specific implementation process, by fine-tuning the historical dataset, a text embedding model with better effect in business-related fields can be obtained, so the database related to user instructions will be recalled more accurately.

[0032] The high-dimensional vector conversion includes: for any text, using the word segmenter of the text embedding model to segment the text to obtain a text sequence; Add special marks, fill and truncate the text sequence obtained after word segmentation, and convert the text sequence obtained after word segmentation into an integer ID sequence; Pass the obtained integer ID sequence to the text embedding model, and obtain the embedding vector by querying the index of the text embedding model; Output the embedded vector to obtain a high-dimensional vector.

[0033] The question-answer matching module also includes a vector matching unit, which is configured with a vector matching strategy. The vector matching strategy includes comparing the instruction vector with the high-dimensional vector in the vector library when the instruction vector is obtained, using the cosine similarity algorithm, and the formula is , A i and B i Represent the components of vectors A and B respectively.

[0034] The similarity range is -1 to 1; -1 indicates that the instruction vector and any high-dimensional vector in the vector library point in opposite directions, 1 indicates that the instruction vector and any high-dimensional vector in the vector library point in exactly the same direction, and 0 indicates that the instruction vector and any high-dimensional vector in the vector library are independent of each other; obtain the database table corresponding to the high-dimensional vector in the vector library whose cosine similarity with the instruction vector is closest to 1, and set it as the database table corresponding to the instruction vector; in the specific implementation process, the most relevant tables in this embodiment are "Users" (user information table) and "UserRegistrations" (user registration record table); The statement generation module is used to combine natural language instructions and related database table descriptions into prompts, and send them to the large language model to generate corresponding SQL query instructions; The question-answer processing module is used to execute SQL query instructions and feed back the query results to the user.

[0035] The statement generation module includes a statement generation unit, which is configured with a statement generation strategy. The statement generation strategy includes obtaining a database table corresponding to a pointing vector, setting it as an instruction database table, and constructing a prompt containing a precise context based on the instruction database table. In the specific implementation process, for example: < Convert user instructions into SQL statements based on the following database table information: Table Users: [Description string of the Users table] Table UserRegistrations: [Description string of the UserRegistrations table] User command: [Distribution of new users in different regions between dates '2022-01-01' and '2022-12-31'. ] > The prompt is sent to the big language model, and the big language model generates accurate SQL query instructions based on the content of the prompt. In the specific implementation process, for example: ```sql SELECT COUNT( ) AS UserCount, Region FROM Users JOIN UserRegistrations ON Users.UserID = UserRegistrations.UserID WHERE UserRegistrations.RegistrationDate BETWEEN '2022-01-01' AND '2022-12-31' GROUP BY Region; ``` The purpose of the SQL query is to count how many users in each geographic region have completed registration within the specified time range (January 1, 2022 to December 31, 2022).

[0036] In Example 2, the present application also provides a complex database question answering method based on a large language model, comprising the following steps: Step S1: receiving a natural language instruction input by a user; Step S2: convert and match the natural language instructions to obtain a relevant database table; Step S2 includes the following sub-steps: Step S201: for any database table, obtain the table name, field name and data type of the database table; set the table name, field name and data type of the database table as the description of the database table; Step S202: construct a vector library, collect and pre-process the description of the database table; Use the fine-tuned text embedding model to convert the description of each database table into a high-dimensional vector and store the high-dimensional vector in the vector library; Step S203: when the user inputs a natural language instruction, the natural language instruction is preprocessed to obtain an instruction text; Step S203 includes the following sub-steps: Step S20301: Acquire a natural language instruction, and perform text cleaning on the natural language instruction, wherein the text cleaning includes removing useless characters, removing or replacing numbers, and removing spaces and tabs; Step S20302: segmenting the natural language instruction after the text cleaning, including: segmenting the text into a number of small units based on spaces to obtain the instruction text; Step S204: establishing a text embedding model, and fine-tuning the text embedding model to obtain a fine-tuned text embedding model; Step S204 includes the following sub-steps: Step S20401: obtaining a large amount of natural language related to natural voice commands input by historical users from the database, performing word segmentation and tokenization on each natural language to obtain a fine-tuning data set; Step S20402: training the text embedding model using the fine-tuning dataset to obtain a fine-tuned text embedding model; Step S205: input the instruction text obtained after preprocessing into the fine-tuned text embedding model, the fine-tuned text embedding model performs high-dimensional vector conversion on the instruction text, and sets the obtained high-dimensional vector representation as the user instruction vector; Step S205 includes the following sub-steps: Step S20501: for any text, use the word segmenter of the text embedding model to perform word segmentation on the text to obtain a text sequence; Step S20502: adding special marks, padding and truncating the text sequence obtained after word segmentation, and converting the text sequence obtained after word segmentation into an integer ID sequence; Step S20503: passing the obtained integer ID sequence to the text embedding model, querying the index of the text embedding model to obtain an embedding vector; outputting the embedding vector to obtain a high-dimensional vector; Step S3: The natural language instruction and the related database table description are combined into a prompt, and sent to the large language model to generate a corresponding SQL query instruction; Step S3 includes the following sub-steps: Step S301: When the instruction vector is obtained, the instruction vector is compared with the high-dimensional vector in the vector library using the cosine similarity algorithm, and the formula is: , A i and B iRepresent the components of vectors A and B respectively.

[0037] The similarity range is from -1 to 1; -1 indicates that the instruction vector and any high-dimensional vector in the vector library point in opposite directions, 1 indicates that the instruction vector and any high-dimensional vector in the vector library point in exactly the same direction, and 0 indicates that the instruction vector and any high-dimensional vector in the vector library are independent of each other; obtain the database table corresponding to the high-dimensional vector in the vector library whose cosine similarity with the instruction vector is closest to 1, and set it as the database table corresponding to the instruction vector; Step S302: Obtain a database table corresponding to the pointing vector, set it as an instruction database table, and construct a Prompt containing an accurate context based on the instruction database table; send the Prompt to the large language model, and the large language model generates an accurate SQL query instruction according to the content of the Prompt; Step S4: Execute the SQL query instruction and feed back the query result to the user.

[0038] Example 3, please refer to Figure 3 As shown, Figure 3 The structural diagram of an electronic device is illustrated, and the electronic device may include: a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus. The memory stores computer-readable instructions, and the processor can call the instructions in the memory. When the computer-readable instructions are executed by the processor, the steps in the complex database question-answering method based on a large language model are executed to achieve the following functions: the natural language instructions input by the user are converted into vectors by using a text embedding model, and then the database most relevant to the user instructions is matched from the vector library, and then the user instructions and the relevant database descriptions are combined into a prompt and sent to the large language model to generate the corresponding SQL query instructions, which are sent to the database management system for execution, and finally the system feeds back the query results to the user.

[0039] Through the description of the above implementation methods, the embodiments of the present invention can be provided as methods, systems or computer program products. Based on such an understanding, the above technical solutions can be essentially or partly contributed to the prior art in the form of software products, which can be stored in a computer-readable storage medium, such as ROM / RAM, a magnetic disk, an optical disk, etc., and include several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.

[0040] In the embodiments provided in the present application, it should be understood that the disclosed system or method can be implemented in other ways. The embodiments described above are merely schematic. For example, the division of modules or units is only a logical function division. There may be other division methods in actual implementation. For example, multiple modules or units can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, and the indirect coupling or communication connection of systems, modules and units can be electrical, mechanical or other forms.

[0041] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application.

Claims

1. A complex database question answering system based on a large language model, characterized by: It includes an instruction receiving module, a question-answer matching module, a sentence generating module and a question-answer processing module; The instruction receiving module is used to receive natural language instructions input by a user; The question-answer matching module is used to convert and match natural language instructions to obtain relevant database tables; The statement generation module is used to combine natural language instructions and related database table descriptions into a prompt, and send it to the large language model to generate corresponding SQL query instructions; The question-answer processing module is used to execute SQL query instructions and feed back query results to the user; The question-answer matching module includes a database table description unit, and the database table description unit is configured with a database table description strategy, and the database table description strategy includes: for any database table, obtaining the table name, field name and data type of the database table; setting the table name, field name and data type of the database table as the description of the database table; The question-answer matching module further includes a vector conversion unit, wherein the vector conversion unit is configured with a vector conversion strategy, wherein the vector conversion strategy includes: when a user inputs a natural language instruction, preprocessing the natural language instruction to obtain an instruction text; Establish a text embedding model, and fine-tune the text embedding model to obtain a fine-tuned text embedding model; The instruction text obtained after preprocessing is input into the fine-tuned text embedding model, the fine-tuned text embedding model converts the instruction text into a high-dimensional vector, and the obtained high-dimensional vector representation is set as the user instruction vector; Build a vector library to collect and preprocess the description of database tables; The description of each database table is converted into a high-dimensional vector using the fine-tuned text embedding model and the high-dimensional vector is stored in the vector library.

2. The complex database question answering system based on a large language model according to claim 1, characterized in that: The preprocessing includes obtaining natural language instructions and performing text cleaning on the natural language instructions, wherein the text cleaning includes removing useless characters, removing or replacing numbers, and removing spaces and tabs; The natural language instructions that have been cleaned are segmented, including: dividing the text into several small units based on spaces to obtain the instruction text.

3. The complex database question answering system based on a large language model according to claim 2, characterized in that: The fine-tuning of the text embedding model includes: obtaining a large amount of natural language related to natural voice instructions input by historical users from a database, segmenting and tokenizing each natural language, and obtaining a fine-tuning dataset; Use the fine-tuning dataset to train the text embedding model; obtain the fine-tuned text embedding model.

4. The complex database question answering system based on a large language model according to claim 3, characterized in that: The high-dimensional vector conversion includes: for any text, using a word segmenter of a text embedding model to perform word segmentation on the text to obtain a text sequence; Add special marks, fill and truncate the text sequence obtained after word segmentation, and convert the text sequence obtained after word segmentation into an integer ID sequence; Pass the obtained integer ID sequence to the text embedding model, and obtain the embedding vector by querying the index of the text embedding model; Output the embedded vector to obtain a high-dimensional vector.

5. The complex database question answering system based on a large language model according to claim 4, characterized in that: The question-answer matching module also includes a vector matching unit, which is configured with a vector matching strategy. The vector matching strategy includes comparing the instruction vector with the high-dimensional vector in the vector library when the instruction vector is obtained, using a cosine similarity algorithm, and the formula is: , A i and B i Represent the components of vectors A and B respectively; The similarity ranges from -1 to 1; -1 indicates that the instruction vector and any high-dimensional vector in the vector library point in opposite directions, 1 indicates that the instruction vector and any high-dimensional vector in the vector library point in exactly the same direction, and 0 indicates that the instruction vector and any high-dimensional vector in the vector library are independent of each other; obtain the database table corresponding to the high-dimensional vector in the vector library whose cosine similarity with the instruction vector is closest to 1, and set it as the database table corresponding to the instruction vector.

6. The complex database question answering system based on a large language model according to claim 1, characterized in that: The statement generation module includes a statement generation unit, which is configured with a statement generation strategy. The statement generation strategy includes obtaining a database table corresponding to a pointing vector, setting it as an instruction database table, and constructing a Prompt containing a precise context based on the instruction database table; sending the Prompt to a large language model, and the large language model generates precise SQL query instructions based on the content of the Prompt.

Citation Information

Patent Citations

  • Natural language-to-SQL interactive generation method based on large language model

    CN117493379A

  • Text2SQL semantic parsing method for domain large language model

    CN118377796A

Cited By

  • Method and device for converting natural language into SQL (Structured Query Language) statement based on large model

    CN119961289A

  • Digital main line automatic modeling method and system based on large language model

    CN120523828A