Query statement generation method, electronic device, and storage medium
By rewriting and extracting information to generate target query statements, the problems of high computational resource consumption and low accuracy in time series analysis in existing technologies are solved, and efficient and adaptable query statement generation is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- ZHEJIANG DAHUA TECH CO LTD
- Filing Date
- 2025-12-24
- Publication Date
- 2026-04-24
AI Technical Summary
Existing Text2SQL technology, when dealing with time series analysis problems, especially year-on-year and month-on-month problems, requires breaking down the user's problem into multiple sub-problems and generating SQL statements for each, resulting in high computational resource consumption, low accuracy, and difficulty in adapting to business scenarios in different fields.
By rewriting the problem to be processed into the target problem, the complexity is reduced, and information extraction processing is performed. The target variable is directly filled into the preset query statement template to generate the target query statement, avoiding splitting and dependence on pre-trained models.
It improves the efficiency and accuracy of query statement generation, reduces computing resource consumption, and adapts to business scenarios in different fields.
Smart Images

Figure CN121387937B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a query statement generation method, electronic device, and storage medium. Background Technology
[0002] Text2SQL technology converts the natural language corresponding to user questions into a Structured Query Language (SQL) that can be executed by a database. Natural language can be text, speech, or any information that can be converted into text. This technology greatly simplifies the interaction between non-technical users and databases, lowering the barrier to data analysis. In some application scenarios, the process of converting the natural language corresponding to user questions into a query language usable by the database typically involves breaking down the user question into multiple sub-questions and generating corresponding SQL statements for each sub-question based on its complexity, ultimately generating the final query statement for the database. However, when the user question is a time series analysis question (such as year-on-year or month-on-month comparisons), this additional process of breaking down the user question into multiple sub-questions and generating corresponding SQL statements for each sub-question is less efficient.
[0003] Therefore, there is an urgent need for a query statement generation method. Summary of the Invention
[0004] This application provides at least one query statement generation method, electronic device, and storage medium.
[0005] This application provides a query statement generation method, which includes: rewriting the problem to be processed in response to the problem of time series analysis to obtain the target problem; performing information extraction processing on the problem to be processed and / or the target problem to obtain the target variable; and filling the target variable into the obtained preset query statement template to obtain the target query statement.
[0006] This application provides a query statement generation device, including: a problem rewriting module, an information extraction module, and a generation module; the problem rewriting module is used to rewrite the problem to be processed in response to the problem representing the time series analysis problem, to obtain the target problem; the information extraction module is used to perform information extraction processing on the problem to be processed and / or the target problem to obtain the target variable; the generation module is used to fill the target variable into the obtained preset query statement template to obtain the target query statement.
[0007] This application provides an electronic device, including a memory and a processor, wherein the processor is used to execute program instructions stored in the memory to implement the above-described query statement generation method.
[0008] This application provides a computer-readable storage medium storing program instructions thereon, which, when executed by a processor, implement the above-described query statement generation method.
[0009] The above scheme, in representing the time series analysis problem of the problem to be processed, rewrites the problem to be processed to obtain the target problem so that the key information of the problem to be processed is retained in the target problem and the complexity is low. Information extraction processing is performed on the problem to be processed and / or the target problem to obtain the target variable. The target variable is filled into the obtained preset query statement template to obtain the target query statement, which can improve the generation efficiency of the target query statement.
[0010] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this application. Attached Figure Description
[0011] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with this application and, together with the specification, serve to explain the technical solutions of this application.
[0012] Figure 1 This is a flowchart illustrating an exemplary embodiment of the query statement generation method of this application;
[0013] Figure 2 yes Figure 1 A schematic diagram of the sub-process of step S12;
[0014] Figure 3 This is another flowchart illustrating an exemplary embodiment of the query statement generation method of this application;
[0015] Figure 4 This is a schematic diagram of the structure of an embodiment of the query statement generation device of this application;
[0016] Figure 5 This is a schematic diagram of the structure of an embodiment of the electronic device of this application;
[0017] Figure 6 This is a schematic diagram of the structure of an embodiment of the computer-readable storage medium of this application. Detailed Implementation
[0018] The embodiments of this application will now be described in detail with reference to the accompanying drawings.
[0019] In the following description, specific details such as particular system architectures, interfaces, and technologies are presented for illustrative purposes rather than for limiting purposes, in order to provide a thorough understanding of this application.
[0020] In this document, the term "and / or" is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. Additionally, the character " / " generally indicates that the preceding and following related objects have an "or" relationship. Furthermore, "many" in this document means two or more. Moreover, the term "at least one" in this document means any combination of at least two of any one or more of a plurality of objects. For example, including at least one of A, B, and C can mean including any one or more elements selected from the set consisting of A, B, and C.
[0021] This application considers that year-on-year and month-on-month comparisons are very common data statistics tasks in daily data analysis. However, for Text2SQL technology, due to the complex time-series calculations and nested queries involved in such tasks, the quality of the generated SQL is poor and difficult to apply directly to production. In some application scenarios, year-on-year and month-on-month comparison problems are usually broken down into multiple sub-problems, and corresponding query statements are generated for each sub-problem to achieve the final query statement. Typically, the original problem is directly broken down, or a pre-trained problem processing model is used to break down the original problem into multiple sub-problems. For example, in the case of a year-on-year / month-on-month comparison problem, the original problem might be "How much did the statistical value of a certain business increase year-on-year last spring?" The resulting sub-problems might be "Sub-problem 1: Calculate the statistical value of a certain business last spring; Sub-problem 2: Calculate the statistical value of a certain business the year before last; Sub-problem 3: Calculate the year-on-year growth rate of sub-problem 1 and sub-problem 2." In this approach, complex subqueries or multi-step queries are usually implemented using CTE syntax, which can decompose complex year-on-year comparison problems into multiple steps, each step solving one sub-problem, and finally combining them into a complete solution. First, this application considers that breaking down a complex original problem into multiple sub-problems may lead to high computational resource consumption. Furthermore, generating separate query statements for each sub-problem may further increase computational resource consumption. This process of first breaking down the original problem and then generating corresponding query statements for each sub-problem results in high computational resource consumption for the entire final query statement generation process. Moreover, errors in the query statements for a single sub-problem can lead to low accuracy in the final query statement. Additionally, this application considers that directly breaking down the original problem in this way requires manual maintenance of the correspondence between the original problem and the breakdown strategy when the original problem belongs to different intentions, resulting in low generalization ability. Furthermore, this application considers that the problem processing model needs to be pre-trained, making it difficult to apply the problem processing model to business scenarios in different domains.
[0022] Therefore, this application provides some query statement generation methods that do not rely on pre-trained models or preset splitting strategies to split the problem to be processed. Instead, the problem to be processed is directly rewritten into a target problem. Under the premise of reducing the complexity of the problem, information extraction and processing are performed on the problem to be processed and / or the target problem to obtain target variables. The target variables are then filled into the obtained preset query statement template to obtain the target query statement, thereby improving the generation efficiency of the target query statement.
[0023] This application provides several query statement generation methods and apparatuses. The application scenarios for these query statement generation methods include, but are not limited to, query statement generation scenarios for time series analysis problems. The execution entity of the query statement generation method can be a query statement generation apparatus, such as an intelligent assistant for time series analysis problems. For example, the query statement generation apparatus can be located in a terminal device, server, or other processing device. The terminal device can be a user equipment (UE), mobile device, user terminal, terminal, cellular phone, cordless phone, personal digital assistant (PDA), handheld device, computing device, in-vehicle device, etc. In some possible implementations, the query statement generation method can be implemented by a processor calling computer-readable instructions stored in memory.
[0024] Please see Figure 1 , Figure 1 This is a flowchart illustrating an exemplary embodiment of the query statement generation method of this application. Specifically, the query statement generation method may include the following steps:
[0025] Step S11: In response to the problem to be processed, which represents the time series analysis problem, the problem to be processed is rewritten to obtain the target problem.
[0026] The pending question can be a question input by the user. The pending question is in natural language input by the user. For example, the pending question could be a query entered by the user into a database or a query entered by the user into query software associated with the database. The pending question can also be in natural language input by the user within a business scenario. For example, business scenarios can include, but are not limited to, any of the following: financial scenarios, medical scenarios, accounting scenarios, e-commerce scenarios, transportation scenarios, etc.
[0027] The methods for obtaining questions to be processed include: obtaining natural language input directly from intelligent assistants, question-answering robots, and web applications as questions to be processed; receiving voice query commands input by users, and converting the voice query commands into text as questions to be processed.
[0028] Time series analysis questions represent user-input queries regarding the statistical situation of business data at at least two points in time within a business scenario. The statistical situation can refer to a statistical measure between the business data at at least two points in time. Statistical measures include, but are not limited to, the difference, sum, product, ratio, growth rate, percentage change, annualized growth rate, and annualized rate of change between the business data at at least two points in time. For example, if the statistical measure is the growth rate between the business data at two points in time, the question type represents a year-on-year or month-on-month comparison in time series analysis. If the statistical measure is the difference between the business data at two points in time, the question type represents a relative size problem in time series analysis. It is understood that different statistical measures between the business data at at least two points in time result in different question types for the question to be processed; the specific question types for each statistical measure will not be elaborated here.
[0029] In cases where the problem to be processed represents a relative size problem, the problem to be processed belongs to the target type. Target type problems are used to calculate the relative size between business data at at least two points in time in the problem to be processed.
[0030] It is also understood that this application does not limit the specific problem type to which the problem to be processed belongs. This application takes the growth rate between business data at two points in time as an example, and the problem type to which the problem to be processed belongs as a year-on-year problem or a month-on-month problem as an example. This will not be elaborated further.
[0031] When the problem to be processed is characterized as a year-on-year (YoY) or month-on-month (MOM) comparison, the problem belongs to the target type. Target type problems are used to calculate the rate of change compared to data from the same historical period or adjacent period corresponding to the candidate time in the problem. Specifically, YoY problems calculate the rate of change of business data between the candidate time in the problem and the corresponding historical period, where the candidate time is later than the corresponding time point of the historical period. Alternatively, YoY problems calculate the rate of change of business data between the candidate time in the problem and the corresponding future period, where the candidate time is earlier than the corresponding time point of the future period. MOM problems calculate the rate of change of business data between the candidate time in the problem and the corresponding adjacent period, where the candidate time can be either earlier or later than the corresponding time point of the adjacent period.
[0032] The target problem represents the rewritten problem to be solved. The complexity of the target problem is lower than that of the problem to be solved. In some application scenarios, the target problem may or may not be any of the sub-problems after decomposition. Specifically, the target problem represents a problem related to calculating statistical values of business data within a single time period.
[0033] In some application scenarios, rewriting the problem to be processed can be achieved by inputting the problem into a large language model for problem rewriting. In other application scenarios, the target parameters associated with the problem to be processed are extracted and then filled into a preset problem rewriting template to obtain the target problem. Specifically, the target parameters include, but are not limited to, at least one of the following: business statistical values of business data, basic statistical units of business data, etc.
[0034] In some embodiments, step S11 may include the following steps: inputting the problem to be processed and preset prompt words into a large language model to obtain whether the problem output by the large language model is a time series analysis problem, the rewritten problem output by the large language model, and the problem type to which the problem to be processed belongs. In response to the problem being a time series analysis problem, the rewritten problem output by the large language model is used as the target problem. For example, in response to the problem being a year-on-year or month-on-month problem, the rewritten problem output by the large language model is used as the target problem. The preset prompt words include a first example of the problem before rewriting and a second example of the problem after rewriting.
[0035] For example, step S11 above can be inputting the problem to be processed into the problem rewriting module to obtain the target problem output by the problem rewriting module. The problem rewriting module may contain a large language model, and the process is implemented through a call to that large language model.
[0036] The problem rewriting module determines whether the user's problem is a time series analysis problem, and if so, outputs the problem type. It also determines whether the user's problem is a year-on-year or month-on-month comparison problem.
[0037] For example, if the problem to be solved is "calculate the growth rate of the number of vehicles captured by cameras in May 2025 and April 2025", then the problem is a time series analysis problem and belongs to the relative size problem type. If the problem to be solved is "calculate the month-on-month change in the number of vehicles captured by cameras in May 2025", then the problem is a time series analysis problem and is a month-on-month change problem. If the problem to be solved is "the number of vehicles captured by cameras in May 2025", then the problem is not a time series analysis problem. For example, the preset prompt template could be set as follows: "You are a data analysis and question rewriting expert. Your task is to determine whether a user's question is a time series analysis question / year-on-year question / month-on-month question. If the user's question is a time series analysis question / year-on-year question / month-on-month question, then you need to rewrite the user's question as a target question for time period statistics. If not, then rewrite the question as empty. Here are a few examples. User question: Calculate the month-on-month change in the number of vehicle captures in May 2025; Output: ['Yes', 'Number of vehicle captures per month']; User question: Number of vehicle captures in May 2025; Output: ['No', 'User question / No question rewriting required / Empty']; User question: {user_question}".
[0038] It is understandable that time series analysis problems include year-on-year or month-on-month comparisons. User problems are the problems to be processed. Using the aforementioned prompt word template, when processing each user's problem, the user's problem is filled into the prompt word template. Then, the preset prompt words corresponding to the filled prompt word template are input into the large language model, which will produce corresponding outputs based on the preset prompt words. Based on the output of the large language model, it can be determined whether the problem to be processed is a time series analysis problem / year-on-year problem / month-on-month problem, and the rewritten problem can be used as the target problem.
[0039] Step S12: Extract information from the problem to be addressed and / or the target problem to obtain the target variable.
[0040] Information extraction processing includes extracting key information from the problem to be processed and / or extracting key information from the target problem. The target variable represents the information to be filled in the preset query template. The target variable can be a variable among the field values of the problem to be processed that can represent the time series analysis problem. In some application scenarios, step S12 above can be to extract the target variable from the problem to be processed, or the target problem, or both the problem to be processed and the target problem.
[0041] Step S13: Fill the target variable into the obtained preset query statement template to obtain the target query statement.
[0042] The preset query template represents a pre-defined query statement without any entered query keywords. The target variable represents the query keywords required in the preset query statement. The target query statement represents a database query statement that the database can directly use for data retrieval. The type of the target query statement varies depending on the type of database. For example, the type of the target query statement can be an SQL statement.
[0043] In some application scenarios, step S13 can be based on the type of the target variable to be filled, searching for a matching position in the preset query template, and filling the target variable into that position to obtain the target query statement. In other application scenarios, step S13 can also be to determine whether the target variable contains variable information corresponding to the preset type. If the target variable contains variable information corresponding to the preset type, the target variable is filled into the corresponding position in the preset query template to obtain the target query statement. If the target variable does not contain variable information corresponding to the preset type, steps S11 to S12 are re-executed, or step S12 is re-executed to obtain a new target variable, and then the new target variable is filled into the preset query template to obtain the target query statement.
[0044] The above scheme, in representing the time series analysis problem of the problem to be processed, rewrites the problem to be processed to obtain the target problem so that the key information of the problem to be processed is retained in the target problem and the complexity is low. Information extraction processing is performed on the problem to be processed and / or the target problem to obtain the target variable. The target variable is filled into the obtained preset query statement template to obtain the target query statement, which can improve the generation efficiency of the target query statement.
[0045] In some embodiments, step S12 may include the following steps: performing key information extraction processing on the problem to be processed to obtain target variables, wherein the target variables include at least one of time period variables, target time offsets, or target time filtering conditions; or performing key information extraction processing on the target problem to obtain target variables, wherein the target variables include at least one of time period variables, target time offsets, target time filtering conditions, initial query statements, statistical variables, or business variables; or performing key information extraction processing on the problem to be processed and the target problem to obtain target variables, wherein the target variables include at least one of time period variables, target time offsets, target time filtering conditions, initial query statements, statistical variables, or business variables.
[0046] The time period variable represents the time unit to which a single piece of business data in the problem to be processed or the target problem belongs. The statistical variable represents the data type of business data in the problem to be processed or the target problem. The business variable represents the business scenario in the problem to be processed or the target problem. The initial query statement represents the database query statement converted from natural language to the target problem. The target time offset represents the time difference between the times of multiple pieces of business data in the time series analysis problem. The target time filter condition represents the time query value of at least one piece of business data in the time series analysis problem. The target time filter condition is used to query the business data with the corresponding time query value in the database.
[0047] In some application scenarios, key information extraction processing is performed on the problem to be processed to obtain target variables. The target variables include at least one of the following: a time period variable, a target time offset, or a target time filtering condition. Specifically, this includes: extracting key information from the problem to be processed to obtain a time period variable; and / or, extracting key information from the problem to be processed to obtain a target time offset; and / or, extracting key information from the problem to be processed to obtain a target time filtering condition. In other application scenarios, step S13 above may involve filling at least one of the time period variable, target time offset, or target time filtering condition into a pre-defined query statement template to obtain a target query statement.
[0048] In other application scenarios, key information extraction processing is performed on the target problem to obtain target variables. These target variables include at least one of the following: a time period variable, a target time offset, a target time filtering condition, an initial query statement, a statistical variable, or a business variable. Specifically, this includes: extracting key information from the target problem to obtain a time period variable; and / or, extracting key information from the target problem to obtain a target time offset; and / or, extracting key information from the target problem to obtain a target time filtering condition; extracting key information from the target problem to obtain an initial query statement; and / or, extracting key information from the target problem to obtain a statistical variable; and / or, extracting key information from the target problem to obtain a business variable. In other application scenarios, step S13 may involve filling at least one of the following—a time period variable, a target time offset, a target time filtering condition, an initial query statement, a statistical variable, or a business variable—into an acquired preset query statement template to obtain a target query statement.
[0049] In some application scenarios, key information extraction processing is performed on the problem to be processed and the target problem to obtain target variables. Target variables include at least one of the following: a time period variable, a target time offset, a target time filtering condition, an initial query statement, a statistical variable, or a business variable. Specifically, this includes: extracting key information from the problem to be processed and the target problem to obtain time period variables; and / or, extracting key information from the problem to be processed and the target problem to obtain target time offsets; and / or, extracting key information from the problem to be processed and the target problem to obtain target time filtering conditions; extracting key information from the problem to be processed and the target problem to obtain an initial query statement; and / or, extracting key information from the problem to be processed and the target problem to obtain statistical variables; and / or, extracting key information from the problem to be processed and the target problem to obtain business variables. In other application scenarios, step S13 above can involve filling at least one of the time period variable, target time offset, target time filtering condition, initial query statement, statistical variable, or business variable into a pre-defined query statement template to obtain a target query statement.
[0050] For example, the target variable includes time variable information related to the time parameters in the problem to be addressed or the target problem. The time variable information includes at least one of a time period variable, a target time offset, or a target time filter condition.
[0051] In some application scenarios, the target variable includes target time filtering conditions and / or target time offsets. The steps described above for extracting key information from the problem to obtain the target variable specifically include the first extraction process corresponding to the time variable information: extracting time points from the problem to obtain at least one time point in the problem; and determining the target time filtering conditions and / or target time offsets based on each time point in the problem. Specifically, determining the target time filtering conditions and / or target time offsets based on each time point in the problem includes: extracting time periods from the problem to obtain time period variables in the problem; and filling at least one time point and the time period variable into an acquired preset time filtering condition template to obtain the target time filtering conditions. And / or, determining the target time offset based on each time point in the problem.
[0052] In other application scenarios, the target variables include target time filtering conditions and / or target time offsets. The steps described above for extracting key information from the target problem to obtain the target variables specifically include a second extraction process corresponding to the time variable information: extracting time points from the target problem to obtain at least one time point in the target problem; and determining the target time filtering conditions and / or target time offsets based on each time point in the target problem. Specifically, determining the target time filtering conditions and / or target time offsets based on each time point in the target problem includes: extracting time periods from the target problem to obtain time period variables in the target problem; filling at least one time point and the time period variable in the target problem into an acquired preset time filtering condition template to obtain the target time filtering conditions; and / or determining the target time offsets based on each time point in the target problem.
[0053] In other application scenarios, the target variable includes target time filtering conditions and / or target time offsets. The steps described above for extracting key information from the problem to be processed and the target problem to obtain the target variable include: performing a first extraction process corresponding to the time variable information and a second extraction process corresponding to the time variable information. Either the target time filtering conditions and / or target time offsets obtained from the first extraction process corresponding to the time variable information, or the target time filtering conditions and / or target time offsets obtained from the second extraction process corresponding to the time variable information, are arbitrarily selected as the target time filtering conditions and / or target time offsets in the target variable. Alternatively, determine whether the target time filtering conditions and / or target time offset obtained from the first extraction process corresponding to the aforementioned time variable information are the same as the target time filtering conditions and / or target time offset obtained from the second extraction process corresponding to the aforementioned time variable information. If the target time filtering conditions and / or target time offset obtained from the first extraction process corresponding to the aforementioned time variable information are different from the target time filtering conditions and / or target time offset obtained from the second extraction process corresponding to the aforementioned time variable information, use the target time filtering conditions and / or target time offset obtained from the first extraction process corresponding to the aforementioned time variable information as the target time filtering conditions and / or target time offset in the target variable.
[0054] It is understood that the processing logic of the first extraction process corresponding to the above-mentioned time variable information is the same as that of the second extraction process corresponding to the above-mentioned time variable information, only the objects of key information extraction are different. This application takes the first extraction process corresponding to the above-mentioned time variable information as an example to introduce the specific processing logic, and will not elaborate further thereafter.
[0055] The target time filtering criteria and / or target time offset represent variable information related to the time parameters in the problem to be processed or the target problem. The time point represents the time corresponding to the business data in the time series analysis problem. In the case of a year-on-year or month-on-month comparison problem, the problem to be processed represents the year-on-year or month-on-month change rate between business data at a first time point and business data at a second time point. For example, at least one time point represents the first and / or second time in a year-on-year or month-on-month comparison problem, i.e., the time corresponding to the earlier or later business data among multiple business data points when comparing year-on-year or month-on-month change rates. The target time offset represents the time difference between the first and second time points in a time series analysis problem (such as a year-on-year or month-on-month comparison problem), i.e., the time difference between multiple business data points when comparing year-on-year or month-on-month change rates.
[0056] In other application scenarios, at least one time point obtained through key point information extraction can be represented as a candidate time. The above-described step of extracting time points from the problem to be processed to obtain at least one time point in the problem can be to extract time points from the problem to obtain a first candidate time, including: using the value of the time point field in the problem to be processed as the first candidate time; and using the first candidate time as at least one time point in the problem to be processed. In other application scenarios, the above-described step of extracting time points from the target problem to obtain at least one time point in the target problem can be to extract time points from the target problem to obtain a second candidate time, including: using the value of the time point field in the target problem as the second candidate time; and using the second candidate time as at least one time point in the target problem. In other application scenarios, the steps of performing the first extraction process corresponding to the aforementioned time variable information and the second extraction process corresponding to the aforementioned time variable information specifically include: extracting time points from the problem to be processed to obtain a first candidate time; extracting time points from the target problem to obtain a second candidate time; in response to the first candidate time and the second candidate time being at the same time, using either the first candidate time or the second candidate time as at least one target time point; in response to the first candidate time and the second candidate time being at different times, using either the first candidate time or the second candidate time as the aforementioned at least one target time point, for example, using the first candidate time as the aforementioned at least one target time point. Based on each target time point, determining target time filtering conditions and / or target time offsets includes: determining target time filtering conditions based on each target time point; or, determining target time offsets based on each target time point; or, determining target time filtering conditions and target time offsets based on each target time point. Here, time point extraction is used to extract the time point information indicated in the problem to be processed and / or the target problem. It is understandable that the above-mentioned processing logic for extracting time points of the problem to be processed to obtain the first candidate time is the same as the above-mentioned processing logic for extracting time points of the target problem to obtain the second candidate time. This application takes the extraction of time points of the problem to be processed to obtain the first candidate time as an example to introduce the specific processing logic, which will not be elaborated on later.
[0057] The target variable includes target time filtering conditions. In some application scenarios, determining the target time filtering conditions based on each target time point includes: obtaining a first time filtering condition based on each time point in the problem to be processed, and using the first time filtering condition as the target time filtering condition. In some application scenarios, determining the target time filtering conditions based on each target time point includes: obtaining a second time filtering condition based on each time point in the target problem, and using the second time filtering condition as the target time filtering condition. In other application scenarios, determining the target time filtering conditions based on each target time point includes: obtaining a first time filtering condition based on each time point in the problem to be processed; obtaining a second time filtering condition based on each time point in the target problem; in response to the first time filtering condition and the second time filtering condition being the same, using either the first time filtering condition or the second time filtering condition as the target time filtering condition; in response to the first time filtering condition and the second time filtering condition being different, using either the first time filtering condition or the second time filtering condition as the target time filtering condition, for example, using the first time filtering condition as the target time filtering condition. It is understood that the processing logic of obtaining the first time-based filtering conditions based on each time point in the problem to be processed is the same as the processing logic of obtaining the second time-based filtering conditions based on each time point in the target problem. This application will use obtaining the first time-based filtering conditions based on each time point in the problem to be processed as an example to introduce the specific processing logic, which will not be elaborated on further.
[0058] The target variable includes a target time offset. In some application scenarios, each target time point includes at least one time point in the problem to be processed. Determining the target time offset based on each target time point includes: obtaining a first time offset based on each time point in the problem to be processed, and using the first time offset as the target time offset. In some application scenarios, each target time point includes at least one time point in the target problem. Determining the target time offset based on each target time point includes: obtaining a second time offset based on each time point in the target problem, and using the second time offset as the target time offset. In other application scenarios, each target time point includes at least one time point in the problem to be processed and at least one time point in the target problem. The determination of the target time offset based on each target time point includes: obtaining a first time offset based on each time point in the problem to be processed; obtaining a second time offset based on each time point in the target problem; in response to the first time offset and the second time offset being at the same time, using either the first time offset or the second time offset as the target time offset; in response to the first time offset and the second time offset being at different times, using either the first time offset or the second time offset as the target time offset, for example, using the first time offset as the target time offset. It is understood that the processing logic for obtaining the first time offset based on each time point in the problem to be processed is the same as the processing logic for obtaining the second time offset based on each time point in the target problem. This application uses obtaining the first time offset based on each time point in the problem to be processed as an example to introduce the specific processing logic, which will not be elaborated further later.
[0059] In some application scenarios, step S13 above can be to fill the time period variable, target time offset and / or target time filter conditions into a preset query statement template to obtain the target query statement.
[0060] Understandably, compared to generating query statements directly based on the target question, this application extracts the time period variable, target time offset, and / or target time filtering conditions and fills them into the preset query statement template to ensure the accuracy of the query time and query time offset used by the target query statement when querying data in the future.
[0061] In some embodiments, the target variable includes target time filtering conditions. The step of extracting key information from the problem to be processed to obtain the target variable includes: extracting time points from the problem to be processed to obtain at least one time point in the problem; extracting time periods from the problem to be processed to obtain time period variables in the problem; and filling at least one time point and the time period variables from the problem into an acquired preset time filtering condition template to obtain the target time filtering conditions.
[0062] The preset time filtering condition template is used to construct target time filtering conditions based on time period variables and at least one time point.
[0063] In some application scenarios, the target time filter condition is obtained by filling a preset time filter condition template with a time period variable and at least one time point. This includes directly filling the preset time filter condition template with a time period variable and at least one time point. A time period variable represents the time unit of a time query value for a single business data point in time series analysis. For example, a time period variable represents the time period variable of a single business data point in year-on-year or month-on-month comparisons, i.e., the time period variable corresponding to the single business data point when comparing year-on-year or month-on-month change rates. For example, a time period variable can be "day," "week," "month," "quarter," or "year," etc., which will not be elaborated further here.
[0064] For example, extracting time-period variables from the problem to be processed and / or the target problem can be achieved by inputting the problem to be processed and / or the target problem into a time-period variable extraction module to obtain time-period variables. Specifically, this includes the following: extracting time-series calculated time-period variables from the problem to be processed and / or the target problem. For example, if the problem to be processed or the rewritten target problem includes at least "the year-on-year comparison of the number of vehicles captured in March 2025", then the time-period variable is "month"; for example, if the problem to be processed or the rewritten target problem includes at least "the month-on-month comparison of the number of vehicles captured in the first quarter of 2025", then the time-period variable is "quarter". The time-period variable module can be implemented using any method, such as large model extraction or engineering extraction.
[0065] In some application scenarios, step S13 above can be to fill at least one time point and / or time period variable, as well as target time filter conditions, into a preset query statement template to obtain the target query statement.
[0066] The target variable includes target time filtering conditions. The steps for extracting key information from the target problem to obtain the target variable include: extracting time points from the target problem to obtain at least one time point; extracting time periods from the target problem to obtain time period variables; and filling the at least one time point and the time period variables from the target problem into the obtained preset time filtering condition template to obtain the target time filtering conditions. It is understandable that the specific implementation process of constructing target time filtering conditions using the target problem can refer to the above-described specific implementation process of constructing target time filtering conditions using the problem to be processed, and will not be repeated here.
[0067] Understandably, compared to generating query statements directly based on the target question, this application extracts at least one time point and time period variable and fills it into the preset query statement template, and fills the constructed target time filtering conditions into the preset query statement template. This ensures the accuracy of the query time and query time offset used by the target query statement when querying data in subsequent queries, as well as the time range corresponding to the target time filtering conditions.
[0068] In some embodiments, the target variable includes a target time offset. The step of extracting key information from the problem to be processed to obtain the target variable includes: extracting time points from the problem to be processed to obtain at least one time point in the problem to be processed; and determining the target time offset based on each time point in the problem to be processed.
[0069] In some application scenarios, the difference between each time point is directly used as the target time offset.
[0070] In some embodiments, the step of determining the target time offset based on each time point in the problem to be processed includes: in response to the existence of two time points in the problem to be processed, taking the difference between the two time points in the problem to be processed as the target time offset; in response to the existence of no two time points in the problem to be processed, taking the problem type to which the problem to be processed belongs as the target problem type; and taking the preset time offset corresponding to the target problem type as the target time offset.
[0071] Here, a single time point corresponds to the query time value of a single business data point that needs to be calculated in the problem to be processed. For example, if the problem to be processed belongs to the year-on-year or month-on-month problem type, the single time point can be the first time point or the second time point mentioned above.
[0072] The preset time offset corresponding to the target problem type is used as the target time offset. The problem type to which the problem to be processed belongs includes, but is not limited to, the year-on-year, month-on-month, or relative size problems in time series analysis. The preset time offset corresponding to the year-on-year problem type is the year-on-year time offset. The preset time offset corresponding to the month-on-month problem type is the month-on-month time offset. The preset time offset corresponding to the relative size problem type is the relative size time offset.
[0073] For example, the problem to be processed and / or the target problem are input into the time offset extraction module to obtain the target time offset, which specifically includes the following: The time offset extraction module is used to extract the offset calculated in the time series of the problem to be processed and / or the target problem. For example, if the problem to be processed or the rewritten target problem includes at least "the year-on-year comparison of the number of process captures in March 2025", the comparison time period is monthly, and the target problem type is the same as the problem type of the year-on-year comparison problem, then the preset time offset corresponding to the target problem type needs to be offset by 12 periods, i.e., 12 months. If there are multiple specific time points in the problem to be processed and / or the target problem, for example, if the problem to be processed or the rewritten target problem includes at least "the increment between June 2025 and January 2025", the first time point is "June 2025", and the second time point is "January 2025", then the time offset is calculated using the time units corresponding to these two time points and the time period. In the above example, there are 5 periods, and the time period is "month", so the target time offset is "5 months". If the problem to be processed and / or the target problem contains keywords such as "year-on-year" or "month-on-month" related to year-on-year or month-on-month comparisons, and the problem to be processed and / or the target problem has only one point in time, then a fixed time offset is used. For example, if the problem to be processed or the rewritten target problem includes at least "March 2nd month-on-month comparison", then the offset is 1 period, and the preset time offset corresponding to the target problem type is "1 day"; if the problem to be processed or the rewritten target problem includes at least "March year-on-year", then the offset is 12 periods, and the preset time offset corresponding to the target problem type is "12 months". Calculated according to the inherent definition of year-on-year or month-on-month comparisons, the preset time offsets are not listed one by one. The extracted preset time offset is used as the target time offset and recorded in the time_offset variable.
[0074] Please see Figure 2 , Figure 2 yes Figure 1 A schematic diagram of the sub-process of step S12.
[0075] In some embodiments, the target variable includes at least one of a time period variable, a statistical variable, or a business variable, and an initial query statement. The step of extracting key information from the target problem to obtain the target variable may include the following steps: Step S21: Transform the target problem to obtain an initial query statement. Step S22: Extract the time period variable, statistical variable, or business variable from the initial query statement.
[0076] Step S21: Transform the target question to obtain the initial query statement.
[0077] In some application scenarios, step S21 above can be to input information from some fields of the target problem into the initial query statement template to obtain the initial query statement.
[0078] In some embodiments, step S21 may include the following steps: inputting the target question into a large language model to obtain a query statement output by the large language model; and using the query statement output by the large language model as the initial query statement.
[0079] The initial query statement represents the database query statement after converting the natural language corresponding to the target question. The large language model is capable of converting the natural language corresponding to the target question into a database query statement.
[0080] For example, step S21 above includes: inputting the target question into the query statement conversion module to obtain the initial query statement output by the query statement conversion module. If the user's problem to be processed is a time series analysis problem and is a year-on-year or month-on-month problem, then the input of the query statement conversion module is the problem rewritten from the large model, i.e., the target question, such as "the number of vehicles captured each month". In other application scenarios, if the user's problem to be processed is not a time series analysis problem, then the input of the query statement conversion module is the user's problem to be processed, such as "the number of vehicles captured in May 2025". After using the output of the query statement conversion module as the target query statement, the target query statement is used to query the database and output the query results. The query statement conversion module can be a Text2SQL module. After determining the input of the Text2SQL module, the target Text2SQL technology in the Text2SQL module can be used to convert the text corresponding to the user's problem into database query language (SQL). The target Text2SQL technology includes, but is not limited to, methods based on large language models, methods based on traditional machine learning and rules, fine-tuning methods based on pre-trained language models (PTM), hybrid methods, etc. The hybrid approach can be a combination of a large language model and at least one candidate method. The candidate method can be a rule-correction method, a method for retrieving similar example query statements from the training library, or an execution feedback method. The combination of the large language model and rule correction can involve using preset rules to verify the correctness of the candidate query statements generated by the large language model, and if correct, using the candidate query statement output by the large language model as the target query statement. The combination of the large language model and retrieving similar example query statements from the training library can involve retrieving candidate query statements similar to the target problem from the training library and correcting the candidate query statement output by the large language model to obtain the initial query statement. The combination of the large language model and the execution feedback method can involve executing the candidate query statements generated by the large language model; if an error occurs, it is regenerated until an executable candidate query statement is obtained and used as the initial query statement. The query statement transformation module can convert the target problem into a semantically correct initial query statement (e.g., an SQL query).
[0081] Step S22: Extract time period variables, statistical variables, or business variables from the initial query statement.
[0082] Time-period variables, statistical variables, or business variables represent variable information related to specific fields in the initial query statement. Step S22 above may involve extracting at least one of the time-period variables, statistical variables, and business variables from the initial query statement.
[0083] In some embodiments, step S22 may include the following steps: using the values of the time period fields in the initial query statement as time period variables; and / or using the values of the statistical fields in the initial query statement as statistical variables; and / or using the values of the business fields in the initial query statement as business variables.
[0084] The time period variable represents the time unit to which the single business data indicated in the initial query belongs, i.e., the time period mentioned above. The statistical variable represents the data type of the business indicated in the initial query. The business variable represents the business scenario indicated in the initial query.
[0085] In some application scenarios, when extracting time period variables from the initial query statement, step S22 may include a first processing method, specifically including: using the value of the time period field in the initial query statement as the time period variable. In other application scenarios, when extracting statistical variables from the initial query statement, step S22 may include a second processing method, specifically including: using the value of the statistical field in the initial query statement as the statistical variable. In other application scenarios, when extracting business variables from the initial query statement, step S22 may include a third processing method, specifically including: using the value of the business field in the initial query statement as the business variable. It is understood that step S22 may include any one, any two, or all three of the above-mentioned first, second, and third processing methods; this application is not limited to this, but this application uses all three as an example. For example, step S22 may involve extracting time period variables, statistical variables, and business variables from the initial query statement.
[0086] For example, the main task is to parse which fields in the "time period statistics" SQL generated by Text2SQL are time periods, statistical values, and business fields. For example, the target problem is to at least deduct "the number of captures in each region each month". The initial query statement generated in step S21 above is "origin_query : "SELECT month, xzqh, count(1) AScapture_count FROM car_capture_table GROUP BY month,xzqh"". The first processing method above can be to extract the "month" field corresponding to the time period field in the initial query statement as a time period variable and fill the time period variable into the target time period field time_dim; the second processing method above can be to extract the "capture_count" field corresponding to the statistical field in the initial query statement as a statistical variable and fill the statistical variable into the target statistical field statistics_dim; the third processing method above can be to extract the "xzqh" corresponding to the business field in the initial query statement as a business variable and fill the business variable into the target business field other_dims.
[0087] In some application scenarios, the steps for extracting key information from the problem to be processed and obtaining the time period variable in the target variable are similar to the first processing method described above. Specifically, it includes the third extraction process corresponding to the time variable information: taking the value of the time period field in the problem to be processed as the time period variable.
[0088] In other application scenarios, the step of extracting key information from the target problem to obtain the time period variable from the target variables specifically includes a fourth extraction process corresponding to the time variable information: using the value of the time period field in the target problem as the time period variable. Alternatively, the target problem is transformed to obtain an initial query statement; the first processing method described above is then executed to extract the time period variable from the initial query statement.
[0089] In other application scenarios, the steps for extracting key information from the problem to be addressed and the target problem to obtain the time-period variable in the target variable include: performing the third extraction process and the fourth extraction process corresponding to the aforementioned time-period variable information. Either the time-period variable obtained from the third extraction process or the time-period variable obtained from the fourth extraction process is arbitrarily selected as the time-period variable in the target variable. Alternatively, it is determined whether the time-period variable obtained from the third extraction process and the time-period variable obtained from the fourth extraction process are the same. If they are different, the time-period variable obtained from the third extraction process is selected as the time-period variable in the target variable.
[0090] It is understandable that the processing logic of using the value of the time period field in the problem to be processed as the time period variable in the third extraction process corresponding to the time variable information above is the same as the processing logic of using the value of the time period field in the target problem as the time period variable in the fourth extraction process corresponding to the time variable information above; the only difference is the object of key information extraction.
[0091] In some application scenarios, step S13 above can be to fill at least one of the time period variable, statistical variable and business variable into the preset query statement template to obtain the target query statement.
[0092] Understandably, compared to generating query statements directly based on the target problem, this application extracts at least one of the time period variables, statistical variables, and business variables and fills them into the preset query statement template to ensure the accuracy of the time period variables, statistical variables, and business variables used by the target query statement when querying data in the future.
[0093] In other application scenarios, step S13 above can be to fill at least one of the time period variable, statistical variable, and business variable, as well as the initial query statement, into a preset query statement template to obtain the target query statement.
[0094] Understandably, compared to directly generating query statements based on the target problem, this application extracts the candidate time and target time offset and fills them into the preset query statement template, and fills the converted initial query statement into the preset query statement template. This ensures the accuracy of the time period variables, statistical variables, business variables, and key query statement fields used by the target query statement when querying data in the future.
[0095] For example, the target variables also include projection variables. After obtaining the time period variables, statistical variables, and business variables, projection variables are constructed based on these variables to find the target query statement. The projection variable can be represented as `all_projection_cols`. In the example above, the projection variable could be "month, xzqh, capture_count". Simultaneously, the time in the text of the question to be processed is extracted as candidate times `stats_time`. Combined with the time unit corresponding to the time period or the time period variable `time_unit`, a target time filtering condition `time_condition` for a certain time period in the user's question can be constructed. For example, the target time filtering condition could be "month = '2025-03'".
[0096] In other application scenarios, the target variable includes, but is not limited to, at least one of the following: candidate time, target time offset, target time filtering condition, time period variable, statistical variable, business variable, and initial query statement. Step S13 above can involve filling at least one of the following into a preset query statement template to obtain the target query statement. The preset query statement template can be an SQL template. The final target query statement can be encapsulated using the SQL template and the target variable. For example, the target query statement could be: "SELECT all_projection_cols,LAG({statistics_dim},{time_offset},0) OVER ({other_dim} ORDER BY {time_dim}) FROM origin_query WHEREtime_condition".
[0097] In other application scenarios, after the target query statement is generated in step S13 above, the target query statement is handed over to the executor corresponding to the database for execution feedback and the execution result is obtained. The execution result and the problem to be processed are encapsulated into data summary prompt words, which are then handed over to the large language model to summarize the query results and obtain the summary data corresponding to the problem to be processed output by the large language model. This module can reuse the current mainstream large model summary capabilities, which will not be elaborated further.
[0098] For example, the summary data may include the following: "The prompt template is: 'You are a data analysis expert. Regarding the user's question: {question}, the system retrieved the following data {data}. Please summarize the data insightfully, combining the user's question and the query results.'" Appendix: Taking the question to be processed as "Comparison of the number of vehicle captures in each administrative region in March 2025 and January 2025" as an example, the vehicle capture table is named car_capture_table, and the main fields are capture time dt and administrative division xzqh. Following the steps described above in this application, the target query statement is obtained. Step 1: First, the intent is determined. This question belongs to time series analysis and needs to be rewritten. The output is ['Yes', 'Number of vehicle captures in each administrative region each month']. Step 2: The process of converting the target question into an initial query statement is executed. The target question, 'Number of vehicle captures each month', will generate the following simple initial query statement: "SELECT xzqh, DATE_FORMAT(dt, '%Y-%m') AS month , COUNT(1) AS capture_countFROM car_capture_table GROUP BY DATE_FORMAT(dt, '%Y-%m'), xzqh". Step 3: Identify the time period and extract the time period from the problem to be processed and / or the target problem. For example, if the target problem is 'the number of vehicles captured each month', then the time period is extracted as "month". Step 4: Calculate the time offset. Extract two time periods from the text and calculate the offset based on the time period. For example, March 2025 and January 2025 have a time period of "month", and these two time points differ by 2 months. Therefore, the target time offset time_offset is 2. Step 5: After parsing the SQL Schema, month is the time period field time_dim, capture_count is extracted as the statistics field statistics_dim, and xzqh is the business field. Step 6: Based on the SQL template and the user's time filtering conditions, generate the time series statistics that meet the requirements.The time filter condition is month = '2025-03', so the final target query statement is: "SELECT xzqh, DATE_FORMAT(dt, '%Y-%m') AS month , COUNT(1) AS capture_count,LAG(capture_count, 2, 0) OVER (xzqh ORDER BY month) FROM car_capture_tableGROUP BY DATE_FORMAT(dt, '%Y-%m'), xzqh WHERE month = '2025-03'".
[0099] Please see Figure 3 , Figure 3 This is another flowchart illustrating an exemplary embodiment of the query statement generation method of this application.
[0100] The following steps S31 to S34 are executed sequentially to obtain the target query statement. Specifically, Step S31: In response to the time series analysis problem representing the problem to be processed, the problem to be processed is rewritten to obtain the target problem. Step S32: Key information is extracted from the problem to be processed and / or the target problem to obtain time period variables, target time offsets, and target time filtering conditions. Step S33: Key information is extracted from the target problem to obtain the initial query statement, statistical variables, and business variables. Step S34: The time period variables, target time offsets, target time filtering conditions, initial query statement, statistical variables, and business variables are filled into the obtained preset query statement template to obtain the target query statement.
[0101] The above scheme, in representing the time series analysis problem of the problem to be processed, rewrites the problem to be processed to obtain the target problem so that the key information of the problem to be processed is retained in the target problem and the complexity is low. Information extraction processing is performed on the problem to be processed and / or the target problem to obtain the target variable. The target variable is filled into the obtained preset query statement template to obtain the target query statement, which can improve the generation efficiency of the target query statement.
[0102] Please see Figure 4 , Figure 4This is a schematic diagram of the structure of an embodiment of the query statement generation device of this application. The query statement generation device 40 includes a problem rewriting module 41, an information extraction module 42, and a generation module 43; the problem rewriting module 41 is used to rewrite the problem to be processed in response to the problem representing the time series analysis problem, to obtain the target problem; the information extraction module 42 is used to perform information extraction processing on the problem to be processed and / or the target problem, to obtain the target variable; the generation module 43 is used to fill the target variable into the obtained preset query statement template, to obtain the target query statement.
[0103] The above scheme, in representing the time series analysis problem of the problem to be processed, rewrites the problem to be processed to obtain the target problem so that the key information of the problem to be processed is retained in the target problem and the complexity is low. Information extraction processing is performed on the problem to be processed and / or the target problem to obtain the target variable. The target variable is filled into the obtained preset query statement template to obtain the target query statement, which can improve the generation efficiency of the target query statement.
[0104] For details on the functions performed by each module, please refer to the query statement generation method; they will not be elaborated here.
[0105] Please see Figure 5 , Figure 5 This is a schematic diagram of the structure of an embodiment of the electronic device of this application. The electronic device 50 includes a memory 51 and a processor 52. The processor 52 is used to execute program instructions stored in the memory 51 to implement the steps in the above-described query statement generation method embodiment. In a specific implementation scenario, the electronic device 50 may include, but is not limited to, a microcomputer or a server. In addition, the electronic device 50 may also include mobile devices such as laptops and tablets, which are not limited here.
[0106] Specifically, processor 52 controls itself and memory 51 to implement the steps in the above-described query statement generation method embodiment. Processor 52 can also be called a CPU (Central Processing Unit). Processor 52 may be an integrated circuit chip with signal processing capabilities. Processor 52 can also be a general-purpose processor, digital signal processor (DSP), application-specific integrated circuit (ASIC), field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. A general-purpose processor can be a microprocessor or any conventional processor. Furthermore, processor 52 can be implemented using integrated circuit chips.
[0107] The above scheme, in representing the time series analysis problem of the problem to be processed, rewrites the problem to be processed to obtain the target problem so that the key information of the problem to be processed is retained in the target problem and the complexity is low. Information extraction processing is performed on the problem to be processed and / or the target problem to obtain the target variable. The target variable is filled into the obtained preset query statement template to obtain the target query statement, which can improve the generation efficiency of the target query statement.
[0108] Please see Figure 6 , Figure 6 This is a schematic diagram of the structure of an embodiment of the computer-readable storage medium of this application. The computer-readable storage medium 60 stores program instructions 601 thereon, which, when executed by a processor, implement the steps in any of the above-described query statement generation method embodiments.
[0109] The above scheme, in representing the time series analysis problem of the problem to be processed, rewrites the problem to be processed to obtain the target problem so that the key information of the problem to be processed is retained in the target problem and the complexity is low. Information extraction processing is performed on the problem to be processed and / or the target problem to obtain the target variable. The target variable is filled into the obtained preset query statement template to obtain the target query statement, which can improve the generation efficiency of the target query statement.
[0110] In some embodiments, the functions or modules of the apparatus provided in this disclosure can be used to perform the methods described in the above method embodiments. The specific implementation can be referred to the description of the above method embodiments, and for the sake of brevity, it will not be repeated here.
[0111] The description of the various embodiments above tends to emphasize the differences between the various embodiments. The similarities or similarities between them can be referred to, and for the sake of brevity, they will not be repeated here.
[0112] In the several embodiments provided in this application, it should be understood that the disclosed methods and apparatus can be implemented in other ways. For example, the apparatus implementations described above are merely illustrative. For instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection of devices or units may be electrical, mechanical, or other forms.
[0113] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0114] If the integrated unit is implemented as 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 technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) or processor to execute all or part of the steps of the methods of various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0115] If the technical solution of this application involves personal information, the product using this technical solution has clearly informed the user of the personal information processing rules and obtained the user's voluntary consent before processing the personal information. If the technical solution of this application involves sensitive personal information, the product using this technical solution has obtained the user's separate consent before processing the sensitive personal information, and also meets the requirement of "express consent". For example, at personal information collection devices such as cameras, clear and prominent signs are set up to inform users that they have entered the scope of personal information collection and that personal information will be collected. If an individual voluntarily enters the collection scope, it is deemed that they have agreed to the collection of their personal information; or on the personal information processing device, with clear signs / information informing users of the personal information processing rules, authorization is obtained from the individual through pop-up information or by asking the individual to upload their personal information; wherein, the personal information processing rules may include information such as the personal information processor, the purpose of personal information processing, the processing method, and the types of personal information processed.
Claims
1. A method for generating query statements, characterized in that, The method includes: In response to the problem to be processed representing a time series analysis problem, the problem to be processed is rewritten to obtain a target problem. The complexity of the target problem is lower than that of the problem to be processed, and the target problem represents a problem related to the calculation of statistical values of business data in a single time period. Information extraction processing is performed on the problem to be processed and / or the target problem to obtain the target variable; The target variable is filled into the obtained preset query statement template to obtain the target query statement; The step of extracting information from the problem to be processed and / or the target problem to obtain the target variable includes: The process involves extracting key information from the problem to be processed to obtain the target variable, which includes at least one of the following: a time period variable, a target time offset, or a target time filtering condition; and extracting key information from the target problem to obtain the target variable, which includes at least one of the following: a time period variable, a target time offset, a target time filtering condition, an initial query statement, a statistical variable, or a business variable. The target variable includes at least one of the time period variable, the statistical variable, or the business variable, as well as the initial query statement. The step of extracting key information from the target question to obtain the target variable includes: transforming the target question to obtain the initial query statement; and extracting the time period variable, the statistical variable, or the business variable from the initial query statement. The target variable includes target time filtering conditions. The step of extracting key information from the problem to be processed to obtain the target variable includes: extracting time points from the problem to be processed to obtain at least one time point in the problem to be processed; extracting time periods from the problem to be processed to obtain time period variables in the problem to be processed; and filling at least one time point in the problem to be processed and the time period variables into the obtained preset time filtering condition template to obtain the target time filtering conditions. The target variable includes a target time offset. The step of extracting key information from the problem to be processed to obtain the target variable includes: extracting time points from the problem to be processed to obtain at least one time point in the problem to be processed; and determining the target time offset based on each time point in the problem to be processed.
2. The method according to claim 1, characterized in that, The step of extracting the time period variable, the statistical variable, or the business variable from the initial query statement includes: Use the value of the time period field in the initial query statement as the time period variable; and / or, Use the values of the statistical fields in the initial query statement as the statistical variables; and / or, The values representing the business fields in the initial query statement are used as the business variables.
3. The method according to claim 1, characterized in that, The step of transforming the target problem to obtain the initial query statement includes: The target question is input into the large language model to obtain the query statement output by the large language model; The query statement output by the large language model is used as the initial query statement.
4. The method according to claim 1, characterized in that, The step of determining the target time offset based on each time point in the problem to be processed includes: In response to the existence of two time points in the problem to be processed, the difference between the two time points in the problem to be processed is taken as the target time offset; Since there are no two points in time in the problem to be processed, the problem type to which the problem to be processed belongs is taken as the target problem type; The preset time offset corresponding to the target problem type is used as the target time offset.
5. An electronic device, characterized in that, include: A memory and a processor, wherein the memory stores program instructions, and the processor retrieves the program instructions from the memory to perform the method as claimed in any one of claims 1-4.
6. A computer-readable storage medium having program instructions stored thereon, characterized in that, When the program instructions are executed by the processor, they are used to implement the method as described in any one of claims 1-4.
Citation Information
Patent Citations
Intelligent question and answer method and device, equipment and medium
CN118153579A
Method and system for realizing Text2SQL (Structured Query Language)
CN120470020A
Micro-report generation method and device and storage medium
CN121072499A
Data analysis system and method based on artificial intelligence
CN121092559A