Sentence generation method, sentence generation device and computer storage medium

By retrieving business knowledge, table information and contextual examples from the knowledge base as prompts, and combining the large language model to generate database query statements, it solves the problem of difficulty in understanding the deep learning model in user natural language conversion and improves the accuracy of query statement generation. and efficiency.

CN118296035BActive Publication Date: 2024-09-06ZHEJIANG DAHUA TECH CO LTD
View PDF 9 Cites 0 Cited by

Patent Information

Application Number
CN202410705912.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-06-03
Publication Date
2024-09-06
Estimated Expiration
2044-06-03

AI Technical Summary

Technical Problem

In the existing technology, deep learning models are difficult to efficiently understand user intentions during the conversion process from user natural language to database query statements, resulting in low accuracy and low efficiency in query statement generation, and the need to frequently adjust model parameters.

Method used

After obtaining user query statements, relevant business knowledge, table information and contextual examples are retrieved from the knowledge base as statement generation prompts, combined with large language models to generate database query statements, and time analysis prompts are provided to enhance the accuracy and efficiency of statement generation.

Benefits of technology

It improves the large language model's ability to understand user query statements, enhances the accuracy and efficiency of database statement generation, avoids frequent adjustments to model parameters, and improves the efficiency of query statement conversion.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118296035B
    Figure CN118296035B
Patent Text Reader

Abstract

The present application discloses a statement generation method, a statement generation device, and a computer storage medium, wherein the statement generation method comprises: obtaining a user query statement; retrieving business knowledge, table information, and / or context examples related to the user query statement from a knowledge base as a statement generation prompt; and generating a database query statement based on the user query statement and the statement generation prompt. In the above manner, the present application increases reference information when generating standard query statements used by the database by querying related additional knowledge in a constructed external knowledge base based on the user query statement, helping the large language model to better understand the user's query statement, thereby improving the accuracy and efficiency when generating data query statements.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of database query, and in particular to a statement generation method, a statement generation device and a computer storage medium. Background Art

[0002] With the continuous development of Internet technology, the birth and development of technical means such as radio, television, satellite communications, and electronic computer communications, as well as the widespread popularization of mobile terminals such as smart phones, the speed and scale of information dissemination have reached an unprecedented level. Therefore, the amount and scale of various data in information dissemination are increasing. The growth of data, on the one hand, brings more valuable information, and on the other hand, it also greatly increases the difficulty of extracting information from the data. Therefore, how to efficiently extract valuable information from the growing mass of data has become a thorny problem.

[0003] In actual application scenarios, users usually query the results they want by inputting easy-to-understand natural language. At this time, the natural language input by the user needs to be converted into a structured database query statement to query the corresponding data from the corresponding database.

[0004] In the prior art, users use deep learning models trained based on massive text data to convert natural language. However, how deep learning models can better understand users' natural language and generate accurate database query statements is an urgent problem to be solved. The method of training and adjusting the model parameters of deep learning models through pre-labeled data will increase the conversion cost of query statements and also affect the efficiency of query statement conversion. Summary of the invention

[0005] The main technical problem solved by the present application is how to improve the accuracy and efficiency of generating database query statements. To this end, the present application provides a statement generating method, a statement generating device and a computer storage medium.

[0006] To solve the above technical problems, a technical solution adopted in the present application is: to provide a statement generation method, the method comprising: obtaining a user query statement; retrieving business knowledge, table information and / or context examples related to the user query statement from a knowledge base as a statement generation prompt; and generating a database query statement based on the user query statement and the statement generation prompt.

[0007] After obtaining the user query statement, the statement generation method further includes: obtaining a template for time analysis prompts, the template including conversion instructions; using the conversion instructions to convert the time description in the user query statement into a specific time, and generating a corresponding time analysis prompt.

[0008] Among them, the time description in the user query statement is converted into a specific time using a conversion instruction, and a corresponding time analysis prompt is generated, including: obtaining the current actual time; based on the time description, using the conversion instruction to convert the current actual time to obtain the specific time; filling the specific time into the user query statement to obtain a time analysis prompt.

[0009] Among them, the knowledge base includes a business knowledge base; before obtaining the user query statement, the statement generation method also includes: obtaining business knowledge related to the query business, the business knowledge includes business term explanations, concept explanations and / or data format descriptions; generating a business semantic vector corresponding to each business knowledge; storing the business semantic vector and the corresponding business knowledge in the business knowledge base.

