Data query method and device and related product
Through intelligent query agents and large models, the problem of low data query efficiency and accuracy in the field of advertising and marketing is solved, and efficient and accurate data query is achieved.
Patent Information
- Application Number
- CN202510085019.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-20
- Publication Date
- 2025-04-15
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The prior art is less efficient and accurate in data queries in the field of advertising marketing, especially for those who are not familiar with structured query languages or professionals who need to spend a lot of time and effort to construct query statements.
Through intelligent query agents and large models, handle the problem to be queryed by users input, generate accurate structured query statements, and query operations in the specified data table to obtain query results.
It significantly improves the efficiency and accuracy of data query, avoiding the difficulty of users to construct query statements on their own and inaccurate situations caused by human understanding deviations.
Smart Images

Figure CN119829609A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the fields of advertising and marketing technology and computer technology, and in particular to a data query method, device and related products. Background Art
[0002] In today's digital age, companies and organizations are increasingly dependent on data. In the field of advertising and marketing, relevant practitioners (such as data analysts) often need to find specific information from massive amounts of advertising data to support decision-making, analyze trends or solve problems.
[0003] In order to query the required data from the delivery data, the data is generally screened manually. However, the manual method has low efficiency and accuracy. With the widespread application of database technology, querying the required delivery data by constructing structured query statements has become a new idea for data query. However, this query method also has some defects. First, for people who are not familiar with structured query language, they cannot independently construct query statements on demand to query data. Secondly, even if relevant practitioners are familiar with structured query language, it takes a certain amount of time and effort to construct query statements; moreover, due to the deviation in the understanding of the data table structure and business logic, the query statement itself may be inaccurate. It can be seen that there is still room for further improvement in query efficiency and accuracy in the method of querying data through query statements. Summary of the invention
[0004] In view of the above situation, the embodiments of the present disclosure provide a data query method, device and related products, aiming to solve the above problems or at least partially solve the above problems.
[0005] In a first aspect, an embodiment of the present disclosure provides a data query method, the method comprising:
[0006] Obtain the query question input by the user and the query delivery data table selected by the user;
[0007] Generate a first target prompt word through an intelligent query agent according to the query question, the table name and column name of the delivery data table to be queried, and the first initial prompt word used when constructing the intelligent query agent;
[0008] Using the first target big model called by the intelligent query agent, the first target prompt word and the to-be-queried delivery data table are processed to generate a structured query statement;
[0009] The structured query statement is used to perform a query operation in the to-be-queried delivery data table to obtain a query result.
[0010] In a second aspect, an embodiment of the present disclosure further provides a data query device, the device comprising:
[0011] The acquisition module is used to obtain the query question input by the user and the delivery data table to be queried selected by the user;
[0012] A first generating module, configured to generate a first target prompt word through an intelligent query agent according to the query question, the table name and column name of the delivery data table to be queried, and the first initial prompt word used when constructing the intelligent query agent;
[0013] A second generation module is used to process the first target prompt word and the to-be-queried delivery data table by using the first target large model called by the intelligent query agent to generate a structured query statement;
[0014] The query module is used to use the structured query statement to perform a query operation in the to-be-queried delivery data table to obtain a query result.
[0015] In a third aspect, an embodiment of the present disclosure further provides an electronic device, comprising: a processor; and a memory arranged to store computer executable instructions, wherein the executable instructions, when executed, cause the processor to execute the steps of the above-mentioned data query method.
[0016] By means of the above technical solution, the data query method, device and related products provided by the embodiments of the present disclosure can effectively solve the above problems existing in querying data using query statements. Specifically, the present disclosure uses a large model called by an intelligent query agent to process the query questions input by the user, and generates an accurate structured query statement; using the structured query statement, a query is performed in the data table to be queried to obtain the query results. It can be seen that the solution provided by the embodiments of the present disclosure does not require the user to construct the query statement himself, and avoids the situation where the query statement is inaccurate due to human understanding deviation, thereby significantly improving the efficiency and accuracy of data queries.
[0017] The above description is only an overview of the technical solution of the present disclosure. In order to more clearly understand the technical means of the present disclosure, it can be implemented according to the contents of the specification. In order to make the above and other purposes, features and advantages of the present disclosure more obvious and easy to understand, the specific implementation methods of the present disclosure are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] The drawings described herein are used to provide a further understanding of the present disclosure and constitute a part of the present disclosure. The illustrative embodiments of the present disclosure and their descriptions are used to explain the present disclosure and do not constitute an improper limitation on the present disclosure. In the drawings:
[0019] Figure 1A schematic diagram of an application environment of the data query method provided by an embodiment of the present disclosure is shown;
[0020] Figure 2 A schematic diagram of a data query method provided by an embodiment of the present disclosure is shown;
[0021] Figure 3 A schematic diagram showing the structure of a data query device provided by an embodiment of the present disclosure is shown;
[0022] Figure 4 A schematic structural diagram of an electronic device provided by an embodiment of the present disclosure is shown. DETAILED DESCRIPTION
[0023] In order to make the purpose, technical solutions and advantages of the present disclosure clearer, the technical solutions of the present disclosure will be clearly and completely described below in combination with the specific embodiments of the present disclosure and the corresponding drawings. Obviously, the described embodiments are only part of the embodiments of the present disclosure, not all of the embodiments. Based on the embodiments in the present disclosure, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present disclosure.
[0024] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, further definition and explanation thereof is not required in subsequent drawings.
[0025] It should be noted that the terms "first", "second", etc. in the specification and claims of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that such usage is interchangeable where appropriate, so that the embodiments of the present disclosure described herein can be implemented in an order other than those illustrated or described herein. In addition, the term "including" and its variants are to be interpreted as open-ended terms meaning "including but not limited to".
[0026] As mentioned above, there are some defects in querying the required delivery data by constructing structured query statements. First, for people who are not familiar with structured query language, they cannot independently construct query statements on demand to query data. Secondly, even if relevant practitioners are familiar with structured query language, it takes a certain amount of time and effort to construct query statements; moreover, due to deviations in the understanding of data table structure and business logic, the query statement itself may be inaccurate. Based on this, the present invention proposes a data query method, device and related products, and the present disclosure is described in detail below through specific embodiments.
[0027] To facilitate understanding of this embodiment, the data query method disclosed in the embodiment of the present disclosure is first described in detail. The data query method provided in the embodiment of the present disclosure can be applied to Figure 1 In an application environment, the client communicates with the server through a network. The server can receive the query question input by the user and the delivery data table to be queried selected by the user through the client; through the intelligent query agent, according to the query question, the table name and column name of the delivery data table to be queried, and the first initial prompt word used when constructing the intelligent query agent, generate a first target prompt word; use the first target large model called by the intelligent query agent to process the first target prompt word and the delivery data table to be queried to generate a structured query statement; use the structured query statement to perform a query operation in the delivery data table to be queried, obtain the query result and return it to the client. Among them, the client can be but not limited to various personal computers, laptops, smart phones and tablets. The server is generally a computer device with a certain computing power, and the computer device includes, for example: a terminal device or a server or other processing device, wherein the terminal device can be a user equipment (UserEquipment, UE), a mobile device, a user terminal, a terminal, a personal digital assistant (PersonalDigitalAssistant, PDA), a handheld device, a computing device, etc. The server can be implemented by an independent server or a server cluster composed of multiple servers. In some possible implementations, the method may be implemented by a processor calling a computer-readable instruction stored in a memory. The present invention is described in detail below through specific embodiments.
[0028] Figure 2 A schematic diagram of the data query method provided by the embodiment of the present disclosure is shown. Figure 2 It can be seen that the embodiment of the present disclosure at least includes steps S201-S204:
[0029] S201: Obtain the query question input by the user and the delivery data table to be queried selected by the user.
[0030] In this embodiment, the query question is a type of question that aims to obtain specific and clear information. This type of question focuses on finding a specific data item, such as the exact value of a specific field in a record, or retrieving data records that meet a certain established, single condition (such as a specific time range, a specific name identifier, etc.). The answer can often be obtained by directly searching and matching the corresponding data content. For example, the query question is "Which delivery channel has the highest purchase volume?"
[0031] This embodiment does not limit the method for obtaining the question to be queried. For example, the user can enter the question to be queried in a web form, a search box, or an input box in a mobile application, and then send it to the server deployed with the method provided by the embodiment of the present disclosure through a network request. The user can also use an intelligent voice device, such as an intelligent speaker, a voice assistant, etc. to input the question to be queried by voice, and the voice data is converted into text data and sent to the server.
[0032] This embodiment does not limit the source of the delivery data table to be queried, and it may be a delivery data table received through other e-commerce platform interfaces, or it may be a delivery data table uploaded by a user.
[0033] S202: Generate a first target prompt word through an intelligent query agent according to the query question, the table name and column name of the query delivery data table, and the first initial prompt word used when constructing the intelligent query agent.
[0034] It should be noted that an intelligent agent can be understood as a program that can automatically perform some target tasks without human intervention and has high intelligence and autonomous learning. The disclosed embodiment does not limit the specific type of intelligent query agent. Exemplarily, the intelligent query agent is implemented using the create_sql_agent plug-in in the open source framework LangChain library.
[0035] The first initial prompt includes: task role and task description. For example, the first initial prompt is "Your role is a data analyst and senior database expert in the field of advertising and marketing. You need to accurately generate corresponding structured query statements based on the data query questions raised by users to query the given delivery data table." Then the first target prompt is "Your role is a data analyst and senior database expert in the field of advertising and marketing. You need to accurately generate corresponding structured query statements based on the data query questions raised by users: Question A to be queried to query the given delivery data table (table names include A1 and A1, column names include B1, B2, B3, B4) to query the given delivery data table."
[0036] S203: Using the first target big model called by the intelligent query agent, the first target prompt word and the to-be-queried delivery data table are processed to generate a structured query statement.
[0037] The first target large model is any large language model, which is not limited in this embodiment. For example, the first target large model is GPT-4O (Generative Pretrained Transformer-4o), Gemini2.0 flash exp model (Google's experimental multimodal AI model), etc.
[0038] S204: Using the structured query statement, a query operation is performed in the to-be-queried delivery data table to obtain a query result.
[0039] The disclosed embodiment can effectively solve the above-mentioned problems existing in querying data using query statements. Specifically, the disclosed embodiment uses the large model called by the intelligent query agent to process the query questions input by the user, and generates an accurate structured query statement; using the structured query statement, query is performed in the table of data to be queried to obtain the query results. It can be seen that the solution provided by the disclosed embodiment does not require the user to construct the query statement himself, and avoids the situation where the query statement is inaccurate due to human understanding deviation, thereby significantly improving the efficiency and accuracy of data query.
[0040] Furthermore, in order to better illustrate the process of the above data query method, as a refinement and extension of the above embodiment, the embodiment of the present invention provides several embodiments, but is not limited thereto, which are specifically as follows.
[0041] Through research, it is found that in actual application scenarios, the first target large model will respond to various questions to be queried and the delivery data tables to be queried, which may cause the model to hallucinate and generate query statements containing fabricated table names or column names, thereby causing query failure. Based on this, in some embodiments of the present disclosure, the first initial prompt word also includes a table name constraint condition, which is used to instruct the first target large model to generate a query statement that meets the first preset condition, and the first preset condition is a set consisting of all table names in the query statement, which is a subset of the set consisting of the table names of each delivery data table to be queried.
[0042] Exemplarily, the table name constraint in the first initial prompt word is "all table names involved in the query statement must and can only be selected from the table names of the delivery data table given by the user, and no other irrelevant table names may appear."
[0043] This embodiment adds a table name constraint to the first initial prompt word, so that the first target prompt word can accurately guide the first target large model to construct a query statement using only the table name of the table selected by the user, thereby reducing the uncertainty caused by model hallucinations, significantly reducing the probability of query failure due to table name errors, and making the data query process more stable and reliable.
[0044] In some embodiments, the first initial prompt word also includes a column name constraint condition, and the column name constraint condition is used to instruct the first target large model to generate a query statement that meets a second preset condition. The second preset condition is a set consisting of all column names in the query statement, which is a subset of the set consisting of column names of each of the data tables to be queried.
[0045] Exemplarily, the column name constraint in the first initial prompt is "all column names involved in the query statement must and can only be selected from the column names of the delivery data table given by the user, and no other irrelevant column names may appear."
[0046] This embodiment can effectively standardize the selection range of column names when the first target large model generates query statements, avoid the model introducing non-existent or irrelevant column names due to its own hallucinations, ensure the accuracy and effectiveness of the query statements, and make the data query process more stable and reliable.
[0047] In some embodiments, the method further includes: standardizing the column names in the delivery data table to be queried according to a preset column name mapping relationship to obtain a new delivery data table to be queried; generating a first target prompt word through an intelligent query agent according to the question to be queried, the table name and column name of the delivery data table to be queried, and the first initial prompt word used when constructing the intelligent query agent, including: generating the first target prompt word according to the question to be queried, the table name and column name of the new delivery data table to be queried, the first initial prompt word, and the structural data of the new delivery data table to be queried; wherein the structural data includes: the definition of each column name in the new delivery data table to be queried, and the corresponding column name positioning parameter set, and the structural data is stored in a preset knowledge base.
[0048] In this embodiment, the mapping relationship between the column names in the delivery data tables from different sources and the customized standardized column names can be determined in advance, which can be achieved by establishing a mapping table or a configuration file, etc. Then, according to the preset column name mapping relationship, the original column names of the delivery data table to be queried are modified into standardized column names to obtain a new delivery data table to be queried.
[0049] When constructing the first target prompt word, the structural data of the new delivery data table to be queried can be added on the basis of the question to be queried, the table name and column name of the new delivery data table to be queried, and the first initial prompt word, so as to improve the accuracy of the first target big model's understanding of the delivery data. Here, the structural data is stored in a preset knowledge base, and the structural data includes: the definition of each column name in the new delivery data table to be queried and the column name positioning parameter set corresponding to each column name. Among them, the column name positioning parameter set contains one or more nouns. These nouns are like "clue words". When the user asks a question to be queried, if the nouns in the set appear in the question, the big model can quickly determine that the question involves the column corresponding to this set.
[0050] For example, assuming that there is a column name "Processor Interface" in the new data table to be queried, the structural data includes the definition data of the column name "Processor Interface" and a column name positioning parameter set, the definition data is: the processor socket type supported by the server, and the column name positioning parameter set includes: LGA3647, SP3, SP5.
[0051] It can be seen that this embodiment eliminates the confusion and differences of column names of data from different sources by standardizing the column names in the delivery data table to be queried, making the data structure clearer and more standardized. On this basis, when constructing the first target prompt word, the column name definition and column name positioning parameter set of the new delivery data table to be queried are added, so that the first target large model can better understand the structure and content of the new delivery data table to be queried, thereby more accurately capturing key data, quickly generating analysis results that are more in line with user needs, and significantly improving the reliability and practicality of the query results.
[0052] In some embodiments of the present disclosure, the preset knowledge base also includes a delivery data question-answer pair; the question in the delivery data question-answer pair is a sample question to be queried, and the answer in the delivery data question-answer pair is a structured query statement corresponding to the sample question to be queried; the method also includes: performing similarity matching on the question to be queried with each sample question to be queried in the delivery data question-answer pair to obtain the most similar question; generating a first target prompt word through an intelligent query agent according to the question to be queried, the table name and column name of the delivery data table to be queried, and the first initial prompt word used when constructing the intelligent query agent, includes: generating a first target prompt word through an intelligent query agent according to the question to be queried, the table name and column name of the delivery data table to be queried, the structured query statement corresponding to the most similar question, and the first initial prompt word used when constructing the intelligent query agent.
[0053] In this embodiment, the preset knowledge base also includes delivery data question-answer pairs. For example, the question in a delivery data question-answer pair is "What is the number of clicks for this delivery plan?" The answer is "select clicks from table1 where delivery plan = *".
[0054] During implementation, after obtaining the question to be queried, the question to be queried is first matched with the sample question to be queried in each data question-answer pair for similarity to obtain the most similar user question. Specifically, for example, the question to be queried and each sample question to be queried can be converted into a vector in a vector space, and the cosine value of the angle between the vector of the question to be queried and the vector of each sample question to be queried is calculated. The closer the cosine value is to 1, the more similar the two questions are. Finally, the sample question to be queried corresponding to the cosine value closest to 1 is taken as the most similar question.
[0055] Then, through the intelligent query agent, the first target prompt word is generated according to the question to be queried, the table name and column name of the delivery data table to be queried, the structured query statement corresponding to the most similar question, and the first initial prompt word used when building the intelligent query agent. Finally, the first target large model is used to process the first target prompt word and the delivery data table to be queried to generate a structured query statement; the structured query statement is used to perform a query operation in the delivery data table to be queried to obtain the query result.
[0056] The sample questions to be queried in the question-answer pair in this embodiment represent the common demand patterns of users when querying the delivery data table. The most similar questions are found through similarity matching, and the structured query statements corresponding to the most similar questions are referred to to generate the first target prompt words that are more in line with user needs, so that the large model can generate more accurate structured query statements, and then more accurately guide subsequent data queries.
[0057] Through research, it is found that in actual application scenarios, simply presenting a query result is relatively thin and cannot more intuitively and comprehensively display the meaning and value behind the data to meet the user's understanding and application needs of the data. Based on this, in some embodiments of the present disclosure, the method further includes steps S205-S208:
[0058] S205: Generate a second target prompt word through the intelligent data analysis agent according to the question to be queried and the second initial prompt word used when constructing the intelligent data analysis agent.
[0059] S206: Using the second target macro model called by the intelligent data analysis agent, the second target prompt word and the query result are processed to generate analysis results in the form of pictures or tables.
[0060] S207: Using the analysis result as the chart image to be analyzed, and generating chart analysis prompt words according to the query question to be queried, the query result, and the storage address of the chart image to be analyzed.
[0061] S208: Utilizing the third target large model, analyzing prompt words according to the chart, and generating a picture analysis result.
[0062] This embodiment does not limit the specific type of the intelligent data analysis agent. Exemplarily, the intelligent data analysis agent is constructed by calling the interface of the create_pandas_dataframe_agent plug-in in the open source framework LangChain library. This embodiment does not limit the second target large model, which can be any large language model.
[0063] During implementation, the second target prompt word can be generated first according to the question to be queried and the second initial prompt word. Among them, the second initial prompt word includes: task role and task description. Exemplarily, the second initial prompt word is "Your role is a data analysis and chart generation expert, who can accurately understand user needs. According to the user's question to be queried and the given query results, use data visualization tools to generate intuitive and appropriate charts, and accurately mark key information and data in the charts." Then the second target prompt word is "Your role is a data analysis and chart generation expert, who can accurately understand user needs. According to the user's question to be queried "What is the personnel structure of the company's department?" and the given query results, use data visualization tools to generate intuitive and appropriate charts, and accurately mark key information and data in the charts."
[0064] Finally, the second target prompt word and the query result are input into the second target large model to generate the analysis result in the form of a picture or a table. In specific implementation, the query result can be saved and managed using a data structure such as DataFrame provided by the pandas library in the Python programming language.
[0065] Here, the third target large model is any large language model with multimodal information processing capabilities. Exemplarily, the third target large model is the GLM-4V-Plus model (a multimodal AI model launched by Zhipu AI, focusing on image and video understanding).
[0066] In the specific implementation, for example, let the question to be queried be question 1, the storage address of the chart image to be analyzed be address 1, and the chart analysis prompt be: Please refer to the question to be queried entered by the user: question 1, and the query result given by AI: query result 1. By analyzing the graphic or table content under storage address 1, the analysis result for question 1 is generated.
[0067] This embodiment can convert simple query results into intuitive analysis results in the form of pictures or tables, thereby improving the application value of data, helping users quickly understand the meaning and value behind the data, and accurately discovering potential information. And on the basis of obtaining the picture or table analysis results, based on the user's query questions and the analysis results in the form of charts, the third target large model is used to generate picture analysis results. By performing simple text analysis on the analysis results in the form of charts, users can quickly understand and apply data, greatly improving the efficiency and accuracy of information transmission.
[0068] In some embodiments of the present disclosure, the method further includes:
[0069] S209: Generate a third target prompt word according to the query question, the query result, the image analysis result and the third initial prompt word through an intelligent data analysis agent;
[0070] S210: Using the second target macro model, the third target prompt word is processed to generate a depth analysis result.
[0071] During implementation, first generate the third target prompt word based on the question to be queried, the query result, the image analysis result and the third initial prompt word. Among them, the third initial prompt word includes: task role and task description. Exemplarily, the third initial prompt word is "Your role is a senior data analyst who can accurately understand user needs. Please give in-depth analysis results for the data table to be queried based on the user's question to be queried, the given query results, and the image analysis results." Suppose the question to be queried is question A, the query result is query result B, and the image analysis result is analysis result C, then the third target prompt word is "Your role is a senior data analyst who can accurately understand user needs. Please give in-depth analysis results for the data table to be queried based on the user's question A, the given query result B, and the analysis result C."
[0072] Finally, the third target prompt word is processed using the second target large model to obtain the in-depth analysis results.
[0073] This embodiment uses the second target large model to generate in-depth analysis results, achieve in-depth mining and accurate analysis of relevant delivery information, and provide more valuable reference for decision-making or further research.
[0074] In practice, it is found that the image analysis results or depth analysis results generated by the intelligent data analysis agent may be in a foreign language, which brings great inconvenience to the user's reading and understanding. Based on this, in some embodiments of the present disclosure, if the image analysis result or the depth analysis result is described in a non-target language, a preset translation interface is called to translate the image analysis result or the depth analysis result, and the translation result is used as the final image analysis result or the final depth analysis result.
[0075] This embodiment does not limit the translation interface. For example, the translation interface is an interface corresponding to the GLM.4.PLUS model (a large-scale base model launched by Zhipu AI, which aims to provide more intelligent and efficient language processing services). Using this interface, the image analysis results or in-depth analysis results can be reflectively translated to obtain translation results. Exemplarily, if the image analysis results are described in English, the translation interface can be called to translate the image analysis results to obtain new image analysis results described in Chinese.
[0076] This embodiment can automatically translate the image analysis results or the depth analysis results to generate analysis content that the user can understand, thereby breaking the language barrier and significantly enhancing the user experience.
[0077] The present disclosure also provides a data query method, including the following steps S1-S13:
[0078] Step S1: Obtain the query question input by the user and the delivery data table to be queried selected by the user.
[0079] In specific implementation, if there are multiple tables of delivery data to be queried, the multiple tables of delivery data to be queried can be merged first to avoid the appearance of the same columns.
[0080] The query question may also be a recommended question selected by the user, which may be a question expanded from the query question previously input by the user using the large model, or a question obtained from a preset knowledge base. Here, the preset knowledge base stores one or more related questions in advance for each column.
[0081] Step S2: According to the preset column name mapping relationship, the column names in the to-be-queried delivery data table are standardized to obtain a new to-be-queried delivery data table.
[0082] Step S3: perform similarity matching between the question to be queried and each sample question to be queried in the delivery data question-answer pairs stored in the preset knowledge base to obtain the most similar question.
[0083] Step S4: Generate a first target prompt word according to the question to be queried, the table name and column name of the new delivery data table to be queried, the structured query statement corresponding to the most similar question, the first initial prompt word, and the structural data of the new delivery data table to be queried.
[0084] In specific implementation, the first initial prompt word includes the task role and task description as well as the constraint conditions, where the constraint conditions include the table name constraint conditions and the column name constraint conditions. The structural data is stored in the preset knowledge base, including: the definition of each column name in the new to-be-queried delivery data table and the corresponding column name positioning parameter set. The preset knowledge base can respond to the user's new operations on the front end, and continuously update the knowledge such as the column name, the column name positioning parameters corresponding to the column name, and related questions in the library.
[0085] In some embodiments, the column name location parameter set can be expanded with the help of a large model. In specific implementation, the prompt word input by the user can be obtained from the front end. For example, the prompt word is "The column name is the processor interface, and the column name location parameter set includes: LGA 3647, SP3, SP5. Please expand the column name location parameter set." According to the prompt word, the large model outputs the expanded column name location parameter as "Socket AM4, TRX40 / sTRX40, WRX80, Socket FM2+". The expanded column name location parameter is added to the original column name location parameter set. The large model is usually trained with a large amount of data and can cover a wide range of knowledge fields. In this embodiment, with the help of the large model, the column name location parameter set is expanded, and more words that may appear in the query question (including some uncommon words) can be included in the set in a timely manner, thereby further improving the accuracy of the first target large model in understanding the query question, and then obtaining more accurate query results. At the same time, the use of the large model to achieve automatic expansion significantly improves the expansion efficiency.
[0086] Step S5: using the first target large model called by the intelligent query agent, the first target prompt word and the to-be-queried delivery data table are processed to generate a structured query statement.
[0087] Step S6: Use a structured query statement to perform a query operation in the to-be-queried delivery data table to obtain a query result.
[0088] Step S7: Generate a second target prompt word through the intelligent data analysis agent according to the query question and the second initial prompt word used when constructing the intelligent data analysis agent.
[0089] Step S8: Using the second target large model called by the intelligent data analysis agent, the second target prompt words and query results are processed to generate a chart image to be analyzed.
[0090] Step S9: Generate chart analysis prompt words according to the query question, query results, and storage address of the chart image to be analyzed.
[0091] Step S10: calling the GLM-4V-Plus model, analyzing the prompt words according to the chart, and generating the picture analysis results.
[0092] Step S11: Generate a third target prompt word according to the query question, the query result, the image analysis result and the third initial prompt word.
[0093] Step S12: using the second target large model, the third target prompt word is processed to generate a deep analysis result.
[0094] Step S13: If the image analysis result or the depth analysis result is described in a foreign language, the GLM.4.PLUS model is called to translate the image analysis result or the depth analysis result, and the translated result described in Chinese is used as the final image analysis result or the final depth analysis result.
[0095] In the data preprocessing stage, this embodiment standardizes the column names of the data table according to the preset column name mapping relationship, lays a unified and standardized foundation for subsequent query and analysis, and improves the accuracy and efficiency of data processing. In the query statement generation process, by matching the similarity between the question to be queried and the sample question in the preset knowledge base, a corresponding structured query statement is obtained, and the table name, column name, structure data and the first initial prompt word of the new data table to be queried are combined to generate an accurate first target prompt word. The prompt word provides strong support for the intelligent query agent to call the first target large model to generate a structured query statement, ensuring the accuracy and pertinence of the query. Using the generated structured query statement, the query operation is quickly executed in the data table to be queried, and the required query results are accurately obtained, realizing efficient data retrieval. In the data analysis stage, the intelligent data analysis agent generates a second target prompt word based on the question to be queried and the second initial prompt word, and then processes the prompt word and the query result with the help of the second target large model to generate an intuitive chart or picture to be analyzed, presenting complex data in a visual form for easy user understanding. It also generates chart analysis prompts based on the query questions, query results, and storage addresses of the chart images to be analyzed, and calls the multimodal interface to generate image analysis results, further interpreting the chart information in depth, and providing users with a more comprehensive data analysis perspective. Subsequently, the third target prompt is generated by combining the query questions, query results, image analysis results, and the third initial prompt, and the second target large model is used again for processing to obtain in-depth analysis results, mining data value from multiple dimensions, and providing in-depth reference for user decision-making. Finally, if the image analysis results or in-depth analysis results are described in a foreign language, they are translated and the translated Chinese results are used as the final output, eliminating language barriers and ensuring that users can obtain and understand the analysis results without obstacles.
[0096] It can be seen that this embodiment realizes the full process automation from data query to in-depth analysis, and then to result presentation and language translation through multi-step collaboration and multi-model cooperation, providing users with accurate information in various forms such as text query results, charts, and chart analysis results, fully meeting the various needs of users in the process of delivery data processing, and greatly facilitating users' understanding of delivery data and application decisions.
[0097] Those skilled in the art will appreciate that, in the above method of the specific implementation manner, the writing order of the steps does not mean a strict execution order, but does not constitute any limitation on the implementation process. The specific execution order of the steps should be determined by their functions and possible internal logic.
[0098] It should be noted that, in practical applications, all the above possible implementation methods can be combined in any way to form possible embodiments of the present disclosure, which will not be described one by one here. The information (including but not limited to device information, user information, etc.) and data (including but not limited to data for analysis, storage and display, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties. The software tools or components appearing in the embodiments of the present disclosure are only examples and do not represent actual use.
[0099] Based on the same concept, the embodiment of the present disclosure further provides a data query device, which corresponds one-to-one to the data query method in the above embodiment. Figure 3 A schematic diagram of the structure of the data query device provided by the embodiment of the present disclosure is shown. Figure 3 As shown, the data query device 300 provided in the embodiment of the present disclosure includes:
[0100] The acquisition module 301 is used to acquire the question to be queried input by the user and the delivery data table to be queried selected by the user.
[0101] The first generation module 302 is used to generate a first target prompt word through an intelligent query agent according to the question to be queried, the table name and column name of the delivery data table to be queried, and the first initial prompt word used when constructing the intelligent query agent.
[0102] The second generation module 303 is used to utilize the first target large model called by the intelligent query agent to process the first target prompt word and the to-be-queried delivery data table to generate a structured query statement.
[0103] The query module 304 is used to use the structured query statement to perform a query operation in the to-be-queried delivery data table to obtain a query result.
[0104] In some embodiments, in the above-mentioned device, the first initial prompt word also includes a table name constraint condition, and the table name constraint condition is used to instruct the first target large model to generate a query statement that meets a first preset condition, and the first preset condition is a set consisting of all table names in the query statement, which is a subset of the set consisting of the table names of each of the data tables to be queried.
[0105] In some embodiments, in the above-mentioned device, the first initial prompt word also includes a column name constraint condition, and the column name constraint condition is used to instruct the first target large model to generate a query statement that meets a second preset condition, and the second preset condition is a set consisting of all column names in the query statement, which is a subset of the set consisting of column names of each of the data tables to be queried.
[0106] In some embodiments, the device further comprises a standardization module, which is used to standardize the column names in the to-be-queried delivery data table according to a preset column name mapping relationship to obtain a new to-be-queried delivery data table;
[0107] The first generating module 302 is used to generate the first target prompt word according to the query question, the table name and column name of the new delivery data table to be queried, the first initial prompt word, and the structural data of the new delivery data table to be queried; wherein the structural data includes: the definition of each column name in the new delivery data table to be queried, and the corresponding column name positioning parameter set, and the structural data is stored in a preset knowledge base.
[0108] In some embodiments, in the device, the preset knowledge base also includes a delivery data question and answer pair; the question in the delivery data question and answer pair is a sample question to be queried, and the answer in the delivery data question and answer pair is a structured query statement corresponding to the sample question to be queried; the device also includes a matching module, which is used to: perform similarity matching on the question to be queried with each sample question to be queried in the delivery data question and answer pair, respectively, to obtain the most similar question; a first generation module 302, which is used to: generate a first target prompt word through an intelligent query agent according to the question to be queried, the table name and column name of the delivery data table to be queried, the structured query statement corresponding to the most similar question, and the first initial prompt word used when constructing the intelligent query agent.
[0109] In some embodiments, the device also includes a chart analysis module, which is used to: generate a second target prompt word through an intelligent data analysis agent according to the question to be queried and the second initial prompt word used when constructing the intelligent data analysis agent; use the second target big model called by the intelligent data analysis agent to process the second target prompt word and the query result to generate an analysis result in the form of a picture or a table; use the analysis result as a chart image to be analyzed; generate a chart analysis prompt word according to the question to be queried, the query result, and the storage address of the chart image to be analyzed; use the third target big model to generate a picture analysis result according to the chart analysis prompt word.
[0110] In some embodiments, the device also includes a deep analysis module, which is used to: generate a third target prompt word based on the question to be queried, the query result, the image analysis result and the third initial prompt word through an intelligent data analysis agent; and use the second target large model to process the third target prompt word to generate a deep analysis result.
[0111] In some embodiments, if the image analysis result is described in a non-target language, the device also includes a translation module for calling a preset translation interface to translate the image analysis result or the depth analysis result, and using the translation result as the final image analysis result or the final depth analysis result.
[0112] The present invention provides a data query device that can effectively solve the above-mentioned problems existing in querying data using query statements. Specifically, the embodiment of the present disclosure uses a large model called by an intelligent query agent to process the query questions input by the user, and generates an accurate structured query statement; using the structured query statement, a query is performed in the table of data to be queried to obtain the query result. It can be seen that the solution provided by the embodiment of the present disclosure does not require the user to construct the query statement himself, and avoids the situation where the query statement is inaccurate due to human understanding deviation, thereby significantly improving the efficiency and accuracy of data query.
[0113] For the specific definition of the data query device, please refer to the definition of the data query method above, which will not be repeated here. Each module in the above-mentioned data query device can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[0114] Figure 4 FIG. 1 shows a schematic diagram of the structure of an electronic device provided by an embodiment of the present disclosure. Figure 4 As shown, at the hardware level, the electronic device includes a processor, and optionally also includes an internal bus, a network interface, and a memory. Among them, the memory may include a memory, such as a high-speed random access memory (RAM), and may also include a non-volatile memory (non-volatile memory), such as at least one disk storage, etc. Of course, the electronic device may also include hardware required for other services.
[0115] The processor, network interface and memory can be interconnected through an internal bus, which can be an ISA (Industry Standard Architecture) bus, a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 4Only one bidirectional arrow is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0116] The memory is used to store programs. Specifically, the program may include program code, and the program code includes computer operation instructions. The memory may include internal memory and non-volatile memory, and provides instructions and data to the processor.
[0117] The processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it, forming a data query device at the logical level. The processor executes the program stored in the memory and is specifically used to execute the above method.
[0118] The processor may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by an integrated logic circuit of hardware in the processor or an instruction in the form of software. The above processor may be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it may also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The disclosed methods, steps and logic block diagrams in the embodiments of the present disclosure may be implemented or executed. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc. The steps of the method disclosed in conjunction with the embodiments of the present disclosure may be directly embodied as being executed by a hardware decoding processor, or may be executed by a combination of hardware and software modules in a decoding processor. The software module may be located in a mature storage medium in the field such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory, and the processor reads the information in the memory and completes the steps of the above method in combination with its hardware.
[0119] The electronic device can execute the data query method provided by the embodiments of the present disclosure, and realize the data query device in Figure 3 The functions of the illustrated embodiments will not be described in detail in the embodiments of the present disclosure.
[0120] The embodiments of the present disclosure also provide a computer-readable storage medium, which stores one or more programs, and the one or more programs include instructions, which, when executed by an electronic device including multiple application programs, can enable the electronic device to execute the data query method provided by multiple embodiments of the present disclosure.
[0121] Those skilled in the art will appreciate that the embodiments of the present disclosure may be provided as methods, systems, or computer program products. Therefore, the present disclosure may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present disclosure may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0122] The present disclosure is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present disclosure. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0123] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0124] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0125] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0126] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0127] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape, disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0128] The embodiments of the present disclosure also provide a computer program product, which carries a program code. The instructions included in the program code can be used to execute the steps of the data query method described in the above method embodiment. For details, please refer to the above method embodiment, which will not be repeated here.
[0129] The computer program product may be implemented in hardware, software or a combination thereof. In one optional embodiment, the computer program product is implemented as a computer storage medium. In another optional embodiment, the computer program product is implemented as a software product, such as a software development kit (SDK).
[0130] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity 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, commodity or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the presence of other identical elements in the process, method, commodity or device including the element.
[0131] It will be appreciated by those skilled in the art that the embodiments of the present disclosure may be provided as methods, systems or computer program products. Therefore, the present disclosure may take the form of a complete hardware embodiment, a complete software embodiment or an embodiment combining software and hardware. Moreover, the present disclosure may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0132] The above are only embodiments of the present disclosure and are not intended to limit the present disclosure. For those skilled in the art, the present disclosure may have various modifications and variations. Any modification, equivalent substitution, improvement, etc. made within the spirit and principle of the present disclosure shall be included in the scope of the claims of the present disclosure.
Claims
1. A data query method, characterized in that: The method comprises: Obtain the query question input by the user and the query delivery data table selected by the user; Generate a first target prompt word through an intelligent query agent according to the query question, the table name and column name of the delivery data table to be queried, and the first initial prompt word used when constructing the intelligent query agent; Using the first target big model called by the intelligent query agent, the first target prompt word and the to-be-queried delivery data table are processed to generate a structured query statement; The structured query statement is used to perform a query operation in the to-be-queried delivery data table to obtain a query result.
2. The method according to claim 1, characterized in that The first initial prompt word also includes a table name constraint condition, and the table name constraint condition is used to instruct the first target large model to generate a query statement that meets the first preset condition. The first preset condition is a set consisting of all table names in the query statement, which is a subset of the set consisting of the table names of each of the data tables to be queried.
3. The method according to claim 1, characterized in that The first initial prompt word also includes a column name constraint condition, and the column name constraint condition is used to instruct the first target large model to generate a query statement that meets the second preset condition. The second preset condition is a set consisting of all column names in the query statement, which is a subset of the set consisting of the column names of each of the data tables to be queried.
4. The method according to claim 1, characterized in that: The method further comprises: According to the preset column name mapping relationship, the column names in the to-be-queried delivery data table are standardized to obtain a new to-be-queried delivery data table; The method of generating a first target prompt word by the intelligent query agent according to the query question, the table name and column name of the query delivery data table, and the first initial prompt word used when constructing the intelligent query agent includes: Generate the first target prompt word according to the query question, the table name and column name of the new delivery data table to be queried, the first initial prompt word, and the structural data of the new delivery data table to be queried; The structural data includes: the definition of each column name in the new delivery data table to be queried and the corresponding column name positioning parameter set, and the structural data is stored in a preset knowledge base.
5. The method according to claim 4, characterized in that The preset knowledge base also includes delivery data question-answer pairs; the questions in the delivery data question-answer pairs are sample questions to be queried, and the answers in the delivery data question-answer pairs are structured query statements corresponding to the sample questions to be queried; The method further comprises: Performing similarity matching between the to-be-queried questions and each sample to-be-queried question in the delivery data question-answer pair, and obtaining the most similar question; The method of generating a first target prompt word by the intelligent query agent according to the query question, the table name and column name of the query delivery data table, and the first initial prompt word used when constructing the intelligent query agent includes: Through the intelligent query agent, a first target prompt word is generated according to the question to be queried, the table name and column name of the data table to be queried, the structured query statement corresponding to the most similar question, and the first initial prompt word used when constructing the intelligent query agent.
6. The method according to any one of claims 1 to 5, characterized in that: The method further comprises: Generate a second target prompt word through an intelligent data analysis agent according to the query question and a second initial prompt word used when constructing the intelligent data analysis agent; Using the second target large model called by the intelligent data analysis agent, the second target prompt word and the query result are processed to generate analysis results in the form of pictures or tables; Using the analysis result as a chart image to be analyzed; Generate a chart analysis prompt word according to the query question, the query result, and the storage address of the chart image to be analyzed; The third target large model is used to generate image analysis results based on the chart analysis prompt words.
7. The method according to claim 6, characterized in that The method further comprises: Generate a third target prompt word through an intelligent data analysis agent according to the query question, the query result, the image analysis result and the third initial prompt word; The third target prompt word is processed using the second target large model to generate a deep analysis result.
8. The method according to claim 7, characterized in that If the image analysis result or the depth analysis result is described in a non-target language, a preset translation interface is called to translate the image analysis result or the depth analysis result, and the translation result is used as the final image analysis result or the final depth analysis result.
9. A data query device, characterized in that: The device comprises: The acquisition module is used to obtain the query question input by the user and the delivery data table to be queried selected by the user; A first generating module, configured to generate a first target prompt word through an intelligent query agent according to the query question, the table name and column name of the delivery data table to be queried, and the first initial prompt word used when constructing the intelligent query agent; A second generation module is used to process the first target prompt word and the to-be-queried delivery data table by using the first target large model called by the intelligent query agent to generate a structured query statement; The query module is used to use the structured query statement to perform a query operation in the to-be-queried delivery data table to obtain a query result.
10. An electronic device, comprising: processor; as well as A memory arranged to store computer executable instructions, wherein when the executable instructions are executed, the processor is caused to perform the steps of the method according to any one of claims 1 to 8.
Citation Information
Patent Citations
Structured query language statement generation method and device, equipment and storage medium
CN118363977A
Database query method and device, electronic equipment and storage medium
CN118779315A
Interactive target statistical analysis method, device, equipment, medium and product
CN119025571A