Query statement model fine tuning method, device and equipment based on large model

By fine-tuning the query statement model, accurate prompts and query statements are generated, solving the problem that existing large AI models cannot meet personalized query requests and improving the query efficiency and accuracy of business systems.

CN119599131AActive Publication Date: 2025-03-11ULTRAPOWER SOFTWARE
View PDF 11 Cites 0 Cited by

Patent Information

Application Number
CN202411671872.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-21
Publication Date
2025-03-11
Estimated Expiration
2044-11-21

AI Technical Summary

Technical Problem

Existing large-scale AI models are unable to generate in-depth suggestions for query statements or perform in-depth operations on the databases of business systems, resulting in the inability to effectively improve the query efficiency of business systems.

Method used

By constructing prompt information that includes intent information of the query request, basic table information, and statement structure information of the query statement, the first and second models in the query statement model are fine-tuned to generate accurate prompt information and query statements.

Benefits of technology

The fine-tuned query model can meet the various personalized query requests of front-end users in different departments of the business system, improving query efficiency and accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119599131A_ABST
    Figure CN119599131A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of data processing, in particular to a query statement model fine tuning method, device and equipment based on a large model. The method comprises the following steps: determining prompt information corresponding to a query corpus of a target business system; wherein the query corpus comprises a plurality of query requests and a query statement corresponding to each query request; the query request is in a natural language form; the prompt information comprises intention information and basic table information of the query request and statement structure information of the query statement; according to a plurality of query requests and the query statements and prompt information corresponding to each query request, performing fine tuning on the queried statement model; wherein the query statement model comprises a first model and a second model; the technical problem that the query efficiency of the service system cannot be effectively improved all the time due to the fact that an existing AI large model cannot meet various personalized query requests of front-end users of various work departments in the service system at all can be solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data processing technology, and in particular to a method, device and equipment for fine-tuning a query statement model based on a large model. Background Art

[0002] In the business systems of various enterprises, institutions and group companies, the database is usually connected to the front-end application through the back-end server, so that the front-end business personnel can query the data in the database and perform other operations. In actual operations, the front-end business personnel send query requests through the front-end application, and the back-end server determines the corresponding query statement according to the query request and sends the query statement to the database, so that the database can query the data in the database according to the query statement, and then transmit the query results to the front-end application through the back-end server.

[0003] In the prior art, the backend server can generate query statements through an AI (Artificial Intelligence) big model. In actual operation, first, an AI big model is used to generate prompt information based on the query request, and then another AI big model is used to generate a query statement based on the query request and the prompt information.

[0004] In the above technical solution, although the prompt information can effectively prompt the generation of query statements, according to actual experience, the existing AI big models used to generate prompt information and query statements in different business systems are usually only pre-trained, resulting in the inability to use the AI ​​big model to generate prompt information that can provide deep prompts for query statements and query statements that can perform deep operations on the database of the business system. That is, the existing AI big model is simply unable to meet the various personalized query requests of front-end users of various work departments in the business system, which ultimately leads to the query efficiency of the business system cannot be effectively improved. Summary of the invention

[0005] In view of this, the purpose of this application is to provide a query statement model fine-tuning method, device and equipment based on a big model, so as to solve the technical problem that the existing AI big model for generating prompt information and generating query statements cannot meet the various personalized query requests of front-end users of various work departments in the business system, which ultimately leads to the query efficiency of the business system cannot be effectively improved.

[0006] In a first aspect, the present application provides a query statement model fine-tuning method based on a large model, the method comprising:

[0007] Determine the prompt information corresponding to the query corpus of the target business system;

[0008] The query corpus includes: multiple query requests and query statements corresponding to each query request; the query request is in natural language form; the prompt information includes: intent information and basic table information of the query request and sentence structure information of the query statement;

[0009] Fine-tune the query statement model through the multiple query requests and the query statements and the prompt information corresponding to each query request;

[0010] Among them, the query statement model includes: a first model and a second model; the first model is used to generate target prompt information according to the target query request input by the user to the target business system; the second model is used to generate a target query statement according to the target query request and the target prompt information.

[0011] In a second aspect, the present application provides a query statement model fine-tuning device based on a large model, the device comprising: a prompt information module and a fine-tuning module;

[0012] The prompt information module is used to determine the prompt information corresponding to the query corpus of the target business system;

[0013] The query corpus includes: multiple query requests and query statements corresponding to each query request; the query request is in natural language form; the prompt information includes: intent information and basic table information of the query request and sentence structure information of the query statement;

[0014] The fine-tuning module is used to fine-tune the query statement model through the multiple query requests and the query statement and the prompt information corresponding to each query request;

[0015] Among them, the query statement model includes: a first model and a second model; the first model is used to generate target prompt information according to the target query request input by the user to the target business system; the second model is used to generate a target query statement according to the target query request and the target prompt information.

[0016] In a third aspect, the present application provides an electronic device, comprising a processor and a memory, wherein the memory is used to store an application program, and the processor runs or executes a software program stored in the memory so that the electronic device implements the above-mentioned large-model-based query statement model fine-tuning method.