[0010] Among them, the knowledge base also includes a table information library; before obtaining the user query statement, the statement generation method also includes: obtaining the table information of each table in all business databases related to the user query statement, the table information includes the table name, the table description information and / or the table field information, the description information is used to describe the purpose of the table, the data source of the table and / or the meaning of the table field; arranging the table information of each table in rows, and extracting the table information semantic vector of each row of table information; storing the table information of each table and the corresponding table information semantic vector in the table information library.

[0011] Among them, the knowledge base also includes a context example library; before obtaining the user query statement, the statement generation method also includes: obtaining context examples containing mutually associated user query statements and database query statements; extracting the example semantic vector of each context example; storing the context examples and the corresponding example semantic vectors in the context example library.

[0012] Among them, business knowledge, table information and / or context examples related to the user query statement are retrieved from the knowledge base as statement generation prompts, including: converting the user query statement into a query semantic vector; retrieving a preset number of business semantic vectors, table information semantic vectors and / or context example semantic vectors related to the query semantic vector from the knowledge base as statement generation prompts.

[0013] Among them, generating a database query statement based on the user query statement and the statement generation prompt includes: inputting the user query statement and the statement generation prompt into a large language model to obtain a database query statement, and the large language model is used to answer a matching database query statement according to the user query statement input by the user.

[0014] To solve the above technical problems, another technical solution adopted in the present application is: to provide a statement generation device, which includes a processor and a memory, the memory is coupled to the processor, the memory stores program data, and the processor is used to execute the program data to implement the statement generation method as mentioned above.

[0015] In order to solve the above technical problems, another technical solution adopted by the present application is: providing a computer-readable storage medium, which stores program data, and when the program data is executed, it is used to implement the above statement generation method.

[0016] The beneficial effect of the present application is that, different from the prior art, the statement generation method provided by the present application includes: obtaining user query statements; retrieving business knowledge, table information and / or context examples related to the user query statements from the knowledge base as statement generation prompts; generating database query statements based on the user query statements and statement generation prompts. Through the above manner, compared with the conventional statement generation method, the present application provides more specific and sufficient statement generation information for the large language model that generates database query statements by analyzing user query statements using natural language and obtaining business knowledge, table information, context examples, etc. related to the user query statements as statement generation prompts, thereby promoting the understanding of the user query statements by the large language model, thereby enhancing the database statement generation capability of the large language model, and by adding the statement generation prompt, there is no need to retrain and adjust the model parameters of the large language model, thereby improving the accuracy and efficiency of converting user query statements into database query statements. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work. Among them:

[0018] Figure 1 It is a flowchart of the first embodiment of the sentence generation method provided by the present application;

[0019] Figure 2 It is a schematic diagram of the overall flow of the sentence generation method applied in the sentence generation device provided by the present application;

[0020] Figure 3 It is a flowchart of the second embodiment of the sentence generation method provided by the present application;

[0021] Figure 4 A flowchart of a specific embodiment of a sentence generation method using a sentence generation device provided by the present application;

[0022] Figure 5 It is a structural schematic diagram of the first embodiment of the sentence generation device provided by the present application;

[0023] Figure 6It is a structural schematic diagram of the second embodiment of the sentence generation device provided by the present application;

[0024] Figure 7 It is a structural schematic diagram of an embodiment of a computer-readable storage medium provided by the present application. DETAILED DESCRIPTION

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

[0026] The term "and / or" in this article is only a description of the association relationship of associated objects, indicating that there may be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the objects associated before and after are in an "or" relationship. In addition, "many" in this article means two or more than two. In addition, the term "at least one" in this article means any combination of at least two of any one or more of a plurality of, for example, including at least one of A, B, and C, can mean including any one or more elements selected from the set consisting of A, B, and C.

[0027] The sentence generation method provided in the present application is mainly applied to a sentence generation device, wherein the sentence generation device of the present application can be a server, or a system composed of a server and a terminal device cooperating with each other. Accordingly, the various parts included in the sentence generation device, such as various units, sub-units, modules, and sub-modules, can all be set in the server, or can be set in the server and the terminal device respectively.

