Method, device, electronic device and computer program product for determining prompt words

Through a vectorized model, the user input and tag collection is processed, and combined with vector matching and text matching, the field names and field values ​​related to user input are filtered out from the data platform, and the target prompt word is determined, which solves the problem of excessive length of prompt word and unrelated information interference. Problem, improving the accuracy and efficiency of SQL generation.

CN119166660BActive Publication Date: 2025-02-21BEIJING VOLCANO ENGINE TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411657968.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-11-19
Publication Date
2025-02-21
Estimated Expiration
2044-11-19

AI Technical Summary

Technical Problem

When converting natural language into SQL queries, the prompt words are too long or contain irrelevant information, resulting in degradation of model performance and waste of computing resources.

Method used

By obtaining user input, word segmentation generates a set of tags, and using vectorized models to process user input and tag collections, generating user input vectors and tag vector collections. Then, match the relevant items from the field name and field value vector library, and determine the target prompt word in combination with text matching.

Benefits of technology

It effectively reduces the amount of irrelevant information in the prompt words, avoids the negative impact of excessive prompt words on model performance, improves the accuracy and efficiency of SQL generation, and reduces the consumption of computing resources.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119166660B_ABST
    Figure CN119166660B_ABST
Patent Text Reader

Abstract

Embodiments of the present disclosure relate to methods, devices, electronic devices, and computer program products for determining prompt words. The method includes obtaining user input and generating a tag set of the user input. The method also includes determining a vector matching field name from a field name vector library based on a user input vector and a tag vector set, and determining a vector matching field value from a field value vector library, and determining a text matching field name through text matching. In addition, the method also includes determining a target prompt word based on the user input, the vector matching field name, the vector matching field value, and the text matching field name. Through the embodiments of the present disclosure, it is possible to accurately filter field names and field values ​​related to user input, reduce irrelevant information in prompt words, thereby improving the accuracy and efficiency of the language model generating SQL, and enabling users to obtain required data from the data platform more quickly and accurately.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and more particularly to a method, device, electronic device and computer program product for determining a prompt word. Background Art

[0002] In the era of the gradual development of language models, the combination of language models and data platforms (for example, business intelligence platforms) has become a very important research direction. The combination of the two can not only fully utilize the advantages of language models in natural language processing and understanding, but also give data platforms more powerful data analysis and interpretation capabilities, thereby realizing intelligent mining and analysis of massive data.

[0003] Users raise query requirements through natural language, which is converted into SQL (Structured Query Language) using language models, and the query is executed through the data platform, presenting the data results directly to the user. This simplifies the traditional data query process, allowing users to quickly obtain data anytime and anywhere, lowering the threshold for data query and meeting diverse data analysis needs. Summary of the invention

[0004] Embodiments of the present disclosure provide a method, an apparatus, an electronic device, and a computer program product for determining a prompt word.

[0005] According to a first aspect of the present disclosure, a method for determining prompt words is provided. The method includes obtaining user input indicating query requirements in natural language form, the user input being part of the prompt words of a language model for generating a structured query language SQL query, and the SQL query is used to obtain data related to the query requirements from a data platform. The method also includes generating a tag set based on the word segmentation result of the user input. The method also includes generating a user input vector of the user input and a tag vector set of the tag set by processing the user input and the tag set using a vectorization model, the tag vector set including a tag vector of each tag in the tag set. The method also includes determining a vector matching field name from a field name vector library based on the user input vector and the tag vector set, the field name vector library being constructed based on the field name in the data platform through the vectorization model. The method also includes determining a vector matching field value from a field value vector library based on the user input vector and the tag vector set, the field value vector library being constructed based on the field value in the data platform through the vectorization model. The method also includes determining a text matching field name from a field name in the data platform through text matching based on the user input. In addition, the method also includes determining a target prompt word for the language model based on the user input, the vector matching field name, the vector matching field value, and the text matching field name.

[0006] According to a second aspect of the present disclosure, a device for determining a prompt word is provided. The device includes a user input acquisition module, configured to acquire user input indicating a query requirement in a natural language form, the user input being a part of a prompt word of a language model for generating a structured query language SQL query, the SQL query being used to acquire data related to the query requirement from a data platform. The device also includes a tag set generation module, configured to generate a tag set based on a word segmentation result of the user input. The device also includes a vector information generation module, configured to generate a user input vector of the user input and a tag vector set of the tag set by processing the user input and the tag set using a vectorization model, the tag vector set including a tag vector of each tag in the tag set. The device also includes a field name vector matching module, configured to determine a vector matching field name from a field name vector library based on the user input vector and the tag vector set, the field name vector library being constructed based on the field name in the data platform through the vectorization model. The device also includes a field value vector matching module, configured to determine a vector matching field value from a field value vector library based on the user input vector and the tag vector set, the field value vector library being constructed based on the field value in the data platform through the vectorization model. The device also includes a field name text matching module, which is configured to determine a text matching field name from a field name in a data platform through text matching based on user input. In addition, the device also includes a prompt content determination module, which is configured to determine a target prompt word for a language model based on user input, a vector matching field name, a vector matching field value, and a text matching field name.

[0007] According to a third aspect of the present disclosure, an electronic device is provided, comprising a processor and a memory coupled to the processor, wherein the memory has instructions stored therein, and when the instructions are executed by the processor, the electronic device executes the method according to the first aspect.

[0008] In a fourth aspect of the present disclosure, a computer program product is provided. The computer program product is tangibly stored on a non-transitory computer readable medium and comprises computer executable instructions, which when executed cause a computer to perform the steps of the method of the first aspect of the present disclosure.

[0009] The purpose of this Summary is to introduce a selection of concepts in a simplified form that are further described in the Detailed Description below. This Summary is not intended to identify key features or essential features of the claimed subject matter, nor is it intended to limit the scope of the claimed subject matter. BRIEF DESCRIPTION OF THE DRAWINGS

[0010] The above and other features, advantages and aspects of the embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. In the accompanying drawings, the same or similar reference numerals represent the same or similar elements, wherein:

[0011] Figure 1 A schematic diagram showing an example environment in which devices and / or methods according to embodiments of the present disclosure may be implemented;

[0012] Figure 2 A flow chart for determining a prompt word according to an embodiment of the present disclosure is shown;

[0013] Figure 3 A schematic diagram showing a process of recalling field names and field values ​​according to an embodiment of the present disclosure;

[0014] Figure 4 A block diagram showing a device for determining a prompt word according to an embodiment of the present disclosure; and

[0015] Figure 5 A block diagram of an electronic device according to an embodiment of the present disclosure is shown.

[0016] Throughout the drawings, the same or similar reference numbers denote the same or similar elements. DETAILED DESCRIPTION

[0017] It is understandable that before using the technical solutions disclosed in the embodiments of the present disclosure, the type, scope of use, usage scenarios, etc. of the personal information (such as voice) involved in the present disclosure should be informed to the user and the user's authorization should be obtained in an appropriate manner in accordance with relevant laws and regulations.