[0017] In a fourth aspect, the present application provides a computer-readable storage medium, wherein the computer-readable storage medium is used to store program codes executed by a processor, wherein the program codes are used to implement the above-mentioned large-model-based query statement model fine-tuning method.

[0018] In a fifth aspect, the present application provides a computer program product, which includes computer instructions. When the computer instructions are executed on an electronic device, the electronic device implements the above-mentioned large-model-based query statement model fine-tuning method.

[0019] Beneficial effects:

[0020] The present application provides a method for fine-tuning a query statement model based on a large model, the method comprising: determining prompt information corresponding to a query corpus of a target business system; wherein the query corpus comprises: a plurality of query requests and a query statement corresponding to each query request; the query request is in a natural language form; the prompt information comprises: intent information and basic table information of the query request and sentence structure information of the query statement; fine-tuning a query statement model is performed through a plurality of query requests and a query statement corresponding to each query request and the prompt information; wherein the query statement model comprises: a first model and a second model; the first model is used to generate target prompt information according to a target query request input by a user to the target business system; the second model is used to generate a target query statement according to the target query request and the target prompt information;

[0021] In summary, the large-model-based query statement model fine-tuning method provided in the present application constructs prompt information including the intent information of the query request, basic table information, and statement structure information of the query statement, so as to simultaneously fine-tune the first model and the second model in the query statement model, so that the fine-tuned first model can generate accurate prompt information according to various personalized query requests of front-end users of various work departments in the business system, and the fine-tuned second model can generate accurate query statements according to various personalized query requests and corresponding prompt information. Therefore, the fine-tuned query statement model in the present application can meet various personalized query requests of front-end users of various work departments in the business system. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments of the present application will be briefly introduced below. The following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.

[0023] Figure 1 A structural diagram of a data query system provided in an embodiment of the present application;

[0024] Figure 2 A flowchart of a query statement model fine-tuning method based on big data provided in an embodiment of the present application;

[0025] Figure 3 A structural diagram of a query statement model fine-tuning device based on big data provided in an embodiment of the present application. DETAILED DESCRIPTION

[0026] In various enterprises, institutions and group companies, in order to facilitate the needs of expanding business and managing companies, various personalized query needs are often generated, such as "statisticing contracts with a contract amount of 5 million and a contract term of more than two years", "statisticing the employee numbers and names of employees with a remaining annual leave of more than 5 days and an average salary of 8,000", etc. When the above data are stored in the database, since query operations on the database usually require query statements corresponding to the database, such as SQL (Structured Query Language), query statements are usually written by technicians who can write query statements according to query requirements. For some query requests with lower query difficulty, the corresponding query statements are usually preset in the business system content for direct retrieval. For some query requests with higher difficulty, technicians are required to write query statements in real time, which results in a time interval between "issuing a query request" and "receiving a query result". If the query request changes during this period, the above time interval will be extended, which results in very low efficiency of manual query.

[0027] With the development of AI big models, backend servers can generate query statements through AI big models; first, an AI big model is used to generate prompt information based on query requests, and then another AI big model is used to generate query statements based on query requests and prompt information. However, according to actual experience, existing AI big models cannot generate prompt information that can provide in-depth prompts for query statements and query statements that can perform in-depth operations on the database of the business system;

[0028] The reason is that the database settings corresponding to different business systems are determined according to actual needs, which makes it impossible for existing AI models to accurately understand the database table structure. For example, even for the same query request, when the data corresponding to the query request is in different databases, the query statements generated according to the query request are usually different. Therefore, the query statement is highly dependent on the manually designed table structure.

[0029] For example, for the query request "Count the employee numbers and names of employees with 5 days of annual leave remaining", since the above query request is relatively simple, it may only need to query one basic table to get the query result, so the corresponding query statement is relatively simple, and the existing AI big model is fully capable of handling it. However, for the above-mentioned query request "Count the employee numbers and names of employees with more than 5 days of annual leave remaining and an average salary of 8,000", according to common sense, employee annual leave and employee salary are usually counted in different basic tables, but the existing big model, which has only been simply fine-tuned, often generates inaccurate query statements for query requirements involving multiple basic tables, resulting in inaccurate query results;

[0030] For another example, for the query request "collect the information of the private enterprise suppliers with the largest number of winning bids in projects with an open bidding amount of more than 500,000 in our city in the past 20 years, preferably with information such as establishment years and company size", since the above query indicators include "open bidding amount", "number of winning bids" and "establishment years", etc., the above query indicators may be scattered in multiple basic tables. For example, some enterprises and institutions tend to count the annual bidding data in a basic table, and some enterprises and institutions tend to count the bidding data every two years in a basic table, which greatly increases the difficulty of determining the statement structure of the corresponding query statement; in addition, since the amount of data in the basic table related to "city bidding" may be very large, it may cause the database 300 to be delayed or even stuck when executing certain query statements, further resulting in delays in returning query results or even returning erroneous query results, ultimately seriously affecting query efficiency and query quality.