[0028] The statement generation method provided in the present application is mainly used in the process of converting a user query statement of a natural language type input by a user into a standard database query statement SQL. When the statement generation device receives the user query statement input by the user, the business knowledge, table information and / or context examples matching the user query statement are retrieved based on the user query statement as statement generation prompts, thereby improving the accuracy of statement generation.

[0029] Current sentence generation methods usually require pre-training and fine-tuning of model parameters of a large language model used for sentence generation based on the current business scenario. The training cost is too high, resulting in inefficiency of the sentence generation method.

[0030] Based on this, the present application provides a sentence generation method, and the technical solution adopted by the present application is described in detail below.

[0031] See also Figure 1 and Figure 2 , Figure 1 It is a flowchart of the first embodiment of the sentence generation method provided by the present application; Figure 2 It is a schematic diagram of the overall flow of the sentence generation method applied in the sentence generation device provided in the present application.

[0032] Step 11: Get the user query statement.

[0033] Specifically, before obtaining the user query statement, the statement generation device constructs a knowledge base related to the current business query demand, and the knowledge base may include a business knowledge base, a table information base and / or a context example base.

[0034] Specifically, the business knowledge base includes business knowledge (such as business terminology explanations, concept explanations, data format descriptions, etc.) and embedded vectors of business knowledge, so as to quickly retrieve information related to user queries and provide background knowledge for the sentence generation device to understand user query sentences.

[0035] Specifically, the statement generation device stores the acquired business knowledge such as business term explanations, concept explanations, data format explanations, etc. related to the current business query requirements in a constructed knowledge table (Knowledge_Table), and the fields of the table mainly include "unique identifier" (id) and "knowledge description" (knowledge_description).

[0036] Specifically, the statement generation device uses an automated script to extract business knowledge such as business term explanations, concept explanations and / or data format explanations related to the current business query requirements from business documents, and writes them into the knowledge description knowledge_description of the knowledge table Knowledge_Table. For example: "Month-on-month comparison: refers to the comparison between two periods, usually comparing the data of one time period with the data of the previous time period."

[0037] Specifically, the sentence generation device inputs the knowledge description of each row in the knowledge table into the text embedding model to obtain the business semantic vector corresponding to each row of the knowledge description, and stores the business semantic vector in the vector database.

[0038] Specifically, the text embedding model may include a word embedding model, a sentence embedding model, etc. The text embedding model may map text data into a vector space, so that the sentence generation device may better understand the meaning and semantic relationship of the text, thereby being able to quickly retrieve business knowledge related to the user's query statement.

[0039] Specifically, the table information library includes table information and embedded vectors of the table information, so as to quickly retrieve table names and fields related to user query statements and provide specific table names and fields for generating database query statements.

[0040] Specifically, the statement generation device will establish an information table (Info_Table) based on a large number of data tables in a business database (such as MySQL, Oracle, MongoDB, Elasticsearch, etc.) related to the current business, which is used to store table information in the business database. The fields of the table include "table name" (table_name), "table description" (table_description) and "field information" (field_info).

[0041] Specifically, the statement generation device uses an automated script to extract the business database, and extracts all the data table names, table descriptions (briefly introducing the purpose of the table, data source, field meaning, etc.) and field information. For example, "play music table (music_Table)", "play music table is used to store song information of each music, including song name, song release date, singer name, song category, album name..." and "song name (songname), song release date (issuingdate), singer name (singername), song category (songclass), album name (albumname)..." are written into the table name table_name, table description table_description and field information field_info of the information table Info_Table respectively.

[0042] Specifically, the sentence generation device inputs each row of extracted table information into a text embedding model to obtain a corresponding table information semantic vector that contains the text semantics of the table information, and stores the table information of each table and the corresponding table information semantic vector in a table information library to facilitate rapid retrieval of table information related to the user's query statement.

[0043] Specifically, the context example library includes examples in the form of "user query statement-database query statement" and the embedding vectors corresponding to these examples, so as to quickly retrieve context examples related to user query statements, provide reference for the sentence generation device, and enhance the understanding ability of the large language model therein.

[0044] Specifically, the statement generation device constructs a context example based on the historical generation record of the database query statement or the user query statement imported by the user and the template corresponding to the database query statement. The specific format of the context example can be as follows: "User query statement: Please help me find the name of the song whose singer is A and the song category is rock, database query statement: SELECT songname FROM music_Table WHERE singername='A' AND songclass='rock'."