[0018] Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as being limited to the embodiments described herein, which are instead provided for a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are only for exemplary purposes and are not intended to limit the scope of protection of the present disclosure.

[0019] In the description of the embodiments of the present disclosure, the term "including" and similar terms should be understood as open inclusion, that is, "including but not limited to". The term "based on" should be understood as "based at least in part on". The term "one embodiment" or "the embodiment" should be understood as "at least one embodiment". The terms "first", "second", etc. may refer to different or the same objects, unless explicitly stated. Other explicit and implicit definitions may also be included below.

[0020] As mentioned above, using language models to convert natural language input by users into SQL queries (also known as Text2SQL) has been widely used in more and more scenarios. This method facilitates users to quickly obtain data from the data platform and perform data analysis. In the related technologies of Text2SQL, the field names and field values ​​in the data platform are filled into the prompt words, so that the language model understands the table structure of the database and the possible value range of the field. This helps the language model accurately map the user's natural language questions to specific fields in the database, and correctly construct query conditions and filters, thereby improving the accuracy of SQL generation.

[0021] However, there are some problems with the above approach. First, overly long prompt words can cause model performance to degrade, and may even exceed the processing capacity of the language model (for example, exceeding the upper limit of the prompt word length). In addition, irrelevant field names and field values ​​can interfere with the model's understanding, increase the risk of errors, and lead to increased computing resources and costs. Therefore, it is necessary to filter field names and field values ​​related to user input from the data platform to avoid problems such as overly long prompt words and interference from irrelevant information.

[0022] To this end, an embodiment of the present disclosure provides a solution for determining prompt words. The solution obtains user input, and based on the user input, generates a tag set related to the word segmentation result of the user input, and then determines the field name and field value related to the user input through vector matching and text matching, thereby determining the target prompt word for use in the language model to generate SQL queries.

[0023] Therefore, through the embodiments of the present disclosure, the amount of irrelevant information in the prompt words can be effectively reduced, and the influence of the prompt words being too long on the model performance can be avoided. At the same time, through the vector matching and text matching methods, the field names and field values ​​related to the user input can be screened out more accurately, and the accuracy and efficiency of SQL generation are improved. This solution not only reduces the complexity of the language model processing prompt words, reduces the consumption of computing resources, but also improves the success rate of data query, so that users can obtain the required data from the data platform more quickly and accurately.

[0024] Figure 1 Schematic diagram of an example environment in which the device and / or method according to an embodiment of the present disclosure may be implemented. Figure 1As shown, the example environment 100 may include a computing device 110, which may be a user terminal, a mobile device, a computer, etc., or a computing system, a single server, a distributed server, or a cloud-based server. The computing device 110 may receive a user input 120, and the user input 120 indicates a user's query requirement in a natural language form. In addition, the user input 120 is part of a prompt word of a language model for generating an SQL query code, and the SQL query is used to obtain data related to the query requirement from the data platform.

[0025] The computing device 110 may generate a tag set 130 based on the word segmentation result of the user input 120. For example, the word segmentation process may split the user input 120 into a number of independent characters, words or phrases (i.e., tags) as the word segmentation result through a word segmentation tool. The computing device 110 may process the user input 120 and the tag set 130 using a vectorization model, respectively, to generate a user input vector of the user input 120 and a tag vector set of the tag set 130, the tag vector set including a tag vector of each tag in the tag set 130. For example, the user input 120 may be input into a vectorization model, and the vectorization model may output a vector of the user input 120.

[0026] The computing device 110 may determine a vector matching field name 150 from a field name vector library 140 based on a user input vector and a set of tag vectors, the field name vector library 140 being constructed based on field names in a data platform through a vectorization model. For example, the computing device 110 may process the user input 120 using a vectorization model, and match its vector with each field name in the field name vector library 140 to determine the most relevant field name. The computing device 110 may determine a vector matching field value 170 from a field value vector library 160 based on a user input vector and a set of tag vectors, the field value vector library 160 being constructed based on field values ​​in a data platform through a vectorization model. For example, the computing device 110 may perform similarity calculations between the user input vector and each field value vector in the field value vector library 160 to filter out the field value that is most relevant to the user input 120.

[0027] The computing device 110 may determine a text matching field name 180 from a field name in the data platform through text matching based on the user input 120. For example, the computing device 110 may analyze the keywords in the user input 120 and match them with the field names in the data platform to find the field name that best matches the user's intent. The computing device 110 may determine a target prompt word 190 for the language model based on the user input 120, the vector matching field name 150, the vector matching field value 170, and the text matching field name 180. For example, the computing device 110 may perform a comprehensive process on these matching results to generate a prompt word 190 that includes the user's query intent. The target prompt word 190 may provide clear context information for the language model, thereby improving the accuracy of SQL query generation.

[0028] Therefore, through the embodiments of the present disclosure, the amount of irrelevant information in the prompt words can be effectively reduced, and the influence of the prompt words being too long on the model performance can be avoided. At the same time, through the vector matching and text matching methods, the field names and field values ​​related to the user input can be screened out more accurately, and the accuracy and efficiency of SQL generation are improved. This solution not only reduces the complexity of the language model processing prompt words, reduces the consumption of computing resources, but also improves the success rate of data queries, so that users can obtain the required data from the data platform more quickly and accurately.

[0029] It should be understood that the architecture and functions in the example environment 100 are described for exemplary purposes only and do not imply any limitation on the scope of the present disclosure. Embodiments of the present disclosure may also be applied to other environments with different structures and / or functions.

[0030] The following will combine Figures 2 to 5 The process according to the embodiment of the present disclosure is described in detail. For ease of understanding, the specific data mentioned in the following description are exemplary and are not intended to limit the scope of protection of the present disclosure. It is understood that the embodiments described below may also include additional actions not shown and / or the actions shown may be omitted, and the scope of the present disclosure is not limited in this respect.

[0031] Figure 2 A flowchart of a method 200 for determining a prompt word according to an embodiment of the present disclosure is shown. The method can be executed by a computing device, which can be a user terminal, a mobile device, a computer, etc. It can also be a computing system, a single server, a distributed server, or a cloud-based server. At box 202, a user input indicating a query requirement in a natural language form can be obtained. The user input is a part of a prompt word for a language model for generating a structured query language SQL query. The SQL query is used to obtain data related to the query requirement from a data platform. For example, refer to Figure 1The computing device 110 may obtain user input 120 indicating a query requirement in a natural language form, where the user input 120 is part of a prompt word of a language model for generating a structured query language SQL query, where the SQL query is used to obtain data related to the query requirement from a data platform.

[0032] At block 204, a tag set may be generated based on the word segmentation result input by the user. Figure 1 , the computing device 110 may generate a tag set 130 based on the word segmentation result of the user input 120. At block 206, a user input vector of the user input and a tag vector set of the tag set may be generated by processing the user input and the tag set using a vectorization model, wherein the tag vector set includes a tag vector of each tag in the tag set. Figure 1 The computing device 110 may process the user input 120 and the tag set 130 by utilizing the vectorization model to generate a user input vector of the user input 120 and a tag vector set of the tag set 130 , wherein the tag vector set includes a tag vector for each tag in the tag set.