[0031] In today's era of rapid technological development, the popularity of AI big models is unstoppable. In order to solve the application difficulties of existing AI big models in generating query statements, this application provides a technical solution for fine-tuning the query statement model based on a big model. Figure 1 The data query system implementation shown is different from the prior art in that the present application improves the ability of query statements generated by the fine-tuned query statement model based on the big model and the accuracy of the generated query statements by providing more prompt information in the fine-tuning stage of the AI ​​big model.

[0032] In summary, the existing AI big model cannot meet the various personalized query requests of front-end users in various work departments in the business system, which ultimately leads to the query efficiency of the business system cannot be effectively improved.

[0033] In order to solve the above technical problems, the present application provides a data query system; Figure 1 As shown, Figure 1The structural diagram of the data query system provided in the embodiment of the present application includes: a front-end application 100, a back-end server 200 and a database 300. In actual operation, the user inputs a query request in natural language form to the front-end application 100 in text form or voice form, such as "query the employee number and name of employees with remaining annual leave of more than 5 days and an average salary of 8,000", and the front-end application 100 transmits the query request to the back-end server 200. The back-end server 200 generates prompt information corresponding to the query request through the first model in the preset query statement model, and then generates a query statement corresponding to the query request and the prompt information through the second model in the query statement model; the back-end server 200 sends the query statement to the database 300, and the database 300 executes the query statement to obtain the query result, and then sends the query result to the user through the back-end server 200 and the front-end application 100.

[0034] It should be emphasized that in the database system, it is the database management system that receives query statements and executes query statements to control the processing of data in the database. Since the execution steps of the database system are existing technologies, the cooperation between the database management system and the database is referred to separately by database 300.

[0035] The terms used in the following embodiments of the present application are only for the purpose of describing specific embodiments, and are not intended to be used as limitations to the present application. As used in the specification and appended claims of the present application, the singular expressions "one", "a kind of", "", "above", "the" and "this" are intended to also include plural expressions, unless there is a clear indication to the contrary in the context. It should also be understood that the term "and / or" used in the present application refers to and includes any or all possible combinations of one or more listed items.

[0036] First, this application provides a query statement model fine-tuning method based on a large model, such as Figure 2 As shown, Figure 2 The flowchart of the query statement model fine-tuning method based on the large model provided in the embodiment of the present application includes: S110 to S120, and the details are as follows:

[0037] S110: Determine prompt information corresponding to the query corpus of the target business system;

[0038] The query corpus includes: multiple query requests and query statements corresponding to each query request; the query request is in natural language form; and the prompt information includes: intent information, basic table information and statement structure information of the query statement.

[0039] Specifically, the target business system refers to various office systems used by users of various enterprises, institutions and group companies in the course of their office work. For example, the target business system corresponding to an insurance company is the insurance business system, and the data therein mostly involves insurance business data such as the insured amount; the target business system corresponding to a financial company is the financial business system, and the data therein mostly involves financial business data such as profit margin.

[0040] In an embodiment of the present application, in order to improve the matching of the query statement model with the target business system, the query statement model is enabled to generate accurate and efficient query statements based on an accurate understanding of the query requests issued by the user in natural language. Therefore, it is necessary to obtain various query requests from various work departments with data query needs in the target business system.

[0041] It should be noted that there are many types of databases and query statements. The embodiments of the present application will subsequently use relational databases and SQL statements as examples to provide specific examples of the method for fine-tuning the query statement model based on a large model.

[0042] In the embodiment of the present application, the query request used to fine-tune the query statement model is in natural language form, because if the fine-tuned query statement model can generate a query statement according to the query statement in natural language form, the processing capability of the fine-tuned query statement model can be significantly improved;

[0043] In the embodiment of the present application, the query corpus includes: a plurality of query requests and a query statement corresponding to each of the query requests;

[0044] Among them, the query request is retrieved from the operation record of the target business system. In actual applications, the types of query requests should try to cover various personalized query requests of users of multiple work departments in the target business system; in actual implementation, in order to improve the statement generation capability of the fine-tuned query statement model, it is also necessary to construct query requests that cannot be accurately resolved by the existing query statement model based on the business data of the target business system and use them as query requests to fine-tune the query statement model, so as to improve the understanding and processing capabilities of the fine-tuned query statement model for query requests;

[0045] For the query request retrieved from the operation record of the target business system, the query statement can be retrieved from the query record of the existing query statement model; as for the constructed query request, the corresponding query statement can be determined by the technical staff.

[0046] In an embodiment of the present application, the prompt information includes: the intent information of the query request and the basic table information and statement structure information of the query statement; in practical applications, the determination of the "intent information" helps to determine the "basic table information" and "statement structure information".

[0047] Among them, "intent information" refers to the "background knowledge" of the query request. For example, the intent information can be "sales department" or "July 2024";

