Large model-based data query and interaction method and program product

Through the data query and interaction method based on big models, the broadness of business intelligence products when understanding user intentions is solved, the accuracy and efficiency of data query are improved, and the user experience is improved.

CN119322821AInactive Publication Date: 2025-01-17HUNDSUN TECH

Patent Information

Application Number
CN202411875507.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-19
Publication Date
2025-01-17
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

Existing business intelligence products are too broad when understanding user intentions, resulting in reduced accuracy and efficiency of data queries and reduced user experience.

Method used

Using data query and interaction methods based on big models, user intentions are formed into prompts and condition fields through big models, vectorized table structure search, target table structure information is filtered, query syntax tree is generated, query instructions are constructed, and database is input to obtain targets. data, thereby generating replies information.

Benefits of technology

It realizes an accurate understanding of user intentions, improves the accuracy and interaction efficiency of data queries, and improves the user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119322821A_ABST
    Figure CN119322821A_ABST
Patent Text Reader

Abstract

According to the data query and interaction method based on the large model and the program product, the user intention forms the prompt and condition fields through the large model, then the vectorization table structure in the knowledge base is retrieved according to the prompt, and the query result is obtained. And screening the query results according to condition fields involved in the user intention to obtain target table structure information corresponding to the user intention. And constructing a query instruction so as to query target data corresponding to the target table structure information in a database. Therefore, accurate understanding of the user intention is realized, the accuracy and the interaction efficiency of the data result interacted with the large model are improved, and the use experience of the user is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of large model applications, and more specifically to a data query and interaction method and program product based on large models. Background Art

[0002] Business Intelligence (BI) products are a type of software tools and services used to help companies collect, manage and analyze data to provide decision support. The core goal of BI products is to transform data into actionable insights to help corporate management and decision makers make more informed decisions.

[0003] However, existing BI products tend to be broad in their understanding of user intent, resulting in reduced accuracy and efficiency of query data, further reducing the user experience of BI product data interaction. Summary of the invention

[0004] The purpose of this application is to provide a data query and interaction method and program product based on a large model, which is used to improve the accuracy and efficiency of query data.

[0005] In order to achieve the above purpose, the technical solution adopted in the embodiment of the present application is as follows: In a first aspect, an embodiment of the present application provides a data query and interaction method based on a large model, including: The user intention is formed into prompts and condition fields through a large model; the condition fields represent the user's screening needs; According to the prompts, the vectorized table structure in the knowledge base is searched to obtain the query results; Filter the query results according to the condition field to obtain target table structure information corresponding to the user intention; Generate a query syntax tree according to the target table structure information; the query syntax tree represents the syntax structure of the query instruction; Generate the query instruction according to the query syntax tree; Inputting the query instruction into a database to obtain target data corresponding to the target table structure information; Generate response information according to the target data and the query instruction.

[0006] Optionally, before the step of forming the user intention into prompts, condition fields and interaction requirement information through the big model, the method further includes: Preprocess the question information input by the user, complete and correct the question information in combination with the context, and obtain the user intention.

[0007] Optionally, the step of forming the user intention into prompt and condition fields through the large model includes: constructing the prompt according to the user intent; Keywords representing the screening requirements in the user intention are extracted to form the condition field.

[0008] Optionally, the step of filtering the query results according to the condition field to obtain target table structure information corresponding to the user intention includes: Obtaining the target field contained in the table structure information in the query result; Matching the target field with the condition field; If they match, the target field is used as the target table structure information; If they do not match, the target field is formatted according to the condition field so that the information of the formatted target field is consistent with the condition field; the information of the target field includes one or a combination of the following: the format of the target field, the unit of the target field or the value of the target field; The formatted target field is used as the target table structure information.

[0009] Optionally, also include: Using the formatted target field as the formatted field; generating explanation information according to the formatted field, the explanation information being used to indicate a target field to be formatted based on the conditional field; The step of generating reply information according to the target data and the query instruction comprises: Reply information is generated according to the target data, the query instruction and the explanation information.