[0033] At block 208, a vector matching field name may be determined from a field name vector library based on the user input vector and the tag vector set, where the field name vector library is constructed based on the field names in the data platform through a vectorization model. Figure 1 , the computing device 110 may determine a vector matching field name 150 from a field name vector library 140 based on the user input vector and the tag vector set, the field name vector library 140 being constructed based on the field names in the data platform through a vectorization model. At block 210, a vector matching field value may be determined from a field value vector library based on the user input vector and the tag vector set, the field value vector library being constructed based on the field values ​​in the data platform through a vectorization model. For example, referring to Figure 1 The computing device 110 may determine a vector matching field value 170 from a field value vector library 160 based on a user input vector and a set of tag vectors, where the field value vector library 160 is constructed through a vectorization model based on field values ​​in a data platform.

[0034] At block 212, a text matching field name may be determined from the field names in the data platform by text matching based on the user input. Figure 1 , the computing device 110 may determine the text matching field name 180 from the field name in the data platform through text matching based on the user input 120. At block 214, a target prompt word for the language model may be determined based on the user input, the vector matching field name, the vector matching field value, and the text matching field name. Figure 1The computing device 110 may determine a target prompt word 190 for a language model based on the user input 120 , the vector matching field name 150 , the vector matching field value 170 , and the text matching field name 180 .

[0035] Therefore, according to the method 200 of the embodiment of the present disclosure, the amount of irrelevant information in the prompt word can be effectively reduced, and the influence of the prompt word being too long on the model performance can be avoided. At the same time, through the vector matching and text matching methods, the field names and field values ​​related to the user input can be screened out more accurately, and the accuracy and efficiency of SQL generation are improved. This solution not only reduces the complexity of the language model processing prompt words, reduces the consumption of computing resources, but also improves the success rate of data query, so that users can obtain the required data from the data platform more quickly and accurately.

[0036] Figure 3 A schematic diagram of a process 300 for recalling field names and field values ​​according to an embodiment of the present disclosure is shown. Based on user input, relevant field names and field values ​​can be recalled from the data platform through a process of vectorized matching and text matching, and the fused recall result can be determined through fusion processing, and then the recall result can be filled into the prompt word to help the language model generate an SQL query. At box 302, user input can be obtained. For example, the user input can be "I want the population of Shanghai in 2024", and the language model can use the input to generate the corresponding SQL query code, and execute the SQL query through the data platform system to obtain the target data from the data table. Since the data platform usually contains a large number of data tables and fields, the language model needs to understand these field names and field values ​​to generate more accurate SQL code and meet user query requirements.

[0037] At block 304, a vectorized matching process may be performed. For example, field names and field values ​​related to the user input may be determined from the data platform through vector matching. Vectorized matching utilizes the semantic similarity between the user input and the fields in the data platform to find the most relevant field information, thereby providing more accurate context information for generating SQL queries.

[0038] At box 306, the user input can be segmented. For example, the segmentation process can split the user input into several independent characters, words or phrases (i.e., tags) through a segmentation tool. The segmentation process decomposes the user input into basic semantic units, which is convenient for subsequent vectorized matching and improves the accuracy of field name and field value recall. In some embodiments, the part-of-speech information of each tag in the segmentation result can be determined by part-of-speech tagging. Part-of-speech tagging can use a part-of-speech tagging tool to assign a part-of-speech tag to each word in the segmentation result, such as a noun, verb, adjective, etc. In some embodiments, a tag set can be determined based on the segmentation result and the part-of-speech information. For example, only nouns and verbs are retained in the tag set, because in the data platform system, field names and field values ​​are usually composed of nouns and verbs. By retaining only nouns and verbs, key information related to data queries can be effectively extracted, and interference with prompt words by irrelevant words can be eliminated.

[0039] At box 308, field name recall can be performed. In some embodiments, the input vector similarity score of each field name in the field name vector library can be determined based on the user input vector. For example, the user input is processed by a vectorized model to generate a corresponding user input vector, and the similarity is calculated (for example, cosine similarity) with each field name vector in the field name vector library to obtain a similarity score. Then, the field names are sorted from high to low according to the similarity score. Based on a preset similarity score threshold, the field names most relevant to the user input are screened out, and the number of candidate sets is limited according to the candidate number threshold to ensure that only a number of field names with the highest similarity are retained. This can avoid recalling too many field names, prevent the prompt words from being too long, and improve the accuracy of generating SQL queries.

[0040] In some embodiments, the token vector similarity score of each field name in the field name vector library can be determined based on the token vector set. For example, the word segmentation result can be represented as a token set , where Wi is a word segmentation tag (e.g., "population") and X is the total number of words in the tag set. Each tag Wi can have multiple similar field names, denoted as In some embodiments, if the tag vector similarity score reaches the highest value (for example, the cosine similarity is 1 at most), it is determined that the field name corresponding to the tag is the field name that matches the second vector. If the vector similarity score is 1 (i.e., they are exactly the same, for example, both are "population"), then only , discard the set Other field names in .

[0041] In some embodiments, if the tag vector similarity score is less than the highest similarity score, the second vector matching field name is determined based on the tag vector similarity score, the similarity score threshold, and the candidate number threshold. For example, when the similarity scores of the tag Wi and all field names Nᵢⱼ in the field name set are less than the highest similarity score, these field names are sorted from high to low by similarity score to filter out the field names most relevant to the tag Wi. Then, the field names below the similarity score threshold (for example, 0.8) are filtered out to retain more relevant candidate field names. In addition, the number of field names can be limited by the candidate number threshold to ensure that the final retained field name set remains within a reasonable range.

[0042] In some embodiments, the field names and field values ​​in the data platform can be processed by the same vectorization method (e.g., the same vectorization model). For example, each field name and field value is converted into a vector representation using vectorization techniques (such as word embedding, encoding model) to build a field name vector library and a field value vector library. In some embodiments, in order to ensure that the data in the vector library is consistent with the field names and field values ​​in the data platform, a daemon process can be configured to monitor the data platform in real time. For example, when the daemon process detects a change in a field name or field value in the data platform, the vectorization process is triggered, and a new vector is replaced or added to the vector library to ensure that the vector library is synchronized with the data on the data platform.

[0043] In some embodiments, the cardinality of the field value (i.e., the number of different field values) may be considered when constructing a field value vector library. The field value cardinality refers to the total number of all different field values ​​under a certain field. For example, the field "city name" contains 1 million different city names, and its field value cardinality is 1 million. Since the storage capacity of the vector library is limited, in order to avoid storing too many field value sets, the field values ​​need to be screened and optimized. For example, a cardinality threshold 𝐶 may be defined, and when the field value cardinality ≤ 𝐶, all field values ​​are vectorized and stored in the field value vector library. For example, if the field value cardinality of "city name" is 1 million, which is less than the threshold 𝐶 (e.g., 2 million), all field values ​​of the field are vectorized. When the field value cardinality > 𝐶, the field value needs to be screened. For example, the occurrence frequency of all field values ​​may be counted, and the 𝐶 field values ​​with the highest frequency may be selected, and then these 𝐶 field values ​​may be vectorized, and their vectors may be stored in the field value vector library.