[0048] "Basic table information" refers to the basic table information of the data involved in the query request in the database. In actual applications, since the database includes a variety of basic tables pre-built by users of different work departments of the target business system according to business needs, such as a basic table recording employee entry information, a basic table recording the return rate of the funds on sale in the past three years, etc., the prompt information should include the basic table information pointing to and / or prompting the above basic tables;

[0049] "Statement structure information" refers to the structure and composition information of a query statement. In actual applications, since one query request may correspond to multiple query statements with different statement structures, for example, the query efficiency will be higher when the current query request uses the xxx clause, the prompt information should also include pointing to and / or the above-mentioned statement structure information that can improve the query accuracy and / or query efficiency. For example, the statement structure information may be "use JOIN clause".

[0050] In one implementation, after S110, the method further includes: Step (1) to Step (3), the details of which are as follows:

[0051] Step (1): replace the spatiotemporal information and / or query index of the query request in the query corpus to obtain a first newly added query request, and determine the query statement corresponding to the first newly added query request.

[0052] Specifically, the spatiotemporal information includes time information such as year, month, day and hour, as well as geographical information such as xxx province and xxx street.

[0053] The purpose of obtaining new query requests is to enrich the types and number of fine-tuning samples, improve the generalization of the fine-tuned query statement model, and further improve the accuracy of the query statements generated by the query statement model; in an embodiment of the present application, a fine-tuning sample includes at least: a query request, a query statement corresponding to the query request, and a prompt message corresponding to the query request.

[0054] For example, for the query request "statistical contract value is 5 million and the contract term is more than two years", "two years" can be replaced with "three years" to obtain the first newly added query request "statistical contract value is 5 million and the contract term is more than three years";

[0055] For another example, for the query request "Count the employee numbers and names of employees with 5 days of annual leave remaining", "annual leave" can be replaced with "marriage leave" to obtain the first new query request "Count the employee numbers and names of employees with 5 days of marriage leave remaining".

[0056] The query indicator in the query request is the key information that can affect the query result of the query request. The query indicator is usually related to the filter condition. The example is as follows:

[0057] "SELECT Sname,Sno

[0058] FROM Student;”

[0059] The meaning of the above SQL statement is to query the names and student numbers of all students from the basic table named Student; among them, "name" and "student number" are query indicators in the query request.

[0060] It should be emphasized that, in the process of obtaining the first newly added query request, the information that can be replaced for the query request is not limited to the spatiotemporal information and / or the query index, but any information that can affect the query statement can be replaced.

[0061] Step (2): performing synonym replacement on the single words and / or short words in the query request and the first newly added query request to obtain a second newly added query request.

[0062] Specifically, for the query request "Contracts with a contract amount of 5 million and a contract term of more than two years", the "contract amount" can be replaced with "total price" to obtain the second new query request "Contracts with a total price of 5 million and a contract term of more than two years".

[0063] Step (3): determining the prompt information corresponding to the first newly added query request and the second newly added query request respectively according to the first newly added query request, the second newly added query request and the query statements respectively corresponding thereto;

[0064] The first newly added query request, the query statement and the prompt information corresponding to the first newly added query request and the second newly added query request, the query statement and the prompt information corresponding to the second newly added query request are used to fine-tune the query statement model.

[0065] Specifically, after generating the query statements and prompt information corresponding to the first new query request and the second new query request respectively, each first new query request and each second new query request and their corresponding query statements and prompt information can be assembled into a fine-tuning sample for fine-tuning the query statement model.

[0066] In one implementation, the intent information includes: business scenario information, context information and spatiotemporal information; S110 includes: step (4), the details of which are as follows:

[0067] Step (4): according to the query request, determining the business scenario information, context information and spatiotemporal information corresponding to each query request in the multiple query requests through the intent recognition model;

[0068] Among them, the business scenario information indicates the business scope of the work department corresponding to the query request in the target business system; the context information indicates the association information between the current query request and the previous query request; and the spatiotemporal information indicates the time information and geographical information in the query request.

[0069] Specifically, the query statement model in the embodiment of the present application is used to serve the query requests in natural language output by users of the target business system, so the query requests are usually colloquial and lack key elements, resulting in the inability of existing query statement models to accurately understand the query requests, and further resulting in the inability to generate accurate query statements. Therefore, it is necessary to supplement the query requests in natural language with corresponding information, such as business scenario information, contextual information, and spatiotemporal information.

[0070] Business scenario information is used to supplement the business scope of the work department for the query request, because in actual business, different indicators may have different meanings for different work departments;

[0071] For example, for the query indicator "sales volume", the query indicator may refer to the contract amount completed in the sales department, but the query indicator may refer to the part of revenue that has been confirmed in the finance department. Therefore, it is necessary to supplement the query request with the prompt information of the above part so that the query statement model can clarify the actual meaning of the query indicator and the basic table corresponding to the query indicator before generating the query statement.

[0072] The context information indicates the association information between the current query request and the previous query request. Because some key information may exist in the previous query request, the current query request will not explain the above key information again.