[0010] Optionally, also include: Extracting keywords used to characterize the target interaction form from the user's intention to form the interaction demand information; the interaction demand information characterizes the user's target interaction form; The step of generating reply information according to the target data and the query instruction comprises: Generate response information having the target interaction form according to the target data, the query instruction and the interaction requirement information.

[0011] Optionally, before the step of forming the user intention into prompt and condition fields through the large model, the step further includes: Get the table structure information of each table in the database; Screening all the table structure information to obtain complete table structure information, fuzzy table structure information and / or formula information; Completing the fuzzy table structure information to obtain completed table structure information; Vectorizing the complete table structure information and the completed table structure information to form vectorized table structure knowledge in the knowledge base; The formula information is vectorized to form vectorized formula information knowledge in the knowledge base.

[0012] In a second aspect, the present application provides a data query and interaction device based on a large model. An extraction module is used to construct a prompt and a condition field from the user's intention; the condition field represents the user's screening requirements; A query module is used to retrieve the vectorized table structure in the knowledge base according to the prompt to obtain the query result; filter the query result according to the condition field to obtain the target table structure information corresponding to the user intention; generate a query syntax tree according to the target table structure information; the query syntax tree represents the syntax structure of the query instruction; generate the query instruction according to the query syntax tree; input the query instruction into the database to obtain the target data corresponding to the target table structure information; An output module is used to generate response information according to the target data and the query instruction.

[0013] In a third aspect, an embodiment of the present application provides an electronic device, including: A memory for storing one or more programs; processor; When the one or more programs are executed by the processor, the method as described in any one of the first aspects above is implemented.

[0014] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements a method as described in any one of the above-mentioned first aspects.

[0015] In a fifth aspect, an embodiment of the present application provides a program product, which, when executed by a processor, implements a method as described in any one of the above-mentioned first aspects.

[0016] Compared with the prior art, the data query and interaction method and program product based on the big model provided in the embodiment of the present application use the big model to form prompts and conditional fields for the user's intention, and then retrieve the vectorized table structure in the knowledge base according to the prompt to obtain the query result. And filter the query results according to the conditional fields involved in the user's intention to obtain the target table structure information corresponding to the user's intention. Then construct a query instruction to query the target data corresponding to the target table structure information in the database. Thereby achieving an accurate understanding of the user's intention, improving the accuracy of the data results and the interaction efficiency of the interaction with the big model, and thus providing the user with a better experience.

[0017] In order to make the above-mentioned objects, features and advantages of the present application more obvious and easy to understand, preferred embodiments are specifically cited below and described in detail with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0019] Figure 1 A schematic diagram of the architecture of data query and interaction based on a large model provided by an embodiment of the present invention; Figure 2 A flowchart of a data query and interaction method based on a large model provided by an embodiment of the present invention; Figure 3 A flowchart of another data query and interaction method based on a large model provided by an embodiment of the present invention; Figure 4 A flowchart of another data query and interaction method based on a large model provided by an embodiment of the present invention; Figure 5 A flowchart of another data query and interaction method based on a large model provided by an embodiment of the present invention; Figure 6 A flowchart of another data query and interaction method based on a large model provided by an embodiment of the present invention; Figure 7 A flowchart of another data query and interaction method based on a large model provided by an embodiment of the present invention; Figure 8 A schematic diagram of the architecture of data query and interaction based on a large model provided by an embodiment of the present invention; Fig. 9 A schematic diagram of a reply message provided by an embodiment of the present invention; Fig.10 A schematic diagram of a data query and interaction device based on a large model provided by an embodiment of the present invention; Fig.11 A schematic diagram of another large model-based data query and interaction device provided by an embodiment of the present invention; Fig.12 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0020] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. The components of the embodiments of the present application described and shown in the drawings here can be arranged and designed in various different configurations.

[0021] Therefore, the following detailed description of the embodiments of the present application provided in the accompanying drawings is not intended to limit the scope of the present application for which protection is sought, but merely represents selected embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without creative work are within the scope of protection of the present application.

[0022] It should be noted that similar reference numerals and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings. At the same time, in the description of this application, the terms "first", "second", etc. are only used to distinguish the description and cannot be understood as indicating or implying relative importance.