[0044] At box 310, field value recall can be performed. In some embodiments, a similarity score for each field value in the field value vector library can be determined based on the user input vector. For example, a similarity calculation is performed between the user input vector and each field value vector in the field value vector library to evaluate the correlation between the user input and each field value. When performing the recall, the recall results can be filtered according to preset conditions. For example, if a field value is a numeric or date type, the field value can be directly discarded because these types of field values ​​may not have semantic importance when generating prompt words. This filtering process helps to exclude irrelevant field values ​​and improve the relevance of the recall results.

[0045] In some embodiments, the first vector matching field value can be determined based on the vector similarity score, the similarity score threshold and the candidate number threshold. For example, the field values ​​are sorted from high to low according to the similarity score with the user input, and then the similarity score threshold is applied to filter out the field values ​​with similarity lower than the threshold, and retain the field values ​​that are highly correlated with the user input. Then, the number of candidate field values ​​is limited according to the candidate number threshold to ensure that only the field values ​​with the highest similarity are selected. Screening by similarity score threshold and candidate number threshold can avoid recalling too many field values, reduce redundant information of prompt words, and improve the accuracy and efficiency of language model generation of SQL queries.

[0046] In some embodiments, the tag vector similarity score of each field value in the field value vector library can be determined based on the tag vector set. For example, each tag vector in the tag set is calculated similarly to the field value vector in the field value vector library to obtain a similarity score for each field value. In some embodiments, the second vector matching field value can be determined based on the tag vector set, the similarity score threshold, the candidate number threshold, and the length range threshold. For example, according to the similarity score, the field values ​​are sorted from high to low by similarity, and the field values ​​below the threshold are filtered out using the similarity score threshold to retain field values ​​that are more relevant to the user input. In addition, the length range threshold can also be applied to filter the string length of the field value so that it is between a predetermined maximum length (Lmax) and a minimum length (Lmin). Through these filtering conditions, the number and length of candidate field values ​​can be limited to ensure that only the most relevant field values ​​are retained.

[0047] In some embodiments, if the tag vector similarity score reaches the highest value, the corresponding tag is determined as the second vector matching field value. Otherwise, based on the similarity score, similarity score threshold and candidate number threshold, the field value whose length meets the requirements is screened out as the second vector matching field value. For example, when the similarity score between the tag vector and the field value vector is the highest value, indicating that the two are completely matched, the field value is directly retained and other similar field values ​​are discarded. If the highest similarity score is not reached, the field value with a high similarity and a length within a predetermined range is screened out as the second vector matching field value based on the similarity score, similarity score threshold and candidate number threshold.

[0048] By executing vectorized matching 304, a total of four recall paths are generated: first, field name recall based on the vector input by the user to obtain the first vector recall field name; second, field name recall based on the vector of the word segmentation mark to obtain the second vector recall field name; third, field value recall based on the vector input by the user to obtain the first vector recall field value; fourth, field value recall based on the vector of the word segmentation mark to obtain the second vector recall field value. In addition, the recalled field names and field values ​​can be sorted in descending order according to similarity. These recall paths use user input and word segmentation marks to match the most relevant field information in the field name and field value vector library. By integrating these recall results, the accuracy of the field name and field value in the prompt word can be improved, thereby improving the effect of generating SQL queries.

[0049] At block 312, text matching may be performed. In some embodiments, a set of field names may be obtained from the data platform, and text matching field names may be determined based on field names in the set that match the user input. For example, if a field name in the set of field names fully or partially matches the user input, that is, the field name is a substring of the user input, the field name is added to the text matching result list.

[0050] In some embodiments, if it is determined that the number of field names in the text matching field name is less than the candidate number threshold, the text matching scores of the remaining field names in the field name set and the user input can be calculated, where the text matching scores are calculated by substring similarity. For example, first, two similarity values ​​between each remaining field name and the user input are calculated: R1 and R2. R1 can be defined by formula (1):

[0051] R1 = 1 – ( dist / sum ) (1)

[0052] in dist is the edit distance between the two strings multiplied by 2, sumis the sum of the lengths of the two strings. R2 can be defined to first find the longest similar substring of the two strings, then calculate its similarity with the shorter string, and return the similarity of the most similar substring. Then, take the maximum value of R1 and R2 as the final text matching score to reflect the similarity between the field name and the user input.

[0053] In some embodiments, the field names to be added to the text matching field names can be determined from the remaining field names based on the text matching scores. For example, the remaining field names are sorted from high to low according to the text matching scores, and field names with higher scores are preferentially selected, and several field names with the highest scores are selected and added to the text matching field names according to the candidate number threshold. In this way, the text matching field name set includes both directly matched field names and the most relevant other field names selected through similarity calculation, thereby enriching the matching results and improving the accuracy of SQL queries.

[0054] At block 314, the fusion recall results may be performed. In some embodiments, the final matching field name may be determined by taking the union of the vector matching field name and the text matching field name. For example, the field names obtained by the vector matching and the text matching are combined into one set to ensure that the field names of both matching methods are retained. For field names that appear in both the vector matching and the text matching, their comprehensive scores may be further calculated to more accurately reflect the relevance of the field name to the user input.

[0055] In some embodiments, field recall information can be generated based on matching field names and vector matching field values ​​in descending order of scores. For example, according to the similarity score and the normalized edit distance score, the matched field names and field values ​​are comprehensively evaluated and sorted from high to low according to the comprehensive score. When the vector similarity score and the text similarity score are integrated, the comprehensive score can be calculated by weighted average, maximum value or other strategies. For example, when the user enters "I want the population of Beijing", the field name set obtained by vector matching and text matching includes "Beijing", "Population" and "Province", and their corresponding similarity scores are 1.0, 0.67 and 0.42 respectively, and the field value set includes "Region", and the similarity score is 1.0. Including these similarity scores in the field recall information can provide clear priority information for the prompt words. By sorting the scores, the language model can pay more attention to field names and field values ​​with higher similarity, thereby generating SQL queries more accurately, reducing errors and redundancy, and improving the accuracy and efficiency of query results.

[0056] In some embodiments, target prompt words can be generated based on field recall information and user input. For example, the sorted field names and field values ​​are combined with user input to construct prompt words for guiding the language model to generate SQL queries. The prompt words contain field names and field values ​​to ensure that the language model fully understands the structure and content of the data platform, so as to accurately map user query requirements to database queries. Finally, the generated target prompt words are passed to the big model to generate SQL queries that meet the user's intentions.

