Query statement generation method and system, and storage medium

By combining word segmentation and an indicator library with a large language model to generate PromQL query statements, the problems of complexity in manual writing and poor model adaptability in existing technologies are solved, and more accurate query statements that meet user needs are generated.

CN120162428BActive Publication Date: 2025-11-28TIANJIN TIANHE COMPUTER TECH CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202510638164.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-05-19
Publication Date
2025-11-28
Estimated Expiration
2045-05-19

AI Technical Summary

Technical Problem

Existing PromQL query statements rely on manual writing, which has a high learning curve, a high error rate, and is difficult to collaborate across teams. When the model generates statements, the input data volume is limited and the adaptability to different scenarios is poor, resulting in query statements that cannot meet user needs.

Method used

By acquiring the user's question description text, performing word segmentation, and combining it with a pre-built indicator library and large language model, a query statement is generated. The word segmentation results and indicator categories are used to determine candidate indicators, and a query statement that meets the user's needs is generated.

Benefits of technology

It improves the accuracy and adaptability of query statements, avoids the generation of incorrect statements by the model, enhances the understanding in specific scenarios, and ensures that query statements meet user needs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120162428B_ABST
    Figure CN120162428B_ABST
Patent Text Reader

Abstract

The application provides a query statement generation method and system and a storage medium. The method obtains a problem description text input by a user in an interactive interface, performs word segmentation processing on the problem description text, determines a first candidate index category according to the word segmentation result, further obtains all indexes in a pre-constructed index library, determines a second candidate index category according to the obtained indexes and the problem description text, and generates at least one recommended query statement according to the first candidate index category, the second candidate index category, the problem description text, and a pre-trained large language model, thereby realizing the generation of the query statement, making the generated query statement more consistent with the user query demand, avoiding the prediction error of the model for the user query demand caused by the difference in the input description of different users, increasing the understanding of the model in a specific scenario, helping the model to discover more comprehensive related indexes, and accurately generating the query statement required by the user.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the field of time series data query, in particular to a query statement generation method and system and a storage medium. BACKGROUND

[0002] PromQL (Prometheus Query Language) is a special language used by Prometheus to query and aggregate time series data. Currently, PromQL query statements are mainly manually written, which has the following problems: 1. High learning threshold, non-professionals are difficult to master complex syntax (such as aggregation functions, label matching, time range operations); 2. Inefficient and error-prone, manual writing of multi-index association queries is time-consuming and prone to logical omissions; 3. Obstacles to cross-team collaboration, business personnel cannot directly obtain monitoring data through natural language, and rely on the secondary development of technical teams.

[0003] Using a model to generate PromQL query statements can solve the above problems to some extent. However, in related technologies, errors in the corpus used by the model can cause the generated statements to not meet user needs; and due to the limitation of the input data volume of the model, it can be difficult for the model to pass all indicators in a large-scale data scenario, thereby causing the model to generate incorrect statements; in addition, the statement descriptions required by users in different fields are very different, and the model is difficult to understand user needs in specific scenarios. SUMMARY

[0004] In view of the above defects or deficiencies in the prior art, the present application aims to provide a query statement generation method, system and storage medium to solve the problems of query statements not meeting user needs and query statement errors in the prior art.

[0005] The embodiment of the present application provides a query statement generation method, which comprises:

[0006] Obtaining a problem description text input by a user in an interactive interface, and performing word segmentation processing on the problem description text, and determining a first candidate indicator category according to the word segmentation result;

[0007] Obtaining all indicators in a pre-constructed indicator library, and determining a second candidate indicator category according to the obtained indicators and the problem description text, wherein the indicator is a data name of a time series, and the indicator category is a classification of the data name;

[0008] Generating at least one recommended query statement based on the first candidate indicator category, the second candidate indicator category, the problem description text, and a pre-trained large language model.

[0009] Optionally, determining the first candidate indicator category according to the word segmentation result comprises:

[0010] updating the number of times of word segmentation of each word in the word segmentation table according to the current word in the word segmentation result;

[0011] determining the first candidate index category according to the current word and the hit rate of the word in each index category in the word segmentation table.

[0012] Optionally, determining the first candidate index category according to the current word and the hit rate of the word in each index category in the word segmentation table comprises:

[0013] determining the prediction selection probability of each index category according to the current word and the hit rate of the word in each index category in the word segmentation table;

[0014] determining the index category with the prediction selection probability greater than the preset probability threshold as the first candidate index category.

[0015] Optionally, determining the prediction selection probability of each index category according to the current word and the hit rate of the word in each index category in the word segmentation table comprises:

[0016] for each index category, determining the sum of the hit rates of the current words in the index category in the word segmentation table as the numerator, and determining the sum of the hit rates of the words in the index category in the word segmentation table as the denominator;

[0017] calculating the probability of the index category being selected under the current word based on the numerator and the denominator to obtain the prediction selection probability of the index category.

[0018] Optionally, determining the second candidate index category according to the obtained index and the problem description text comprises:

[0019] constructing category context information according to the obtained index;