[0023] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0024] In view of the fact that the existing BI products have a relatively broad understanding of user intent, resulting in low accuracy and interaction efficiency of data results in subsequent interaction with large models. This application provides a data query and interaction mechanism based on large models, which can be optionally Figure 1 The schematic diagram of the architecture of data query and interaction based on the big model provided by the embodiment of the present invention is shown in FIG. Figure 1 The architecture includes: a database 100, a data processing module 101, a large model 102 and an interactive interface 103.

[0025] The database 100 may include one or more data storage systems for storing business data, such as different types of table data in financial scenarios.

[0026] The data processing module 101 is used to standardize data from different sources in the database 100 (e.g., table structure information of a table) to form a knowledge base containing vectorized table structures. The table structure information includes, but is not limited to, the Chinese and English names of the table, the Chinese and English descriptions of the table, the Chinese and English descriptions of the fields in the table, and the field types.

[0027] Furthermore, the interactive interface 103 is an interface for providing user input and response display.

[0028] The large model 102 is used to understand the user's intention, and then search the knowledge base based on the user's intention to obtain the corresponding query result. In this application, the query result is the table structure information required by the user's intention. In this application, the large model 102 constructs a query syntax tree based on the target table structure information, and then uses the query syntax tree to construct a query instruction. The query instruction is used to query the target data corresponding to the target table structure information in the database 100. Then, the target data is used to form the reply information, and the reply is displayed through the interactive interface 103.

[0029] Furthermore, in order to better display the query path of the large model 102 in the database 100 so that the user can obtain more detailed and multi-dimensional interaction results, the implementation of the present application can also display the query instruction as part of the reply information.

[0030] Combine the following Figure 1 , the data query and interaction method based on the big model provided by the present application is exemplified. Specifically, Figure 2 A flow chart of a data query and interaction method based on a large model provided by an embodiment of the present invention, see Figure 2 , the method comprising: Step 206: The user intention is structured into prompt and condition fields through the large model.

[0031] Specifically, the condition field represents the user's screening requirements.

[0032] Step 207: Search the vectorized table structure in the knowledge base according to the prompt to obtain the query result.

[0033] Step 208: Filter the query results according to the condition fields to obtain target table structure information corresponding to the user's intention.

[0034] Step 209: Generate a query syntax tree according to the target table structure information.

[0035] Specifically, the query syntax tree represents the syntax structure of the query instruction.

[0036] Step 210: Generate a query instruction according to the query syntax tree.

[0037] Step 211: Input the query instruction into the database to obtain the target data corresponding to the target table structure information.

[0038] Step 212: Generate response information based on the target data and the query instruction.

[0039] The embodiment of the present invention provides a data query and interaction method based on a big model. The big model is used to form prompts and conditional fields for user intentions, and then the vectorized table structure in the knowledge base is retrieved according to the prompts to obtain query results. The query results are screened according to the conditional fields involved in the user intentions to obtain the target table structure information corresponding to the user intentions. Then, a query instruction is constructed to query the target data corresponding to the target table structure information in the database. In this way, the user intentions can be accurately understood, the accuracy of the data results and the interaction efficiency of the interaction with the big model can be improved, and the user experience can be improved.

[0040] Optionally, since the question information input by the user may be incomplete, contain typos or missing words, in order to more accurately and comprehensively obtain the user's true intention. In a possible implementation, the input question information may be preprocessed. Figure 2 On the basis of Figure 3 A flow chart of another data query and interaction method based on a large model provided by an embodiment of the present invention, see Figure 3 , before step 206, further comprising: Step 205: pre-process the question information input by the user, complete and correct the question information in combination with the context, and obtain the user's intention.

[0041] For the above step 206, in order to facilitate understanding of the user's intention, the user's intention may be further divided. Figure 2 On the basis of Figure 4A flow chart of another data query and interaction method based on a large model provided by an embodiment of the present invention, see Figure 4 , step 206, comprising: Step 206 - 1 : extract keywords in the user's intention that are used to represent the screening requirements and form a condition field.

[0042] Step 206-2: Construct a prompt based on the user's intention.