[0045] Specifically, the context examples may include the corresponding relationships of query statements in different query scenarios, such as single-table query, multi-table query, single-condition query, and multi-condition query, etc. By providing the large language model in the sentence generation device with context examples of multiple query scenarios, the adaptability of the sentence generation device to different query scenarios is improved.

[0046] Specifically, the sentence generation device inputs the constructed context examples into the text embedding model to obtain the example semantic vector corresponding to each context example, and stores the example semantic vector and the corresponding context example in the context example library, so as to quickly retrieve the context example information related to the user query statement.

[0047] Specifically, a user query sentence is a sentence that uses natural language to express the user's query needs. For example, "Please help me find songs released in 2023", "Please help me find the number of sunny days in January", etc. Natural language is a language form used by humans to communicate and express their thoughts in daily life, including oral language and written language. It is a tool used by humans to communicate, transmit information and express meaning, and has characteristics in terms of vocabulary, grammar and semantics.

[0048] Specifically, the user query statement includes the characteristics of the specific data that the user wants to search for in the database, and the user query statement can be obtained by user input or import or extracted from the database. Exemplarily, the user query statement can be pre-stored in the database, and the statement generation device can obtain the user query statement by calling the database. Of course, the user query statement can also be imported by the user, and the user can input the user query statement on the display screen connected to the statement generation device in advance, and then import it into the statement generation device. Therefore, there are many ways to obtain the user query statement, which are not specifically limited here.

[0049] Specifically, after obtaining the user query statement, the statement generation device obtains a template of a time analysis prompt, the template includes a conversion instruction; uses the conversion instruction to convert the time description in the user query statement into a specific time, and generates a corresponding time analysis prompt.

[0050] In one embodiment of the present application, the sentence generation device uses Figure 3 The method shown converts the time description in the user query statement into a specific time. Figure 3 , Figure 3 It is a flowchart of the second embodiment of the sentence generation method provided by this application.

[0051] Step 31: Get the current actual time.

[0052] Specifically, the statement generating device obtains the current actual time, such as today's date is 2023-05-12.

[0053] Step 32: Based on the time description, use the conversion instruction to convert the current actual time to obtain the specific time.

[0054] Specifically, the time description is a description of time in the user query sentence, such as "today", "yesterday", "two days ago", "nearly a month", etc. The sentence generation device generates a specific time according to the current actual time and the time description. For example, if the current actual time is 2023-05-12 and the time description is two days ago, the specific time is 2023-05-10.

[0055] Step 33: Fill in the specific time into the user query statement to obtain a time analysis prompt.

[0056] Specifically, the template of the time analysis prompt may include conversion instructions, context examples, user input and output prompts. In a specific embodiment, the template of the time analysis prompt may be as follows:

[0057] "Conversion instruction: Please analyze the time description in the user query statement and rewrite the user query statement according to today's date. The rewritten user query statement must be semantically consistent and contain a specific time, such as 2023-06-01.

[0058] \n Context example: \n User query statement: Please query the weather conditions in City A yesterday. Today's date is 2023-05-12. Rewritten user query statement: Please query the weather conditions in City A on 2023-05-11. \n …… \nQuery: [User query statement], today's date is [query time] Rewritten user query statement: ".

[0059] Among them, "\n" represents a line break character, and "[]" represents the slot of the template, which needs to be filled with the corresponding specific content, namely the query time and the user query statement.

[0060] Step 12: Retrieve business knowledge, table information, and / or context examples related to the user's query statement from the knowledge base as statement generation prompts.

[0061] Specifically, the statement generation device constructs a template for the statement generation prompt, which can be composed of instructions, business knowledge, table information, context examples, the user's query statement, input prompts, and other parts.

[0062] In an embodiment of the present application, an example of a template for a statement generation prompt is: "Instruction: Please generate an accurate database query statement for the user's query based on business knowledge, table information, and context examples. Business knowledge: [Business knowledge related to the user's query statement]. Table information: [Table information related to the user's query statement]. Context examples: [Context examples related to the user's query statement]. User's query statement: [User's query statement]. Database query statement:".