[0020] inputting the category context information and the problem description text into a large language model to obtain the second candidate index category.

[0021] Optionally, generating at least one recommended query sentence based on the first candidate index category, the second candidate index category, the problem description text and the pre-trained large language model comprises:

[0022] obtaining a candidate index list in the index library based on the first candidate index category and the second candidate index category;

[0023] constructing index context information according to the candidate index list, and inputting the index context information and the problem description text into a large language model to obtain at least one recommended query sentence.

[0024] Optionally, after generating at least one recommended query sentence, it further comprises:

[0025] displaying a recommended query sentence in an interactive interface;

[0026] In response to detecting that the user triggers a confirmation operation for the recommended query sentence, the hit times and hit rates of each word in the word segmentation table are updated based on the index category corresponding to the recommended query sentence and the current word in the word segmentation result.

[0027] Optionally, the construction of the index library comprises:

[0028] Obtaining a time series database, and extracting each index and corresponding label name from the time series database;

[0029] Determining label description information corresponding to each label name, and determining an index category corresponding to each index;

[0030] According to each index and the corresponding index category and label description information, an index library is constructed.

[0031] Embodiments of the present application also provide a query sentence generation system, which comprises an interactive module, a word segmenter, a context constructor, a model usage module and a feedback device, wherein:

[0032] The interactive module is configured to obtain a problem description text input by a user in an interactive interface, and display a recommended query sentence in the interactive interface, and in response to detecting that the user triggers a confirmation operation for the recommended query sentence, send the index category corresponding to the recommended query sentence and the current word in the word segmentation result to the feedback device;

[0033] The word segmenter is configured to perform word segmentation processing on the problem description text, and determine a first alternative index category according to the word segmentation result;

[0034] The context constructor is configured to obtain all indexes in a pre-constructed index library, construct category context information according to the obtained indexes, input the category context information and the problem description text into the large language model to obtain a second alternative index category, and based on the first alternative index category and the second alternative index category, obtain an alternative index list in the index library, construct index context information according to the alternative index list, and input the index context information and the problem description text into the large language model to obtain at least one recommended query sentence;

[0035] The feedback device is configured to update the hit times and hit rates of each word in the word segmentation table.

[0036] Embodiments of the present application also provide an electronic device, which comprises:

[0037] A processor and a memory;

[0038] The processor calls the program or instruction stored in the memory to execute the steps of the query statement generation method provided in any of the embodiments of the present application.

[0039] The present application also provides a computer readable storage medium storing a program or instruction, which causes a computer to execute the steps of the query statement generation method provided in any of the embodiments of the present application.

[0040] In summary, the query statement generation method provided in the present application can obtain the problem description text input by the user in the interactive interface, perform word segmentation processing on the problem description text, determine the first candidate index category according to the word segmentation result, further obtain all indexes in the pre-constructed index library, determine the second candidate index category according to the obtained indexes and the problem description text, and generate at least one recommended query statement according to the first candidate index category, the second candidate index category, the problem description text and the pre-trained large language model, thereby realizing the generation of the query statement. This method can enable the large language model to generate the query statement within a specific index category range by combining the first candidate index category, the second candidate index category and the problem description text, avoid the model from generating the query statement according to its own experience, and cause other indexes in addition to the index library to exist in the query statement, so that the generated query statement is more in line with the user query demand. Moreover, this method determines the candidate index categories through word segmentation and the index library, respectively, for the large language model to generate the statement, can avoid the difference in the description input by different users from causing the model to predict the user query demand incorrectly, can increase the understanding of the model in a specific scenario, help the model to discover more comprehensive related indexes, and enable the model to accurately generate the query statement required by the user. BRIEF DESCRIPTION OF DRAWINGS

[0041] In order to more clearly illustrate the specific embodiments of the present application or the technical solutions in the prior art, the drawings needed in the specific embodiments or prior art description will be briefly introduced below. Obviously, the drawings in the following description are some embodiments of the present application, and those skilled in the art can also obtain other drawings according to these drawings without creative labor.

[0042] Figure 1 is a flowchart of a query statement generation method provided by an embodiment of the present application;

[0043] Figure 2 is a schematic diagram of a query statement generation system provided by an embodiment of the present application;

[0044] Figure 3 is an interactive process schematic diagram of a query statement generation system provided by an embodiment of the present application;

[0045] Figure 4 is a structural schematic diagram of an electronic device provided by an embodiment of the present application. DETAILED DESCRIPTION

[0046] The present application will be further described below in conjunction with the accompanying drawings and embodiments. It can be understood that the specific embodiments described herein are only used to explain the related application, and not to limit the application. In addition, it should be noted that, for the sake of description, only the parts related to the application are shown in the drawings.

[0047] It should be noted that the embodiments in the present application and the features in the embodiments can be combined with each other without conflict. The present application will be described in detail below with reference to the accompanying drawings and in conjunction with the embodiments.

[0048] Embodiment one

[0049] As mentioned in the background, in view of the problems in the prior art, the present application proposes a query statement generation method. Figure 1 is a flowchart of a query statement generation method provided by an embodiment of the present application. Referring to Figure 1 , the query statement generation method specifically includes:

[0050] S110, obtaining the problem description text input by the user in the interactive interface, and performing word segmentation processing on the problem description text, and determining the first candidate index category according to the word segmentation result.

[0051] Specifically, the interactive interface can be a Web UI, and the user can interact through a browser. Specifically, the interactive interface can be used for the user to input the problem description text, and can be used for the user to display the generated recommended query statement, and can be used for detecting the operation triggered by the user for the recommended query statement, etc.

[0052] In the embodiment of the present application, the problem description text can describe the time series data that the user needs to query in the time series database, reflecting the user's query demand. Among them, the time series database can store time series (i.e. time series data), such as TSDB (Time Series Database); the time series can be a numerical sequence of the index changing with time, which is uniquely determined by the index and the label, for example, CPU_usage_active{cluster=” HPC”, device=”ln1”}, which represents the CPU usage rate of the ln1 device on the HPC cluster.

[0053] For example, the user can enter the problem description text in the text box in the interactive interface; or the user can select the problem description text from the popular description text displayed in the interactive interface, where the popular description text can be obtained by counting and sorting the problem description texts entered by each user in history.

[0054] Specifically, after obtaining the problem description text input by the user in the interactive interface, the problem description text can be processed by word segmentation, for example, using a Chinese word segmenter (such as Jieba) to extract Chinese words in the problem description text to obtain each current word.

[0055] The word segmenter can have the ability to extract the object in the Chinese information, for example, the problem description text is "HPC cluster ln1 node CPU usage", in which the CPU usage is an indicator, and the object in the problem description text can be extracted by algorithm configuration.

[0056] To avoid the influence of invalid words on the generation efficiency of subsequent query statements, TF-IDF (Term Frequency-Inverse Document Frequency) algorithm can also be used to filter out key information from all current words and remove invalid words such as "need", "here", "I" and the like.

[0057] After obtaining the word segmentation result, the first candidate indicator category can be further determined based on the word segmentation result. The indicator is the data name of the time series, and the indicator category is the classification of the data name.

[0058] For example, the indicator can be understood as the name of a measurable phenomenon, such as CPU usage. The indicator category can be understood as the classification of the indicator, such as the category of CPU usage is CPU, and the category of total device memory bytes is device.

[0059] In one specific embodiment, determining the first candidate indicator category based on the word segmentation result includes the following steps:

[0060] Step 11, updating the word segmentation times of each word in the word segmentation table according to the current words in the word segmentation result;

[0061] Step 12, determining the first candidate indicator category according to the current words and the hit rate of the words under each indicator category in the word segmentation table.

[0062] In step 11, the word segmentation times of each word in the word segmentation table can be updated according to each current word in the word segmentation result. The word segmentation table can be used to record the association between the words and the indicator categories in the indicator library; the word segmentation table can include the hit times, word segmentation times and hit rate of each word under each indicator category.

[0063] wherein, the hit times is the number of times that the word is hit in the recommended query sentence generated by the large language model, the segmentation times is the number of times that the word is segmented from the problem description text input by the user, and the hit rate is used to describe the probability that the word is hit in the recommended query sentence generated by the large language model, which can reflect the frequency of the word being hit, for example, the hit rate is equal to the ratio between the hit times and the segmentation times. For example, Table 1 shows a segmentation table.

[0064] Table 1: A segmentation table

[0065]

[0066] After updating the segmentation table, further, in step 12, the first candidate index category can be determined by querying the index categories related to the current word in the segmentation table, and combining the hit rate of the current word in each index category.

[0067] For the above step 12, in an example, the first candidate index category is determined according to the current word and the hit rate of the word in each index category in the segmentation table, including the following steps:

[0068] Step 121, determining the prediction selection probability of each index category according to the current word and the hit rate of the word in each index category in the segmentation table.

[0069] Step 122, determining the index category with a prediction selection probability greater than a preset probability threshold as the first candidate index category.

[0070] In step 121, the index categories related to the current word can be queried in the segmentation table to obtain the hit rate of the current word in each index category related to it, and then the prediction selection probability of each index category related to it is calculated according to the hit rate of the current word in each index category related to it.

[0071] For the above step 121, optionally, the prediction selection probability of each index category is determined according to the current word and the hit rate of the word in each index category in the segmentation table, including:

[0072] For each index category, the sum of the hit rates of the current words under the index category in the segmentation table is determined as the numerator, and the sum of the hit rates of the words under the index category in the segmentation table is determined as the denominator; based on the numerator and the denominator, the probability of the index category being selected under the current word is calculated to obtain the prediction selection probability of the index category.

[0073] Wherein, each index category related to the current word can be searched from the segmentation table, and then for each index category, the corresponding prediction selection probability is determined respectively.

[0074] Specifically, for each index category, the probability of the index category being selected under the current word, i.e., the predicted selection probability, can be calculated by taking the sum of the hit rates of the current words under the index category as the numerator and taking the sum of the hit rates of all words under the index category as the denominator, as shown in the following formula:

[0075] ;