[0073] For example, if the previous query request was "Which contracts with a contract value of 6 million are being executed?", and the current query request is "What about the ones with a contract value of 5 million?"; in the second query request mentioned above, "5 million" is obviously used to replace the "6 million" in the first query request, but if there is no prompt for the connection between the two query requests, it is likely that the existing query statement model will not be able to accurately understand the query request, and further lead to the inability to generate accurate query statements.

[0074] In actual operation, new query requests can also be added by adding modal particles at multiple positions in the query request to try to imitate various types of query requests that the target business system may receive, thereby further expanding the query request.

[0075] It should be emphasized that in the process of using the query statement model, the business department that issues the query request is provided to the query statement model by the front-end application 100 through the back-end server 200. In actual operation, it can be specifically determined through interface information, and this application will not go into details.

[0076] In an embodiment of the present application, the intent recognition model is obtained by training a large AI model.

[0077] In one implementation, the basic table information includes: the number of basic tables, table structure information of each basic table, and the size of the data volume in each basic table; the query request includes at least one query index; S110 also includes: step (5), the details of which are as follows:

[0078] Step (5): according to the query index, determining the basic table information of the target basic table corresponding to the query request in the database corresponding to the target business system;

[0079] The target basic table is a basic table including fields corresponding to the query index.

[0080] Specifically, after determining the query index, the number of target basic tables can be determined among all basic tables in the database, as well as the table structure information of each target basic table and the size of the data volume in each target basic table.

[0081] Table structure information usually includes: table name, field, record, data type, primary key (primary code), foreign key (foreign code), constraint and index, etc.; the field in the basic table is the attribute name of the attribute column, which corresponds to the query index in the query request. For example, the query index in the query request "query the employee number and name of employees with remaining annual leave of more than 5 days and average salary of 8000" is "annual leave", "average salary", "employee number" and "name". In order to generate the corresponding query statement (the basic table where the data is located needs to be stated in the query statement), it is necessary to find the basic table with fields such as "annual leave", "holiday", "salary", "average salary", "employee number" and "name" in the multiple basic tables existing in the database, and determine the above multiple basic tables as the target basic tables.

[0082] In one implementation, the statement structure information includes: query strategies and query clauses, and the query strategies include: join query, nested query, set query, and query based on derived tables; S110 also includes: step (6), the details of which are as follows:

[0083] Step (6): Determine the corresponding statement structure information according to the query statement.

[0084] Specifically, in the prior art, technicians can select appropriate query strategies and query clauses based on comprehensive considerations of factors such as specific needs, the amount of data in the basic table and system performance. However, a query statement model that has not been fine-tuned through the fine-tuning samples in the embodiments of the present application cannot determine the query strategy and query clause. It can only fill in the relevant parameters into the preset template, which ultimately causes the generated SQL statement to occupy more system resources, resulting in a decrease in query performance.

[0085] After determining the query statement, the query strategy and query clause in the query statement can be determined accordingly; when the number of basic tables including the query index is greater than or equal to 2, a "multi-table query" is required; when performing a multi-table query, query statements using different query strategies need to be constructed according to different situations. The query strategies include connection query, nested query, set query, and query based on derived tables, etc. Query statements using different query strategies have different statement structures;

[0086] In the query statement for the query request, some query clauses with fixed operation meanings can be used to perform data operations. For example, in the SQL statement, the more common clauses used for data query usually include: SELECT clause, FROM clause and WHERE clause, and the more special clauses used for data query usually include: GROUP BY clause, HAVING clause, ORDER BY clause, LIMIT clause, JOIN clause, DISTINCT clause and INTO clause; among them, the GROUP BY clause is used to group data by one or more columns; the HAVING clause is used to filter the grouped results; the ORDER BY clause is used to sort the query results; the LIMIT clause is used to limit the number of records returned; the JOIN clause: used to connect multiple tables and retrieve data based on the related fields between these tables; the DISTINCT clause is used to remove duplicate records in the query results; the INTO clause is used to insert the query results into another table.

[0087] In one implementation, after S120, the method further includes: step (7), the details of which are as follows:

[0088] Step (7): inputting the target query request input by the user into the target business system into the first model, and allowing the first model to determine the target prompt information according to the target query request;

[0089] Among them, the intention information and basic table information in the target prompt information are determined by the first model according to the target query request; the query strategy in the target prompt information is determined by the first model according to the scale of data volume in the basic table and the number of basic tables in the basic table information; the query clause in the target prompt information is determined by the first model according to the data operation corresponding to the query request, and the data operations include: grouping, filtering, sorting and deduplication.

[0090] Specifically, step (7) is the process of using the fine-tuned query statement model;

[0091] In actual operation, the front-end application 100 sends the target query request in the natural language form input by the user and the target interface information of the electronic device where the front-end application 100 is located to the back-end server 200, and the back-end server 200 transmits the query request and the interface information to the first model; wherein the "target" mentioned in step (7) is used to indicate that the query request, etc. is determined by the user in the process of using the fine-tuned query statement model;