[0057] Figure 4 FIG. 4 is a block diagram of an apparatus 400 for determining a prompt word according to some embodiments of the present disclosure. Figure 4 As shown, the device 400 includes a user input acquisition module 402, which is configured to acquire user input indicating query requirements in natural language form, and the user input is part of a prompt word of a language model for generating a structured query language SQL query, and the SQL query is used to obtain data related to the query requirements from a data platform. The device 400 also includes a tag set generation module 404, which is configured to generate a tag set based on the word segmentation result of the user input. The device 400 also includes a vector information generation module 406, which is configured to generate a user input vector of the user input and a tag vector set of the tag set by processing the user input and the tag set using a vectorization model, and the tag vector set includes a tag vector of each tag in the tag set.

[0058] The device 400 also includes a field name vector matching module 408, which is configured to determine a vector matching field name from a field name vector library based on a user input vector and a tag vector set, and the field name vector library is constructed based on the field name in the data platform through a vectorization model. The device 400 also includes a field value vector matching module 410, which is configured to determine a vector matching field value from a field value vector library based on a user input vector and a tag vector set, and the field value vector library is constructed based on the field value in the data platform through a vectorization model. The device 400 also includes a field name text matching module 412, which is configured to determine a text matching field name from a field name in the data platform through text matching based on user input. In addition, the device 400 also includes a prompt content determination module 414, which is configured to determine a target prompt word for a language model based on user input, a vector matching field name, a vector matching field value, and a text matching field name.

[0059] Figure 5 A block diagram of an electronic device 500 is shown in accordance with some embodiments of the present disclosure. Figure 5 1 shows a block diagram of an electronic device 500 according to some embodiments of the present disclosure, and the device 500 may be a device or apparatus described in an embodiment of the present disclosure. Figure 5As shown, the device 500 includes a central processing unit (CPU) and / or a graphics processing unit (GPU) 501, which can perform various appropriate actions and processes according to computer program instructions stored in a read-only memory (ROM) 502 or loaded from a storage unit 508 to a random access memory (RAM) 503. In the RAM 503, various programs and data required for the operation of the device 500 can also be stored. The CPU / GPU 501, the ROM 502, and the RAM 503 are connected to each other via a bus 504. An input / output (I / O) interface 505 is also connected to the bus 504. Although not shown in FIG. Figure 5 As shown in FIG. 5 , device 500 may further include a co-processor.

[0060] A number of components in the device 500 are connected to the I / O interface 505, including: an input unit 506, such as a keyboard, a mouse, etc.; an output unit 507, such as various types of displays, speakers, etc.; a storage unit 508, such as a disk, an optical disk, etc.; and a communication unit 509, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 509 allows the device 500 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.

[0061] The various methods or processes described above may be performed by the CPU / GPU 501. For example, in some embodiments, the methods may be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as a storage unit 508. In some embodiments, part or all of the computer program may be loaded and / or installed on the device 500 via the ROM 502 and / or the communication unit 509. When the computer program is loaded into the RAM 503 and executed by the CPU / GPU 501, one or more steps or actions in the methods or processes described above may be performed.

[0062] In some embodiments, the methods and processes described above may be implemented as a computer program product. The computer program product may include a computer-readable storage medium carrying computer-readable program instructions for executing various aspects of the present disclosure.

[0063] Computer readable storage medium can be a tangible device that can hold and store instructions used by an instruction execution device. Computer readable storage medium can be, for example, but not limited to, an electrical storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination thereof. More specific examples (non-exhaustive list) of computer readable storage medium include: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a static random access memory (SRAM), a portable compact disk read-only memory (CD-ROM), a digital versatile disk (DVD), a memory stick, a floppy disk, a mechanical encoding device, for example, a punch card or a convex structure in a groove on which instructions are stored, and any suitable combination thereof. The computer readable storage medium used here is not interpreted as a transient signal itself, such as a radio wave or other freely propagating electromagnetic wave, an electromagnetic wave propagated by a waveguide or other transmission medium (for example, a light pulse by an optical fiber cable), or an electrical signal transmitted by a wire.

[0064] The computer-readable program instructions described herein can be downloaded from a computer-readable storage medium to each computing / processing device, or downloaded to an external computer or external storage device via a network, such as the Internet, a local area network, a wide area network, and / or a wireless network. The network can include copper transmission cables, optical fiber transmissions, wireless transmissions, routers, firewalls, switches, gateway computers, and / or edge servers. The network adapter card or network interface in each computing / processing device receives the computer-readable program instructions from the network and forwards the computer-readable program instructions for storage in the computer-readable storage medium in each computing / processing device.

[0065] The computer program instructions for performing the operations of the present disclosure may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine-dependent instructions, microcode, firmware instructions, state setting data, or source code or object code written in any combination of one or more programming languages, including object-oriented programming languages, and conventional procedural programming languages. Computer-readable program instructions may be executed entirely on a user's computer, partially on a user's computer, as a separate software package, partially on a user's computer, partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., using an Internet service provider to connect via the Internet). In some embodiments, an electronic circuit, such as a programmable logic circuit, a field programmable gate array (FPGA), or a programmable logic array (PLA), may be customized by utilizing the state information of the computer-readable program instructions, and the electronic circuit may execute the computer-readable program instructions, thereby implementing various aspects of the present disclosure.

[0066] These computer-readable program instructions can be provided to a processing unit of a general-purpose computer, a special-purpose computer, or other programmable data processing device, thereby producing a machine, so that when these instructions are executed by the processing unit of the computer or other programmable data processing device, a device that implements the functions / actions specified in one or more boxes in the flowchart and / or block diagram is generated. These computer-readable program instructions can also be stored in a computer-readable storage medium, and these instructions cause the computer, programmable data processing device, and / or other equipment to work in a specific manner, so that the computer-readable medium storing the instructions includes a manufactured product, which includes instructions for implementing various aspects of the functions / actions specified in one or more boxes in the flowchart and / or block diagram.

[0067] Computer-readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device so that a series of operating steps are performed on the computer, other programmable data processing apparatus, or other device to produce a computer-implemented process, thereby causing the instructions executed on the computer, other programmable data processing apparatus, or other device to implement the functions / actions specified in one or more boxes in the flowchart and / or block diagram.

[0068] The flow chart and block diagram in the accompanying drawings show the possible architecture, function and operation of the equipment, method and computer program product according to multiple embodiments of the present disclosure. In this regard, each frame in the flow chart or block diagram can represent a part of a module, program segment or instruction, and a part of the module, program segment or instruction includes one or more executable instructions for realizing the specified logical function. In some alternative implementations, the function marked in the frame can also occur in a sequence different from that marked in the accompanying drawings. For example, two continuous frames can actually be executed substantially in parallel, and they can also be executed in the opposite order sometimes, depending on the functions involved. It should also be noted that each frame in the block diagram and / or flow chart, and the combination of frames in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.