[0076] In the formula, the probability of the index category being selected under the current word, i.e., the predicted selection probability, ~ is the hit rate of the kth current word under the index category, is the number of current words under the index category, is the hit rate of the mth word under the index category, is the number of words under the index category.

[0077] For example, if the current word includes , the predicted selection probability of the CPU index category under the current word is:

[0078] ;

[0079] Through the above optional implementation, the predicted selection probability of each index category can be accurately determined, which facilitates subsequent screening of the alternative categories for sentence generation by the large language model, so that the model-generated sentence is more accurate and meets the user's demand.

[0080] After obtaining the predicted selection probability of each index category, the predicted selection probability can reflect the probability of each index category being selected under the user's current word. Further, in step 122, the index category with a predicted selection probability greater than a preset probability threshold can be selected as the first alternative index category.

[0081] Through steps 121-122, the predicted selection probability of each index category can be used to determine the alternative index category, ensuring the accuracy of the alternative index category and obtaining an index category that meets the user's query demand, thereby helping the model to generate a more accurate query sentence.

[0082] S120, obtaining all indexes in the pre-constructed index library, and determining a second alternative index category according to the obtained indexes and the problem description text.

[0083] ​In the embodiment of the present application, in addition to determining the first candidate indicator category based on the word segmentation result of the problem description text, the second candidate indicator category can also be determined according to the indicator library and the problem description text, so as to help the model generate a query statement within the scope of the indicator library and avoid the model generating a query statement for an indicator that does not exist in the time series database.

[0084] It should be noted that in the embodiment of the present application, the purpose of determining the first candidate indicator category based on the word segmentation result of the problem description text and the word segmentation table is to: the first candidate indicator category can be input into the large language model together with the second candidate indicator category, avoid the model directly using the second candidate indicator category to generate a reference statement, provide a correction mechanism for the model, solve the deviation of the second candidate indicator category caused by the difference in the description input by different users, and thus help the large language model better understand the user semantics, provide the model with relevant indicators that the model has not understood or discovered, and the model can better understand the user demand in a specific scenario.

[0085] The indicator library can include various indicator categories and indicators under various indicator categories. In an example, the construction of the indicator library includes the following steps:

[0086] Step 21, acquiring a time series database, and extracting indicators and corresponding label names from the time series database;

[0087] Step 22, determining label description information corresponding to each label name, and determining indicator categories corresponding to each indicator;

[0088] Step 23, constructing an indicator library according to each indicator and corresponding indicator category and label description information.

[0089] The time series database can be a TSDB for storing various time series. In step 21, the time series database can be acquired, and indicators and corresponding label names can be extracted from each time series in the time series database.

[0090] Further, in step 22, label description information corresponding to each label name can be determined, which can describe the explanation of all label names and the explanation of indicators. Furthermore, indicator categories corresponding to each indicator, i.e., the classification involved by the indicators, can also be determined.

[0091] Further, in step 23, an indicator library can be constructed according to each indicator and corresponding indicator category and label description information, and the indicator library can store indicators under each indicator category and label description information corresponding to the indicators.

[0092] For example, the definition of the indicator library is as follows:

[0093] {

[0094] "<category1>": [

[0095] {

[0096] "metric": "<metric>",

[0097] "labels": ["<label1>", "<label2>"],

[0098] "desc": "<label description information>"

[0099] },

[0100] {

[0101] "metric": "<metric>",

[0102] "labels": ["<label1>", "<label2>"],

[0103] "desc": "<label description information>"

[0104] }, ...

[0106] ],

[0107] "<category2>": [

[0108] {

[0109] "metric": "<metric>",

[0110] "labels": ["<label1>", "<label2>"],

[0111] "desc": "<label description information>"

[0112] },

[0113] {

[0114] "metric": "<metric>",

[0115] "labels": ["<label1>", "<label2>"],

[0116] "desc": "<label description information>"

[0117] }, ...

[0119] ], ...

[0121] }

[0122] In the embodiments of the present application, taking the CPU index category and the device index category as examples, part of the information in the index library is displayed:

[0123] {

[0124] “CPU”: [

[0125] {

[0126] “metric”: “CPU_usage_idle”,

[0127] “labels”: [“cluster”, “device”, “CPU”],

[0128] “desc”: cluster indicates a cluster, device indicates a device reflected by the index, CPU indicates a CPU ID or an overall CPU on the device, and the index indicates an idle usage rate of a CPU on a device in a cluster.

[0129] },

[0130] {

[0131] “metric”: “CPU _usage_user”,

[0132] “labels”: [“cluster”, “device”, “CPU”],

[0133] “desc”: cluster indicates a cluster, device indicates a device reflected by the index, CPU indicates a CPU ID or an overall CPU on the device, and the index indicates a user state usage rate of a CPU on a device in a cluster.

[0134] }

[0135] ],

[0136] “MEM”: [

[0137] {

[0138] “metric”: “mem_total”,

[0139] “labels”: [“cluster”, “device”],

[0140] “desc”: cluster indicates a cluster, device indicates a device reflected by the index, and the index indicates a total number of memory bytes of a device in a cluster.

[0141] },

[0142] {

[0143] "metric": "mem_used_percent",

[0144] "labels": ["cluster", "device"],

[0145] "desc": "cluster indicates cluster, device indicates the device reflected by the index, and the index indicates the memory usage of a device in a cluster.

[0146] } ]

[0148] }

