Information processing method, device, equipment and storage medium based on large language model
By generating flexible SQL statements through a large language model, the problem of insufficient flexibility of traditional data analysis systems in complex query scenarios is solved, and more efficient and accurate query results are achieved.
Patent Information
- Application Number
- CN202311238693.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-22
- Publication Date
- 2025-09-19
- Estimated Expiration
- 2043-09-22
AI Technical Summary
Traditional data analysis systems have low flexibility in complex query scenarios, requiring multiple interface switches and fixed SQL statements, resulting in insufficient system flexibility.
By interacting with query requests through a large language model, the query conditions, result sources, and filter fields are determined, flexible and accurate SQL statements are generated, and query results are generated in combination with database information.
It improves the flexibility and accuracy of SQL statement generation, enhances user experience, and ensures the completeness and accuracy of query results.
Smart Images

Figure CN119690981B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of data processing technology, specifically to the fields of artificial intelligence, intelligent search, big data, and natural language processing, and in particular to an information processing method, apparatus, device, and storage medium based on a large language model. Background Art
[0002] Traditional data analysis systems are mainly based on graphical user interface interactions. For complex query scenarios, multiple switches on the interface are required, and fixed SQL statements are usually triggered during the query process, making the system less flexible. Summary of the Invention
[0003] The present disclosure provides a method, apparatus, device, and storage medium for information processing based on a large language model.
[0004] According to one aspect of the present disclosure, a method for information processing based on a large language model is provided, the method comprising: obtaining a query request; interacting with a large language model based on the query request to determine query conditions, sources of query results, and filter fields for generating an SQL statement; combining the query conditions, sources of query results, and filter fields based on the large language model to generate the SQL statement; and inputting the SQL statement into the large language model for execution to obtain a query result corresponding to the query request.
[0005] According to a second aspect of the present disclosure, a large language model-based information processing device is provided, comprising: a first acquisition module for acquiring a query request; a second acquisition module for interacting with the large language model based on the query request to determine query conditions, sources of query results, and filter fields for generating an SQL statement; a third acquisition module for combining the query conditions, sources of query results, and filter fields based on the large language model to generate the SQL statement; and an execution module for inputting the SQL statement into the large language model for execution to obtain a query result corresponding to the query request.
[0006] According to a third aspect of the present disclosure, an electronic device is provided, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute the method described in the first aspect.
[0007] According to a fourth aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to enable the computer to execute the method described in the first aspect.
[0008] According to a fifth aspect of the present disclosure, a computer program product is provided, comprising a computer program, wherein the computer program implements the steps of the method according to the first aspect when executed by a processor.
[0009] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0010] The accompanying drawings are used to better understand the present invention and do not constitute a limitation of the present invention.
[0011] Figure 1 A flowchart of a method for processing information based on a large language model provided in an embodiment of the present disclosure;
[0012] Figure 2 A flowchart of another information processing method based on a large language model provided in an embodiment of the present disclosure;
[0013] Figure 2a A schematic diagram of extracting a team name provided in an embodiment of the present disclosure;
[0014] Figure 2b A schematic diagram of table reference information provided in an embodiment of the present disclosure;
[0015] Figure 3 A flowchart of another information processing method based on a large language model provided in an embodiment of the present disclosure;
[0016] Figure 4 A flowchart of another information processing method based on a large language model provided in an embodiment of the present disclosure;
[0017] Figure 5 A flowchart of another information processing method based on a large language model provided in an embodiment of the present disclosure;
[0018] Figure 6 A logical diagram of an information processing method based on a large language model provided in an embodiment of the present disclosure;
[0019] Figure 7 A logical diagram of extracting team names provided in an embodiment of the present disclosure;
[0020] Figure 8 A logical flow chart for generating and executing SQL statements provided in an embodiment of the present disclosure;
[0021] Figure 9 A logical diagram of displaying query results provided by an embodiment of the present disclosure;
[0022] Figure 10 A schematic diagram of the structure of an information processing device based on a large language model provided by an embodiment of the present disclosure;
[0023] Figure 11 The block diagram is a block diagram of an electronic device for implementing an information processing method based on a large language model according to an embodiment of the present disclosure. DETAILED DESCRIPTION
[0024] The following description of exemplary embodiments of the present disclosure is made in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding. These details should be considered as merely exemplary. Therefore, those skilled in the art will recognize that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, for the sake of clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.
[0025] Data processing is the process of extracting and deriving valuable and meaningful data from large amounts of disorganized, difficult-to-understand data. Data is a representation of facts, concepts, or instructions, and can be processed manually or automatically. Once interpreted and given meaning, data becomes information. Data processing involves the collection, storage, retrieval, processing, transformation, and transmission of data.
[0026] Artificial Intelligence (AI) is a new technical science that studies and develops theories, methods, technologies and application systems for simulating, extending and expanding human intelligence. It can simulate the information process of human consciousness and thinking. Its main goal is to enable humans to perform complex tasks that usually require human intelligence.
[0027] Intelligent Search is a new generation of search that combines artificial intelligence technology. In addition to providing traditional functions such as fast retrieval and relevance sorting, it can also provide user role registration, automatic identification of user interests, semantic understanding of content, intelligent information filtering and push, etc.
[0028] Big Data refers to the volume of data involved, which is so large that it cannot be captured, managed, processed, and organized into information that helps business decisions more effectively within a reasonable time through mainstream software tools. It includes structured, semi-structured, and unstructured data.
[0029] Natural Language Processing (NLP) is an important field in computer science and artificial intelligence. It includes various theories and methods that enable effective communication between humans and computers using natural language. It is mainly used in machine translation, public opinion monitoring, automatic summarization, opinion extraction, text classification, question answering, text semantic comparison, speech recognition, Chinese OCR, etc.
[0030] Figure 1 A flowchart of a method for processing information based on a large language model is provided in an embodiment of the present disclosure. Figure 1 As shown, the method includes but is not limited to the following steps:
[0031] S101, obtaining a query request.
[0032] In some implementations, the query request includes the intent and purpose of the user's query.
[0033] Optionally, the query request may be a request input by the user in real time, or may be a request determined from historical query requests of the user.
[0034] For example, the query request may be "How was the revenue of the financial product last year?" or "How much is Zhang San's income?" It can be understood that when the query request is "How was the revenue of the financial product last year?", the user's query intention or purpose is to obtain the revenue of the financial product last year; when the query request is "How much is Zhang San's income?", the user's query intention or purpose is to obtain Zhang San's income.
[0035] S102 , interacting with the large language model based on the query request to determine query conditions for generating SQL statements, sources of query results, and filter fields.
[0036] A large language model (LLM) is a deep learning model trained using large amounts of text data. It can generate natural language text or understand the meaning of language text and handle a variety of natural language tasks. LLMs can be trained based on small-scale datasets in specific fields to customize solutions to specific problems in different fields.
[0037] Optionally, the large language model can be a model such as a chat generation pre-trained converter that can intelligently understand and process text.
[0038] In some implementations, a query request can be fed into a pre-trained large language model. This means the query request interacts with the large language model, which then determines the query conditions, the source of the query results, and the filter fields. Optionally, the query conditions can be understood as the where clause in a Structured Query Language (SQL) statement, the source of the query results can be understood as the from clause in a SQL statement, and the filter fields can be understood as the select clause in a SQL statement.
[0039] In some implementations, the query condition (where condition) can include the specific team or individual name being queried. For example, if the query request is "How much is Zhang San's income?", the specific individual name "Zhang San" is identified as the query condition. When determining the query condition based on the large language model, the specific team or individual name can be parsed first. If relevant results exist in the database, similarity is calculated and sorted, and the result with the highest similarity is selected as the query condition.
[0040] In some implementations, the source of the query result (from condition) is the source of the result obtained based on the query request and the query condition; for example, based on the query request "What is Zhang San's income", the query result obtained is Zhang San's income status table. The income status table may include other information besides Zhang San's income. Therefore, it can be considered that when querying the query request, the source of the query result is the income status table.
[0041] In some implementations, the filter field (select field) is used to narrow the scope of the fields in the table to obtain fields that are more relevant to the query request for processing, so as to improve the efficiency and accuracy of the query. For example, the income status table obtained by the query request "What is Zhang San's income" includes information such as completed income, income completion rate, completed operating profit, and completed operating profit rate. However, the query request is to obtain Zhang San's income status, so the filter fields can be determined to be completed income and income completion rate to improve the accuracy of the query analysis.
[0042] Furthermore, an SQL statement is generated by obtaining query conditions, the source of query results, and filter fields, thereby improving the flexibility and accuracy of the SQL statement.
[0043] S103: Combine the query conditions, the source of the query results, and the filter fields based on the large language model to generate an SQL statement.
[0044] In some implementations, after determining the query conditions (where conditions), the source of the query results (from conditions), and the filter fields (select fields), the query conditions, the source of the query results, and the filter fields can be combined into guidance information based on a large language model. For example, the query conditions, the source of the query results, and the filter fields are extracted using a large language model, and the extracted important information is combined into guidance information. The guidance information includes at least important information related to the current query request, and a corresponding SQL statement is generated based on the guidance information. This can ensure the accuracy of the SQL statement while ensuring the conciseness of the SQL statement. That is, after obtaining the where conditions, from conditions, and select fields used to generate the SQL statement, important information is extracted from the where conditions, from conditions, and select fields based on the large language model, and the extracted important information is combined into guidance information, and a corresponding SQL statement is generated based on the guidance information.
[0045] In some implementations, the input of the large language model may also include examples of SQL statement generation. Based on the SQL examples, the large language model combines and processes information such as the input query conditions, the source of the query results, and the filter fields to obtain more accurate and reasonable SQL statements.
[0046] S104: Input the SQL statement into the large language model for execution to obtain a query result corresponding to the query request.
[0047] It can be understood that the SQL statement includes the query conditions corresponding to the query request, the source of the query results, and important information of the filter fields. Therefore, after determining the SQL statement, the SQL statement is input into the large language model, and the large language model again extracts the information features of the query request included in the SQL statement, and obtains query results that are highly similar to the SQL statement based on the extracted information features.
[0048] In the disclosed embodiment, SQL statements are generated based on information such as query conditions related to the query request, the source of the query results, and the filter fields, thereby improving the flexibility of generating SQL statements. Different query requests correspond to different SQL statements, which can ensure that the query results obtained based on SQL statements and large language models are more accurate, thereby solving the current problem of low flexibility in obtaining SQL statements and improving the user experience.
[0049] Figure 2 A flowchart of a method for processing information based on a large language model is provided in an embodiment of the present disclosure. Figure 2 As shown, the method includes but is not limited to the following steps:
[0050] S201, obtaining a query request.
[0051] In the embodiment of the present disclosure, the implementation method of step S201 can be implemented by using any of the methods in the embodiments of the present disclosure, which is not limited here and will not be described in detail.
[0052] S202: Generate first guidance information based on the query request, and input the first guidance information into the large language model to obtain identification information of the queried object as a query condition.
[0053] In some implementations, the first guidance information may be a richer text generated by adding limitations to the query request to facilitate a more detailed and comprehensive expression of the query request, such as adding modifiers, adjectives, or details to the query request, thereby more accurately determining the purpose of the query request based on the first guidance information.
[0054] Furthermore, after generating the first guide information, the first guide information is input into the large language model to output identification information of the queried object. It is understood that the identification information of the queried object can be information that can uniquely correspond to the queried object, such as the name or number of the queried object.
[0055] Optionally, the identification information of the queried object may be a specific team or individual name, such as a department name, product name, industry name, or person name.
[0056] After the identification information of the queried object is determined, the identification information is used as a query condition for subsequent querying to obtain the information of the queried object.
[0057] For example, the following content can be displayed in the dialog box: Extract the team name (or department name, or product name or industry name) from a sentence. If the team name (or department name, or product name or industry name) can be extracted, the result will be returned. If the team name (or department name, or product name or industry name) cannot be extracted, None will be returned as the first guidance information, such as Figure 2a As shown, the team name (or department name, or product name or industry name) is extracted by inputting a query request, and different results are returned depending on whether the team name can be extracted.
[0058] S203 : Generate second guidance information based on the query request and the description information of the business table in the database, and input the second guidance information into the large language model to obtain a candidate business table as a source of the query result.
[0059] In some implementations, database configuration information can be obtained and, based on the configuration information, business table descriptive information can be determined to improve the efficiency and accuracy of obtaining information related to the business tables. Database configuration information is understood to include information related to different types of business tables. This information may include the data volume, descriptive information, storage location, and other related information of the business tables. The descriptive information of the business tables in the database is used to explain the function of the business tables and the information they contain. The descriptive information may include, but is not limited to, the name of the business table and the function of the business table.
[0060] For example, the database may include three business tables. The names of the first business table, the second business table, and the third business table are bap_acg_fin_complete_report, bap_acg_cost_complete_report, and bap_acg_ltc_detail, respectively.
[0061] Among them, the description information of the business table bap_acg_fin_complete_report may include the function of the business table: used to store and analyze application data of revenue completion indicators, and the record content of the business table: indicator data under different time periods (annual, quarterly, monthly) and cycle types (annual, quarterly, monthly), including completed revenue, completed operating profit, completed operating profit margin and completed revenue completion rate, etc.
[0062] The description information of the business table bap_acg_cost_complete_report may include the function of the business table: used to store and analyze application data of cost completion indicators, and the record content of the business table: cost forecast data under different time periods (annual, quarterly, monthly), period types (annual, quarterly, monthly), indicator types (ACG overall, ACG Core, ACG MA), business types (overall, by industry, by product, by sales), and different levels of classification (zero-level classification, first-level classification, second-level classification, third-level classification, fourth-level classification).
[0063] The description of the business table bap_acg_ltc_detail may include the table's function as a table for storing detailed information about contracts, business opportunities, and projects. The table's records include various attributes and date information related to business opportunities, projects, and sales, as well as forecast and budget data related to revenue and profit.
[0064] Optionally, table reference information may be generated based on the description information of the business table, and the query request may be written into the first preset prompt word to generate a first target prompt word; the table reference information and the first target prompt word may be concatenated to generate the second guidance information.
[0065] It is understandable that the table reference information at least includes information that can reflect the main function and record content of the business table, so that the function of the table and other information can be determined through the table reference information.
[0066] Furthermore, the query request is written into the first preset prompt word to obtain a first target prompt word. The first target prompt word is used to prompt or guide the large language model to output query results that better match the query request. Optionally, the first preset prompt word must include at least a field related to the question in the query request, but non-existent fields cannot be arbitrarily fabricated.
[0067] It can be understood that the second guidance information is the information determined after the table reference information and the first target prompt word are spliced and enriched with text. Therefore, after determining the second guidance information, the second guidance information is input into the large language model, which can output a candidate business table that is highly similar to the query request, thereby improving the accuracy of obtaining the candidate business table.
[0068] In some implementations, there may be one or more candidate business tables, each of which is the source of the query results. When there are multiple candidate business tables, the table names of the candidate business tables may be separated by specific characters, such as ",". If no candidate business table results are found, "None" is returned.
[0069] For example, Figure 2b As shown, the dialog box includes second guidance information, wherein the second guidance information can be obtained by splicing the table reference information and the first target prompt word, wherein the part in the dotted box is the table reference information.
[0070] S204 , extracting a table creation pattern statement of the candidate business table, generating third guidance information based on the table creation pattern statement and the query request, and inputting the third guidance information into the large language model to obtain a screening field.
[0071] It's understood that a schema statement is a statement for creating a new table. This statement determines all fields or key fields included in the candidate business table. A field is a column in a table, typically used to store a specific data type. Each field has a unique name that identifies it; alternatively, fields can have different data types, such as numbers and dates. Each field has a data type and length.
[0072] After determining the candidate business table, third guidance information can be generated based on the table creation schema (schema) statement and query request of the candidate business table. The third guidance information can be used to guide the large language model to obtain the fields involved in the query request. The third guidance information is input into the large language model to obtain the fields involved in the query request as the filter fields. The filter fields are analyzed and processed to narrow the scope of the query fields, making the query content and query conditions more accurate and efficient.
[0073] S205: Combine the query conditions, the source of the query results, and the filter fields based on the large language model to generate an SQL statement.
[0074] In the embodiment of the present disclosure, the implementation of step S205 can be implemented in any of the embodiments of the present disclosure, which is not limited here and will not be described in detail.
[0075] S206: Input the SQL statement into the large language model for execution to obtain a query result corresponding to the query request.
[0076] In some implementations, the query results can also be formatted to obtain query results in JSON format; based on the table building pattern statement and the query results in JSON format, the sixth guidance information is generated. The query results in JSON format are easier to understand and analyze. The table building pattern statement may include English and other forms. Therefore, the sixth guidance information is input into the large language model to obtain a data report of the query results, and the presentation results of the data report are more intuitive, which is easier for users to understand and consult, thereby improving the user experience.
[0077] In the embodiment of the present disclosure, the implementation of step S206 can be implemented in any of the embodiments of the present disclosure, which is not limited here and will not be described in detail.
[0078] In the embodiment of the present disclosure, by setting the query conditions of the query request, the source of the query results and the filter fields, the richer and more complete guidance information ensures the accuracy and completeness of the information obtained, and combines the description information of the business table in the database and the table building pattern statement of the candidate business table as part of the guidance information to ensure the integrity of the information contained in the guidance information. Based on the more complete and accurate query conditions, the source of the query results and the filter fields, the SQL statement is determined, and the SQL statement is executed to obtain a more accurate query result. By converting the format of the query results, based on the table building pattern statement and the query results in JSON format, a data report of the query results is determined, and the query results are displayed in a more intuitive form to facilitate the user's understanding and reference.
[0079] Figure 3A flowchart of a method for processing information based on a large language model is provided in an embodiment of the present disclosure. Figure 3 As shown, the method includes but is not limited to the following steps:
[0080] S301, obtaining a query request.
[0081] In the embodiment of the present disclosure, the implementation method of step S301 can be implemented by using any of the methods in the embodiments of the present disclosure, which is not limited here and will not be described in detail.
[0082] S302: Generate first guidance information based on the query request, and input the first guidance information into the large language model to obtain identification information of the queried object as a query condition.
[0083] In the embodiment of the present disclosure, the implementation method of step S302 can be implemented by using any of the methods in the embodiments of the present disclosure, which is not limited here and will not be described in detail.
[0084] S303 : Generate second guidance information based on the query request and the description information of the business table in the database, and input the second guidance information into the large language model to obtain a candidate business table as a source of the query result.
[0085] In the embodiment of the present disclosure, the implementation method of step S303 can be implemented by using any of the methods in the embodiments of the present disclosure, which is not limited here and will not be described in detail.
[0086] S304 , extracting a table creation pattern statement of the candidate business table, generating third guidance information based on the table creation pattern statement and the query request, and inputting the third guidance information into the large language model to obtain a screening field.
[0087] In the embodiment of the present disclosure, the implementation method of step S304 can be implemented by using any of the methods in the embodiments of the present disclosure, which is not limited here and will not be described in detail.
[0088] S305 , obtaining the hierarchical information and field default values of the fields in the candidate business table, and generating SQL statement reference examples of different hierarchies based on the hierarchical information, field default values and the source of the query result.
[0089] In some implementations, the hierarchical information of the fields in the candidate business table includes at least the hierarchical relationship between the fields in the candidate business table. The hierarchical relationship can be used to represent the parent-child relationship between data. A data can have one or more parents and one or more children. Common hierarchical relationships include organizational structure, product category, region, etc. For example, the fields in the candidate business table include cloud computing and big data development platform, where the big data development platform is a sub-team of cloud computing, and there is a hierarchical relationship between cloud computing and the big data development platform.
[0090] Optionally, the hierarchical information may include: indicator type information page_type, business type information category, a hierarchical relationship of a zero-level category category_l0, a first-level category category_l1, a second-level category category_l2, a third-level category category_l3, and a fourth-level category category_l4.
[0091] It can be understood that category_l0 is the maximum level, category_l1 is the next level of category_l0, category_l2 is the next level of category_l1, category_l3 is the next level of category_l2, and category_l3 is the next level of category_l4.
[0092] In some implementations, the default value of a field in a candidate business table means that when the user does not enter a value for a field, the system automatically sets it to a default value and stores it, thereby ensuring data integrity. For example, the default value of a field can be a number or string with no special meaning, such as 0, null, or empty.
[0093] Generate SQL statement reference examples at different levels based on the field's hierarchical information, field default values, and the source of the query results to ensure that the large language model can output more accurate query results.
[0094] Optionally, a preset candidate query request can be obtained, and the target level of the object queried by the candidate query request can be determined; based on the level information and field default values, the query condition examples and filter field examples of the candidate query request can be determined; based on the query condition examples, filter field examples and the source of the query results, a SQL statement reference example of the target level can be generated.
[0095] For example, assuming that when querying a team, individual, entirety, or industry, the preset candidate query request may be "How is the revenue completion of my team in Q1 of 23?", it is determined that the query object of the candidate query request is "my team," and the target level of the query object is the zero-level classification; therefore, an example of query conditions for determining the candidate query request based on level information and field default values may be: "d_year=2023AND d_quarter=1AND date_type='QUARTER'ANDpage_type='ACG Core'AND category='overall'AND category_l0='overview'AND category_l1='EMPTY'AND category_l2='EMPTY'AND category_l3='EMPTY'AND category_l4='EMPTY'", where d_year represents year information, d_quarter represents quarter information, date_type represents date type information, and EMPTY is the field default value, which is used to represent the entirety; accordingly, an example of filtering fields for determining the candidate query request based on level information and field default values may be "SELECT net_revenue,revenue_completion_rate,d_year,d_quarter,category,category_l0,category_l1,category_l2,category_l3,category_l4", where net_revenue represents revenue and revenue_completion_rate represents revenue completion rate. The query result source is "FROM bap_acg_fin_complete_report". Based on the query condition example, filter field example, and query result source, the SQL statement reference example for generating the target level is as follows:
[0096] "SELECT net_revenue,revenue_completion_rate,d_year,d_month,category,category_l0,category_l1,category_l2,category_l3,category_l4
[0097] FROM bap_acg_fin_complete_report
[0098] WHERE d_year=2023AND d_month IN(1,2,3)AND date_type='MONTH'ANDpage_type='ACG Core'AND category='Product'AND category_l0<>'EMPTY'ANDcategory_l1='EMPTY'AND category_l2='EMPTY'AND category_l3='EMPTY'ANDcategory_l4='EMPTY'".
[0099] For example, assuming that the preset candidate query request is to query subordinates, subordinates, sub-teams, each team, each sub-team, sub-industry, each industry, and each sub-industry, for example, the preset candidate query request is "How is the income completion status of the subordinate team from January to March 23?", it is determined that the query object of the candidate query request is "sub-team", and the target level of the query object is the first-level classification. Therefore, the query condition example of the candidate query request determined based on the level information and the field default value can be: "WHERE d_year=2023AND d_month IN(1,2,3)AND date_type='MONTH'AND page_type='ACG Core'AND category='Product by product'AND category_l0<>'EMPTY'AND category_l1='EMPTY'AND category_l2='EMPTY'AND category_l3='EMPTY'AND category_l4 = 'EMPTY'"; an example of a filter field for determining candidate query requests based on hierarchy information and field default values could be "SELECT net_revenue, revenue_completion_rate, d_year, d_month, category, category_l0, category_l1, category_l2, category_l3, category_l4", where d_month represents month-related information; the source of the query results is "FROM bap_acg_fin_complete_report", then based on the query condition example, filter field example, and query result source, a reference example of an SQL statement for generating the target hierarchy is:
[0100] "SELECT net_revenue,revenue_completion_rate,d_year,d_month,category,category_l0,category_l1,category_l2,category_l3,category_l4
[0101] FROM bap_acg_fin_complete_report
[0102] WHERE d_year=2023AND d_month IN(1,2,3)AND date_type='MONTH'ANDpage_type='ACG Core'AND category='Product'AND category_l0<>'EMPTY'ANDcategory_l1='EMPTY'AND category_l2='EMPTY'AND category_l3='EMPTY'ANDcategory_l4='EMPTY'".
[0103] For example, suppose the query is for the third-level category category_l3, and the preset candidate query request is "Which L3 teams have a total team revenue of more than 1 million yuan in Q1 2023?" It is known that the hierarchical information corresponding to the query object is category_l3. Therefore, the query condition example for determining the candidate query request based on the hierarchical information and field default values is "WHERE d_year=2023AND d_quarter=1AND date_type='QUARTER'AND page_type='ACG Core'AND category='Product'AND category_l0<>'EMPTY'AND category_l1<>'EMPTY'AND category_l2<>'EMPTY'AND category_l3<>'EMPTY'AND category_l4='EMPTY'AND net_revenue>1000000;". Accordingly, the filter field example for determining the candidate query request based on the hierarchical information and field default values is "SELECT category_l3"; the source of the query result is "FROM bap_acg_fin_complete_report", based on the query condition example, filter field example, and the source of the query results, the SQL statement reference example for generating the target level is as follows:
[0104] "SELECT category_l3
[0105] FROM bap_acg_fin_complete_report
[0106] WHERE d_year=2023AND d_quarter=1AND date_type='QUARTER'AND page_type='ACG Core'AND category='Product'AND category_l0<>'EMPTY'AND category_l1<>'EMPTY'AND category_l2<>'EMPTY'AND category_l3<>'EMPTY'AND category_l4='EMPTY'AND net_revenue>1000000;".
[0107] S306 : Generate fourth guidance information based on the SQL statement reference example and hierarchical information, the query request, and the filter field, and input the fourth guidance information into the large language model to obtain an SQL statement.
[0108] Optionally, hierarchical information and SQL statement reference examples can be used as the first information; second information can be generated based on the query request and filter fields; the current query time can be obtained as the third information; hierarchical information of the object queried by the query request can be obtained as the fourth information; the query request can be written into the second preset prompt word to generate a second target prompt word; the first to fourth information can be spliced with the second target prompt word to obtain the fourth guidance information.
[0109] That is, the first information includes complete hierarchical information and all SQL statement reference examples, and the second information includes query request-related information and filter field-related information. Optionally, the query request-related information may include the following two points: first, a revenue query requires the return of revenue and revenue completion rate; second, a cost query requires the return of cost and delivery cost. The filter field-related information may include certain mandatory requirements, such as the need for the filter field to include hierarchical information of business type information, time information (year, quarter, month), etc.
[0110] In some implementations, the time of the current query is obtained as the third information. For example, if the current query time is June 28, 2023, the third information is June 28, 2023.
[0111] In some implementations, the hierarchical information of the object queried by the query request is obtained and used as the fourth information. For example, the current hierarchical information is: page_type = ACG Core, category = Overall, category_l0 = Overview, category_l1 = EMPTY, category_12 = EMPTY, category_l3 = EMPTY, category_l4 = EMPTY; it is understandable that the corresponding next-level information can be expressed as: page_type = 'ACG Core' AND category = 'Product' AND category_l0 <> 'EMPTY' AND category_l1 = 'EMPTY' AND category_l2 =
[0112] 'EMPTY'AND category_l3='EMPTY'AND category_l4='EMPTY'.
[0113] In some implementations, if the team in the query request belongs to the "sub-product" level, the query condition statement contains category_l0<>'EMPTY'; if the query request contains the expression "various teams", it is processed as a "sub-team".
[0114] In some implementations, the value of the category* field in the SQL statement query condition cannot be 'EMPTY' before the last non-'EMPTY' level; for example, in the following two situations:
[0115] Case 1: category_l0<>'EMPTY'AND category_l1='EMPTY'AND category_l2<>'EMPTY'AND category_l3='EMPTY'AND category_l4='EMPTY'. This statement results in an error because the last non-EMPTY level is category_l2, but category_l1='EMPTY'. This violates the requirement that the value before the last non-EMPTY level cannot be 'EMPTY', resulting in an error.
[0116] Case 2: category_l0<>'EMPTY'AND category_l1<>'EMPTY'AND category_l2<>'EMPTY'AND category_l3='EMPTY'AND category_l4='EMPTY'. This statement is correct because the last non-EMPTY level is category_l2, and category_l0 and category_l1 before category_l2 both meet the requirement that the value before the last non-EMPTY level cannot be 'EMPTY'. Therefore, the result is normal.
[0117] In some implementations, the query is written into a second preset prompt word to generate a second target prompt word. This second target prompt word is used to prompt the large language model to improve the accuracy of the output results. Optionally, the second preset prompt word must include fields related to the query request, and any fields that do not exist in the data table cannot be forged, and other content will not be output.
[0118] Furthermore, the first information, the second information, the third information, the fourth information and the second target prompt word are spliced together to obtain fourth guidance information, which is used to guide the large language model. The fourth guidance information includes relevant information of the query request and SQL reference examples. The SQL statement input by the large language model based on the fourth guidance information is more accurate.
[0119] In some implementations, the initial SQL statement output by the large language model can also be syntax-checked; for example, whether the SQL statement meets the aforementioned requirement that the value before the last non-'EMPTY' level cannot be 'EMPTY', and whether there is a syntax error in the SQL statement is determined; if there is a syntax error, the error log is input into the large language model, and the initial SQL statement is syntax-corrected based on the error log until the final SQL statement is obtained, thereby ensuring the accuracy of the SQL statement.
[0120] Optionally, the error log may include, but is not limited to, information such as the query request corresponding to the syntax error of the SQL statement, the current query time of the query request, the error cause of the syntax error, or the error type.
[0121] It is understandable that after the error log is input into the large language model, the large language model can perform syntax correction and adjustment on the initial SQL statement again based on the error log until a final correct SQL statement is obtained.
[0122] In some implementations, if the large language model fails to correct the initial SQL statement after multiple corrections, the generation of the SQL statement can be stopped to avoid meaningless waste of computing resources. The fourth guidance information can be adjusted and the SQL statement can be generated again.
[0123] S307: Input the SQL statement into the large language model for execution to obtain a query result corresponding to the query request.
[0124] In the embodiment of the present disclosure, the implementation method of step S307 can be implemented by using any of the methods in the embodiments of the present disclosure, which is not limited here and will not be described in detail.
[0125] In an embodiment of the present disclosure, adaptive SQL statement reference examples of different levels are generated through information such as the hierarchical information and field default values of the fields in the candidate business table, and the SQL statement reference examples and various information of the query request are combined to generate fourth guidance information. The fourth guidance information is input into the large language model, so that the large language model can better understand the SQL reference examples, and output more accurate and reasonable SQL statements for query requests based on the SQL reference examples, and perform syntax checking on the SQL statements to avoid syntax errors in the SQL statements affecting the query results, thereby ensuring the accuracy of the query results.
[0126] Figure 4 A flowchart of a method for processing information based on a large language model is provided in an embodiment of the present disclosure. Figure 4 As shown, the method includes but is not limited to the following steps:
[0127] S401: Obtain a query request.
[0128] In the embodiment of the present disclosure, the implementation method of step S401 can be implemented by using any of the methods in the embodiments of the present disclosure, which is not limited here and will not be described in detail.
[0129] S402 , interacting with the large language model based on the query request to determine query conditions for generating SQL statements, sources of query results, and filter fields.
[0130] In the embodiment of the present disclosure, the implementation method of step S402 can be implemented by using any of the methods in the embodiments of the present disclosure, which is not limited here and will not be described in detail.
[0131] S403: Combine the query conditions, the source of the query results, and the filter fields based on the large language model to generate an SQL statement.
[0132] In the embodiment of the present disclosure, the implementation method of step S403 can be implemented by using any of the methods in the embodiments of the present disclosure, which is not limited here and will not be described in detail.
[0133] S404: Input the SQL statement into the large language model for execution to obtain a query result corresponding to the query request.
[0134] In the embodiment of the present disclosure, the implementation method of step S404 can be implemented by using any of the methods in the embodiments of the present disclosure, which is not limited here and will not be described in detail.
[0135] S405: Convert the query result into a JSON format.
[0136] JSON format is a lightweight data exchange format that is easy to read and write, and easy for machines to parse and generate. Therefore, the query results can be formatted and converted into a JSON format that is easier to read and understand, so as to facilitate subsequent processing of the query results.
[0137] S406 , obtaining display prompt words for the query results, and generating fifth guidance information based on the display prompt words and the query results in JSON format, and inputting the fifth guidance information into the large language model to obtain a view display result of the query results.
[0138] Optionally, the display prompt word can be a related prompt word for the display method. For example, the display prompt word can be a broken line to prompt the use of a line chart for display. The display prompt word can also be a bar, pie, or table to prompt the use of a bar chart, pie chart, or table for display.
[0139] After obtaining the display prompt word of the query result, the display prompt word and the query result in JSON format are displayed to generate fifth guidance information, which is mainly used to guide the model to display the query result in JSON format in a manner corresponding to the display prompt word.
[0140] Furthermore, the fifth guidance information is input into the large language model, which processes the query results in JSON format and displays them according to the display method corresponding to the display prompt word, thereby obtaining a view display result of the query results. It is understood that if the display prompt word is "columnar," the query results in JSON format processed by the large language model will be displayed in the form of a bar chart, that is, the view display result is a bar chart.
[0141] In the embodiment of the present disclosure, after determining the query results, the query results are converted into a JSON format that is easier to understand and analyze, and based on the display prompt words of the query results, the query results are displayed in the best form, so that the view display results of the query results are clearer and more intuitive.
[0142] Figure 5A flowchart of a method for processing information based on a large language model is provided in an embodiment of the present disclosure. Figure 5 As shown, the method includes but is not limited to the following steps:
[0143] S501: Obtain a query request.
[0144] In the embodiment of the present disclosure, the implementation method of step S501 can be implemented by using any of the methods in the embodiments of the present disclosure, which is not limited here and will not be described in detail.
[0145] S502: Generate first guidance information based on the query request, and input the first guidance information into the large language model to obtain identification information of the queried object as a query condition.
[0146] In the embodiment of the present disclosure, the implementation method of step S502 can be implemented by using any of the methods in the embodiments of the present disclosure, which is not limited here and will not be described in detail.
[0147] S503 : Generate second guidance information based on the query request and the description information of the business table in the database, and input the second guidance information into the large language model to obtain a candidate business table as a source of the query result.
[0148] In the embodiment of the present disclosure, the implementation method of step S503 can be implemented by using any of the methods in the embodiments of the present disclosure, which is not limited here and will not be described in detail.
[0149] S504 , extracting a table creation pattern statement of the candidate business table, generating third guidance information based on the table creation pattern statement and the query request, and inputting the third guidance information into the large language model to obtain a screening field.
[0150] In the embodiment of the present disclosure, the implementation method of step S504 can be implemented by using any of the methods in the embodiments of the present disclosure, which is not limited here and will not be described in detail.
[0151] S505 , obtaining the hierarchical information and field default values of the fields in the candidate business table, and generating SQL statement reference examples of different hierarchies based on the hierarchical information, field default values and the source of the query result.
[0152] In the embodiment of the present disclosure, the implementation method of step S505 can be implemented by using any of the methods in the embodiments of the present disclosure, which is not limited here and will not be described in detail.
[0153] S506 : Generate fourth guidance information based on the SQL statement reference example and hierarchical information, the query request, and the filter field, and input the fourth guidance information into the large language model to obtain an SQL statement.
[0154] In the embodiment of the present disclosure, the implementation method of step S506 can be implemented by using any of the methods in the embodiments of the present disclosure, which is not limited here and will not be described in detail.
[0155] S507: Input the SQL statement into the large language model for execution to obtain a query result corresponding to the query request.
[0156] In the embodiment of the present disclosure, the implementation method of step S507 can be implemented by using any of the methods in the embodiments of the present disclosure, which is not limited here and will not be described in detail.
[0157] S508: Convert the query result into a JSON format.
[0158] In the embodiment of the present disclosure, the implementation method of step S508 can be implemented by using any of the methods in the embodiments of the present disclosure, which is not limited here and will not be described in detail.
[0159] S509 , obtaining display prompt words for the query results, and generating fifth guidance information based on the display prompt words and the query results in JSON format, and inputting the fifth guidance information into the large language model to obtain a view display result of the query results.
[0160] In the embodiment of the present disclosure, the implementation method of step S509 can be implemented by using any of the methods in the embodiments of the present disclosure, which is not limited here and will not be described in detail.
[0161] In the embodiment of the present disclosure, the accuracy and completeness of the various information of the query request obtained are ensured through richer and more complete guidance information. The description information of the business table in the database and the table creation model statement of the candidate business table and other information are used as part of the guidance information to ensure the integrity of the information contained in the guidance information. In addition, adaptive SQL statement reference examples of different levels are generated through information such as the hierarchical information and field default values of the fields in the candidate business table, and then the fourth guidance information is generated and input into the large language model, so that the large language model can better understand the SQL reference example and output a more accurate and reasonable SQL statement for the query request based on the SQL reference example. The query results are displayed in two ways: data report and optimal form, which is convenient for users to understand and consult, solving the current problem of low flexibility in obtaining SQL statements and improving the user experience.
[0162] Figure 6 This is a schematic diagram of a method for processing information based on a large language model provided by an embodiment of the present disclosure. Figure 6As shown, the user inputs a query request (Query) and generates a first guide message (Prompt) based on the query request. The first guide message is input into the large language model to output the identification information of the query object (team, individual name), and then the identification information is used as the query condition for subsequent queries; further, multiple tables are selected based on the query request (Query), and candidate business tables (candidate tables) are obtained according to the second guide message (Prompt) as the source of the query structure; further, Schema field selection is performed, and the third guide message is determined by the table building Schema statement and the query request and input into the large language model to obtain the filter field, the query condition, the source of the query result and the filter field are combined, and combined with the SQL statement reference example (Few-shot) and input into the large language model to obtain the generated SQL statement (NL2SQL), execute the SQL statement, and display the SQL statement (TableQA), and feedback the query result to the user, that is, the BI analysis result.
[0163] Alternatively, as Figure 7 As shown in the figure, it is a logical diagram for extracting team names; a prompt is generated according to the user query request (Query), and the prompt is input into the large language model to parse the team name and individual name of the queried object to determine whether the return result can be extracted. If not, "None" is returned. If there is a result, the similarity of the team list / individual list is calculated and sorted, and the team or individual with the highest similarity is determined as the final result.
[0164] Alternatively, as Figure 8 As shown in the figure, it is a logical flow chart for generating and executing SQL statements. First, the hierarchical relationship and field default values are obtained in the knowledge base. Then, SQL reference examples are generated, that is, where condition examples and select field examples are generated. The user query request (Query), filter fields, and SQL reference examples are combined into guidance information (prompt) and input into the large language model to obtain the SQL statement. After obtaining the SQL statement, a syntax check is performed. If an error occurs, an error log (error log) is returned, which is corrected by the large language model to obtain the correct SQL statement and execute it.
[0165] Alternatively, as Figure 9 As shown, it is a logical diagram for displaying query results; the query results, that is, the SQL execution results, are converted into JSON format, and the JSON format query results are input into the big language model, or the JSON format query results and table creation mode statements are input into the big language model to determine the best display format (table, bar chart, pie chart, etc.) or generate a data report.
[0166] Figure 10 This is a schematic diagram of the structure of a large language model information processing device provided by the embodiment of the present disclosure. Figure 10 As shown, the large language model-based information processing device 1000 includes:
[0167] A first acquisition module 1001 is used to acquire a query request;
[0168] The second acquisition module 1002 is used to interact with the large language model based on the query request to determine the query conditions, query result sources and filter fields for generating SQL statements;
[0169] The third acquisition module 1003 is used to combine the query conditions, the source of the query results and the filter fields based on the large language model to generate an SQL statement;
[0170] The execution module 1004 is used to input the SQL statement into the large language model for execution to obtain the query result corresponding to the query request.
[0171] In some implementations, the second obtaining module 1002 includes:
[0172] Based on the query request, first guidance information is generated, and the first guidance information is input into the large language model to obtain identification information of the queried object as a query condition;
[0173] Generate second guidance information based on the query request and description information of the business table in the database, and input the second guidance information into the large language model to obtain a candidate business table as a source of the query result;
[0174] A table creation pattern statement of the candidate business table is extracted, and third guidance information is generated based on the table creation pattern statement and the query request. The third guidance information is input into the large language model to obtain a screening field.
[0175] In some implementations, the second obtaining module 1002 further includes:
[0176] Obtain database configuration information and determine the description information of the business table based on the configuration information.
[0177] In some implementations, the second obtaining module 1002 includes:
[0178] Generate table reference information based on the description information of the business table, and write the query request into the first preset prompt word to generate a first target prompt word;
[0179] The table reference information and the first target prompt word are concatenated to generate the second guiding information.
[0180] In some implementations, the third obtaining module 1003 includes:
[0181] Obtain the hierarchical information and default values of the fields in the candidate business table, and generate SQL statement reference examples at different levels based on the hierarchical information, default values, and the source of the query results;
[0182] Based on the SQL statement reference example and hierarchical information, the query request and the filter field, fourth guidance information is generated, and the fourth guidance information is input into the large language model to obtain the SQL statement.
[0183] In some implementations, the third obtaining module 1003 includes:
[0184] Obtaining a preset candidate query request and determining a target level of the object queried by the candidate query request;
[0185] Determine query condition examples and filter field examples for candidate query requests based on hierarchical information and field default values;
[0186] Generate SQL statement reference examples for the target layer based on query condition examples, filter field examples, and the source of the query results.
[0187] In some implementations, the third obtaining module 1003 includes:
[0188] Use hierarchical information and SQL statement reference examples as the first information;
[0189] generating second information based on the query request and the filter fields;
[0190] Get the current query time as the third information;
[0191] Obtaining hierarchical information of the object queried by the query request as fourth information;
[0192] Writing the query request into the second preset prompt word to generate a second target prompt word;
[0193] The first to fourth information are spliced with the second target prompt word to obtain the fourth guiding information.
[0194] In some implementations, the third obtaining module 1003 includes:
[0195] Perform syntax verification on the initial SQL statements output by the large language model;
[0196] If there is a syntax error, the error log is input into the large language model, and the syntax of the initial SQL statement is corrected based on the error log until the final SQL statement is obtained.
[0197] In some implementations, executing module 1004 includes:
[0198] Convert the query results to JSON format.
[0199] Obtain display prompt words for the query results, and generate fifth guidance information based on the display prompt words and the query results in JSON format, and input the fifth guidance information into the large language model to obtain a view display result of the query results.
[0200] In some implementations, executing module 1004 includes:
[0201] Convert the query results to JSON format.
[0202] Based on the table creation mode statement and the query result in JSON format, sixth guidance information is generated, and the sixth guidance information is input into the large language model to obtain a data report of the query result.
[0203] In the disclosed embodiment, SQL statements are generated based on information such as query conditions related to the query request, the source of the query results, and the filter fields, thereby improving the flexibility of generating SQL statements. Different query requests correspond to different SQL statements, which can ensure that the query results obtained based on SQL statements and large language models are more accurate, thereby solving the current problem of low flexibility in obtaining SQL statements and improving the user experience.
[0204] In the technical solutions disclosed herein, the acquisition, storage, and application of user personal information involved comply with the provisions of relevant laws and regulations and do not violate public order and good morals.
[0205] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium, and a computer program product.
[0206] Figure 11 A schematic block diagram of an example electronic device 1100 that can be used to implement embodiments of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital assistants, cellular phones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are provided as examples only and are not intended to limit the implementation of the present disclosure described and / or claimed herein.
[0207] like Figure 11As shown, the device 1100 includes a computing unit 1101, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 1102 or a computer program loaded from a storage unit 1108 into a random access memory (RAM) 1103. Various programs and data required for the operation of the device 1100 can also be stored in the RAM 1103. The computing unit 1101, the ROM 1102, and the RAM 1103 are connected to each other via a bus 1104. An input / output (I / O) interface 1105 is also connected to the bus 1104.
[0208] Various components in device 1100 are connected to I / O interface 1105, including an input unit 1106, such as a keyboard and mouse; an output unit 1107, such as various types of displays and speakers; a storage unit 1108, such as a magnetic disk and optical disk; and a communication unit 1109, such as a network card, a modem, a wireless communication transceiver, etc. Communication unit 1109 allows device 1100 to exchange information / data with other devices via a computer network such as the Internet and / or various telecommunication networks.
[0209] The computing unit 1101 can be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 1101 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units that run machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 1101 performs the various methods and processes described above, such as based on the large language model information processing method. For example, in some embodiments, the information processing method can be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as a storage unit 1108. In some embodiments, part or all of the computer program can be loaded and / or installed on the device 1100 via the ROM 1102 and / or the communication unit 1109. When the computer program is loaded into the RAM 1103 and executed by the computing unit 1101, one or more steps of the large language model information processing method described above can be performed. Alternatively, in other embodiments, the computing unit 1101 may be configured to execute the large language model-based information processing method in any other appropriate manner (for example, by means of firmware).
[0210] Various embodiments of the systems and techniques described herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), system-on-chip systems (SOCs), programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments can include being implemented in one or more computer programs that are executable and / or interpreted on a programmable system that includes at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0211] The program code for implementing the method of the present disclosure can be written in any combination of one or more programming languages. These program codes can be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device so that when the program code is executed by the processor or controller, the functions / operations specified in the flow chart and / or block diagram are implemented. The program code can be executed entirely on the machine, partially on the machine, as a stand-alone software package, partially on the machine and partially on a remote machine, or entirely on a remote machine or server.
[0212] In the context of the present disclosure, a machine-readable medium can be a tangible medium that can contain or store a program for use by or in conjunction with an instruction execution system, device or equipment. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium can include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0213] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0214] The systems and techniques described herein can be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network (LAN), a wide area network (WAN), and the Internet.
[0215] A computer system may include a client and a server. The client and server are generally remote from each other and typically interact through a communication network. The client-server relationship arises through computer programs running on the respective computers and having a client-server relationship with each other. The server may be a cloud server, a server in a distributed system, or a server integrated with a blockchain.
[0216] It should be understood that the various forms of the processes shown above can be used to reorder, add, or delete steps. For example, the steps described in this disclosure can be performed in parallel, sequentially, or in a different order, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved. This is not limited herein.
[0217] The above specific embodiments do not constitute a limitation on the scope of protection of this disclosure. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions may be made based on design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this disclosure shall be included within the scope of protection of this disclosure.
Claims
1. A method for information processing based on a large language model, wherein: The method comprises: Get query request; Interacting with the large language model based on the query request to determine query conditions, sources of query results, and filter fields for generating structured query language SQL statements; Combining the query condition, the source of the query result, and the screening field based on the large language model to generate the SQL statement; Inputting the SQL statement into the large language model for execution to obtain a query result corresponding to the query request; wherein interacting with the large language model based on the query request to determine query conditions for generating the SQL statement, a source of the query result, and a filter field includes: generating first guidance information based on the query request, and inputting the first guidance information into the large language model to obtain identification information of the queried object as the query condition; generating second guidance information based on the query request and description information of the business table in the database, and inputting the second guidance information into the large language model to obtain a candidate business table as a source of the query result; A table creation pattern statement of the candidate business table is extracted, and third guidance information is generated based on the table creation pattern statement and the query request, and the third guidance information is input into the large language model to obtain the screening field.
2. The method according to claim 1, wherein Before generating the second guidance information based on the query request and the description information of the service table in the database, the method further includes: Configuration information of the database is acquired, and description information of the service table is determined based on the configuration information.
3. The method according to claim 1, wherein The generating of the second guidance information based on the query request and the description information of the service table in the database includes: Generate table reference information based on the description information of the business table, and write the query request into a first preset prompt word to generate a first target prompt word; The table reference information and the first target prompt word are concatenated to generate the second guidance information.
4. The method according to any one of claims 1 to 3, wherein The step of combining the query conditions, the source of the query results, and the filter fields based on the large language model to generate the SQL statement includes: Obtaining hierarchical information and field default values of fields in the candidate business table, and generating SQL statement reference examples of different hierarchies based on the hierarchical information, the field default values, and the source of the query result; Based on the SQL statement reference example and the hierarchical information, the query request and the filter field, fourth guidance information is generated, and the fourth guidance information is input into the large language model to obtain the SQL statement.
5. The method according to claim 4, wherein The generating of SQL statement reference examples at different levels based on the level information, the field default values, and the source of the query results includes: Obtaining a preset candidate query request and determining a target level of an object queried by the candidate query request; Determining a query condition example and a filter field example for the candidate query request based on the hierarchical information and the field default value; Based on the query condition example, the filter field example, and the source of the query result, a SQL statement reference example of the target level is generated.
6. The method according to claim 5, wherein: The generating of fourth guidance information based on the SQL statement reference example, the hierarchical information, the query request, and the filter field includes: The hierarchical information and the SQL statement reference example are used as first information; generating second information based on the query request and the screening field; Get the current query time as the third information; Obtaining hierarchical information of the object queried by the query request as fourth information; Writing the query request into a second preset prompt word to generate a second target prompt word; The first information to the fourth information are concatenated with the second target prompt word to obtain the fourth guiding information.
7. The method according to claim 5, wherein: Inputting the fourth guidance information into the large language model to obtain the SQL statement includes: Performing syntax check on the initial SQL statement output by the large language model; If there is a grammatical error, the error log is input into the large language model, and the grammar of the initial SQL statement is corrected based on the error log until the final SQL statement is obtained.
8. The method according to claim 1, wherein Inputting the SQL statement into the large language model for execution to obtain a query result corresponding to the query request includes: Convert the query result to a JSON format. A display prompt word of the query result is obtained, and based on the display prompt word and the query result in JSON format, fifth guidance information is generated and input into the large language model to obtain a view display result of the query result.
9. The method according to claim 1, wherein: Inputting the SQL statement into the large language model for execution to obtain a query result corresponding to the query request includes: Convert the query result to a JSON format. Based on the table creation mode statement and the query result in the JSON format, sixth guidance information is generated, and the sixth guidance information is input into the large language model to obtain a data report of the query result.
10. An information processing device based on a large language model, comprising: A first acquisition module is used to obtain a query request; A second acquisition module is used to interact with the large language model based on the query request to determine the query conditions, query result sources and filter fields for generating SQL statements; a third acquisition module, configured to combine the query condition, the source of the query result, and the filter field based on the large language model to generate the SQL statement; An execution module is configured to input the SQL statement into the large language model for execution, and obtain a query result corresponding to the query request. The second acquisition module includes: generating first guidance information based on the query request, and inputting the first guidance information into the large language model to obtain identification information of the queried object as the query condition; generating second guidance information based on the query request and description information of the business table in the database, and inputting the second guidance information into the large language model to obtain a candidate business table as a source of the query result; A table creation pattern statement of the candidate business table is extracted, and third guidance information is generated based on the table creation pattern statement and the query request, and the third guidance information is input into the large language model to obtain the screening field.
11. The device according to claim 10, wherein The second acquisition module further includes: Configuration information of the database is acquired, and description information of the service table is determined based on the configuration information.
12. The device according to claim 10, wherein The second acquisition module includes: Generate table reference information based on the description information of the business table, and write the query request into a first preset prompt word to generate a first target prompt word; The table reference information and the first target prompt word are concatenated to generate the second guidance information.
13. The device according to any one of claims 10 to 12, wherein: The third acquisition module includes: Obtaining hierarchical information and field default values of fields in the candidate business table, and generating SQL statement reference examples of different hierarchies based on the hierarchical information, the field default values, and the source of the query result; Based on the SQL statement reference example and the hierarchical information, the query request and the filter field, fourth guidance information is generated, and the fourth guidance information is input into the large language model to obtain the SQL statement.
14. The device according to claim 13, wherein The third acquisition module includes: Obtaining a preset candidate query request and determining a target level of an object queried by the candidate query request; Determining a query condition example and a filter field example for the candidate query request based on the hierarchical information and the field default value; Based on the query condition example, the filter field example, and the source of the query result, a SQL statement reference example of the target level is generated.
15. The device according to claim 14, wherein The third acquisition module includes: The hierarchical information and the SQL statement reference example are used as first information; generating second information based on the query request and the screening field; Get the current query time as the third information; Obtaining hierarchical information of the object queried by the query request as fourth information; Writing the query request into a second preset prompt word to generate a second target prompt word; The first information to the fourth information are concatenated with the second target prompt word to obtain the fourth guiding information.
16. The device according to claim 13, wherein The third acquisition module includes: Performing syntax check on the initial SQL statement output by the large language model; If there is a grammatical error, the error log is input into the large language model, and the grammar of the initial SQL statement is corrected based on the error log until the final SQL statement is obtained.
17. The device according to claim 10, wherein The execution module includes: Convert the query result to a JSON format. A display prompt word of the query result is obtained, and based on the display prompt word and the query result in JSON format, fifth guidance information is generated and input into the large language model to obtain a view display result of the query result.
18. The device according to claim 10, wherein The execution module includes: Convert the query result to a JSON format. Based on the table creation mode statement and the query result in the JSON format, sixth guidance information is generated, and the sixth guidance information is input into the large language model to obtain a data report of the query result.
19. An electronic device comprising: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 9.
20. A non-transitory computer-readable storage medium storing computer instructions, wherein: The computer instructions are used to cause the computer to execute the method according to any one of claims 1 to 9.
21. A computer program product comprising a computer program, which, when executed by a processor, implements the steps of the method according to any one of claims 1 to 9.
Citation Information
Patent Citations
Interactive data analysis method and device, medium and electronic equipment
CN110837545A
Structured query language conversion method based on natural language, and related equipment thereof
CN111177184A