[0043] In another possible implementation, the user intent includes the user's filtering conditions for the data in the table, such as the time range, amount, field value, etc. Based on these conditions, the data in the database may be inconsistent. Therefore, before querying the target data of a specific table, it is necessary to filter the conditions in the user intent and the query results obtained through the knowledge base. The following is a possible implementation. Specifically, in Figure 2 On the basis of Figure 5 A flow chart of another data query and interaction method based on a large model provided by an embodiment of the present invention, see Figure 5 , step 208, comprising: Step 208-1: Obtain the target field included in the table structure information in the query result.

[0044] Step 208-2: Match the target field with the condition field.

[0045] Specifically, if there is no match, execute step 208 - 3 ; if there is a match, use the target field as the target table structure information and execute step 209 .

[0046] Step 208-3: Format the target field according to the condition field so that the information of the formatted target field is consistent with the condition field.

[0047] The target field information includes one or a combination of the following: the format of the target field, the unit of the target field, or the value of the target field. For formatting, you can use the "formatting plug-in, which is specifically used to process the conditional fields in the user's intention, such as time, amount, or field value. The plug-in unifies the expression entered by the user with the format, unit, and value required by the database table field, ensuring that the query instructions generated subsequently fully match the expected input of the database, thereby improving the accuracy of the query instructions.

[0048] Step 208-4: Use the formatted target fields as target table structure information.

[0049] In a possible implementation, since the target field is formatted in step 208, the corresponding target field may be changed, such as format, unit, etc. Therefore, in order to intuitively reflect this change to the user, the change may be included as part of the reply information. Figure 5 , also includes: Step 208-5: Use the formatted target field as the formatted field.

[0050] Step 208-6: Generate explanation information based on the formatted fields.

[0051] Specifically, the explanation information is used to indicate a target field to be formatted based on the conditional field.

[0052] Correspondingly, step 212 includes: Step 212-1: Generate reply information based on target data, query instructions and explanation information.

[0053] Optionally, in another possible implementation, the user's intention may include a form requirement for the reply information, for example, the user wishes to present the queried data in the form of a bar chart. Therefore, in order to more accurately present the reply information that matches the user's intention, specifically, Figure 4 On the basis of Figure 6 A flow chart of another data query and interaction method based on a large model provided by an embodiment of the present invention, see Figure 6 , step 206, further comprising: Step 206 - 3 : extract keywords in the user's intention that are used to characterize the target interaction form, and form interaction demand information.

[0054] Among them, the interaction demand information represents the user's target interaction form.

[0055] Correspondingly, step 212 includes: Step 212-2: Generate response information in a target interactive format according to the target data, query instructions, and interaction requirement information.

[0056] Combination Figure 1 It can be seen that the present application involves the need to establish a knowledge base for the table structure information of the table in the database, and a possible implementation method is provided below to exemplify the establishment of the knowledge base. It can be completed before the process steps of the above method example. Figure 7 A flow chart of another data query and interaction method based on a large model provided by an embodiment of the present invention, see Figure 7 , the method comprising: Step 200: Obtain table structure information of each table in the database.

[0057] Step 201: Screen all table structure information to obtain complete table structure information, fuzzy table structure information and / or formula information.

[0058] Specifically, for the table data contained in the database, there may be incomplete information such as field meaning, data value, format, structure, etc., or the meaning may be unclear. Therefore, based on this situation, the present application selects it separately, that is, fuzzy table structure information, so as to complete its information in step 202.

[0059] For example, the fuzzy table structure information includes: last year's second quarter, net income, greater than 500,000; if the user's question is to query: last year's second quarter, the 10S234 product net income greater than 500,000 sellers information. Obviously, the specific table structure meaning of the fuzzy table structure information is not clear, and it cannot be confirmed whether it meets the user's question. Therefore, in the stage of building the knowledge base, after the fuzzy table structure information is screened out, the fuzzy table structure information can be completed based on the business scenario to which the table belongs, the product information corresponding to the business, the time and the specific meaning of the field.

[0060] Step 202: Complete the fuzzy table structure information to obtain the completed table structure information.