[0063] Specifically, the statement generation device uses a text embedding model to convert the user's query statement into a vector form, retrieves at most K of the most relevant business knowledge semantic vectors from the business knowledge base, retrieves M of the most relevant table information semantic vectors from the table information base, that is, table names and table fields, and retrieves N of the most relevant context example semantic vectors from the context example base, where the specific values of K, M, and N can be set according to user requirements or business scenarios and are not limited here.

[0064] Specifically, the statement generation device fills the retrieved business knowledge, table information, and context examples into the template of the statement generation prompt to generate a statement generation prompt.

[0065] In this embodiment, by retrieving business knowledge, table information, and context examples related to the user's query statement from the knowledge base as statement generation prompts, the understanding of the user's query statement by the large language model can be enhanced, thereby improving the accuracy of the generated database query statement.

[0066] Step 13: Generate a database query statement based on the user's query statement and the statement generation prompt.

[0067] Specifically, the statement generation device inputs the obtained statement generation prompt into the large language model to obtain a database query statement SQL related to the user's query statement, such as "SELECT * songname FROM music_Table WHEREsingername='A' AND songclass=’rock’".

[0068] The following describes the statement generation method provided by the present application with a specific embodiment as an example. Refer to Figure 4 , Figure 4A flowchart of a specific embodiment of a sentence generation method using a sentence generation device provided in the present application.

[0069] Specifically, the sentence generation device obtains the user's query sentence: "Please help me check the weather conditions of City A yesterday", inputs the user query sentence into the text embedding model to obtain the corresponding vector, and then calls the knowledge base retrieval interface to obtain the table information, business knowledge base and context examples related to the user query sentence from the table information library, business knowledge base and context example library of the knowledge base respectively.

[0070] The statement generation device fills the obtained table information: "Weather table, fields: location, weather", business knowledge: "Weather refers to the atmospheric conditions in a specific area", and context example: "Query the weather conditions in City A yesterday-SELECT weather FROMweather_Table WHERE place='City A' AND event_time = '2023-07-01'" into the template of the statement generation prompt to generate the corresponding statement generation prompt.

[0071] The sentence generation device inputs the sentence generation prompt into the large language model, thereby obtaining an output database query sentence, so as to realize intelligent question and answer of answering the matching database query sentence according to the user query sentence input by the user.

[0072] Specifically, a large language model (LLM) refers to a deep learning model trained using a large amount of text data, which can generate natural language text or understand the meaning of language text, so the large language model can be used to convert natural language into machine language.

[0073] Different from the prior art, the sentence generation method provided by the present application includes: obtaining user query statements; retrieving business knowledge, table information and / or context examples related to the user query statements from the knowledge base as sentence generation prompts; generating database query statements based on the user query statements and the sentence generation prompts. Through the above method, compared with the conventional sentence generation method, the present application provides more specific and sufficient sentence generation information for the large language model that generates database query statements by analyzing user query statements using natural language and obtaining business knowledge, table information, context examples, etc. related to the user query statements as sentence generation prompts, thereby promoting the large language model's understanding of user query statements, thereby enhancing the database statement generation capability of the large language model, and by adding sentence generation prompts, there is no need to retrain and adjust the model parameters of the large language model, thereby improving the accuracy and efficiency of converting user query statements into database query statements.

[0074] The method of the above embodiment can be implemented by using a sentence generation device. Figure 5 Describe, Figure 5 It is a structural diagram of the first embodiment of the sentence generation device provided by the present application.

[0075] like Figure 5 As shown, the statement generating device 50 of the embodiment of the present application includes a query acquiring module 51 , a prompt generating module 52 , and a database statement generating module 53 .

[0076] The query acquisition module 51 is used to acquire user query statements.

[0077] The prompt generation module 52 is used to retrieve business knowledge, table information and / or context examples related to the user query statement from the knowledge base as statement generation prompts.

[0078] The database statement generating module 53 is used to generate a database query statement based on the user query statement and the statement generating prompt.

[0079] The method of the above embodiment can be implemented by using a sentence generation device. Figure 6 , Figure 6 6 is a schematic diagram of the structure of the second embodiment of the sentence generation device provided by the present application. The sentence generation device 60 includes a memory 61 and a processor 62. The memory 61 is used to store program data, and the processor 62 is used to execute the program data to implement the following method:

[0080] Obtain a user query statement; retrieve business knowledge, table information and / or context examples related to the user query statement from a knowledge base as a statement generation prompt; and generate a database query statement based on the user query statement and the statement generation prompt.