[0092] The inference logic of the first model to generate target prompt information is as follows:

[0093] 1) The first model determines the intent information (including business scenario information, context information and spatiotemporal information), basic table information and the data operation corresponding to the query request (including grouping, filtering, sorting and deduplication) according to the target query request and the target interface information;

[0094] The process of determining the query strategy and query clauses needs to refer to the size of the data in the basic table and the number of the basic tables. Therefore, before determining the query statement structure information, the basic table information needs to be determined first.

[0095] In the embodiment of the present application, the number of basic tables and the scale of the amount of data in each basic table can be set to multiple intervals respectively; wherein the interval of the number of basic tables can be referred to as the number interval, and the interval of the scale of the amount of data in the basic table can be referred to as the scale interval; in actual operation, the corresponding query strategy and query clause can be determined according to the number interval of the number of basic tables corresponding to the query request and the scale interval of the corresponding amount of data;

[0096] For example, the quantity interval can be set to [0, 1], [2, 4], [5, ∞], with the unit being pieces;

[0097] The scale interval can be set to [0, 200], [201, 800], [801, 2000], and the unit is the number of records.

[0098] After the above intervals are set, for a specific query request, if the number interval to which the number of basic tables belongs is [2, 4], the scale interval to which the number of two basic tables belongs is [0, 200], and the scale interval to which the number of the third basic table belongs is [201, 800]; in this embodiment of the present application, the query strategy corresponding to the query request is determined to be a connection query.

[0099] In practical applications, how to determine different query strategies according to different quantity intervals and scale intervals can be determined according to actual needs.

[0100] 2) The first model determines the query strategy according to the size of the data volume in the basic table and the number of basic tables in the basic table information, and the first model determines the query clause according to the data operation;

[0101] When the query request is determined, the data operation required for the data in the basic table of the database can also be determined, and accordingly, the query clause corresponding to the data operation can also be determined.

[0102] In actual operation, the functions of the above-mentioned special clauses in the SQL statement can also be completed by other clauses; for example, the results of multiple SELECT statements can be merged and aggregate functions can be used in each SELECT statement to calculate group statistical information. Although the above-mentioned execution logic can also realize the function of the GROUP BY clause, it is far less efficient than using the GROUP BY clause. Therefore, the embodiment of the present application prompts query requests that need to use special clauses, so that the fine-tuned query statement model can obtain accurate query statements.

[0103] It should be emphasized that the data operations corresponding to the query request are not limited to grouping, filtering, sorting and deduplication, and the specific operations can be determined according to actual needs. The above are only shown for example.

[0104] 3) The first model assembles the intent information, basic table information and sentence structure information (including query strategy and intent information) into target prompt information.

[0105] Among them, in actual operation, in the process of fine-tuning the first model through the fine-tuning sample, inference guidance information can be added to the fine-tuning sample, such as "first determine the intention information, and then based on...", to guide the first model to generate prompt information according to the inference logic mentioned above; it should be emphasized that the essence of "inference guidance information" is also prompt information, but there are two reasons for defining it as inference guidance information: first, the inference guidance information is only used in the fine-tuning stage for the first model. After fine-tuning the first model through a large number of fine-tuning samples, the first model can master the inference logic. Therefore, in the process of the user using the fine-tuned first model and the second model, there is no need to generate the inference guidance information to assist the first model in generating prompt information; second, in order to distinguish the prompt information used by the second model in the embodiment of the present application, to prevent semantic confusion;

[0106] It should be emphasized that the reason why the inference guidance information is only used in the fine-tuning stage of the first model is because the inference logic guided by the inference guidance information is fixed and will not change due to different query requests; however, the prompt information generated by the first model will change according to different information such as the query request, so accurate prompt information must be generated by the first model to prompt the second model to generate accurate query statements.

[0107] S120: fine-tuning a query statement model through the plurality of query requests and the query statements and the prompt information corresponding to each query request;

[0108] Among them, the query statement model includes: a first model and a second model; the first model is used to generate target prompt information according to the target query request input by the user to the target business system; the second model is used to generate a target query statement according to the target query request and the target prompt information.

[0109] Specifically, in actual operation, the fine-tuning sample, in addition to the query request, query statement and prompt information, usually also includes: a query statement generation command, the query statement generation command is used to command the query statement model to generate a query statement, such as "please generate an SQL query statement".

[0110] An example of a fine-tuning sample is shown below:

[0111] For the question "Please generate an SQL query statement to query the profit margin [indicator name] in X Province, X City, X District [region] from October 2023 to October 2024 [date]", the prompt word part may be "The number of basic tables is 2, the data volume of basic table A is 500, and the data volume of basic table is 800. Generate an SQL query statement based on basic table A {field 1, field 2, ...} and basic table B {field 1, field 2, ...} to query the average profit margin of the sales department [scenario]. It is recommended to use nested query..."

[0112] In actual operation, the query statement model can be an open source large model, or it can be a query statement model currently used by the target business system to generate SQL statements. This application does not make specific limitations on this.