[0069] The embodiments of the present disclosure have been described above, and the above description is exemplary, not exhaustive, and is not limited to the disclosed embodiments. Many modifications and changes will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the described embodiments. The choice of terms used herein is intended to best explain the principles of the embodiments, practical applications, or technical improvements to the technology in the market, or to enable other persons of ordinary skill in the art to understand the embodiments disclosed herein.

[0070] Some example implementations of the present disclosure are listed below.

[0071] Example 1. A method for determining a prompt word, comprising:

[0072] Obtaining a user input indicating a query requirement in a natural language form, wherein the user input is a part of a prompt word of a language model for generating a structured query language (SQL) query, wherein the SQL query is used to obtain data related to the query requirement from a data platform;

[0073] Generate a tag set based on the word segmentation result input by the user;

[0074] Generate a user input vector of the user input and a tag vector set of the tag set by processing the user input and the tag set using a vectorization model, the tag vector set including a tag vector for each tag in the tag set;

[0075] Based on the user input vector and the tag vector set, determine a vector matching field name from a field name vector library, wherein the field name vector library is constructed based on the field names in the data platform through the vectorization model;

[0076] Based on the user input vector and the set of tag vectors, determining a vector matching field value from a field value vector library, wherein the field value vector library is constructed based on the field values ​​in the data platform through the vectorization model;

[0077] Based on the user input, determining a text matching field name from field names in the data platform by text matching; and

[0078] A target prompt word for the language model is determined based on the user input, the vector matching field name, the vector matching field value, and the text matching field name.

[0079] Example 2. The method according to Example 1, wherein generating the tag set comprises:

[0080] Generate the word segmentation result input by the user through word segmentation processing;

[0081] Determine the part-of-speech information of each tag in the word segmentation result through part-of-speech tagging; and

[0082] The tag set is generated based on the word segmentation result and the part-of-speech information.

[0083] Example 3. The method according to any one of Examples 1-2, wherein determining the vector matching field name from the field name vector library comprises:

[0084] Based on the user input vector, determining an input vector similarity score of each field name in the field name vector library;

[0085] Determine a first vector matching field name based on the input vector similarity score, the similarity score threshold, and the candidate number threshold;

[0086] Based on the tag vector set, determining a tag vector similarity score for each field name in the field name vector library;

[0087] Determining a second vector matching field name based on the tag vector similarity score, the similarity score threshold, and the candidate number threshold; and

[0088] The vector matching field name is determined based on the first vector matching field name and the second vector matching field name.

[0089] Example 4. The method of any one of Examples 1-3, wherein determining that the second vector matches the field name comprises:

[0090] In response to determining that the tag vector similarity score reaches the highest similarity score, determining the corresponding tag as the second vector matching field name; or

[0091] In response to determining that the token vector similarity score is less than a maximum similarity score, determining that a second vector matches the field name based on the token vector similarity score, the similarity score threshold, and the candidate number threshold.

[0092] Example 5. The method according to any one of Examples 1-4, wherein determining the vector matching field value from the field value vector library includes

[0093] Based on the user input vector, determining an input vector similarity score for each field value in the field value vector library;

[0094] Determining a first vector matching field value based on the vector similarity score, the similarity score threshold, and the candidate number threshold;

[0095] Based on the set of labeled vectors, determining a labeled vector similarity score for each field value in the field value vector library;

[0096] Determining a second vector matching field value based on the tag vector similarity score, the similarity score threshold, the candidate number threshold, and the length range threshold; and

[0097] The vector matching field value is determined based on the first vector matching field value and the second vector matching field value.

[0098] Example 6. The method of any one of Examples 1-5, wherein determining that the second vector matches a field value comprises:

[0099] In response to the tag vector similarity score reaching the highest similarity score, determining the corresponding tag as the second vector matching field value; or

[0100] In response to the tag vector similarity score being less than the highest similarity score, based on the tag vector similarity score, the similarity score threshold and the candidate number threshold, a field value whose field value length meets the length range threshold is determined as the second vector matching field value.

[0101] Example 7. The method according to any one of Examples 1-6, wherein determining the text matching field name comprises:

[0102] Acquire a set of field names from the data platform; and

[0103] The text matching field name is determined based on the field name in the field name set that belongs to the substring of the user input.

[0104] Example 8. The method according to any one of Examples 1-7, further comprising:

[0105] In response to determining that the number of field names in the text matching field names is less than a candidate number threshold, determining a text matching score between the remaining field names in the field name set and the user input, the text matching score being determined by substring similarity; and

[0106] Based on the text matching score, field names to be added to the text matching field names are determined from the remaining field names.

[0107] Example 9. The method according to any one of Examples 1-8, wherein determining the target prompt word for the language model comprises:

[0108] Determine the matching field name by taking a union based on the vector matching field name and the text matching field name;

[0109] Based on the matching field name and the vector matching field value, generating field recall information in a format in descending order of scores; and

[0110] The target prompt word is generated based on the field recall information and the user input.

[0111] Example 10. A device for determining a prompt word, comprising:

[0112] A user input acquisition module is configured to acquire user input indicating a query requirement in a natural language form, wherein the user input is a part of a prompt word of a language model for generating a structured query language SQL query, wherein the SQL query is used to acquire data related to the query requirement from a data platform;

[0113] A tag set generating module, configured to generate a tag set based on the word segmentation result input by the user;

[0114] a vector information generating module configured to generate a user input vector of the user input and a tag vector set of the tag set by processing the user input and the tag set using a vectorization model, the tag vector set including a tag vector of each tag in the tag set;

[0115] A field name vector matching module, configured to determine a vector matching field name from a field name vector library based on the user input vector and the tag vector set, wherein the field name vector library is constructed based on the field names in the data platform through the vectorization model;

[0116] A field value vector matching module, configured to determine a vector matching field value from a field value vector library based on the user input vector and the tag vector set, wherein the field value vector library is constructed based on the field value in the data platform through the vectorization model;

[0117] A field name text matching module, configured to determine a text matching field name from field names in the data platform through text matching based on the user input; and

[0118] The prompt content determination module is configured to determine a target prompt word for the language model based on the user input, the vector matching field name, the vector matching field value, and the text matching field name.

[0119] Example 11. The apparatus according to Example 10, wherein the tag set generation module comprises:

[0120] A word segmentation result generating module, configured to generate the word segmentation result input by the user through word segmentation processing;

[0121] a part-of-speech information determination module, configured to determine the part-of-speech information of each tag in the word segmentation result through part-of-speech tagging; and

[0122] The tag set second generating module is configured to generate the tag set based on the word segmentation result and the part-of-speech information.

[0123] Example 12. The apparatus according to any one of Examples 10-11, wherein the field name vector matching module comprises:

[0124] An input score determination module, configured to determine an input vector similarity score of each field name in the field name vector library based on the user input vector;

[0125] A first field name determination module is configured to determine a first vector matching field name based on the input vector similarity score, a similarity score threshold, and a candidate number threshold;

[0126] a tag score determination module configured to determine a tag vector similarity score of each field name in the field name vector library based on the tag vector set;