[0081] The method of the above embodiment can be implemented using a computer-readable storage medium. Figure 7 , Figure 7 1 is a schematic diagram of the structure of an embodiment of a computer-readable storage medium provided by the present application. The computer-readable storage medium 70 stores program data 71. When the program data 71 is executed by a processor, it is used to implement the following method:

[0082] Obtain a user query statement; retrieve business knowledge, table information and / or context examples related to the user query statement from a knowledge base as a statement generation prompt; and generate a database query statement based on the user query statement and the statement generation prompt.

[0083] When the embodiments of the present application are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) or a processor to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program code.

[0084] The above description is only an implementation method of the present application, and does not limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly used in other related technical fields, are also included in the patent protection scope of the present application.

Claims

1. A sentence generation method, characterized in that: The statement generation method comprises: Get the user query statement; Retrieving business knowledge, table information and context examples related to the user query statement from a knowledge base as statement generation prompts, wherein the context examples include corresponding relationships between query statements in different query scenarios; The knowledge base also includes a table information base; Before obtaining the user query statement, the statement generation method further includes: Acquire table information of each table in all business databases related to the user query statement, the table information including table name, description information of the table and / or field information of the table, the description information is used to describe the purpose of the table, the data source of the table and / or the meaning of the fields of the table; Arranging the table information of each table in rows, and extracting the table information semantic vector of each row of the table information; storing the table information of each table and the corresponding semantic vector of the table information in the table information library; The knowledge base also includes a context example library; Before obtaining the user query statement, the statement generation method further includes: Obtaining a context example including a user query statement and a database query statement that are associated with each other; extracting a paradigm semantic vector for each of the context paradigms; Storing the context examples and the corresponding example semantic vectors in the context example library; The user query statement and the statement generation prompt are input into a model to generate a database query statement.

2. The sentence generation method according to claim 1, characterized in that: After obtaining the user query statement, the statement generation method further includes: Obtaining a template for a time analysis prompt, the template including a conversion instruction; The conversion instruction is used to convert the time description in the user query statement into a specific time, and a corresponding time analysis prompt is generated.

3. The sentence generation method according to claim 2, characterized in that: The using the conversion instruction to convert the time description in the user query statement into a specific time and generate a corresponding time analysis prompt includes: Get the current actual time; Based on the time description, using the conversion instruction to convert the current actual time to obtain a specific time; The specific time is filled into the user query statement to obtain the time analysis prompt.

4. The sentence generation method according to claim 1, characterized in that: The knowledge base includes a business knowledge base; Before obtaining the user query statement, the statement generation method further includes: Acquire business knowledge related to the query business, wherein the business knowledge includes explanations of business terms, concepts and / or data formats; Generate a business semantic vector corresponding to each of the business knowledge; The business semantic vector and the corresponding business knowledge are stored in the business knowledge base.

5. The sentence generation method according to claim 1, characterized in that: The retrieving business knowledge, table information and context examples related to the user query statement from the knowledge base as statement generation prompts includes: Converting the user query statement into a query semantic vector; A preset number of business semantic vectors, table information semantic vectors and context example semantic vectors related to the query semantic vector are retrieved from the knowledge base as sentence generation prompts.

6. The sentence generation method according to claim 1, characterized in that: The user query statement and the statement generation prompt are input into a large language model to obtain the database query statement, and the large language model is used to answer the matching database query statement according to the user query statement input by the user.

7. A sentence generating device, characterized in that: The sentence generating device includes a memory and a processor coupled to the memory; The memory is used to store program data, and the processor is used to execute the program data to implement the statement generation method according to any one of claims 1 to 6.

8. A computer storage medium, characterized in that: The computer storage medium is used to store program data, and when the program data is executed by a computer, it is used to implement the statement generation method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Configurable method and system for converting natural language into sql

    CN112347121A

  • SQL statement generation method and device, electronic equipment and storage medium

    CN116955406A

  • Structured query statement generation method and device, equipment and medium

    CN117149812A

  • SQL (Structured Query Language) generation method and device based on background knowledge enhancement, equipment and medium

    CN117312372A

  • SQL (Structured Query Language) statement generation method and device based on large language model, equipment and medium

    CN117743371A