[0149] Through the above example, part of the information in the time series database of large-scale data can be extracted to construct an index library. Compared with the large-scale time series database, due to the high cardinality, the number of time series in the time series database is tens of millions, and after refining, the data in the constructed index library can be reduced by thousands of times or more, which facilitates subsequent quick access to index categories from the index library and improves the efficiency of the overall process.

[0150] For example, CPU_usage_active{cluster="HPC", device="ln1"} 90% indicates that the current CPU usage of the ln1 device in the HPC cluster is 90%. However, in actual situations, due to the existence of multiple clusters and ten-thousand-level devices in supercomputing centers, intelligent computing centers, data centers, etc., the CPU_usage_active index will have <cluster number * device number> unique time series, causing data expansion in the TSDB. In contrast, the index library removes label values and uses label description to refine the TSDB, which can greatly reduce the data volume to provide it to a large language model as category context information.

[0151] In the embodiments of the present application, all indexes can be obtained from the index library, and then the second candidate index category is determined according to the obtained indexes and the problem description text.

[0152] In a specific implementation, the second candidate index category is determined according to the obtained indexes and the problem description text, including:

[0153] The category context information is constructed according to the obtained indexes; and the category context information and the problem description text are input into a large language model to obtain the second candidate index category.

[0154] The category context information can be constructed according to the indicators obtained from the indicator library. The context information refers to the range of input information that the model refers to when generating an answer, and is used to help the model understand the current context and generate relevant content. The category context information can help the large language model identify the indicator categories contained in the problem description text.

[0155] Further, the category context information and the problem description text can be input into the large language model, so that the large language model identifies the indicator categories contained in the problem description text based on the category context information, and obtains the second candidate indicator category.

[0156] Through the above embodiments, the indicators in the indicator library can be used to construct context information, which is input into the large language model together with the problem description text, to help the large language model identify the indicator categories contained in the problem description text, improve the accuracy of the second candidate indicator category, help the model understand user demand in a specific query scenario, and avoid the model outputting indicator categories not involved in the TSDB, thereby avoiding the model generating query statements for indicators that do not exist in the TSDB.

[0157] S130, based on the first candidate indicator category, the second candidate indicator category, the problem description text, and the pre-trained large language model, generating at least one recommended query statement.

[0158] The large language model can be a neural network model trained through massive text data and can understand and generate natural language text.

[0159] Specifically, after obtaining the first candidate indicator category and the second candidate indicator category, context information can be constructed according to the first candidate indicator category and the second candidate indicator category, and the context information and the problem description text are input into the large language model to obtain at least one recommended query statement.

[0160] In a specific embodiment, based on the first candidate indicator category, the second candidate indicator category, the problem description text, and the pre-trained large language model, at least one recommended query statement is generated, including:

[0161] Based on the first candidate indicator category and the second candidate indicator category, a candidate indicator list is obtained from the indicator library; indicator context information is constructed according to the candidate indicator list, and the indicator context information and the problem description text are input into the large language model to obtain at least one recommended query statement.

[0162] Specifically, all indicators under the first candidate indicator category can be queried from the indicator library, and all indicators under the second candidate indicator category can be queried from the indicator library, and a candidate indicator list can be constructed according to all the indicators obtained by querying.

[0163] Further, the index context information can be constructed according to the alternative index list, and the index context information can help the large language model to generate a query statement that meets the user's problem description.

[0164] Specifically, the index context information and the problem description text can be input into the large language model together, so that the large language model can understand the problem description text in combination with the index context information, and generate a recommended query statement, such as a PromQL statement, that meets the user's needs.

[0165] The above embodiments can help the large language model to identify the index that the user needs to query from the problem description text by constructing the index context information from the first alternative index category and the second alternative index category, so as to accurately generate a corresponding recommended query statement, so that the statement generated by the large language model is more in line with the user's needs.

[0166] In the embodiments of the present application, in order to achieve more accurate query statement recommendation, after generating the recommended query statement, the word segmentation table can be updated based on the user's feedback to ensure more accurate recommendation next time.

[0167] In some embodiments, after generating the at least one recommended query statement, the method further includes:

[0168] displaying the recommended query statement on the interactive interface; and updating the hit frequency and hit rate of each word in the word segmentation table based on the index category corresponding to the recommended query statement and the current word in the word segmentation result, in response to detecting that the user triggers a confirmation operation for the recommended query statement.

[0169] Further, after obtaining the recommended query statement, the recommended query statement can be displayed on the interactive interface.

[0170] After displaying the recommended query statement on the interactive interface, the operation triggered by the user for the displayed recommended query statement can be detected on the interactive interface. Specifically, if it is detected that the user triggers a confirmation operation for the recommended query statement, it indicates that the current query statement recommendation is successful, and the word segmentation table can be updated according to the index category corresponding to the recommended query statement and the current word in the word segmentation result, such as updating the hit frequency and hit rate of the current word in the index category corresponding to the recommended query statement in the word segmentation table.