[0127] A second field name determination module is configured to determine a second vector matching field name based on the tag vector similarity score, the similarity score threshold, and the candidate number threshold; and

[0128] The field name vector matching second module is configured to determine the vector matching field name based on the first vector matching field name and the second vector matching field name.

[0129] Example 13. The apparatus according to any one of Examples 10-12, wherein the second field name determination module comprises:

[0130] The second field name second determination module is configured to determine the corresponding tag as the second vector matching field name in response to determining that the tag vector similarity score reaches the highest similarity score; or, in response to determining that the tag vector similarity score is less than the highest similarity score, determine the second vector matching field name based on the tag vector similarity score, the similarity score threshold and the candidate number threshold.

[0131] Example 14. An apparatus according to any one of Examples 10-13, wherein the field value vector matching module includes

[0132] an input score second determination module configured to determine an input vector similarity score of each field value in the field value vector library based on the user input vector;

[0133] A first field value determination module is configured to determine a first vector matching field value based on the vector similarity score, the similarity score threshold and the candidate number threshold;

[0134] a second tag score determination module configured to determine a tag vector similarity score for each field value in the field value vector library based on the tag vector set;

[0135] A second field value determination module is configured to determine a second vector matching field value based on the tag vector similarity score, the similarity score threshold, the candidate number threshold, and the length range threshold; and

[0136] The field value vector matching second module is configured to determine the vector matching field value based on the first vector matching field value and the second vector matching field value.

[0137] Example 15. The apparatus of any one of Examples 10-14, wherein determining the second field value determination module comprises:

[0138] The second field value second determination module is configured to determine the corresponding tag as the second vector matching field value in response to the tag vector similarity score reaching the highest similarity score; or, in response to the tag vector similarity score being less than the highest similarity score, determine the field value whose field value length meets the length range threshold as the second vector matching field value based on the tag vector similarity score, the similarity score threshold and the candidate number threshold.

[0139] Example 16. The apparatus according to any one of Examples 10-15, wherein the field name text matching module comprises:

[0140] A field name set acquisition module is configured to acquire a field name set from the data platform; and

[0141] The second text matching field name module is configured to determine the text matching field name based on the field name in the field name set that belongs to the substring of the user input.

[0142] Example 17. The apparatus according to any one of Examples 10-16, further comprising:

[0143] a text score determination module configured to determine, in response to determining that the number of field names in the text matching field names is less than a candidate number threshold, a text matching score between the remaining field names in the field name set and the user input, wherein the text matching score is determined by substring similarity; and

[0144] The adding field determining module is configured to determine the field names to be added to the text matching field names from the remaining field names based on the text matching scores.

[0145] Example 18. The apparatus according to any one of Examples 10-17, wherein the prompt content determination module comprises:

[0146] A matching field name determination module is configured to determine the matching field name by taking a union based on the vector matching field name and the text matching field name;

[0147] A recall information generation module configured to generate field recall information in a format arranged in descending order of scores based on the matching field name and the vector matching field value; and

[0148] The prompt content second determination module is configured to generate the target prompt word based on the field recall information and the user input.

[0149] Example 19. An electronic device comprising:

[0150] Processor; and

[0151] A memory coupled to the processor, the memory having instructions stored therein, wherein when the instructions are executed by the processor, the electronic device performs actions, the actions comprising:

[0152] Obtaining a user input indicating a query requirement in a natural language form, wherein the user input is a part of a prompt word of a language model for generating a structured query language (SQL) query, wherein the SQL query is used to obtain data related to the query requirement from a data platform;

[0153] Generate a tag set based on the word segmentation result input by the user;

[0154] Generate a user input vector of the user input and a tag vector set of the tag set by processing the user input and the tag set using a vectorization model, the tag vector set including a tag vector for each tag in the tag set;

[0155] Based on the user input vector and the tag vector set, determine a vector matching field name from a field name vector library, wherein the field name vector library is constructed based on the field names in the data platform through the vectorization model;

[0156] Based on the user input vector and the set of tag vectors, determining a vector matching field value from a field value vector library, wherein the field value vector library is constructed based on the field values ​​in the data platform through the vectorization model;

[0157] Based on the user input, determining a text matching field name from field names in the data platform by text matching; and

[0158] A target prompt word for the language model is determined based on the user input, the vector matching field name, the vector matching field value, and the text matching field name.

[0159] Example 20. The electronic device of Example 19, wherein generating the tag set comprises:

[0160] Generate the word segmentation result input by the user through word segmentation processing;

[0161] Determine the part-of-speech information of each tag in the word segmentation result through part-of-speech tagging; and

[0162] The tag set is generated based on the word segmentation result and the part-of-speech information.

[0163] Example 21. The electronic device of any of Examples 19-20, wherein determining from the field name vector library that the vector matches the field name comprises:

[0164] Based on the user input vector, determining an input vector similarity score of each field name in the field name vector library;

[0165] Determine a first vector matching field name based on the input vector similarity score, the similarity score threshold, and the candidate number threshold;

[0166] Based on the tag vector set, determining a tag vector similarity score for each field name in the field name vector library;

[0167] Determining a second vector matching field name based on the tag vector similarity score, the similarity score threshold, and the candidate number threshold; and

[0168] The vector matching field name is determined based on the first vector matching field name and the second vector matching field name.

[0169] Example 22. The electronic device of any of Examples 19-21, wherein determining that the second vector matches the field name comprises:

[0170] In response to determining that the tag vector similarity score reaches the highest similarity score, determining the corresponding tag as the second vector matching field name; or

[0171] In response to determining that the token vector similarity score is less than a maximum similarity score, determining that a second vector matches the field name based on the token vector similarity score, the similarity score threshold, and the candidate number threshold.

[0172] Example 23. An electronic device according to any one of Examples 19-22, wherein determining the vector matching field value from the field value vector library includes

[0173] Based on the user input vector, determining an input vector similarity score for each field value in the field value vector library;

[0174] Determining a first vector matching field value based on the vector similarity score, the similarity score threshold, and the candidate number threshold;

[0175] Based on the set of labeled vectors, determining a labeled vector similarity score for each field value in the field value vector library;

[0176] Determining a second vector matching field value based on the tag vector similarity score, the similarity score threshold, the candidate number threshold, and the length range threshold; and

[0177] The vector matching field value is determined based on the first vector matching field value and the second vector matching field value.

[0178] Example 24. The electronic device of any of Examples 19-23, wherein determining that the second vector matches a field value comprises:

[0179] In response to the tag vector similarity score reaching the highest similarity score, determining the corresponding tag as the second vector matching field value; or

[0180] In response to the tag vector similarity score being less than the highest similarity score, based on the tag vector similarity score, the similarity score threshold and the candidate number threshold, a field value whose field value length meets the length range threshold is determined as the second vector matching field value.

[0181] Example 25. The electronic device of any one of Examples 19-24, wherein determining that the text matches a field name comprises:

[0182] Acquire a set of field names from the data platform; and