[0113] In summary, the large-model-based query statement model fine-tuning method provided in the embodiment of the present application constructs prompt information including the intent information of the query request, basic table information, and statement structure information of the query statement, so as to simultaneously fine-tune the first model and the second model in the query statement model, so that the fine-tuned first model can generate accurate prompt information according to various personalized query requests of front-end users of various work departments in the business system, and the fine-tuned second model can generate accurate query statements according to various personalized query requests and corresponding prompt information. Therefore, the fine-tuned query statement model in the present application can meet various personalized query requests of front-end users of various work departments in the business system.

[0114] In the second aspect, the present application provides a query statement model fine-tuning device based on a large model, such as Figure 3 As shown, Figure 3 A structural diagram of a query statement model fine-tuning device based on a large model provided in an embodiment of the present application, the device comprising: a prompt information module 410 and a fine-tuning module 420;

[0115] The prompt information module 410 is used to determine the prompt information corresponding to the query corpus of the target business system; wherein the query corpus includes: multiple query requests and query statements corresponding to each query request; the query request is in the form of natural language; the prompt information includes: the intent information and basic table information of the query request and the sentence structure information of the query statement;

[0116] A fine-tuning module 420, configured to fine-tune the query statement model through multiple query requests and the query statements and prompt information corresponding to each query request;

[0117] Among them, the query statement model includes: a first model and a second model; the first model is used to generate target prompt information according to the target query request input by the user to the target business system; the second model is used to generate a target query statement according to the target query request and the target prompt information.

[0118] In one implementation, the fine-tuning module 420 is further configured to replace the temporal and spatial information and / or query index of the query request in the query corpus to obtain a first newly added query request, and determine a query statement corresponding to the first newly added query request;

[0119] The fine-tuning module 420 is further configured to perform synonym replacement on the single words and / or short words in the query request in the query corpus and the first newly added query request to obtain a second newly added query request, and determine a query statement corresponding to the second newly added query request;

[0120] The fine-tuning module 420 is further configured to determine the prompt information corresponding to the first newly added query request and the second newly added query request respectively according to the first newly added query request, the second newly added query request and the query statements respectively corresponding thereto;

[0121] The first newly added query request, the query statement and prompt information corresponding to the first newly added query request, and the second newly added query request, the query statement and prompt information corresponding to the second newly added query request are used to fine-tune the query statement model.

[0122] In one implementation, the intent information includes: business scenario information, context information, and spatiotemporal information; the prompt information module 410 is further used to determine the business scenario information, context information, and spatiotemporal information corresponding to each query request in the multiple query requests through the intent recognition model according to the query request;

[0123] Among them, the business scenario information indicates the business scope of the work department corresponding to the query request in the target business system; the context information indicates the association information between the current query request and the previous query request; and the spatiotemporal information indicates the time information and geographical information in the query request.

[0124] In one implementation, the basic table information includes: the number of basic tables, table structure information of each basic table, and the size of the data volume in each basic table; the query request includes at least one query index; the prompt information module 410 is further used to determine the basic table information of the target basic table corresponding to the query request in the database corresponding to the target business system according to the query index;

[0125] The target basic table is a basic table including fields corresponding to the query index.

[0126] In one implementation, the statement structure information includes: query strategies and query clauses, and the query strategies include: join query, nested query, set query and query based on derived table; the prompt information module 410 is also used to determine the corresponding statement structure information according to the query statement.

[0127] In one implementation, the apparatus further includes: a data transmission module;

[0128] A data transmission module, used for inputting the target query request input by the user to the target business system into the first model, so that the first model determines the target prompt information according to the target query request;

[0129] Among them, the intention information and the basic table information in the target prompt information are determined by the first model according to the target query request; the query strategy in the target prompt information is determined by the first model according to the scale of the data volume in the basic table and the number of the basic tables in the basic table information; the query clause in the target prompt information is determined by the first model according to the data operation corresponding to the query request, and the data operation includes: grouping, filtering, sorting and deduplication.

[0130] Third, the present application also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements steps S110 to S120 provided in the above embodiment when executing the computer program.

[0131] Fourth, the present application also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, steps S110 to S120 of the above embodiment are executed.

[0132] Fifth, the computer program product provided in the present application includes a computer-readable storage medium storing program code. The instructions included in the program code can be used to execute the method in the previous method embodiment. The specific implementation can refer to steps S110 to S120 of the method embodiment, which will not be repeated here.

[0133] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components 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 the devices or units can be electrical, mechanical or other forms.

[0134] In addition, the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0135] Furthermore, the functional modules in the various embodiments of the present application may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.

[0136] It should be noted that if the function is implemented in the form of a software function module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application can essentially be embodied in the form of a software product, or the part that contributes to the prior art or the part of the technical solution. The computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) 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) random access memory (RAM), disk or optical disk, and other media that can store program codes.

[0137] In this document, relational terms such as first and second, etc. are used merely to distinguish one entity or operation from another entity or operation, but do not necessarily require or imply any such actual relationship or order between these entities or operations.