[0171] Through the above embodiments, the user behavior can be recorded based on the feedback mechanism, and the word segmentation table can be updated through the feedback mechanism, which can improve the understanding ability of the large language model in generating the recommended query statement in the subsequent process, so that the large language model can more accurately recommend the query statement.

[0172] The method for generating a query statement provided by the embodiments of the present application can obtain a problem description text input by a user in an interactive interface, perform word segmentation processing on the problem description text, determine a first candidate index category according to the word segmentation result, further obtain all indexes in a pre-constructed index library, determine a second candidate index category according to the obtained indexes and the problem description text, and generate at least one recommended query statement according to the first candidate index category, the second candidate index category, the problem description text and a pre-trained large language model, so as to realize the generation of the query statement. This method can enable the large language model to generate a query statement within a specific index category range by combining the first candidate index category, the second candidate index category and the problem description text, avoid the model from generating a query statement according to its own experience, cause other indexes in addition to the index library to exist in the query statement, and make the generated query statement more consistent with the user query demand. Moreover, this method determines the candidate index categories by word segmentation and the index library, and is used for the sentence generation of the large language model, can avoid the difference in the input description of different users from causing the model to predict the user query demand incorrectly, can increase the understanding of the model in a specific scenario, help the model to discover more comprehensive related indexes, and enable the model to accurately generate the query statement required by the user.

[0173] Embodiment two

[0174] The embodiments of the present application also provide a system for generating a query statement, which comprises an interactive module, a word segmenter, a context constructor, a large language model and a feedback device, wherein:

[0175] The interactive module is configured to obtain a problem description text input by a user in an interactive interface, and display a recommended query statement in the interactive interface and send the index category corresponding to the recommended query statement and the current word in the word segmentation result to the feedback device in response to detecting that the user triggers a confirmation operation on the recommended query statement.

[0176] The word segmenter is configured to perform word segmentation processing on the problem description text and determine a first candidate index category according to the word segmentation result.

[0177] The context constructor is configured to obtain all indexes in a pre-constructed index library, construct category context information according to the obtained indexes, input the category context information and the problem description text into the large language model to obtain a second candidate index category, and obtain a candidate index list in the index library based on the first candidate index category and the second candidate index category, construct index context information according to the candidate index list, and input the index context information and the problem description text into the large language model to obtain at least one recommended query statement.

[0178] The feedback device is configured to update the hit frequency and hit rate of each word in the word segmentation table.

[0179] On the basis of each of the above embodiments, optionally, the word segmenter is further configured to update the word segmentation times of each word in the word segmentation table according to the current word in the word segmentation result; and determine the first candidate index category according to the current word and the hit rates of the words under each index category in the word segmentation table.

[0180] On the basis of each of the above embodiments, optionally, the word segmenter is further configured to determine the prediction selection probability of each index category according to the current word and the hit rates of the words under each index category in the word segmentation table; and determine the index category with a prediction selection probability greater than a preset probability threshold as the first candidate index category.

[0181] On the basis of each of the above embodiments, optionally, the word segmenter is further configured to, for each index category, determine the sum of the hit rates of the current words under the index category in the word segmentation table as a numerator, and determine the sum of the hit rates of the words under the index category in the word segmentation table as a denominator; and calculate the probability of the index category being selected under the current word based on the numerator and the denominator to obtain the prediction selection probability of the index category.

[0182] On the basis of each of the above embodiments, the system further comprises an index library, wherein the construction of the index library comprises:

[0183] obtaining a time series database and extracting each index and a corresponding label name from the time series database;

[0184] determining label description information corresponding to each label name and determining an index category corresponding to each index;

[0185] constructing the index library according to each index, the corresponding index category and the label description information.

[0186] Figure 2 is a schematic diagram of a query statement generation system provided by an embodiment of the present application, as shown in Figure 2 The user's question description can be input into the word segmenter and the context constructor at the same time. The word segmenter can update the word segmentation times in the word segmentation table. The context constructor can obtain the index from the index library. The context constructor can also construct category context information and index context information and input them into a large language model (LLM). After the LLM generates a recommended query statement, it can be sent to the interaction module for display. The interaction module can also send user feedback to the feedbacker, which can update the hit times and hit rates in the word segmentation table.

[0187] Figure 3is the interactive process schematic diagram of the query statement generation system provided by the embodiment of the application, as shown in 3, first, the interactive module can obtain the problem description, and push the problem description to the context constructor and the word segmenter. Among them, the word segmentation table can obtain the index list, push the index list to the context constructor, and then the context constructor constructs the category context, and pushes the category context and the index category to the large language model, the large language model determines the second alternative index category, and returns the second alternative index category to the context constructor.