[0061] Step 203: vectorize the complete table structure information and the completed table structure information to form vectorized table structure knowledge in the knowledge base.

[0062] Step 204: vectorize the formula information to form vectorized formula information knowledge in the knowledge base.

[0063] Combined with the above examples, the following provides a possible implementation of the architecture of data query and interaction based on a large model. Specifically, Figure 1 On the basis of Figure 8 The schematic diagram of the architecture of data query and interaction based on the big model provided by the embodiment of the present invention is shown in FIG. Figure 8 , this architecture provides a specific implementation of a method for data query and interaction based on a large model: First, the data processing module 101 constructs a knowledge base based on the table data stored in the database 100 .

[0064] The specific method is to obtain the table structure definition in the database 100, that is, the table structure information. The table structure information includes but is not limited to: the Chinese and English names of the table, the Chinese and English descriptions of the table, the Chinese and English descriptions of the fields contained in the table, and the field types, etc. Optionally, the following Table 1 provides an example of table structure information:

[0065] Table 1: Example of table structure information Furthermore, combined with the previous Figure 7 The example shown is to filter the table structure. The complete table structure information and the completed table structure information are vectorized to construct the "vectorized table structure" part in the knowledge base, that is, the "vectorized table structure knowledge" described above.

[0066] In the case where the table structure information involves formulas, the formula information is extracted through screening and stored in the form of a formula document. The formula document contains the fields and formulas in the table structure information. Then, the "vectorized formula document" part of the knowledge base is constructed based on the formula document. That is, the "vectorized formula information knowledge" described above.

[0067] During the interaction between the user and the large model, the original user intention input by the user is first obtained based on the interaction interface 103 .

[0068] Furthermore, in order to better understand the user's true intention, the user's input can be preprocessed. The preprocessing completes and corrects the question information input by the user through the context to obtain the user's intention.

[0069] Then, the user intent is split into prompts, condition fields, and interaction requirement information. Optionally, the Retrieval-Augmented Generation (RAG) technology can be used to split the above three parts of information.

[0070] Optionally, when using the RAG technology, keywords related to prompts, conditional fields, and interaction requirement information in the intent may be extracted first, and then prompts, conditional fields, and interaction requirement information may be constructed based on the keywords.

[0071] The prompt is used to input the knowledge base and retrieve the table structure information related to the user's intention. Optionally, if the table structure information involves a formula, the "vectorized formula document" will also be queried to obtain the corresponding formula information.

[0072] Optionally, the formula information can be maintained record by record, such as "net income = income - expenditure", and a separate formula or term explanation is stored in a field for subsequent retrieval and recall. In addition, there is no restriction on the search order of "vectorized formula information knowledge" and "vectorized table structure knowledge" in the knowledge base.

