Information processing method and device based on large language model, equipment and storage medium
Through the information processing method based on the large language model, SQL statements are dynamically generated and executed, and the problem of insufficient flexibility in complex query scenarios is solved, and more flexible and accurate query results are achieved.
Patent Information
- Application Number
- CN202311238693.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-22
- Publication Date
- 2025-03-25
- Estimated Expiration
- 2043-09-22
AI Technical Summary
Traditional data analysis systems are less flexible in complex query scenarios, require frequent interface switching, and are usually fixed SQL statements during querying, which are difficult to meet the needs of flexible query.
The information processing method based on the large language model is adopted. By obtaining the query request and interacting with the large language model, the query conditions, the source of the query results and the filter fields for generating the SQL statements are determined, and SQL statements are generated based on the combination of these information. Finally, the SQL statements are input to the large language model for execution to obtain the query results.
It improves the flexibility and accuracy of SQL statement generation, and can dynamically generate suitable SQL statements based on different query requests, thereby obtaining more accurate query results and improving user experience.
Smart Images

Figure CN119690981A_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, device, equipment, 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; 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, there is provided an information processing device based on a large language model, comprising: a first acquisition module, used to acquire a query request; a second acquisition module, used to interact with the large language model based on the query request, and determine the query conditions, the source of the query results, and the filter fields for generating an SQL statement; a third acquisition module, used to combine the query conditions, the source of the query results, and the filter fields based on the large language model to generate the SQL statement; and an execution module, used to input the SQL statement into the large language model for execution, and obtain the 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 so that the at least one processor can 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 cause 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 solution and do not constitute a limitation of the present disclosure.
[0011] Figure 1 A flowchart of a large language model information processing method provided by an embodiment of the present disclosure;
[0012] Figure 2 A flowchart of another information processing method based on a large language model provided by 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 by an embodiment of the present disclosure;
[0015] Figure 3 A flowchart of another information processing method based on a large language model provided by an embodiment of the present disclosure;
[0016] Figure 4 A flowchart of another information processing method based on a large language model provided by an embodiment of the present disclosure;
[0017] Figure 5 A flowchart of another information processing method based on a large language model provided by an embodiment of the present disclosure;
[0018] Figure 6 A logical schematic diagram of a large language model information processing method provided by an embodiment of the present disclosure;
[0019] Figure 7 A logical schematic diagram of extracting team names provided in an embodiment of the present disclosure;
[0020] Figure 8 A logic flow chart for generating and executing SQL statements provided in an embodiment of the present disclosure;
[0021] Fig. 9 A logical diagram of displaying query results provided by an embodiment of the present disclosure;
[0022] Fig.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] Fig.11 The invention 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 is a description of exemplary embodiments of the present disclosure in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art 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 to extract and derive valuable and meaningful data for people with certain characteristics from a large amount of chaotic and difficult to understand data. Data is a form of expression of facts, concepts or instructions, which can be processed by manual or automatic devices. After the data is interpreted and given a certain meaning, it becomes information. Data processing is 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 quick retrieval, relevance sorting and other functions, 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 amount of data involved that is so large that it cannot be captured, managed, processed, and organized into more proactive information to help business decisions within a reasonable time through mainstream software tools, including structured, semi-structured, and unstructured data.
[0029] Natural Language Processing (NLP) is an important direction in the fields of computer science and artificial intelligence. It is a variety of theories and methods that can realize effective communication between people 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 and other aspects.
[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] By way of example, a query request may be "How was the revenue of the financial product last year?" or "How much is Zhang San's income?" It is understandable 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; and 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 the query conditions for generating SQL statements, the source of the query results, and the screening fields.
[0036] A large language model (LLM) refers to a deep learning model trained using a large amount of text data. It can generate natural language text or understand the meaning of language text, and can handle a variety of natural language tasks. A large language model can be trained based on small-scale data sets 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, the query request can be input into a pre-trained large language model, that is, the query request interacts with the large language model, and the large language model determines the query conditions, the source of the query results, and the filter fields. Optionally, the query conditions can be understood as the where conditions in a structured query language (SQL) statement, the source of the query results can be understood as the from conditions in a SQL statement, and the filter fields can be understood as the select conditions in a SQL statement.
[0039] In some implementations, the query condition (where condition) may include the specific team or individual name of the query. For example, when 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 may be parsed first. If there are relevant results in the database, the 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 "How much is Zhang San's income", the query result is Zhang San's income table, which may include other information besides Zhang San's income. Therefore, it can be considered that when the query request is queried, the source of the query result is the income table.
[0041] In some implementations, a filter field (select field) is used to narrow the fields in a 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 query request is "How much is Zhang San's income?" The income situation table obtained 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 situation, 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 the screening fields, thereby improving the flexibility and accuracy of the SQL statement.
[0043] S103, combining 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 the large language model. For example, the query conditions, the source of the query results, and the filter fields are extracted through the large language model, and the extracted important information is combined into guidance information, which includes at least the relevant important information of the current query request. The corresponding SQL statement is generated according to the guidance information, which can ensure the accuracy of the SQL statement while ensuring the simplicity of the SQL statement. That is to say, after obtaining the where conditions, from conditions, and select fields used to generate the SQL statement, the important information of the where conditions, from conditions, and select fields is extracted based on the large language model, and the extracted important information is combined into guidance information, and the corresponding SQL statement is generated according to the guidance information.
[0045] In some implementations, the input of the large language model may also include examples of SQL statement generation. The large language model combines the input query conditions, the source of the query results, the filter fields and other information based on the SQL examples to obtain more accurate and reasonable SQL statements.
[0046] S104, inputting the SQL statement into the large language model for execution, and obtaining the 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 the SQL statement is determined, 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 embodiments, 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 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 embodiments of the present disclosure, the implementation method of step S201 can be implemented by 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 description 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] Further, after the first guide information is generated, the first guide information is input into the large language model, and the identification information of the queried object is output. It is understandable that the identification information of the queried object can be information such as the name or number of the queried object that can uniquely correspond to 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, and return the result if it can be extracted. If it cannot be extracted, return None 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 name can be extracted.
[0058] S203, generating second guidance information based on the query request and the 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.
[0059] In some implementations, the configuration information of the database may be obtained, and the descriptive information of the business table may be determined based on the configuration information to improve the efficiency and accuracy of obtaining the relevant information of the business table. The configuration information of the database is understood to include relevant information of different types of business tables, and the relevant information may include the data volume, descriptive information, storage location and other relevant information of the business table; the descriptive information of the business table in the database is used to explain the role of the business table and the information contained therein, wherein the descriptive information may include but is not limited to the name of the business table and the role of the business table.
[0060] By way of example, the database may include three business tables, and the names of the first business table, the second business table, and the third business table are respectively: bap_acg_fin_complete_report, bap_acg_cost_complete_report, and bap_acg_ltc_detail.
[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, the record content of the business table: cost forecast data under different time periods (annual, quarterly, monthly), cycle 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 information of the business table bap_acg_ltc_detail may include the function of the business table: a table used to store detailed information such as contracts, business opportunities, and projects; the record content of the business table: contains 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 a 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 second guide information.
[0065] It can be understood 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, and the first target prompt word is used to prompt or guide the large language model to output a query result that better matches the query request. Optionally, the first preset prompt word needs to include at least a field related to the question in the query request, but non-existent fields cannot be forged at will.
[0067] It can be understood that the second guide information is information determined after the table reference information and the first target prompt word are concatenated and the text is enriched. Therefore, after the second guide information is determined, the second guide 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, the number of candidate business tables may be one or more, and the candidate business tables are 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 result of the candidate business table is obtained, "None" is returned.
[0069] For example, Figure 2b As shown, the dialog box includes second guide information, wherein the second guide information can be obtained by concatenating the table reference information and the first target prompt word, wherein the portion in the dotted box is the table reference information.
[0070] S204, extracting a table building pattern statement of the candidate business table, generating third guidance information based on the table building pattern statement and the query request, and inputting the third guidance information into the large language model to obtain a screening field.
[0071] It can be understood that the table creation schema statement is a statement for creating a new table, and all the fields or key fields included in the candidate business table are determined through the table creation schema statement. A field is a column in a table, usually used to store a specific data type, and each field has a unique name to identify the field; optionally, the field can be a different data type such as a number, a date, etc., and each field has a data type and a length.
[0072] After determining the candidate business table, third guidance information can be generated based on the table creation 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 filter fields. The filter fields are analyzed and processed to narrow the scope of the query fields, so that the query content and query conditions are more accurate and efficient.
[0073] S205, combining 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 method of step S205 can be implemented by any method in the embodiments of the present disclosure, which is not limited here and will not be repeated.
[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 converted into a format 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 on the query results. The presentation results of the data report are more intuitive, which is convenient for users to understand and consult, thereby improving the user experience.
[0077] In the embodiment of the present disclosure, the implementation method of step S206 can be implemented by any method in the embodiments of the present disclosure, which is not limited here and will not be repeated.
[0078] In the disclosed embodiment, 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, determine the SQL statement based on the more complete and accurate query conditions, the source of the query results and the filter fields, and execute the SQL statement to obtain a more accurate query result, and determine the data report of the query result based on the table building pattern statement and the query result in JSON format by format conversion of the query result, and display the query result 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 embodiments of the present disclosure, the implementation method of step S301 may be implemented in any manner 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 embodiments of the present disclosure, the implementation method of step S302 may be implemented in any manner 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 embodiments of the present disclosure, the implementation method of step S303 may be implemented in any manner in the embodiments of the present disclosure, which is not limited here and will not be described in detail.
[0086] S304, extracting a table building pattern statement of the candidate business table, generating third guidance information based on the table building 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 embodiments of the present disclosure, the implementation method of step S304 may be implemented in any manner 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: the hierarchical relationship of indicator type information page_type, business type information category, zero-level category category_l0, first-level category category_l1, second-level category category_l2, third-level category category_l3 and 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 a 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 hierarchical information of the field, the field default value, 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, whole 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 zero-level classification; therefore, an example of the query condition for determining the candidate query request based on the level information and the field default value 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 represents the field default value, which is used to characterize the whole; accordingly, an example of determining the filter field of the candidate query request based on the level information and the field default value 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 source of the query result is "FROM bap_acg_fin_complete_report", then based on the query condition example, the filter field example and the source of the query result, the reference example of the SQL statement for generating the target level is:
[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 of the subordinate team from January to March 23", it is determined that the query object of the candidate query request is "subordinate 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'"; the example of the filter field for determining the candidate query request based on the hierarchy information and the field default value may be "SELECTnet_revenue,revenue_completion_rate,d_year,d_month,category,category_l0,category_l1,category_l2,category_l3,category_l4", where d_month represents the information related to the month; the source of the query result is "FROM bap_acg_fin_complete_report", then based on the query condition example, the filter field example and the source of the query result, the reference example of the 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 queried object is category_l3. Therefore, the query condition example for determining the candidate query request based on the hierarchical information and the field default value is "WHERE d_year=2023AND d_quarter=1AND date_type='QUARTER'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'AND net_revenue>1000000;" and accordingly, the filter field example for determining the candidate query request based on the hierarchical information and the field default value is "SELECT category_l3"; the source of the query result is "FROM bap_acg_fin_complete_report", based on the query condition example, the filter field example, and the source of the query result, 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 the filter field; the current query time can be obtained as the third information; the hierarchical information of the object queried by the query request can be obtained as the fourth information; the query request is written into the second preset prompt word to generate a second target prompt word; the first information to the fourth information are 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, query request related information may include the following two points: first, querying revenue needs to return revenue and revenue completion rate, and second, querying cost needs to return cost and delivery cost. The filter field related information may include some necessary requirements, such as the filter field needs to include hierarchical information of business type information, time information (year, quarter, month), etc.
[0110] In some implementations, the current query time 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 the hierarchical information is 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 can be understood that the corresponding next hierarchical information can be expressed as: page_type = 'ACG Core' AND category = 'Product by 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 "each team", it is processed as a "sub-team".
[0114] In some implementations, the value before the last non-'EMPTY' level of the category* field in the query condition of an SQL statement cannot be 'EMPTY'; for example, in the following two cases:
[0115] Case 1: category_l0<>'EMPTY'AND category_l1='EMPTY'AND category_l2<>'EMPTY'AND category_l3='EMPTY'AND category_l4='EMPTY'. The result of this statement is wrong because the last non-'EMPTY' level is category_l2, but category_l1='EMPTY'. Therefore, the requirement that the value before the last non-'EMPTY' level cannot be 'EMPTY' is violated, and the judgment result is wrong.
[0116] Case 2: category_l0<>'EMPTY'AND category_l1<>'EMPTY'AND category_l2<>'EMPTY'AND category_l3='EMPTY'AND category_l4='EMPTY'. The result of 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'. The judgment result is normal.
[0117] In some implementations, the query request is written into the second preset prompt word to generate a second target prompt word, which is used to prompt the large language model to improve the correctness of the output result. Optionally, the second preset prompt word needs to include fields related to the query request, and any fields that do not exist in any data table cannot be forged, and other content is not output.
[0118] Furthermore, the first information, the second information, the third information, the fourth information and the second target prompt word are concatenated to obtain fourth guidance information, and the fourth guidance information 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 above-mentioned requirement that the value before the last non-'EMPTY' level cannot be 'EMPTY', and whether there is a syntax error in the SQL statement; 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 current 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 to generate the SQL statement again.
[0123] S307, input the SQL statement into the large language model for execution, and obtain the query result corresponding to the query request.
[0124] In the embodiments of the present disclosure, the implementation method of step S307 may be implemented in any manner in the embodiments of the present disclosure, which is not limited here and will not be described in detail.
[0125] In the disclosed embodiment, 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, and 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, obtaining a query request.
[0128] In the embodiments of the present disclosure, the implementation method of step S401 may be implemented in any manner 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 the query conditions for generating SQL statements, the source of the query results, and the screening fields.
[0130] In the embodiments of the present disclosure, the implementation method of step S402 may be implemented in any manner in the embodiments of the present disclosure, which is not limited here and will not be described in detail.
[0131] S403, combining 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 embodiments of the present disclosure, the implementation method of step S403 may be implemented in any manner 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 embodiments of the present disclosure, the implementation method of step S404 may be implemented in any manner 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 to parse and generate by machines. 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 of 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 graph 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 used 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] Further, the fifth guidance information is input into the large language model, and the large language model processes the query result in JSON format, and displays it according to the display method corresponding to the display prompt word, so as to obtain a view display result of the query result. It can be understood that if the display prompt word is "columnar", the query result 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 disclosed embodiment, 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, obtaining a query request.
[0144] In the embodiments of the present disclosure, the implementation method of step S501 may be implemented in any manner 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 embodiments of the present disclosure, the implementation method of step S502 may be implemented in any manner 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 embodiments of the present disclosure, the implementation method of step S503 may be implemented in any manner in the embodiments of the present disclosure, which is not limited here and will not be described in detail.
[0149] S504, extracting a table building pattern statement of the candidate business table, generating third guidance information based on the table building 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 embodiments of the present disclosure, the implementation method of step S504 may be implemented in any manner 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 embodiments of the present disclosure, the implementation method of step S505 can be implemented by 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 embodiments of the present disclosure, the implementation method of step S506 may be implemented in any manner 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 embodiments of the present disclosure, the implementation method of step S507 may be implemented in any manner 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 embodiments of the present disclosure, the implementation method of step S508 may be implemented in any manner 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 of 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 embodiments of the present disclosure, the implementation method of step S509 may be implemented in any manner in the embodiments of the present disclosure, which is not limited here and will not be described in detail.
[0161] In the disclosed embodiment, the accuracy and completeness of each information of the query request obtained is ensured through richer and more complete guidance information, and the description information of the business table in the database and the table creation mode 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, and the hierarchical information of the fields in the candidate business table and the field default values and other information are used to generate adaptive SQL statement reference examples of different levels, 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 more accurate and reasonable SQL statements for query requests based on the SQL reference example, and display the query results in two display methods, data report and optimal form, so that users can understand and consult them easily, solve the problem of low flexibility in obtaining SQL statements, and improve user experience.
[0162] Figure 6 A schematic diagram of a large language model information processing method 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) according to the query request, inputs the first guide message into the large language model to output the identification information (team, individual name) of the query object, and then uses the identification information as the query condition for subsequent queries; further, multiple table selection is performed 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) Input into the large language model, 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, if Figure 7 As shown, it is a logical diagram for extracting team names; a guide message (prompt) is generated according to a user query request (Query), and the guide message is input into a large language model to parse the team name and individual name of the queried object to determine whether the returned 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, if 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, and 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 guide 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, if Fig. 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 large language model, or the JSON format query results and table building mode statements are input into the large language model to determine the best display format (table, bar chart, pie chart, etc.) or generate data reports.
[0166] Fig.10 The structure diagram of a large language model information processing device provided by the embodiment of the present disclosure is as follows. Fig.10 As shown, the large language model-based information processing device 1000 includes:
[0167] The 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, the source of the query results and the screening fields for generating the SQL statement;
[0169] The third acquisition module 1003 is used to combine the query conditions, the source of the query results and the screening 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 acquisition module 1002 includes:
[0172] Based on the query request, first guide information is generated, and the first guide 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 mode statement of the candidate business table is extracted, and third guidance information is generated based on the table creation mode statement and the query request, and the third guidance information is input into the large language model to obtain a screening field.
[0175] In some implementations, the second acquisition module 1002 further includes:
[0176] The configuration information of the database is obtained, and the description information of the business table is determined based on the configuration information.
[0177] In some implementations, the second acquisition 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 guide information.
[0180] In some implementations, the third acquisition module 1003 includes:
[0181] Obtain the hierarchical information and field default values of the fields in the candidate business table, and generate reference examples of SQL statements at different levels based on the hierarchical information, field 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 guide information is generated, and the fourth guide information is input into the large language model to obtain the SQL statement.
[0183] In some implementations, the third acquisition module 1003 includes:
[0184] Obtaining a preset candidate query request and determining a target level of an object queried by the candidate query request;
[0185] Determine query condition examples and filter field examples for candidate query requests based on the hierarchical information and field default values;
[0186] Generate SQL statement reference examples at the target level based on the query condition examples, filter field examples, and the source of the query results.
[0187] In some implementations, the third acquisition module 1003 includes:
[0188] Take the hierarchical information and SQL statement reference examples as the first information;
[0189] generating second information based on the query request and the screening 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 information to the fourth information are spliced with the second target prompt word to obtain the fourth guiding information.
[0194] In some implementations, the third acquisition module 1003 includes:
[0195] Perform syntax check 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, the execution module 1004 includes:
[0198] Convert the query results to JSON format.
[0199] The 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 the view display result of the query result.
[0200] In some implementations, the execution 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, the sixth guide information is generated, and the sixth guide information is input into the large language model to obtain a data report of the query result.
[0203] In the disclosed embodiments, 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 user experience.
[0204] In the technical solution disclosed herein, the acquisition, storage and application of user personal information involved are in compliance 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] Fig.11 A schematic block diagram of an example electronic device 1100 that can be used to implement an embodiment 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 processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.
[0207] like Fig.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. In the RAM 1103, various programs and data required for the operation of the device 1100 can also be stored. 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] A number of components in the device 1100 are connected to the I / O interface 1105, including: an input unit 1106, such as a keyboard, a mouse, etc.; an output unit 1107, such as various types of displays, speakers, etc.; a storage unit 1108, such as a disk, an optical disk, etc.; and a communication unit 1109, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 1109 allows the device 1100 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0209] The computing unit 1101 may 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 running 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 a large language model information processing method. For example, in some embodiments, the information processing method may 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 may 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 may 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 implementations of the systems and techniques described above 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), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including 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 may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0212] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may 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 may 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 may 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 with 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 may 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 the server are generally remote from each other and usually interact through a communication network. The relationship of client and server is generated by computer programs running on respective computers and having a client-server relationship with each other. The server may be a cloud server, a server of a distributed system, or a server combined with a blockchain.
[0216] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this disclosure can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and this document does not limit this.
[0217] The above specific implementations do not constitute a limitation on the protection scope of the present disclosure. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present disclosure shall be included in the protection scope of the present disclosure.
Claims
1. A method for information processing based on a large language model, wherein: The method comprises: Get the query request; Interacting with the large language model based on the query request to determine query conditions, sources of query results, and screening 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; The SQL statement is input into the large language model for execution to obtain a query result corresponding to the query request.
2. The method according to claim 1, wherein: The step of interacting with the large language model based on the query request to determine the query conditions, the source of the query results, and the screening fields for generating the SQL statement includes: Based on the query request, first guide information is generated, and the first guide information is input 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 building pattern statement of the candidate business table is extracted, and third guidance information is generated based on the table building pattern statement and the query request, and the third guidance information is input into the large language model to obtain the screening field.
3. The method according to claim 2, wherein: Before generating the second guide information based on the query request and the description information of the business table in the database, the method further includes: The configuration information of the database is acquired, and the description information of the service table is determined based on the configuration information.
4. The method according to claim 2, wherein: The generating 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 guide information.
5. The method according to any one of claims 2 to 4, wherein: The step of combining the query condition, the source of the query result and the filter field based on the large language model to generate the SQL statement includes: 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, 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 screening field, fourth guide information is generated, and the fourth guide information is input into the large language model to obtain the SQL statement.
6. The method according to claim 5, wherein: The generating of SQL statement reference examples at different levels based on the level information, the field default value and the source of the query result includes: Obtaining a preset candidate query request, and determining a target level of an object queried by the candidate query request; Determine a query condition example and a screening field example of 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.
7. The method according to claim 6, wherein: The generating fourth guidance information based on the SQL statement reference example and the hierarchical information, the query request and the screening field includes: The hierarchical information and the SQL statement reference example are used as the 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.
8. The method according to claim 5, wherein: The step of inputting the fourth guide 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.
9. The method according to claim 1, wherein: The step of 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.
10. The method according to claim 2, wherein: The step of 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.
11. An information processing device based on a large language model, comprising: A first acquisition module, used to acquire 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, the source of the query results and the screening fields for generating the SQL statement; A third acquisition module, configured to combine the query condition, the source of the query result and the screening field based on the large language model to generate the SQL statement; The execution module is used to input the SQL statement into the large language model for execution to obtain the query result corresponding to the query request.
12. The device according to claim 11, wherein The second acquisition module includes: Based on the query request, first guide information is generated, and the first guide information is input 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 building pattern statement of the candidate business table is extracted, and third guidance information is generated based on the table building pattern statement and the query request, and the third guidance information is input into the large language model to obtain the screening field.
13. The device according to claim 12, wherein: The second acquisition module further includes: The configuration information of the database is acquired, and the description information of the service table is determined based on the configuration information.
14. The device according to claim 12, 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 guide information.
15. The device according to any one of claims 12 to 14, wherein: The third acquisition module includes: 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, 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 screening field, fourth guide information is generated, and the fourth guide information is input into the large language model to obtain the SQL statement.
16. The device according to claim 15, 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; Determine a query condition example and a screening field example of 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.
17. The device according to claim 16, wherein: The third acquisition module includes: The hierarchical information and the SQL statement reference example are used as the 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.
18. The device according to claim 15, 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.
19. The device according to claim 11, wherein: The execution module comprises: 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.
20. The device according to claim 12, wherein: The execution module comprises: 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.
21. 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 10.
22. 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-10.
23. 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 10.
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
Business data query method, device and equipment and storage medium
CN112506946A
Structured query language statement generation method and device
CN113032417A
Dialogue system, method and device, electronic equipment and computer readable storage medium
CN113761138A
Cited By
SQL (Structured Query Language) statement processing method and device, electronic equipment and storage medium
CN120705166A
Query method and device based on large language model, equipment and medium
CN120821736A
A query method, device and equipment based on a large language model and a medium
CN120821736B