[0188] And the word segmenter can segment the problem description, and push the word segmentation to the word segmentation table for updating, and return the index category to the word segmenter from the word segmentation table, the word segmenter determines the first alternative index category, and pushes the first alternative index category to the context constructor, and then the context constructor constructs the index context according to the alternative index category (including the first alternative index category and the second alternative index category), and pushes the problem description and the index context to the large language model, the large language model generates the recommended query statement.

[0189] Further, the large language model returns the recommended query statement and the corresponding index category to the interactive module, and the interactive module displays the result and feeds back the user operation, returns the user operation to the feedback device, and the feedback device updates the word segmentation table according to the feedback, and returns the hit situation to the word segmentation table for updating.

[0190] The query statement generation system provided by the embodiment of the application can be applied to the steps in the query statement generation method provided by the method embodiment of the application, and has the execution steps and beneficial effects which will not be repeated here.

[0191] Embodiment three

[0192] Figure 4 is a structural schematic diagram of an electronic device provided by an embodiment of the application. As shown in Figure 4 The electronic device 400 includes one or more processors 401 and a memory 402.

[0193] The processor 401 can be a central processing unit (CPU) or other forms of processing units with data processing capability and / or instruction execution capability, and can control other components in the electronic device 400 to perform desired functions.

[0194] The memory 402 can include one or more computer program products that can include various forms of computer-readable storage media, such as volatile memory and / or non-volatile memory. The volatile memory, for example, can include random access memory (RAM), and / or a cache, and / or the like. The non-volatile memory, for example, can include read-only memory (ROM), hard disk, flash memory, and / or the like. The computer-readable storage media can store one or more computer program instructions executable by the processor 401 to implement the method for generating a query statement of any embodiment of the present application and / or other desired functions. The computer-readable storage media can also store various contents such as initial extrinsic parameters, threshold values, and / or the like.

[0195] In one example, the electronic device 400 can further include an input device 403 and an output device 404, which are interconnected through a bus system and / or other forms of connection mechanisms (not shown). The input device 403 can include, for example, a keyboard, a mouse, and / or the like. The output device 404 can output various information to the outside, including pre-warning prompt information, braking force, and / or the like. The output device 404 can include, for example, a display, a speaker, a printer, a communication network and a remote output device connected thereto, and / or the like.

[0196] Of course, in order to simplify, Figure 4 Only some of the components in the electronic device 400 related to the present application are shown in FIG. 4, and components such as buses, input / output interfaces, and / or the like are omitted. In addition, the electronic device 400 can include any other appropriate components according to specific application cases.

[0197] In addition to the above method and device, an embodiment of the present application can also be a computer program product including computer program instructions, which, when executed by a processor, cause the processor to perform the steps of the method for generating a query statement provided by any embodiment of the present application.

[0198] The computer program product can be written in any combination of one or more programming languages, including an object-oriented programming language such as Java, C++, and / or the like, and conventional procedural programming languages, such as the "C" programming language, or the like. The program code can execute entirely on the user's computing device, partly on the user's device, as a stand-alone software package, partly on the user's computing device and partly on a remote computing device, or entirely on the remote computing device or server.

[0199] In addition, an embodiment of the present application can also be a computer readable storage medium, having stored thereon computer program instructions which, when executed by a processor, cause the processor to perform the steps of the method of generating a query statement according to any of the embodiments of the present application.

[0200] The computer readable storage medium can take the form of one or more combinations of any type of computer readable medium. The computer readable medium can be a computer readable signal medium or a computer readable storage medium. The computer readable storage medium can include, for example, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples (a non-exhaustive list) of the computer readable storage medium include an electrical connection having one or more wires, a portable disc, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0201] It should be noted that the terms used in the present application are only for describing specific embodiments and are not intended to limit the scope of the present application. As shown in the specification and claims of the present application, unless the context clearly indicates otherwise, the terms "one", "a", "an", and / or "the" do not specifically refer to the singular, but can also include the plural. The terms "include", "contain" or any other variant thereof are intended to cover non-exclusive inclusion, so that the process, method or device including a series of elements not only includes those elements, but also includes other elements not explicitly listed or inherent to such process, method or device. Without more limitations, the element defined by the statement "including a" does not exclude the presence of additional identical elements in the process, method or device including the element.

[0202] It should also be noted that the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", and the like indicate the orientation or positional relationship based on the orientation or positional relationship shown in the drawings, and are only for the convenience of describing the present application and simplifying the description, and do not indicate or imply that the devices or elements referred to must have a particular orientation, be constructed and operated in a particular orientation, and therefore cannot be understood as limiting the present application. Unless otherwise explicitly specified and limited, the terms "mount", "connect", "connect" and the like should be broadly understood, for example, it can be a fixed connection, or a detachable connection, or an integral connection; it can be a mechanical connection, or an electrical connection; it can be a direct connection, or an indirect connection through an intermediate medium, or a communication between two elements inside. For those skilled in the art, the specific meaning of the above terms in the present application can be understood according to the specific circumstances.

