Data query method and device, electronic equipment and storage medium
By determining the indicators and metadata for matching query information for information extraction and processing, and generating query statements to be executed, the problems of low data query efficiency and strong manual dependence in the prior art are solved, and efficient and accurate data query is achieved.
Patent Information
- Application Number
- CN202411230684.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-03
- Publication Date
- 2025-02-07
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
In the prior art, data query efficiency is low and has strong artificial dependence, resulting in limited accuracy and efficiency of data analysis.
By determining the indicators and metadata that match the query information, performing information extraction processing, and generating query statements to be executed, thereby quickly and accurately obtaining the query results.
It improves the efficiency and accuracy of data query, reduces manual dependency, and reduces the probability of incorrect data being queried.
Smart Images

Figure CN119396873A_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of data query technology, and in particular, relates to a data query method, device, electronic device and computer-readable storage medium. Background Art
[0002] The business data table of an enterprise refers to a table used to record the internal business data of the enterprise. It is the main basis for enterprise managers to analyze the operational efficiency, economic benefits, etc. of the enterprise. Before analyzing the business data, it is usually necessary to accurately query the required data from the business data table of the database through a structured query language to ensure that the subsequent analysis can be based on correct data.
[0003] Currently, query information from user questions is usually converted into structured query statements through manual writing to perform data query, which is inefficient and highly dependent on manual work. Summary of the invention
[0004] The embodiments of the present application provide a data query method, device, electronic device and storage medium, which can improve data query efficiency.
[0005] In a first aspect, an embodiment of the present application provides a data query method, including:
[0006] Determine the index that matches the acquired query information and obtain the index to be queried;
[0007] Determine metadata matching the query information to obtain metadata to be queried;
[0008] Performing information extraction processing on the query information according to the to-be-queried index and the to-be-queried metadata to obtain a to-be-queried data factor, wherein the to-be-queried data factor is used to reflect a data screening condition when performing a data query corresponding to the query information;
[0009] A query statement to be executed is generated based on the data factor to be queried, and a query result corresponding to the query information is obtained based on the query statement to be executed.
[0010] In a second aspect, an embodiment of the present application provides a data query device, including:
[0011] The module for determining the index to be queried is used to determine the index matching the acquired query information and obtain the index to be queried;
[0012] A module for determining metadata to be queried, used to determine metadata matching the query information, and obtain the metadata to be queried;
[0013] A module for determining factors of data to be queried, used for performing information extraction processing on the query information according to the indicators to be queried and the metadata to be queried, to obtain factors of data to be queried, wherein the factors of data to be queried are used to reflect data screening conditions when performing data query corresponding to the query information;
[0014] The query module is used to generate a query statement to be executed based on the data factor to be queried, and obtain a query result corresponding to the query information based on the query statement to be executed.
[0015] In a third aspect, an embodiment of the present application provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the data query method described in the first aspect when executing the computer program.
[0016] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the data query method described in the first aspect are implemented.
[0017] In a fifth aspect, an embodiment of the present application provides a computer program product. When the computer program product is run on an electronic device, the electronic device executes the data query method described in the first aspect above.
[0018] Compared with the prior art, the embodiments of the present invention have the following beneficial effects:
[0019] In an embodiment of the present application, after obtaining the query information, the indicators that match the query information and the metadata that match the query information are first determined to obtain the indicators to be queried and the metadata to be queried. Since the determined indicators to be queried can indicate the data to be queried, and the metadata to be queried can reflect information such as the content and attributes of the data related to the query information, therefore, information extraction processing is performed on the query information based on the indicators to be queried and the metadata to be queried, which is equivalent to fully extracting information from the query information in combination with the information of the data to be queried and the data related to the query information, so as to obtain a data factor to be queried with higher accuracy. Furthermore, the query statement to be executed generated based on the data query factor can quickly and accurately query the query result corresponding to the query information, without the need to manually analyze the query information and write query statements, thereby effectively reducing manual dependence and improving the efficiency of data query. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art are briefly introduced below.
[0021] Figure 1It is a flowchart of a data query method provided by an embodiment of the present application;
[0022] Figure 2 It is a flowchart of another data query method provided in an embodiment of the present application;
[0023] Figure 3 is a structural diagram of a data query device provided in an embodiment of the present application;
[0024] Figure 4 It is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0025] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.
[0026] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, integers, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or combinations thereof.
[0027] It should also be understood that the term “and / or” used in the specification and appended claims refers to and includes any and all possible combinations of one or more of the associated listed items.
[0028] In addition, in the description of the present application specification and the appended claims, the terms "first", "second", "third", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance.
[0029] References to "one embodiment" or "some embodiments" etc. described in the specification of this application mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Therefore, the phrases "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. appearing in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways.
[0030] Embodiment 1:
[0031] Figure 1A schematic diagram of a data query method provided by an embodiment of the present invention is shown, and is described in detail as follows:
[0032] Step S101, determining an indicator that matches the acquired query information, and obtaining an indicator to be queried.
[0033] The above indicators refer to a series of quantitative or qualitative standards used to measure the efficiency and effectiveness of an organization, team or individual in achieving a goal or achieving a specific purpose. For example, enterprise-related indicators include sales, profit margins and revenue growth rates.
[0034] Optionally, the query information may be information input by a user through a client or the like, or may be automatically generated information.
[0035] For example, assuming that the above data query method is applied to the server, the server obtains the query information entered by the user on the client, and after obtaining the corresponding query result, returns the query result to the client for display. For another example, assuming that a report task is set on the server: generating the sales of major categories of goods on that day at 23:00 every day, when the report task is triggered at 23:00, the server can obtain the automatically generated query information: query the sales of major categories of goods on that day.
[0036] In the embodiment of the present application, in order to improve the accuracy of data query, after obtaining the query information, the indicators matching the query information are first determined to obtain the indicators to be queried, so as to understand the data to be queried through the indicators to be queried.
[0037] Step S102: determine metadata matching the query information to obtain metadata to be queried.
[0038] The metadata is information describing the characteristics, content, context, structure, etc. of the data. The metadata in the embodiment of the present application describes the information of the related attributes of the indicator, including but not limited to the dimensions of the indicator and the dimension values corresponding to different dimensions.
[0039] For example, the dimensions corresponding to the indicators may include region, store, major category of goods, minor category of goods, product brand, sales amount, sales volume and statistical date; the dimension value corresponding to each dimension includes the specific value corresponding to the dimension. For example, the specific values corresponding to the major category of fruits may include berries, melons, oranges, stone fruits and pome fruits, etc., and the specific values corresponding to the stores may include Tianhong 01, Tianhong 02 and Junshang 3019, etc., that is, the identification of each store (such as the name that can uniquely identify the store).
[0040] It should be noted that the dimensions corresponding to different indicators may be different, and the dimensions corresponding to each indicator can be pre-defined. For example, for the indicator of labor cost, the corresponding dimensions can be defined as follows: business format, region, city, city level, store, store nature, store code, labor cost and statistical date, etc.
[0041] It should be pointed out that when inputting query information, influenced by personal habits, the user may use abbreviations and other methods to describe the information related to dimensions and dimension values, and when directly generating corresponding query statements or directly identifying the metadata in the query information through semantic recognition and other methods, some information may be ignored or even erroneous information may be identified. Therefore, in some embodiments, each dimension and the dimension value corresponding to the dimension may be pre-stored, and metadata matching the query information may be found based on the stored data to ensure that the metadata corresponding to the query information can be accurately determined, which is conducive to improving the accuracy of data query.
[0042] For example, suppose the query information is: What is the sales volume of berries in Jun Shang 3019 in May 2024? If a query statement is generated directly based on the query information, the sales volume of berries in Jun Shang store in May 2024 will be mistakenly queried based on the query information, that is, 3019 will be ignored and the sales volume of berries in all Jun Shang stores in May 2024 will be queried.
[0043] To ensure the accuracy of the query, the query information is matched with the pre-stored metadata, and the dimensions that can be queried include: Jun Shang, and its specific dimension value is: Jun Shang 3019. The metadata to be queried is: Jun Shang 3019, so that when performing subsequent queries, it can be clearly determined that the query is: the sales of berries in store Jun Shang 3019 in May 2024.
[0044] For another example, suppose the query information is: What is the profit margin of Baogou Center in June 2024; directly identifying based on the semantics of the query information will identify the store as: Baogou Center, but in fact, matching the query information with the pre-stored metadata, it can be determined that the metadata matching the query information includes the store, and the specific dimension value of the store is: Baoan Shopping Center. If a query is based on the incorrectly identified "Baogou Center", usually no relevant data can be queried or wrong data can be queried. However, based on the metadata to be queried "Baoan Shopping Center", the correct data can be accurately queried.
[0045] In an embodiment of the present application, metadata matching the query information is found from various metadata, that is, dimensions and / or dimension values existing in the query information are found, and used as the metadata to be queried, so that the scope of the data to be queried can be further refined in combination with the metadata to be queried, thereby improving the accuracy of the final query result.
[0046] Step S103, extracting information from the query information according to the query index and the query metadata to obtain a query data factor, wherein the query data factor is used to reflect a data screening condition when querying data corresponding to the query information.
[0047] Data factors refer to variables or attributes that affect data results. The above-mentioned data factors to be queried can reflect the data screening conditions when performing data queries corresponding to the query information based on information such as variables or attributes that affect data query results.
[0048] Optionally, when performing information extraction processing on the query information, the query information can be first segmented to obtain the corresponding multiple words, and then each of the obtained words can be matched with the indicators to be queried, and each of the obtained words can be matched with the metadata to be queried, so as to fully extract the information in the query information that matches the indicators to be queried and the metadata to be queried, and determine the data factors to be queried with higher accuracy.
[0049] In the embodiment of the present application, since the indicator to be queried can reflect the data to be queried, and the metadata to be queried can reflect the information of the data related to the data to be queried, therefore, by performing information extraction processing on the query information according to the indicator to be queried and the metadata to be queried, it is possible to fully extract the information related to the indicator to be queried and the metadata to be queried in the query information, better determine the screening conditions when performing data query, avoid missing useful information in the query information, and obtain a data factor to be queried with higher accuracy.
[0050] Step S104: generating a query statement to be executed based on the data factor to be queried, and obtaining a query result corresponding to the query information based on the query statement to be executed.
[0051] Optionally, the query statement to be executed may be generated by natural language processing or manual writing.
[0052] Since the data factors to be queried reflect the data screening conditions when performing data query, after generating the corresponding query statement to be executed according to the data factors to be queried, the query statement to be executed can be used to quickly and accurately screen the required data from the corresponding data source and obtain a query result with higher accuracy.
[0053] In some embodiments, after obtaining the query results based on the query statement to be executed, the appropriate chart type can be determined based on the query information and the query results (for example, when the query result is a development trend, a line chart can be selected as the appropriate chart type), and then a corresponding chart can be generated based on the query results to effectively display the query results through intuitive charts.
[0054] In some embodiments, after obtaining the query results, a comprehensive analysis may be performed on the query information, the to-be-queried index determined during the query process, the to-be-queried metadata, and the query results obtained by the query, to generate summary information including the query results, and then present the summary information to the user. Optionally, the summary includes but is not limited to trend analysis, index analysis, and development suggestions.
[0055] In some embodiments, when the query results include multiple data related to numerical values, if the query information contains sorting requirements, the query results can be processed according to the sorting requirements and displayed to the user. If the query information does not contain sorting requirements, the query results can be displayed to the user in an appropriate sorting manner based on the actual application scenario and the type of query results, which is conducive to improving user experience.
[0056] For example, assuming the query information is: What is the labor cost of each business format in June, the summary information displayed to the user can be: The labor cost data of each business format in June shows that supermarkets have the highest labor cost, reaching 5.32 million yuan, followed by shopping centers and department stores, which are 4.5 million yuan and 2.99 million yuan respectively. The labor cost of department store functions is 2.5 million yuan, the cost of shopping centers is 2.25 million yuan, and the cost of supermarket functions and digitalization is 1.9 million yuan and 1.8 million yuan respectively. The labor cost of the logistics center is 1.65 million yuan, the offset part is 980,000 yuan, the cost of innovative business is 800,000 yuan, and the cost of department store self-operation is 660,000 yuan. It is worth noting that the labor cost of the headquarters function is negative, with a value of -1.28 million yuan, which may be because the income of the headquarters function offsets part of the cost.
[0057] In an embodiment of the present application, during a data query, an indicator matching the query information and metadata matching the query information are first determined based on the acquired query information to obtain the indicator to be queried and the metadata to be queried. Since the determined indicator to be queried can indicate the data to be queried, and the metadata to be queried can reflect information such as the content and attributes of the data related to the query information, therefore, information extraction processing is performed on the query information based on the indicator to be queried and the metadata to be queried, which is equivalent to fully extracting information from the query information in combination with the information of the data to be queried and the data related to the query information, and a data factor to be queried with higher accuracy can be obtained; furthermore, a query statement to be executed generated based on the data query factor can quickly and accurately query and obtain the query result corresponding to the query information, without the need to manually analyze the query information and write the query statement, which can effectively reduce manual dependence and improve the efficiency of data query, while reducing the probability of querying erroneous data.
[0058] In some embodiments, before extracting information from the query information according to the query index and the query metadata to obtain the query data factor, the method further includes:
[0059] The query requirement is determined based on the query information and the indicators to be queried.
[0060] Determine the processing logic that matches the query requirement and obtain the target processing logic, where the target processing logic is used to indicate a calculation method for obtaining the query result that meets the query requirement based on the indicator data corresponding to the indicator to be queried.
[0061] The above-mentioned query information is subjected to information extraction processing according to the above-mentioned indicators to be queried and the above-mentioned metadata to be queried to obtain the data factors to be queried, including:
[0062] According to the above-mentioned indicators to be queried, the above-mentioned metadata to be queried and the above-mentioned target processing logic, the above-mentioned query information is subjected to information extraction processing to obtain the above-mentioned data factors to be queried.
[0063] The above query requirements are used to indicate the data that the user needs to query. According to the query requirements, the type of data that the user needs to query (such as month-on-month, statistics and trends, etc.) can be determined. For example, assuming that the query information is: What is the month-on-month sales volume of Jun Shang 3019 berries in May 2024, then the query requirement can be considered as: The month-on-month sales volume of Jun Shang 3019 berries in May 2024, and it can be determined that the type of data to be queried is: month-on-month.
[0064] Indicator data refers to data that can reflect the indicator. For example, when the indicator to be queried is sales volume, the corresponding indicator data may be sales volume data that can reflect sales volume, such as the daily sales volume of each product of the enterprise.
[0065] The above processing logic is the calculation logic of the data, which can convert the original data into the required target data, and can include various calculation steps in the conversion process. The target processing logic in the embodiment of the present application is a method for calculating the query result that meets the query requirements based on the indicator data corresponding to the query indicator for the query information.
[0066] To ensure that the query results required by the user can be obtained accurately, before conducting a query, you can first determine the query requirements based on the query information and the indicators to be queried, and then determine the processing logic that matches the query requirements based on the query requirements to obtain the target processing logic. This will avoid the situation where the required data cannot be directly queried from the data source in the future. Based on the target processing logic, you can calculate the query results that meet the query requirements according to the indicator data corresponding to the indicators to be queried.
[0067] For example, assuming the query information is: What is the month-on-month sales volume of berries of Junshang 3019 in June 2024, then the query demand can be considered as: What is the month-on-month sales volume of berries of Junshang 3019 in June 2024.
[0068] According to the query requirement, it can be determined that the type of data to be queried is: month-on-month. Combined with the data type (month-on-month), the processing logic that matches the query requirement is determined as: calculating the data changes in two adjacent time periods (such as two consecutive months or two quarters). The determined target processing logic is: calculating the sales changes of Junshang 3019's berries in June and May 2024.
[0069] Optionally, when determining the data type corresponding to the query requirement, the query requirement may be matched with pre-stored definitions of various data types, thereby determining the data type corresponding to the query requirement based on the data type that has a higher degree of matching with the query requirement.
[0070] For example, suppose the definition of statistics is: statistical queries usually involve basic statistical analysis of data sets, such as calculating sums, averages, medians, maximums and minimums, etc.; the definition of trend is: trend analysis focuses on the changing patterns of data over time, helping to identify long-term trends and cyclical fluctuations; the definition of year-on-year is: comparing data from the same quarter or period with data from the same quarter or period of the previous year; the definition of quarter-on-quarter is: comparing data from two consecutive time periods.
[0071] Assuming that the query requirement is to compare the changes in labor costs of various business types in May and May of last year, then according to the query requirement and the definition of each data type, it can be determined that the data type corresponding to the query requirement is: year-on-year.
[0072] After obtaining the target processing logic, the query information can be extracted from multiple angles in combination with the query indicators, the query metadata and the target processing logic to further improve the accuracy of the obtained data factors to be queried, which is conducive to improving the accuracy of the final query results.
[0073] For example, suppose the query information is: What is the month-on-month sales volume of berries of Junshang 3019 in June 2024? The determined indicators to be queried include: sales volume; the determined data factors to be queried include: store-Junshang 3019, major product category-berries; the determined target processing logic is: calculate the sales changes of berries of Junshang 3019 in June and May 2024.
[0074] Based on this information, the query information is extracted and processed, and the following data factors to be queried can be extracted: the indicator is: sales, the store is: Jun Shang 3019, the major product category is: berries, and the time period is: 202405 and 202406.
[0075] If a query statement is generated directly based on the semantics of the query information, the month-on-month sales will usually be queried from the data source, or the month-on-month sales will be ignored. The query result returned is the sales data, and there is a high probability that 3019 will be ignored. The month-on-month sales of Junshang store will be directly queried, and the correct query result cannot be obtained. In the embodiment of the present application, through the above processing, the query information can be comprehensively analyzed, and the associated data factors to be queried can be effectively extracted, thereby ensuring the accuracy of the data query.
[0076] In the embodiment of the present application, since the determined target processing logic can reflect the logic of obtaining query results that meet the query requirements by processing the indicator data corresponding to the indicator to be queried, therefore, combining the target processing logic and the indicator to be queried and the metadata to be queried can better perform sufficient information extraction on the query information, and obtain the data factors to be queried with higher accuracy, so that the corresponding data can be quickly and accurately queried based on these data factors to be queried subsequently, and then, after the queried data is processed accordingly in combination with the target processing logic, the required query results are obtained, which can effectively ensure the accuracy of the obtained query results.
[0077] In some embodiments, determining the query requirement based on the query information and the to-be-queried indicator includes:
[0078] The query information, the indicators to be queried and the prompt word (the fourth prompt word) are input into the large language model to obtain the query demand output by the large language model. The fourth prompt word is used to instruct the large language model to perform demand analysis based on the query information and the indicators to be queried to obtain the query demand.
[0079] The above-mentioned large language model (LLM) refers to a deep learning model trained with a large amount of text data, which can better understand the meaning of the text and generate text with high accuracy.
[0080] In order to improve the accuracy of query requirements corresponding to query information and accurately understand the data that users need to query, the query information and the indicators to be queried can be used as inputs of the large language model to automatically generate corresponding query requirements through the large language model.
[0081] Among them, in order to reduce the training cost, a general large language model can be used to automatically generate query requirements. At this time, when generating query requirements through the general large language model, the first prompt word can be used to guide the general large language model to specifically generate content that is more in line with the needs of data query, thereby obtaining more accurate query requirements.
[0082] In an embodiment of the present application, the query information, the factors to be queried and the first prompt word can be input into the large language model together. The first prompt word can be used to guide the general large language model to perform targeted demand analysis based on the content described by the query information and the semantics of the indicators to be queried, thereby generating query requirements with higher accuracy. There is no need to additionally train the large language model for the demand analysis, which can reduce the model training cost, that is, reduce the data query cost.
[0083] In some embodiments, before determining the processing logic matching the query requirement and obtaining the target processing logic, the method further includes:
[0084] Determine the time information according to the above query requirements;
[0085] Correspondingly, the above-mentioned processing logic that matches the above-mentioned query requirement is determined to obtain the target processing logic, including:
[0086] Based on the time information, a processing logic matching the query requirement is determined to obtain the target processing logic.
[0087] Optionally, the above time information includes but is not limited to a time range and a time granularity (ie, a basic unit for dividing time).
[0088] Specifically, the time-related description can be determined first according to the query requirements, so as to determine the required time information. When determining the target processing logic, the time information can be combined to better determine the processing logic that matches the query requirements. While reducing the difficulty of determining the target processing logic, a target processing logic with higher accuracy can be obtained.
[0089] Optionally, the query requirement may be processed by natural language processing (such as text matching or regular expression matching) to obtain the required time information.
[0090] For example, suppose the query demand is: the month-on-month sales of berries of Jun Shang 3019 in June 2024. By analyzing the query demand through the large language model, the time-related descriptions can be obtained including June 2024 and month-on-month. Combining the month-on-month and the date June 2024, the specific time information that can be converted includes: the time granularity is month, and the time range includes June 2024 and May 2024.
[0091] In an embodiment of the present application, relevant time requirements are also determined based on the query requirements. After obtaining the time information, the processing logic that matches the query requirements is determined in combination with the time information to improve the accuracy of the obtained target processing logic, which is beneficial to improving the accuracy of subsequent information extraction and reducing the difficulty of extraction.
[0092] In some embodiments, the generating of the query statement to be executed based on the data factor to be queried, and obtaining the query result corresponding to the query information based on the query statement to be executed, includes:
[0093] The query information, the data factors to be queried and the first prompt word are input into the large language model to obtain the query statement to be executed output by the large language model. The first prompt word is used to instruct the large language model to convert the data factors to be queried into an executable structured query statement based on the query information to obtain the query statement to be executed.
[0094] The query statement to be executed is executed based on the data source to obtain query data corresponding to the query statement to be executed.
[0095] The query data is processed based on the target processing logic to obtain the query results that meet the query requirements.
[0096] The above data source is the source of the original data, which may include various forms of data, such as structured table data, semi-structured XML (Extensible Markup Language) files or JSON (JavaScript Object Notation) files, and unstructured text files and images. In the embodiment of the present application, the data source refers to a database or database server that stores relevant data such as business data.
[0097] Since manually generated query statements have high requirements for professionalism and are highly dependent on human intervention, in order to reduce the human intervention of data queries, when generating query statements to be executed, the corresponding query statements to be executed can be automatically generated through a large language model.
[0098] In order to reduce the cost of data query, when automatically generating query statements to be executed through a large language model, the query information, the data factors to be queried and the first prompt word are input into the general large language model together. The first prompt word is used to guide the large language model to convert the data factors to be queried into executable structured query statements based on the content described by the query information. Without the need for additional training of the large language model, the large language model can quickly generate query statements to be executed with high accuracy.
[0099] like Figure 2 As shown, after obtaining the query statement to be executed, the query statement to be executed can be executed based on the data source to obtain the query data corresponding to the query statement to be executed. Finally, the query data is processed accordingly according to the previously determined target processing logic to obtain the query result that meets the query requirements.
[0100] For example, assuming the query information is: the top 10 stores in South China in terms of sales in March, then the query requirement can be determined as: the top 10 stores in South China in terms of sales in March; the target processing logic can be: sort the stores in South China in descending order according to the size of sales in March, and obtain the top 10 stores.
[0101] After the query data is obtained through the query, the query data is processed according to the target processing logic to obtain the top 10 stores.
[0102] In the embodiment of the present application, a large language model is used to automatically generate a query statement to be executed with high accuracy based on the factors of the data to be queried, without relying on manual generation, which can reduce manual dependence and the probability of error. At the same time, after the query data is obtained by query, combined with the previously determined target processing logic, the query data can be quickly and accurately processed to obtain a query result that meets the query requirements.
[0103] In some embodiments, the above step S101 includes:
[0104] Get real-time question information and historical question information entered by the user.
[0105] The real-time question information, the historical question information and the second prompt word are input into the large language model to obtain the query information and intention index output by the large language model. The second prompt word is used to instruct the large language model to analyze the query information and the intention query index corresponding to the real-time question information according to the real-time question information and the historical question information to obtain the query information and the intention index.
[0106] The above-mentioned indicators to be queried are determined from various indicators stored in the indicator platform according to the above-mentioned intention indicators.
[0107] The above-mentioned intention indicators refer to the description information of the suspected indicators in the query information corresponding to the real-time question information. For example, if the assumed indicators include labor costs, and the determined query information is: how did the labor costs of various business formats change in June compared with May, it can be analyzed that the intention indicators in the query information include: labor costs.
[0108] Since some users may omit some of the same information in the second or subsequent input when continuously inputting question information for query, in an embodiment of the present application, the real-time question information and historical question information input by the same user are obtained at the same time, and then the obtained real-time question information and historical question information are used together as inputs of the large language model. The large language model is guided by the second prompt word to analyze the real-time question information and the historical question information to obtain the content that the user actually needs to ask, obtain the query information corresponding to the real-time question information, and analyze the description information of the suspected indicators in the query information to obtain the intention indicator.
[0109] For example, assuming that the real-time question information is: What about May 2024? Based on the real-time question information, it is impossible to determine what information about May 2024 the user needs to query.
[0110] At this time, the real-time question information, historical question information, and the second prompt word are input into the large language model together. Assuming that the historical question information includes: What is the profit margin in June 2024, the large language model, based on the guidance of the second prompt word, can analyze the current information to be queried based on the real-time question information and the historical question information: What is the profit margin in May 2024, that is, the query information corresponding to the real-time question information is: What is the profit margin in May 2024. Continuing to analyze the query information, the intent indicator can include: profit margin.
[0111] For another example, suppose the historical question information includes: What is the labor cost of each business format in June, and suppose the real-time question information is: What are the changes compared to May? At this time, the real-time question information and the historical question information can be analyzed through the large language model to obtain the query information: The changes in the labor costs of each business format in May and June. By analyzing the query information, it can be determined that the intention indicators include: labor costs.
[0112] After obtaining the query information and the intention indicator, the indicator to be queried can be quickly and accurately determined from various indicators stored in the indicator platform according to the intention indicator.
[0113] In an embodiment of the present application, the user's historical question information and real-time question information are obtained, and the historical question information and real-time question information are analyzed through a large language model, which can better determine the content of the user's current question, obtain query information with higher accuracy, and determine the intention indicator based on the description information of the suspected indicator in the query information. Furthermore, based on the intention indicator, the indicator to be queried can be quickly and accurately queried from the indicator platform, which is conducive to improving data query efficiency.
[0114] In some embodiments, the above-mentioned determination of the above-mentioned to-be-queried indicator from various indicators stored in the indicator platform according to the above-mentioned intention indicator includes:
[0115] The above intention indicators are subjected to feature extraction processing to obtain query feature vectors corresponding to the above intention indicators.
[0116] The matching degree corresponding to each of the above indicators is determined according to the similarity between the above query feature vector and the indicator feature vector corresponding to each indicator stored in the above indicator platform.
[0117] The above-mentioned index to be queried is determined according to the above-mentioned index whose matching degree is greater than or equal to the matching threshold.
[0118] In the embodiment of the present application, in order to improve data query efficiency, the indicator feature vector corresponding to each indicator can be pre-stored through the indicator platform.
[0119] When it is necessary to determine the indicator that matches the query information, the intent indicator can be first subjected to feature extraction processing to obtain the query feature vector corresponding to the intent indicator, and then the similarity between the indicator feature vector and the query feature vector is calculated directly based on the indicator feature vectors pre-stored in the indicator platform and the query feature vector (such as cosine similarity or) to obtain the matching degree corresponding to the indicator.
[0120] After obtaining the matching degree corresponding to each indicator, the indicator matching the query information is determined according to the matching degree to obtain the indicator to be queried.
[0121] Among them, since the query information may include one or more indicators, when determining the indicator matching the query information according to the matching degree, the indicator with a matching degree greater than or equal to the matching threshold (such as 0.95) can be used as the indicator to be queried.
[0122] In some embodiments, after determining multiple indicators (referred to as candidate indicators) whose matching degree is greater than or equal to a matching threshold (such as 0.95), each candidate indicator, query information and prompt word (fifth prompt word) can also be input into the large language model. The fifth prompt word is used to guide the large language model to combine the semantics of the query information, and select the candidate indicator that best matches the semantics of the query information from the various candidate indicators, and use it as the indicator to be queried.
[0123] For example, assuming the query information is: changes in labor costs of various business formats in May and June, the determined intention indicator is: labor costs, and the determined candidate indicators include: total labor costs, annual labor costs, monthly labor costs and daily labor costs. These candidate indicators, query information and the fifth prompt word can be input into the large language model. The large language model analyzes these data and can determine that the candidate indicator that best matches the semantics of the query information is: monthly labor costs. The final indicator to be queried is: monthly labor costs.
[0124] In the embodiment of the present application, the indicator matching the intended indicator is determined based on the indicator feature vector corresponding to each indicator pre-stored in the indicator platform, without the need for additional feature extraction processing of each indicator, which can improve the efficiency of data query. At the same time, when determining the indicator to be queried, the indicator matching the intended indicator is directly found from each pre-stored existing indicator, without the need to process the query information through word segmentation or semantic analysis, which is conducive to improving the efficiency of data query.
[0125] In some embodiments, metadata feature vectors corresponding to various metadata may be pre-stored in a metadata database, and when determining metadata to be queried, the metadata to be queried is determined from various metadata according to the similarity between the query information feature and the metadata feature vector.
[0126] In some embodiments, after obtaining the query result corresponding to the query information based on the query statement to be executed, the method further includes:
[0127] The query information, the query results and the third prompt word are used as inputs of the large language model to obtain a data report output by the large language model. The third prompt word is used to instruct the large language model to select a chart type that matches the query information and the query results, and generate a chart corresponding to the query result based on the selected chart type.
[0128] In the embodiment of the present application, after obtaining the query result, the third prompt word is determined, and then the query information, the query result and the third prompt word are input into the large language model, and a suitable report is quickly and accurately generated through the large language model. Among them, the third prompt word is used to instruct the large language model to select a chart type that matches the query information and the query result, and then the query result is processed according to the selected chart type to generate a chart corresponding to the query result, so that complex data can be presented more intuitively through a chart of a type that matches the query result, and the readability of the query result is better enhanced, which is conducive to improving user experience.
[0129] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0130] Embodiment 2:
[0131] Corresponding to the data query method described in the above embodiment, Figure 3 A structural block diagram of a data query device provided in an embodiment of the present application is shown. For ease of explanation, only the parts related to the embodiment of the present application are shown.
[0132] Reference Figure 3The device includes: a module for determining the index to be queried 31, a module for determining the metadata to be queried 32, a module for determining the data factor to be queried 33 and a query module 34.
[0133] The to-be-queried indicator determination module 31 is used to determine an indicator that matches the acquired query information to obtain the to-be-queried indicator.
[0134] The metadata to be queried determining module 32 is used to determine metadata matching the query information to obtain the metadata to be queried.
[0135] The module 33 for determining the data factors to be queried is used to extract information from the query information according to the query indicators and the metadata to be queried to obtain the data factors to be queried. The data factors to be queried are used to reflect the data screening conditions when performing the data query corresponding to the query information.
[0136] The query module 34 is used to generate a query statement to be executed based on the above-mentioned data factors to be queried, and obtain a query result corresponding to the above-mentioned query information based on the above-mentioned query statement to be executed.
[0137] In an embodiment of the present application, during a data query, an indicator matching the query information and metadata matching the query information are first determined based on the acquired query information to obtain the indicator to be queried and the metadata to be queried. Since the determined indicator to be queried can indicate the data to be queried, and the metadata to be queried can reflect information such as the content and attributes of the data related to the query information, therefore, information extraction processing is performed on the query information based on the indicator to be queried and the metadata to be queried, which is equivalent to fully extracting information from the query information in combination with the information of the data to be queried and the data related to the query information, and a data factor to be queried with higher accuracy can be obtained; furthermore, a query statement to be executed generated based on the data query factor can quickly and accurately query and obtain the query result corresponding to the query information, without the need to manually analyze the query information and write the query statement, which can effectively reduce manual dependence and improve the efficiency of data query, while reducing the probability of querying erroneous data.
[0138] In some embodiments, the data query device further includes:
[0139] The query demand determination module is used to determine the query demand based on the query information and the indicators to be queried.
[0140] The target processing logic determination module is used to determine the processing logic that matches the above query requirements and obtain the target processing logic. The above target processing logic is used to indicate the calculation method of obtaining the above query results that meet the above query requirements based on the indicator data corresponding to the above indicator to be queried.
[0141] The above-mentioned data factor determination module 33 includes:
[0142] The extraction unit is used to perform information extraction processing on the query information according to the above-mentioned indicators to be queried, the above-mentioned metadata to be queried and the above-mentioned target processing logic to obtain the above-mentioned data factors to be queried.
[0143] In some embodiments, the data query device further includes:
[0144] Determine the time information based on the above query requirements.
[0145] Correspondingly, the above target processing logic determination module is specifically used for:
[0146] Based on the time information, a processing logic matching the query requirement is determined to obtain the target processing logic.
[0147] In some embodiments, the data query device further includes:
[0148] The demand analysis module is used to input the above-mentioned query information, the above-mentioned indicators to be queried and the first prompt word into the large language model to obtain the above-mentioned query demand output by the above-mentioned large language model, and the above-mentioned first prompt word is used to instruct the above-mentioned large language model to perform demand analysis based on the above-mentioned query information and the above-mentioned indicators to be queried to obtain the above-mentioned query demand.
[0149] In some embodiments, the query module 34 includes:
[0150] The query statement to be executed is generated by a unit, which is used to input the query information, the data factor to be queried and the first prompt word into the large language model to obtain the query statement to be executed output by the large language model, wherein the first prompt word is used to instruct the large language model to convert the data factor to be queried into an executable structured query statement based on the query information to obtain the query statement to be executed.
[0151] The execution unit is used to execute the query statement to be executed based on the data source to obtain the query data corresponding to the query statement to be executed.
[0152] The processing unit is used to process the query data based on the target processing logic to obtain the query result that meets the query requirement.
[0153] In some embodiments, the data query device further includes:
[0154] The acquisition module is used to obtain real-time question information and historical question information input by the user.
[0155] A query information determination module, used to input the real-time question information, the historical question information, and the second prompt word into the large language model, and obtain the query information and the intention index output by the large language model, wherein the second prompt word is used to instruct the large language model to analyze the query information and the intention query index corresponding to the real-time question information according to the real-time question information and the historical question information, and obtain the query information and the intention index;
[0156] The indicator determination module is used to determine the above-mentioned indicator to be queried from various indicators stored in the indicator platform according to the above-mentioned intention indicator.
[0157] In some embodiments, the data query device further includes:
[0158] The feature extraction module is used to perform feature extraction processing on the above-mentioned intention indicators to obtain the query feature vector corresponding to the above-mentioned query information.
[0159] The matching degree determination module is used to determine the matching degree corresponding to each of the above indicators based on the similarity between the above query feature vector and the indicator feature vector corresponding to each of the above indicators stored in the above indicator platform.
[0160] The determination module is used to determine the above-mentioned indicator to be queried according to the above-mentioned indicator whose matching degree is greater than or equal to the matching threshold.
[0161] In some embodiments, the data query device further includes:
[0162] A chart generation module is used to use the above-mentioned query information, the above-mentioned query results and the third prompt word as inputs of the large language model to obtain a data report output by the above-mentioned large language model, and the above-mentioned third prompt word is used to instruct the above-mentioned large language model to select a chart type that matches the above-mentioned query information and the above-mentioned query results, and generate a chart corresponding to the above-mentioned query results based on the above-mentioned selected chart type.
[0163] It should be noted that the information interaction, execution process, etc. between the above-mentioned devices / units are based on the same concept as the method embodiment of the present application. Their specific functions and technical effects can be found in the method embodiment part and will not be repeated here.
[0164] Embodiment three:
[0165] Figure 4 This is a schematic diagram of the structure of an electronic device provided by an embodiment of the present application. Figure 4 As shown, the electronic device 4 of this embodiment includes: at least one processor 40 ( Figure 4Only one processor is shown in the figure), a memory 41, and a computer program 42 stored in the memory 41 and executable on the at least one processor 40, wherein the processor 40 implements the steps in any of the above-mentioned method embodiments when executing the computer program 42.
[0166] The electronic device 4 may be a computing device such as a desktop computer, a notebook, a PDA, or a cloud server. The electronic device may include, but is not limited to, a processor 40 and a memory 41. Those skilled in the art will appreciate that Figure 4 It is only an example of the electronic device 4 and does not constitute a limitation on the electronic device 4. It may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, it may also include input and output devices, network access devices, etc.
[0167] The processor 40 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.
[0168] In some embodiments, the memory 41 may be an internal storage unit of the electronic device 4, such as a hard disk or memory of the electronic device 4. In other embodiments, the memory 41 may also be an external storage device of the electronic device 4, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped on the electronic device 4. Further, the memory 41 may also include both an internal storage unit of the electronic device 4 and an external storage device. The memory 41 is used to store an operating system, an application program, a boot loader (BootLoader), data, and other programs, such as the program code of the computer program, etc. The memory 41 may also be used to temporarily store data that has been output or is to be output.
[0169] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.
[0170] An embodiment of the present application also provides a network device, which includes: at least one processor, a memory, and a computer program stored in the memory and executable on the at least one processor, wherein the processor implements the steps in any of the above-mentioned method embodiments when executing the computer program.
[0171] An embodiment of the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in the above-mentioned method embodiments can be implemented.
[0172] An embodiment of the present application provides a computer program product. When the computer program product runs on an electronic device, the electronic device can implement the steps in the above-mentioned method embodiments when executing the computer program product.
[0173] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, which can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a computer-readable storage medium. When the computer program is executed by the processor, the steps of the above-mentioned various method embodiments can be implemented. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may at least include: any entity or device that can carry the computer program code to the camera / electronic device, recording medium, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, RandomAccess Memory), electric carrier signal, telecommunication signal and software distribution medium. For example, a USB flash drive, a mobile hard disk, a magnetic disk or an optical disk. In some jurisdictions, according to legislation and patent practice, computer-readable media cannot be electric carrier signals and telecommunication signals.
[0174] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0175] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0176] In the embodiments provided in the present application, it should be understood that the disclosed devices / network equipment and methods can be implemented in other ways. For example, the device / network equipment embodiments described above are merely schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0177] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0178] The embodiments described above are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.
Claims
1. A data query method, characterized in that: include: Determine the index that matches the acquired query information and obtain the index to be queried; Determine metadata matching the query information to obtain metadata to be queried; Performing information extraction processing on the query information according to the to-be-queried index and the to-be-queried metadata to obtain a to-be-queried data factor, wherein the to-be-queried data factor is used to reflect a data screening condition when performing a data query corresponding to the query information; A query statement to be executed is generated based on the data factor to be queried, and a query result corresponding to the query information is obtained based on the query statement to be executed.
2. The data query method according to claim 1, characterized in that: Before extracting the query information according to the to-be-queried index and the to-be-queried metadata to obtain the to-be-queried data factor, the method further includes: Determine the query requirement based on the query information and the indicator to be queried; Determine a processing logic that matches the query requirement and obtain a target processing logic, wherein the target processing logic is used to indicate a calculation method for obtaining the query result that meets the query requirement according to the indicator data corresponding to the indicator to be queried; The extracting process of the query information according to the to-be-queried index and the to-be-queried metadata to obtain the to-be-queried data factor includes: According to the to-be-queried index, the to-be-queried metadata and the target processing logic, information extraction processing is performed on the query information to obtain the to-be-queried data factor.
3. The data query method according to claim 2, characterized in that: Before determining the processing logic matching the query requirement and obtaining the target processing logic, the method further includes: Determine time information according to the query requirement; Correspondingly, the determining of the processing logic matching the query requirement to obtain the target processing logic includes: Based on the time information, a processing logic matching the query requirement is determined to obtain the target processing logic.
4. The data query method according to claim 2, characterized in that: The generating a query statement to be executed based on the data factor to be queried, and obtaining a query result corresponding to the query information based on the query statement to be executed, includes: The query information, the data factor to be queried and the first prompt word are input into a large language model to obtain the query statement to be executed output by the large language model, wherein the first prompt word is used to instruct the large language model to convert the data factor to be queried into an executable structured query statement based on the query information to obtain the query statement to be executed, Execute the query statement to be executed based on the data source to obtain query data corresponding to the query statement to be executed; The query data is processed based on the target processing logic to obtain the query result that meets the query requirement.
5. The data query method according to claim 1, characterized in that: The step of determining an indicator that matches the acquired query information to obtain the indicator to be queried includes: Obtain real-time question information and historical question information input by users; Inputting the real-time question information, the historical question information, and the second prompt word into a large language model to obtain the query information and the intention index output by the large language model, wherein the second prompt word is used to instruct the large language model to analyze the query information and the intention query index corresponding to the real-time question information according to the real-time question information and the historical question information, and obtain the query information and the intention index; The indicator to be queried is determined from various indicators stored in the indicator platform according to the intention indicator.
6. The data query method according to claim 5, characterized in that: Determining the to-be-queried indicator from various indicators stored in the indicator platform according to the intention indicator includes: Performing feature extraction processing on the intention indicator to obtain a query feature vector corresponding to the intention indicator; Determine the matching degree corresponding to each of the indicators according to the similarity between the query feature vector and the indicator feature vector corresponding to each of the indicators stored in the indicator platform; The indicator to be queried is determined according to the indicator whose matching degree is greater than or equal to a matching threshold.
7. The data query method according to any one of claims 1 to 6, characterized in that: After obtaining the query result corresponding to the query information based on the query statement to be executed, the method further includes: The query information, the query result and the third prompt word are used as inputs of a large language model to obtain a data report output by the large language model, wherein the third prompt word is used to instruct the large language model to select a chart type that matches the query information and the query result, and to generate a chart corresponding to the query result based on the selected chart type.
8. A data query device, characterized in that: include: The module for determining the index to be queried is used to determine the index matching the acquired query information and obtain the index to be queried; A module for determining metadata to be queried, used to determine metadata matching the query information, and obtain the metadata to be queried; A module for determining factors of data to be queried, used for performing information extraction processing on the query information according to the indicators to be queried and the metadata to be queried, to obtain factors of data to be queried, wherein the factors of data to be queried are used to reflect data screening conditions when performing data query corresponding to the query information; The query module is used to generate a query statement to be executed based on the data factor to be queried, and obtain a query result corresponding to the query information based on the query statement to be executed.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the method according to any one of claims 1 to 7 is implemented.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Data processing method, device and equipment and computer readable storage medium
CN116821103A
Response statement generation method and device, electronic equipment and storage medium
CN117874207A
Business data query method, device and equipment and computer readable storage medium
CN118069795A