[0138] The above description is only an embodiment of the present application and is not intended to limit the protection scope of the present application. For those skilled in the art, the present application may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.

Claims

1. A query statement model fine-tuning method based on a large model, characterized in that: The method comprises: Determine the prompt information corresponding to the query corpus of the target business system; The query corpus includes: multiple query requests and query statements corresponding to each query request; the query request is in natural language form; the prompt information includes: intent information and basic table information of the query request and sentence structure information of the query statement; Fine-tune the query statement model through the multiple query requests and the query statements and the prompt information corresponding to each query request; Among them, the query statement model includes: a first model and a second model; the first model is used to generate target prompt information according to the target query request input by the user to the target business system; the second model is used to generate a target query statement according to the target query request and the target prompt information.

2. The method according to claim 1, characterized in that Before fine-tuning the query statement model, the method further includes: Replacing the spatiotemporal information and / or query index of the query request in the query corpus to obtain a first newly added query request, and determining the query statement corresponding to the first newly added query request; Performing synonym replacement on the single words and / or short words in the query request in the query corpus and the first newly added query request to obtain a second newly added query request, and determining the query statement corresponding to the second newly added query request; Determine, according to the first newly added query request, the second newly added query request and the query statements respectively corresponding to the first newly added query request and the second newly added query request; The first newly added query request, the query statement and the prompt information corresponding to the first newly added query request and the second newly added query request, the query statement and the prompt information corresponding to the second newly added query request are used to fine-tune the query statement model.

3. The method according to claim 1, characterized in that The intention information includes: business scenario information, context information and time and space information; the prompt information corresponding to the query corpus of the determined target business system includes: According to the query request, determining the business scenario information, context information and spatiotemporal information corresponding to each of the query requests in the multiple query requests through an intent recognition model; Among them, the business scenario information indicates the business scope of the work department corresponding to the query request in the target business system; the context information indicates the association information between the current query request and the previous query request; the spatiotemporal information indicates the time information and geographical information in the query request.

4. The method according to claim 1, characterized in that The basic table information includes: the number of the basic tables, the table structure information of each of the basic tables and the size of the data in each of the basic tables; the query request includes at least one query indicator; the prompt information corresponding to the query corpus of the target business system is determined, and also includes: According to the query index, determining basic table information of a target basic table corresponding to the query request in a database corresponding to the target business system; The target basic table is a basic table including fields corresponding to the query index.

5. The method according to claim 1, characterized in that: The statement structure information includes: query strategies and query clauses, wherein the query strategies include: join query, nested query, set query and query based on derived table; the prompt information corresponding to the query corpus of the target business system is determined, and further includes: According to the query statement, the corresponding statement structure information is determined.

6. The method according to claim 5, characterized in that After fine-tuning the query statement model, the method further includes: Inputting the target query request input by the user into the target business system into the first model, and allowing the first model to determine the target prompt information according to the target query request; Among them, the intention information and the basic table information in the target prompt information are determined by the first model according to the target query request; the query strategy in the target prompt information is determined by the first model according to the scale of the data volume in the basic table and the number of the basic tables in the basic table information; the query clause in the target prompt information is determined by the first model according to the data operation corresponding to the query request, and the data operation includes: grouping, filtering, sorting and deduplication.

7. A query statement model fine-tuning device based on a large model, characterized in that: The device comprises: a prompt information module and a fine-tuning module; The prompt information module is used to determine the prompt information corresponding to the query corpus of the target business system; The query corpus includes: multiple query requests and query statements corresponding to each query request; the query request is in natural language form; the prompt information includes: intent information and basic table information of the query request and sentence structure information of the query statement; The fine-tuning module is used to fine-tune the query statement model through the multiple query requests and the query statement and the prompt information corresponding to each query request; Among them, the query statement model includes: a first model and a second model; the first model is used to generate target prompt information according to the target query request input by the user to the target business system; the second model is used to generate a target query statement according to the target query request and the target prompt information.

8. An electronic device, characterized in that: The electronic device includes a processor and a memory, the memory is used to store an application, and the processor runs or executes a software program stored in the memory so that the electronic device implements the large model-based query statement model fine-tuning method as described in any one of claims 1 to 6.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium is used to store program codes executed by a processor, and the program codes are used to implement the query statement model fine-tuning method based on a large model as described in any one of claims 1 to 6.

10. A computer program product, characterized in that The computer program product includes computer instructions. When the computer instructions are executed on an electronic device, the electronic device implements the query statement model fine-tuning method based on a large model as described in any one of claims 1 to 6.

Citation Information

Patent Citations

  • Data query method and device, electronic equipment and computer readable storage medium

    CN117349315A

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

    CN117743371A

  • AI large model prompt information generation method and device, equipment and storage medium

    CN117785917A

  • Method and system for automatically generating sql and replying questions

    CN118093634A

  • Database query statement generation method and device, equipment and storage medium

    CN118227655A