[0203] The principles and implementation manners of the present application are described herein by using specific examples, and the above example descriptions are only used to help understand the method of the present application and its core idea. The above descriptions are only preferred embodiments of the present application, and it should be pointed out that, due to the limited nature of the language expression, there are objectively infinite specific structures, and for ordinary skilled persons in the technical field, some improvements, refinements or changes can be made without departing from the principles of the present application, and the above technical features can also be combined in an appropriate manner; these improvements, refinements, changes or combinations, or the direct application of the inventive concept and technical solution to other occasions without improvement, shall be regarded as the protection scope of the present application.

Claims

1. A method of generating a query statement, characterized by, The method comprises the following steps: obtaining a problem description text input by a user in an interactive interface, and performing word segmentation processing on the problem description text, wherein the problem description text describes a time series that the user needs to query in a time series database; determining a first candidate index category according to the word segmentation result, wherein the first candidate index category is determined according to the word segmentation result and a word segmentation table, the word segmentation table is used to record the association relationship between a word and an index category in an index library, and the word segmentation table further includes the hit frequency, word segmentation frequency and hit rate of each word under each index category; obtaining all indexes in a pre-constructed index library, and determining a second candidate index category according to the obtained indexes and the problem description text, wherein an index is a data name of a time series, an index category is a classification of a data name, and the index library includes each index category and indexes under each index category; obtaining a candidate index list in the index library based on the first candidate index category and the second candidate index category, including: querying all indexes under the first candidate index category from the index library, and querying all indexes under the second candidate index category from the index library, and constructing a candidate index list according to all the indexes obtained by querying; constructing index context information according to the candidate index list, and inputting the index context information and the problem description text into a large language model to help the large language model identify the index that the user needs to query from the problem description text, and obtaining at least one recommended query sentence.

2. The method of claim 1, wherein, The method further comprises the following steps: updating the word segmentation frequency of each word in the word segmentation table according to the current word in the word segmentation result; determining the first candidate index category according to the current word and the hit rate of the word under each index category in the word segmentation table.

3. The method of claim 2, wherein, The method further comprises the following steps: determining the prediction selection probability of each index category according to the current word and the hit rate of the word under each index category in the word segmentation table; determining the index category with a prediction selection probability greater than a preset probability threshold as the first candidate index category.

4. The method of claim 3, wherein, The method further comprises the following steps: for each index category, summing the hit rates of the current words under the index category in the word segmentation table to determine a numerator, and summing the hit rates of the words under the index category in the word segmentation table to determine a denominator; calculating the probability of selecting the index category under the current word based on the numerator and the denominator to obtain the prediction selection probability of the index category.

5. The method of claim 1, wherein, The method further comprises the following steps: constructing category context information according to the obtained indexes; inputting the category context information and the problem description text into the large language model to obtain the second candidate index category.

6. The method of claim 2, wherein, The method further comprises the following steps after generating the at least one recommended query sentence: display the recommended query statement on the interactive interface; in response to detecting that the user triggers a confirmation operation for the recommended query statement, updating the hit frequency and hit rate of each word in the segmentation table based on the index category corresponding to the recommended query statement and the current word in the segmentation result.

7. The method of claim 1, wherein, The construction of the index library includes: obtain a time series database, and extract each index and the corresponding label name from the time series database; determine the label description information corresponding to each label name, and determine the index category corresponding to each index; construct an index library according to each index and the corresponding index category and label description information.

8. A system for generating a query statement, characterized by, The system includes an interactive module, a word segmenter, a context constructor, a large language model, and a feedback device, wherein: The interactive module is used to obtain the problem description text input by the user in the interactive interface, and is used to display the recommended query statement on the interactive interface, and in response to detecting that the user triggers a confirmation operation for the recommended query statement, sends the index category corresponding to the recommended query statement and the current word in the segmentation result to the feedback device, wherein the problem description text describes the time series that the user needs to query in the time series database; The word segmenter is used to perform segmentation processing on the problem description text, determine a first alternative index category according to the segmentation result, and determine the first alternative index category according to the segmentation result and a segmentation table, wherein the segmentation table is used to record the association between the word and the index category in the index library, and the segmentation table further includes the hit frequency, segmentation frequency, and hit rate of each word under each index category; The context constructor is used to obtain all indexes in the pre-constructed index library, construct category context information according to the obtained indexes, input the category context information and the problem description text into the large language model to obtain a second alternative index category, and based on the first alternative index category and the second alternative index category, obtain an alternative index list in the index library, construct index context information according to the alternative index list, and input the index context information and the problem description text into the large language model to help the large language model identify the index that the user needs to query from the problem description text, and obtain at least one recommended query statement; The feedback device is used to update the hit frequency and hit rate of each word in the segmentation table; The index library includes each index category and the indexes under each index category; The context constructor is further used to query all indexes under the first alternative index category from the index library, and query all indexes under the second alternative index category from the index library, and construct an alternative index list according to all the indexes obtained by querying.

9. A computer-readable storage medium, characterized in that, The computer readable storage medium stores programs or instructions, which make the computer execute the steps of the query statement generation method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Text generation method and device based on artificial intelligence, computer equipment and medium

    CN112395385A

  • Structured query statement generation method and device, equipment and medium

    CN117149812A

  • Log query statement generation method and device, equipment and storage medium

    CN118152341A