[0073] Therefore, the "query result set" fed back by the knowledge base may include one or more table structure information. In the case of formula information, it also includes the corresponding public information. Optionally, an example of a query result set is provided below: User input: View the information of sellers whose net income of 10S234 product was greater than 500,000 in the second quarter of last year The following is the formula information returned by the search: { "table":{ "tbtranscfm":["prd_code", "cfm_date", "seller_code", "selling_amt", "income_amt"], "tbsellerinfo:["seller_code", "seller_name"] }, "tableRelationship":[ tbtranscfm.seller_code = tbsellerinfo.seller_code ], "condition":[ "tbtranscfm.prd_code='10S234'", "tbtranscfm.income_amt-tbtranscfm.selling_amt>=Net income is greater than 500,000", "tbtranscfm.cfm_date = last year's second quarter" ], diffField:[ "tbtranscfm.cfm_date", "tbtranscfm.income_amt", "tbtranscfm.selling_amt" ], knowledge:[ "Net income = total income - total sales" ] } Furthermore, the condition field defines the user's query conditions and data filtering requirements. Therefore, the target field in the "query result set" can be matched based on the condition field. If the match is successful, it means that the target field meets the user's intended requirements. If the match is unsuccessful, it means that the target field does not meet the user's intended requirements. Among them, this dissatisfaction may mean: inconsistent format, inconsistent unit, etc.

[0074] Therefore, it is necessary to format the unmatched target fields to improve the accuracy of subsequent query instructions. In a possible implementation, a formatting plug-in may be used to unify the unmatched target fields, such as format, unit and value.

[0075] For example, the user inputs: "Look at the information of sellers whose net income of product 10S234 was greater than 500,000 in the second quarter of last year." According to the user's input, the confirmation time (format yyyyMMdd), income, and sales (unit: RMB) fields in the database will be matched. According to the big model, the filter value information in the user input is extracted, including "second quarter of last year" and "greater than 500,000." Through the formatting plug-in, "second quarter of last year" can be converted into: confirmation time>=20230401 and confirmation time<=20230630; and "greater than 500,000" can be converted into: income-sales>=500000.

[0076] Based on the formatted target field, a query syntax tree can be constructed. Taking Structured Query Language (SQL) as an example, the JSON format of the constructed SQL syntax tree structure is as follows: { "table": { "Table 1": [the query field corresponding to Table 1...], "Table 2": [the query field corresponding to Table 2...], … }, "tableRelationship'":[ Table 1. Field 1 = Table 2. Field 2, … ], 'condition":[ Condition field 1, Condition field 2, … ] "diffField":[ Formatted field 1, Formatted field 2, … ] } It should be noted that, for the above example of the SQL syntax tree structure, the "formatted field" is used to indicate which fields need to be formatted and converted. The formatting target can be indicated by the "condition field". For example, the condition field indicates: US dollars; the "formatted field" is marked as RMB. This means that the "RMB" in the "formatted field" is formatted as "US dollars".

[0077] Then, the SQL statement to be detected is generated based on the SQL syntax tree structure. Then, in order to adapt to different types of database syntax and its boundary rules in the database, in a possible implementation, the SQL statement to be detected is checked and syntax corrected by a syntax detector.

[0078] Optionally, the syntax detector is modified as follows: SQL statement to be tested: SELCT name, age, FROM users WHERE age>20 AND; After correction, the correct SQL statement is: SELECT name, age FROM users WHERE age>20; The correct SQL statement corrected by the syntax detector is input as a query instruction into the database 100 to perform data query to obtain the target data.

[0079] At this time, based on the user's interactive demand information, for example, the user wants to display the target data in the form of a bar chart, table, etc., the target data is converted into graphical data. Then, the explanation information composed of the formatted fields and the correct SQL statement are combined to form the reply information, and then the reply is displayed through the interactive interface 103.

[0080] Optional, Fig. 9 A schematic diagram of a reply information provided by an embodiment of the present invention shows the display of the reply information in the interactive interface 103. The user's question is: how much is the sales of each commodity category in 2023? Then, after the target data is queried, a graphical data display can be performed based on the interactive demand information, such as Fig. 9 The bar chart shown in . Furthermore, since the query statement involves the user's query conditions, that is, the condition field mentioned above. Therefore, based on the query statement, the reasoning of the query process can be explained, such as Fig. 9As shown: "According to the requirements, the sales of each commodity category in 2023 are to be queried. The tables involved include the retail example table. Grouping and aggregation are performed by the commodity category field, and data with a time year equal to 2023 is selected. The result will return the commodity category and 2023 sales fields."

[0081] Optionally, see above. If formatting occurs in the large model processing, the formatted information will also be explained in the above example, for example, the unit is adjusted from RMB to USD.

[0082] Continue to see Fig. 9 In addition to explaining the information, it can also provide further interactive interfaces, such as "view SQL code", to specifically display the specific implementation details of the query instruction. For another example, for the display form of graphical data, an interactive interface can be provided so that users can adjust it based on their needs, such as adjusting from a bar chart to a pie chart, a table, etc.

[0083] In the embodiment of the present application, the SQL syntax JSON tree structure application is introduced: the innovative use of JSON-based tree data structure to accurately represent the tables, fields and conditions in the SQL query significantly improves the generation accuracy and readability of SQL statements, while enhancing the maintainability of query statements. At the same time, combined with RAG technology, it can more accurately understand the user's natural language input, realize conversational analysis, and make the data analysis process more intuitive and convenient, similar to daily chat. And through technical means such as automatic completion of typos, refined metadata management, filter value formatting processing, and built-in syntax detector plug-in, this technology significantly improves the accuracy and executability of generated SQL statements, reduces data acquisition problems caused by SQL errors, and improves the stability and reliability of the system.

[0084] Optionally, the present application also provides a data query and interaction device based on a large model, which can be used to execute each step of the above example to achieve the corresponding technical effect. Specifically, Fig.10 A schematic diagram of a data query and interaction device based on a large model provided by an embodiment of the present invention, see Fig.10 The device 30 includes: an extraction module 300, a query module 301 and an output module 302.

[0085] The extraction module 300 is used to construct the user intention into prompts and condition fields; the condition fields represent the user's screening requirements.

[0086] The query module 301 is used to retrieve the vectorized table structure in the knowledge base according to the prompt to obtain the query results; filter the query results according to the condition field to obtain the target table structure information corresponding to the user's intention; generate a query syntax tree according to the target table structure information; the query syntax tree represents the grammatical structure of the query instruction; generate a query instruction according to the query syntax tree; input the query instruction into the database to obtain the target data corresponding to the target table structure information.

[0087] The output module 302 is used to generate response information according to the target data and the query instruction.

[0088] Optionally, the extraction module 300 is further used to pre-process the question information input by the user, complete and correct the question information in combination with the context, and obtain the user's intention.

[0089] The extraction module 300 is specifically used to construct prompts according to user intentions; extract keywords in the user intentions that are used to characterize screening requirements to form condition fields.

[0090] Optionally, the query module 301 is specifically used to obtain the target field included in the table structure information in the query result; match the target field with the condition field; if they match, use the target field as the target table structure information; if they do not match, format the target field according to the condition field so that the information of the formatted target field is consistent with the condition field; and use the formatted target field as the target table structure information.

[0091] The output module 302 is further used to use the formatted target field as the formatted field; generate explanation information according to the formatted field; and generate reply information according to the target data, the query instruction and the explanation information.

[0092] Optionally, the extraction module 300 is further used to extract keywords in the user's intention that are used to characterize the target interaction form, and constitute interaction demand information.

[0093] Correspondingly, the output module 302 is specifically used to generate reply information with a target interaction form according to the target data, query instructions and interaction demand information.

[0094] In a possible implementation, the device may also construct a knowledge base. Fig.10 On the basis of Fig.11 A schematic diagram of another data query and interaction device based on a large model provided by an embodiment of the present invention, see Fig.11 , the device also includes: a construction module 303.

[0095] Construction module 303 is used to obtain the table structure information of each table in the database; screen all the table structure information to obtain complete table structure information, fuzzy table structure information and / or formula information; complete the fuzzy table structure information to obtain the completed table structure information; vectorize the complete table structure information and the completed table structure information to form vectorized table structure knowledge in the knowledge base; vectorize the formula information to form vectorized formula information knowledge in the knowledge base.

[0096] The embodiment of the invention further provides an electronic device, which can execute all the steps of the above examples of the embodiment of the invention to achieve the corresponding technical effects. Specifically, Fig.12 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention, see Fig.12 , the electronic device 50, comprises: a memory 501, a processor 500; Memory 501, used to store one or more programs; Processor 500; When one or more programs are executed by the processor, when the electronic device 50 is used to execute the steps shown in the above-mentioned method examples, it can achieve each step and the corresponding technical effects.

[0097] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely schematic. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the devices, methods and computer program products according to the multiple embodiments of the present application. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of the code, and a part of the module, program segment or code contains one or more executable instructions for implementing the specified logical functions. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of boxes in the block diagram and / or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.

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

[0099] If the function is implemented in the form of a software function module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a program product, which is stored in a computer-readable storage medium and includes a number of instructions for a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, and other media that can store program codes.

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

[0101] It will be apparent to those skilled in the art that the present application is not limited to the details of the exemplary embodiments described above, and that the present application can be implemented in other specific forms without departing from the spirit or essential features of the present application. Therefore, the embodiments should be considered exemplary and non-limiting in all respects, and the scope of the present application is defined by the appended claims rather than the above description, and it is intended that all changes falling within the meaning and scope of the equivalent elements of the claims be included in the present application. Any reference numeral in a claim should not be considered as limiting the claim to which it relates.

Claims

1. A data query and interaction method based on a large model, characterized in that: include: The user intent is structured into prompt and condition fields through a large model; The condition field represents the user's screening requirements; According to the prompts, the vectorized table structure in the knowledge base is searched to obtain the query results; Filter the query results according to the condition field to obtain target table structure information corresponding to the user intention; Generate a query syntax tree according to the target table structure information; The query syntax tree represents the syntax structure of the query instruction; Generate the query instruction according to the query syntax tree; Inputting the query instruction into a database to obtain target data corresponding to the target table structure information; Generate response information according to the target data and the query instruction.

2. The method according to claim 1, characterized in that The step of forming the user intention into prompt and condition fields through the big model includes: constructing the prompt according to the user intent; Keywords representing the screening requirements in the user intention are extracted to form the condition field.

3. The method according to claim 1, characterized in that The step of filtering the query results according to the condition field to obtain target table structure information corresponding to the user intention includes: Obtaining the target field contained in the table structure information in the query result; Matching the target field with the condition field; If they match, the target field is used as the target table structure information; If they do not match, the target field is formatted according to the condition field so that the information of the formatted target field is consistent with the condition field; the information of the target field includes one or a combination of the following: the format of the target field, the unit of the target field or the value of the target field; The formatted target field is used as the target table structure information.

4. The method according to claim 3, characterized in that Also includes: Using the formatted target field as the formatted field; generating explanation information according to the formatted field, the explanation information being used to indicate a target field to be formatted based on the conditional field; The step of generating reply information according to the target data and the query instruction comprises: Reply information is generated according to the target data, the query instruction and the explanation information.

5. The method according to claim 1, characterized in that Also includes: Extracting keywords used to characterize the target interaction form from the user intention to form the interaction demand information; The interaction requirement information represents the target interaction form of the user; The step of generating reply information according to the target data and the query instruction comprises: Generate response information having the target interaction form according to the target data, the query instruction and the interaction requirement information.

6. The method according to claim 1, characterized in that Before the step of forming the user intention into prompt and condition fields through the large model, it also includes: Get the table structure information of each table in the database; Screening all the table structure information to obtain complete table structure information, fuzzy table structure information and / or formula information; Completing the fuzzy table structure information to obtain completed table structure information; Vectorizing the complete table structure information and the completed table structure information to form vectorized table structure knowledge in the knowledge base; The formula information is vectorized to form vectorized formula information knowledge in the knowledge base.

7. A data query and interaction device based on a large model, characterized in that: An extraction module, used to construct a prompt and a condition field from the user's intention; the condition field represents the user's screening requirements; A query module is used to search the vectorized table structure in the knowledge base according to the prompt to obtain the query result; Filter the query results according to the condition field to obtain target table structure information corresponding to the user intention; Generate a query syntax tree according to the target table structure information; The query syntax tree represents the syntax structure of the query instruction; Generate the query instruction according to the query syntax tree; Inputting the query instruction into a database to obtain target data corresponding to the target table structure information; An output module is used to generate response information according to the target data and the query instruction.

8. An electronic device, characterized in that: include: A memory for storing one or more programs; processor; When the one or more programs are executed by the processor, the method according to any one of claims 1 to 6 is implemented.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.

10. A program product, characterized in that When the program product is executed by a processor, the method according to any one of claims 1 to 6 is implemented.

Citation Information

Patent Citations

  • BI query method, apparatus and device based on NL2SQL and medium

    CN113656540A

  • Question processing method and device based on large language model, equipment and storage medium

    CN117407513A

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

    CN117827886A

  • SQL (Structured Query Language) statement generation method and device, equipment and storage medium

    CN117931843A

  • Library query system, method and equipment based on information retrieval and large model and medium

    CN118733611A

Cited By

  • Intelligent interaction method and system of NL2API based on LLM

    CN121958642A