[0183] The text matching field name is determined based on the field name in the field name set that belongs to the substring of the user input.

[0184] Example 26. The electronic device according to any one of Examples 19-25, wherein the actions further include:

[0185] In response to determining that the number of field names in the text matching field names is less than a candidate number threshold, determining a text matching score between the remaining field names in the field name set and the user input, the text matching score being determined by substring similarity; and

[0186] Based on the text matching score, field names to be added to the text matching field names are determined from the remaining field names.

[0187] Example 27. The electronic device of any one of Examples 19-26, wherein determining the target prompt word for the language model comprises:

[0188] Determine the matching field name by taking a union based on the vector matching field name and the text matching field name;

[0189] Based on the matching field name and the vector matching field value, generating field recall information in a format in descending order of scores; and

[0190] The target prompt word is generated based on the field recall information and the user input.

[0191] Example 28. A computer-readable storage medium having one or more computer instructions stored thereon, wherein the one or more computer instructions are executed by a processor to implement the method according to any one of Examples 1 to 9.

[0192] Example 29. A computer program product tangibly stored on a computer-readable medium and comprising computer-executable instructions that, when executed by a device, cause the device to perform the method according to any one of Examples 1 to 9.

[0193] Although the disclosure has been described in language specific to structural features and / or methodological logical actions, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. Instead, the specific features and actions described above are merely example forms of implementing the claims.

Claims

1. A method for determining a prompt word, comprising: Obtaining a user input indicating a query requirement in a natural language form, wherein the user input is a part of a prompt word of a language model for generating a structured query language (SQL) query, wherein the SQL query is used to obtain data related to the query requirement from a data platform; Generate a tag set based on the word segmentation result input by the user; Generate a user input vector of the user input and a tag vector set of the tag set by processing the user input and the tag set using a vectorization model, the tag vector set including a tag vector for each tag in the tag set; Based on the user input vector and the tag vector set, determine a vector matching field name from a field name vector library, wherein the field name vector library is constructed based on the field names in the data platform through the vectorization model; Based on the user input vector and the set of tag vectors, determining a vector matching field value from a field value vector library, wherein the field value vector library is constructed based on the field values ​​in the data platform through the vectorization model; Based on the user input, determining a text matching field name from field names in the data platform by text matching; and A target prompt word for the language model is determined based on the user input, the vector matching field name, the vector matching field value, and the text matching field name.

2. The method of claim 1, wherein generating the tag set comprises: Generate the word segmentation result input by the user through word segmentation processing; Determine the part-of-speech information of each tag in the word segmentation result through part-of-speech tagging; as well as The tag set is generated based on the word segmentation result and the part-of-speech information.

3. The method according to claim 1, wherein determining the vector matching field name from the field name vector library comprises: Based on the user input vector, determining an input vector similarity score of each field name in the field name vector library; Determine a first vector matching field name based on the input vector similarity score, the similarity score threshold, and the candidate number threshold; Based on the tag vector set, determining a tag vector similarity score for each field name in the field name vector library; Determine a second vector matching field name based on the tag vector similarity score, the similarity score threshold, and the candidate number threshold; as well as The vector matching field name is determined based on the first vector matching field name and the second vector matching field name.

4. The method of claim 3, wherein determining that the second vector matches the field name comprises: In response to determining that the tag vector similarity score reaches the highest similarity score, determining the corresponding tag as a second vector matching field name; or In response to determining that the token vector similarity score is less than a maximum similarity score, determining that a second vector matches the field name based on the token vector similarity score, the similarity score threshold, and the candidate number threshold.

5. The method of claim 1, wherein determining the vector matching field value from the field value vector library comprises Based on the user input vector, determining an input vector similarity score for each field value in the field value vector library; Determining a first vector matching field value based on the vector similarity score, the similarity score threshold, and the candidate number threshold; Based on the set of labeled vectors, determining a labeled vector similarity score for each field value in the field value vector library; Determining a second vector matching field value based on the tag vector similarity score, the similarity score threshold, the candidate number threshold, and the length range threshold; as well as The vector matching field value is determined based on the first vector matching field value and the second vector matching field value.

6. The method of claim 5, wherein determining that the second vector matches a field value comprises: In response to the tag vector similarity score reaching a maximum similarity score, determining the corresponding tag as a second vector matching field value; or In response to the tag vector similarity score being less than the highest similarity score, based on the tag vector similarity score, the similarity score threshold and the candidate number threshold, a field value whose field value length meets the length range threshold is determined as the second vector matching field value.

7. The method of claim 1, wherein determining the text matches a field name comprises: Obtain a set of field names from the data platform; as well as The text matching field name is determined based on the field name in the field name set that belongs to the substring of the user input.

8. The method according to claim 7, further comprising: In response to determining that the number of field names in the text matching field names is less than a candidate number threshold, determining a text matching score between the remaining field names in the field name set and the user input, the text matching score being determined by substring similarity; as well as Based on the text matching score, field names to be added to the text matching field names are determined from the remaining field names.

9. The method of claim 8, wherein determining the target cue word for the language model comprises: Determine the matching field name by taking a union based on the vector matching field name and the text matching field name; Based on the matching field name and the vector matching field value, generating field recall information in a format arranged in descending order of scores; as well as The target prompt word is generated based on the field recall information and the user input.

10. A device for determining a prompt word, comprising: A user input acquisition module is configured to acquire user input indicating a query requirement in a natural language form, wherein the user input is a part of a prompt word of a language model for generating a structured query language SQL query, wherein the SQL query is used to acquire data related to the query requirement from a data platform; A tag set generating module, configured to generate a tag set based on the word segmentation result input by the user; a vector information generating module configured to generate a user input vector of the user input and a tag vector set of the tag set by processing the user input and the tag set using a vectorization model, the tag vector set including a tag vector of each tag in the tag set; A field name vector matching module, configured to determine a vector matching field name from a field name vector library based on the user input vector and the tag vector set, wherein the field name vector library is constructed based on the field names in the data platform through the vectorization model; A field value vector matching module, configured to determine a vector matching field value from a field value vector library based on the user input vector and the tag vector set, wherein the field value vector library is constructed based on the field value in the data platform through the vectorization model; A field name text matching module is configured to determine a text matching field name from field names in the data platform through text matching based on the user input; as well as The prompt content determination module is configured to determine a target prompt word for the language model based on the user input, the vector matching field name, the vector matching field value, and the text matching field name.

11. An electronic device, comprising: processor; as well as A memory coupled to the processor, the memory having instructions stored therein, wherein when the instructions are executed by the processor, the electronic device executes the method according to any one of claims 1 to 9.

12. A computer program product tangibly stored on a non-transitory computer readable medium and comprising computer executable instructions for performing the method according to any one of claims 1 to 9.

Citation Information

Patent Citations

  • Method and equipment for converting text into SQL (Structured Query Language) statement

    CN116629227A

  • Medical insurance intelligent query method and system based on NL2SQL

    CN118132579A