Prompt word construction method and device

By identifying keywords in the target text and filtering similar enumeration values, and building prompt words with other field values, the problem of too long prompt words caused by the large number of enumeration values ​​in the enumeration type field is solved, and the accuracy of SQL statement generation is improved and efficiency.

CN119312802APending Publication Date: 2025-01-14HISENSE GRP HLDG CO LTD
View PDF 0 Cites 3 Cited by

Patent Information

Application Number
CN202411206511.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-29
Publication Date
2025-01-14

AI Technical Summary

Technical Problem

In the prior art, the large number of enumeration values ​​in the enumeration type field leads to too long prompt words, resulting in a decrease in the accuracy of the language model generating SQL statements.

Method used

By identifying keywords in the target text, filter out enumeration values ​​similar to the keywords, and construct prompt words in combination with other field values ​​to reduce the length of prompt words.

Benefits of technology

It improves the accuracy and efficiency of the language big model to generate SQL statements, avoids passive truncation of prompt words, and enhances the model's attention to enumeration type field values.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119312802A_ABST
    Figure CN119312802A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of data processing, in particular to a cue word construction method and device. In the embodiment of the invention, the electronic equipment determines the keyword contained in the to-be-processed target text and determines the target enumeration value similar to the keyword in the enumeration value corresponding to the target field of the enumeration type to construct the cue word based on the target enumeration value, so that the constructed cue word is accurate, the length of the cue word is shortened, and the user experience is improved. And the efficiency and the accuracy of the text2sql are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data processing technology, and in particular to a prompt word construction method and device. Background Art

[0002] With the development of language big model technology, language big model has been applied to various industries and fields, and converting text into Structured Query Language (SQL) statements is one of its aspects.

[0003] An existing method for converting text into SQL statements based on a large language model is to add all the fields contained in a data table and the full value corresponding to each field to a prompt word, and the large language model generates an SQL statement for the text based on the prompt word.

[0004] However, as the application of large language models becomes more and more widespread, some fields may be enumeration type fields, and the number of enumeration values ​​ranges from 2 to 9000+. If all enumeration values ​​of enumeration type fields are written into the prompt word, the prompt word will be too long, resulting in passive truncation of the prompt word, which in turn leads to a decrease in the accuracy of SQL statements generated by the large language model. Based on this, how to reduce the length of the prompt word while ensuring accuracy has become a problem that needs to be solved. Summary of the invention

[0005] The present application provides a prompt word construction method and device to solve the problem of low accuracy of SQL statement generation by a large language model caused by the excessive length of prompt words in the prior art.

[0006] In a first aspect, an embodiment of the present application provides a method for constructing a prompt word, the method comprising:

[0007] According to the field type of each field saved in advance, determining a target field whose field type is an enumeration type among the candidate fields for constructing the prompt word;

[0008] Perform keyword recognition on the target text to be processed, determine the keywords contained in the target text, and determine the target enumeration value similar to the keyword in each enumeration value according to the keywords;

[0009] A target prompt word is constructed according to the target enumeration value and field values ​​corresponding to other fields in the candidate fields except the target field.

[0010] In a second aspect, an embodiment of the present application further provides an electronic device, which includes at least a processor and a memory, and the processor is used to implement the steps of the prompt word construction method as described above when executing a computer program stored in the memory.

[0011] In an embodiment of the present application, according to the field type of each field saved in advance, a target field whose field type is an enumeration type in the candidate field for constructing a prompt word is determined; keyword recognition is performed on the target text to be processed, the keywords contained in the target text are determined, and according to the keywords, a target enumeration value similar to the keyword in each enumeration value is determined; according to the target enumeration value and the field values ​​corresponding to other fields in the candidate field except the target field, a target prompt word is constructed. In an embodiment of the present application, the electronic device determines the keywords contained in the target text to be processed, and by determining the target enumeration value similar to the keyword in the enumeration value corresponding to the target field of the enumeration type, a prompt word is constructed based on the target enumeration value, so that the constructed prompt word is accurate, and the length of the prompt word is shortened, thereby improving the efficiency and accuracy of text2sql. BRIEF DESCRIPTION OF THE DRAWINGS

[0012] In order to more clearly illustrate the technical solution of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0013] Figure 1 A schematic diagram of a prompt word construction process provided in an embodiment of the present application;

[0014] Figure 2 A schematic diagram of keyword extraction provided in an embodiment of the present application;

[0015] Figure 3 A schematic diagram of regular matching provided in an embodiment of the present application;

[0016] Figure 4 A schematic diagram of regular matching based on business domain knowledge provided in an embodiment of the present application;

[0017] Figure 5 A schematic diagram of similarity matching provided in an embodiment of the present application;

[0018] Figure 6 An overall flow chart for constructing prompt words provided in the embodiment of the present application;

[0019] Figure 7 A schematic diagram of the structure of a prompt word construction device provided in an embodiment of the present application;

[0020] Figure 8 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0021] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application will be further described in detail below in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present application.

[0022] By using a large language model, SQL statements can be generated quickly without the need for SQL programming experience, saving time and effort in writing SQL statements. In addition, compared with manually written SQL statements, SQL statements generated using a large language model are relatively more accurate and stable, which can help reduce errors and vulnerabilities. This is where the text2sql task comes in. text2sql converts text into SQL language. A more academic definition is: converting natural language problems in the database field into structured language that can be executed in a relational database.

[0023] For text2sql tasks, they are usually SQL queries based on a single table, and the database table structure is simple and contains a small number of fields. The common method is to build prompt words based on static database table structure information, write the table structure of each database table into the prompt words, and fine-tune the text2sql task. However, for text2sql tasks in vertical business fields, the database table structure is complex, and SQL queries are usually multi-table queries. Using traditional static prompt words will cause the prompt words to be too long, and it is impossible to explain the values ​​and meanings of all field enumeration values ​​in the prompt words.

[0024] Based on this, in order to shorten the length of prompt words and improve the accuracy of SQL statement generation, the embodiment of the present application provides a prompt word construction method and medium, which can achieve better results by recalling only the key enumeration values ​​of the target field of the enumeration type into the prompt word.

[0025] In an embodiment of the present application, based on the field type of each field saved in advance, a target field whose field type is an enumeration type in the candidate fields for constructing a prompt word is determined; keyword recognition is performed on the target text to be processed to determine the keywords contained in the target text, and based on the keywords, a target enumeration value similar to the keyword in each enumeration value is determined; and a target prompt word is constructed based on the target enumeration value and the field values ​​corresponding to other fields in the candidate fields except the target field.

[0026] Figure 1 A schematic diagram of a prompt word construction process provided in an embodiment of the present application, the process includes:

[0027] S101: According to the field type of each field saved in advance, determine a target field whose field type is an enumeration type among candidate fields for constructing a prompt word.

[0028] A prompt word construction method provided in an embodiment of the present application is applied to an electronic device, which may be a PC or a server.

[0029] In the related art, when fine-tuning the language model, some fields in the database table are enumeration type fields and appear in the library table in the form of code. This requires the value and meaning of the enumeration value of the explanation field to be displayed in the fine-tuning prompt word, so that the language model can understand the relationship between the field value and the question in sql. For example, the question: "How many male personnel registered in 2019", sql: "select count(*)from person where xb='0'and time like'2019%'", in order to make the language model better understand the relationship between the input and output of the labeled sample, and improve the final performance of the fine-tuning model, it is necessary to display a supplementary explanation in the prompt word: "person table field xb-gender-enumeration field, the value range is: 0: male, 1: female".

[0030] However, since the number of enumeration values ​​of enumeration type fields in the database ranges from 2 to more than 9000, if all enumeration values ​​of enumeration type fields are displayed in the prompt word, on the one hand, the prompt word will be too long, resulting in passive truncation of the prompt word and an increase in fine-tuning resources. On the other hand, it is not conducive to the large language model to focus on the enumeration values ​​related to the current sample.

[0031] Based on this, in an embodiment of the present application, the field type of each field is pre-stored in the electronic device. After the electronic device determines the candidate field for constructing the prompt word, the electronic device determines the target field whose field type is an enumeration type in the candidate field according to the stored field type of each field, and recalls the value of the target field. The number of the candidate fields is one or more, and the number of the target fields is one or more, but the number of the target fields does not exceed the number of the candidate fields.

[0032] Among them, in the embodiment of the present application, the enumeration type corresponds to multiple field values.

[0033] Table 1 is an example of a field of an enumeration type provided in an embodiment of the present application:

[0034] Field Name Notes Number of enumeration values JbXj Approved driving type 16 YJX Original driving model 16 CfDJ Initial issuing authority 408 ZT Driver's license status 19

[0035] Table 1

[0036] As shown in Table 1 above, the fields “ZJCX”, “YZJCX”, “CCFZJC” and “ZT” are all fields of enumeration type, and the corresponding numbers of enumeration values ​​are 16, 16, 408 and 19 respectively.

[0037] S102: Perform keyword recognition on the target text to be processed, determine the keywords contained in the target text, and determine, based on the keywords, a target enumeration value similar to the keyword in each enumeration value corresponding to the target field.

[0038] Since the number of enumeration values ​​corresponding to the target fields of the enumeration type is not equal, if the enumeration value of each target field is added to the prompt word, the prompt word may be too long and be truncated. Based on this, in an embodiment of the present application, the electronic device will filter the target enumeration values ​​related to the SQL statement corresponding to the target text from the enumeration values ​​corresponding to the target field, thereby reducing the length of the prompt word.

[0039] Specifically, the electronic device performs keyword recognition on the target text to be processed to determine the keywords contained in the target text. For example, the electronic device can recognize the keywords contained in the target text according to a keyword recognition algorithm; the electronic device can also use a trained network model for keyword detection to determine the keywords contained in the target text; the electronic device can also use an exhaustive method to search for keywords from the target text according to a pre-configured keyword thesaurus. The number of keywords contained in the target text can be one or more.

[0040] Figure 2 The keyword extraction schematic diagram provided in the embodiment of the present application is as follows: Figure 2 As shown, three keywords can be extracted from "new energy car", namely "new energy car", "new energy" and "car". The electronic device matches each keyword separately and takes the union of similar enumeration values ​​corresponding to each keyword as the target enumeration value.

[0041] Specifically, after the electronic device determines the keywords included in the target text, the electronic device determines the target enumeration value similar to the keyword in each enumeration value corresponding to the target field. If the number of keywords is one, the electronic device directly determines the target enumeration value similar to the keyword; if the number of keywords is multiple, the electronic device determines the candidate enumeration value similar to the keyword for each keyword, and then determines the candidate enumeration value corresponding to each keyword as the target enumeration value.

[0042] The number of target enumeration values ​​determined by the electronic device may be one or more.

[0043] S103: construct a target prompt word according to the target enumeration value and field values ​​corresponding to other fields in the candidate fields except the target field.

[0044] In the embodiment of the present application, after the electronic device determines the target enumeration value of the target field of the enumeration type, the electronic device constructs a target prompt word according to the target enumeration value and field values ​​corresponding to other fields except the candidate field.

[0045] Specifically, the electronic device stores a prompt word template, and the electronic device can add the target enumeration value and field values ​​corresponding to other fields except the candidate field to the prompt word template, and determine the added prompt word template as the target prompt word.

[0046] In an embodiment of the present application, the electronic device determines the keywords contained in the target text to be processed, and constructs prompt words based on the target enumeration values ​​by determining the target enumeration values ​​corresponding to the target field of the enumeration type that are similar to the keywords, so that the constructed prompt words are accurate, the length of the prompt words is shortened, and the efficiency and accuracy of text2sql are improved.

[0047] In order to shorten the length of the prompt word and improve the accuracy of SQL statement generation, based on the above embodiment, in the embodiment of the present application, after determining the target field whose field type is an enumeration type in the candidate fields for constructing the prompt word, and before performing keyword recognition on the target text to be processed and determining the keywords contained in the target text, the method further includes:

[0048] Obtain each pre-saved enumeration value corresponding to the target field, concatenate each enumeration value to obtain a target string, and determine a target length of the target string;

[0049] If the target length exceeds the preset length threshold, a subsequent step of performing keyword recognition on the target text to be processed is performed to determine the keywords contained in the target text.

[0050] In actual application, some enumeration type target fields may correspond to only a few enumeration values, which has little impact on the length of the prompt word. Therefore, in order to reduce resource consumption, in an embodiment of the present application, the electronic device can filter the target fields to select the target fields that need to determine the target enumeration values.

[0051] Specifically, for each target field, the electronic device obtains each pre-saved enumeration value corresponding to each target field, concatenates each enumeration value to obtain a target string, and determines a target length of the target string. The electronic device determines whether to recall the value of the target field according to the target length.

[0052] If the electronic device determines that the target length of the target field exceeds a preset length threshold, the electronic device recalls the value of the target field.

[0053] In order to shorten the length of the prompt word and improve the accuracy of SQL statement generation, based on the above embodiments, in the embodiment of the present application, the method further includes:

[0054] If the target length does not exceed the preset length threshold, each of the enumeration values ​​is determined as the target enumeration value.

[0055] If the electronic device determines that the target length of the target field does not exceed the preset length threshold, the electronic device does not recall the field value of the target field, but adds each enumeration value of the target field to the prompt word.

[0056] In order to shorten the length of the prompt word and improve the accuracy of SQL statement generation, based on the above embodiments, in the embodiment of the present application, the target enumeration value similar to the keyword in each enumeration value corresponding to the target field is determined according to the keyword, including:

[0057] According to the content corresponding to each enumeration value, the enumeration value containing the keyword is determined as the target enumeration value.

[0058] In the embodiment of the present application, the electronic device may use a regular matching method to determine a target enumeration value similar to the keyword in each enumeration value corresponding to the target field.

[0059] Specifically, the electronic device determines the enumeration value containing the keyword as the target enumeration value according to the content corresponding to each enumeration value.

[0060] In addition, in an embodiment of the present application, the electronic device can also add business knowledge constraints, and then match based on keywords. For example, the field "administrative division / issuing authority / administrative division where the registered residence is located / management jurisdiction" is closely related to the business scenario, such as the administrative division field in the vehicle and driver management scenario in the project, which contains the administrative division codes of all provinces, cities and districts in Shandong, but actual questions usually do not ask about multiple cities at once. If you only focus on vehicles in Qingdao / Jinan, that is, you only need to add the administrative divisions starting with "3702 / 3701" to the prompt word, and other administrative division code values ​​can be filtered out.

[0061] Among them, in the embodiment of the present application, if the electronic device adopts the above two regular matching strategies, the enumeration values ​​obtained by the two regular matching strategies are both determined as the target enumeration values.

[0062] Figure 3 A schematic diagram of regular matching provided in the embodiment of the present application, such as Figure 3As shown, the target text is "Among the drivers in Qingdao, what is the percentage of Tajiks?", the electronic device determines that the target field is "ethnicity" and the keyword is "Tajik". The electronic device determines that the target enumeration value is "32: Tajiks" through regular matching.

[0063] Figure 4 A schematic diagram of regular matching based on business domain knowledge provided in the embodiment of the present application, such as the Figure 4 As shown in the figure, the target text is "Which district in Qingdao / Jinan has the most white cars", the electronic device determines the target field as "administrative division", and determines the keyword as "Qingdao / Jinan". Through the pre-saved business domain knowledge, it can be known that the administrative division field in the vehicle and driver management scenario in the project contains the administrative division codes of all provinces, cities and districts in Shandong, but in actual questions, multiple cities are usually not asked at once. Therefore, only the vehicles in Qingdao / Jinan need to be paid attention to, that is, only the administrative divisions starting with "3702 / 3701" need to be added to the prompt words. Based on this, the target enumeration values ​​similar to "Qingdao" determined by the electronic device are "370201: City District", "370202: Shinan District", "370203: Shibei District" and "370204: Taidong District", and "370101: City District", "370102: Lixia District", "370103: Shizhong District" and "370104: Huaiyin District" similar to "Jinan" are determined.

[0064] In order to shorten the length of the prompt word and improve the accuracy of SQL statement generation, based on the above embodiments, in the embodiment of the present application, the target enumeration value similar to the keyword in each enumeration value corresponding to the target field is determined according to the keyword, including:

[0065] Determine the similarity between each enumeration value and the keyword, wherein the number of the keywords is one or more;

[0066] According to the numerical value of each similarity corresponding to each enumeration value and each keyword, each similarity is sorted;

[0067] The enumeration values ​​corresponding to the preset number of similarities ranked at the top in the sorting result are determined as the target enumeration values.

[0068] In the embodiment of the present application, the electronic device may also determine the target enumeration value similar to the keyword in each enumeration value of the target field by similarity matching.

[0069] It should be noted that in the embodiment of the present application, the number of keywords determined by the electronic device can be one or more. If the number of keywords determined by the electronic device is one, the electronic device determines the similarity between each enumeration value and the keyword, and sorts each enumeration value according to the numerical value of the similarity corresponding to each enumeration value; and determines the preset number of enumeration values ​​ranked first in the sorting result as the target enumeration value.

[0070] If the electronic device determines multiple keywords, it sorts each similarity according to the numerical value of each similarity corresponding to each enumeration value and each keyword, and determines the enumeration values ​​corresponding to the top preset number of similarities in the sorting result as the target enumeration values.

[0071] Among them, the electronic device can first determine the word vector corresponding to each enumeration value and the word vector corresponding to the keyword, and use the cosine similarity algorithm to compare the similarity between the word vector corresponding to the keyword and the word vector corresponding to each enumeration value.

[0072] The electronic device may determine the union of the target enumeration value obtained by regular matching and the target enumeration value obtained by similarity matching, and construct the prompt word according to the union. This may be implemented by the following formula:

[0073]

[0074] Among them, recall_value represents the union, w i represents each keyword extracted from the keyword, v represents each enumeration value of the target field, R represents the regular matching strategy, S represents the similarity matching strategy, a represents the parameter setting of the regular matching strategy, and b represents the parameter setting of the similarity matching strategy.

[0075] Figure 5 A schematic diagram of similarity matching provided in an embodiment of the present application, such as the Figure 5 As shown, the electronic device extracts keywords from the target text and determines keywords; the electronic device determines the similarity between each enumeration value and each keyword, and sorts the similarities, and determines the enumeration values ​​corresponding to the top ten similarities as target enumeration values.

[0076] In order to shorten the length of the prompt word and improve the accuracy of SQL statement generation, based on the above embodiments, in the embodiment of the present application, the process of determining each enumeration value corresponding to the target field includes:

[0077] Obtaining a predetermined target data table for constructing a prompt word, and determining an enumeration value written into the target field in the target data table;

[0078] If the enumeration value is a code value, a pre-saved mapping relationship between the code value and the field value is obtained, and each field value corresponding to each code value in the mapping relationship is updated to each enumeration value.

[0079] In actual application, the enumeration values ​​of some fields in the data table are replaced by code values, which is not conducive to understanding and is not conducive to the recall of field values. Therefore, in an embodiment of the present application, the electronic device stores a mapping relationship between field values ​​and code values ​​established according to the data table association.

[0080] Specifically, in the embodiment of the present application, the electronic device obtains a predetermined target data table for constructing a prompt word, and determines the enumeration value written into the target field in the target data table. If the electronic device determines that the enumeration value is a code value, it obtains a pre-saved mapping relationship between the code value and the field value, and updates each field value corresponding to each code value in the mapping relationship to each enumeration value.

[0081] Table 2 is an example of the mapping relationship between the code value and the field value corresponding to the business system classification field provided in the embodiment of the present application:

[0082] Code Value Field Value 17 Examination Supervision 20 Internet Services 19 Tax exchange 22 High Law Exchange 25 Comprehensive supervision

[0083] Table 2

[0084] As shown in Table 2, in the business system classification field, the field value corresponding to the code value 17 is examination supervision, the field value corresponding to the code value 20 is Internet service, the field value corresponding to the code value 19 is tax exchange, the field value corresponding to the code value 22 is high law exchange, and the field value corresponding to the code value 25 is comprehensive supervision.

[0085] In order to shorten the length of the prompt word and improve the accuracy of SQL statement generation, based on the above embodiments, in the embodiment of the present application, before determining the target field whose field type is an enumeration type among the candidate fields for constructing the prompt word according to the field type of each field saved in advance, the method further includes:

[0086] Constructing an initial prompt word according to the candidate field and the field value corresponding to the candidate field;

[0087] Determining the initial character length of the initial prompt word;

[0088] If the initial character length exceeds the preset prompt word character length threshold, a subsequent step of determining a target field whose field type is an enumeration type in the candidate fields for constructing the prompt word according to the pre-saved field type of each field is performed.

[0089] In order to avoid wasting resources of the electronic device, in an embodiment of the present application, the electronic device may first determine whether value recall is required before value recall, that is, the electronic device determines whether the initial character length of the initial prompt word constructed based on the full enumeration value exceeds the prompt word character length threshold.

[0090] Specifically, the electronic device recalls the field value corresponding to each candidate field obtained by the upstream module table and field recall, and combines it into the prompt word through certain rules to obtain the initial prompt word. The initial prompt word is token monitored to determine the initial character length of the initial prompt word. If the token upper limit is not exceeded, that is, the initial character length exceeds the prompt word character length threshold, the electronic device determines that the target field of the enumeration type needs to be recalled.

[0091] In order to shorten the length of the prompt word and improve the accuracy of SQL statement generation, based on the above embodiments, in the embodiment of the present application, the method further includes:

[0092] If the initial character length does not exceed the prompt word character length threshold, the initial prompt word is determined as a target prompt word for generating an SQL statement of the target text.

[0093] In an embodiment of the present application, if the electronic device determines that the initial character length of the initial prompt word does not exceed the prompt word character length threshold, the electronic device determines that value recall is not required, and the electronic device determines the initial prompt word as the target prompt word for generating the SQL statement of the target text.

[0094] In order to shorten the length of the prompt word and improve the accuracy of SQL statement generation, based on the above embodiments, in the embodiment of the present application, the method further includes:

[0095] Inputting the target prompt word and the target text into a language macromodel;

[0096] Obtain the SQL statement corresponding to the target text output by the language model.

[0097] In the embodiment of the present application, after the electronic device determines the target prompt word, the electronic device can input the target prompt word and the target text into the language model. The language model performs an SQL query on the target text according to the target prompt word, and the language model determines and outputs the SQL statement corresponding to the target text. The electronic device obtains the SQL statement corresponding to the target text output by the language model.

[0098] Figure 6 The overall flow chart of the prompt word construction provided in the embodiment of the present application is as follows: Figure 6 As shown:

[0099] The first step is token monitoring: the electronic device recalls the enumeration values ​​of all fields obtained by the upstream module table and field recall, and combines them into the prompt word according to certain rules for token monitoring. If it does not exceed the token upper limit (prompt word character length threshold), the full field enumeration value is added to the prompt word; if it exceeds the token upper limit, proceed to the next step.

[0100] The second step is to monitor the enumeration value: the prompt words that exceed the upper limit of the token cannot be randomly truncated, otherwise it will affect the semantic integrity and the understanding of the language model, resulting in the output of wrong results. Therefore, the electronic device needs to monitor the enumeration values ​​involved in the target field of each enumeration type. The enumeration values ​​of the target fields that do not exceed the preset length threshold are fully added, and the target fields that exceed the preset length threshold will enter the next step.

[0101] The third step is truncation strategy: the electronic device performs keyword recognition on the target text to be processed, determines the keywords contained in the target text, and determines the target enumeration value similar to the keyword in each enumeration value corresponding to the target field based on the keywords.

[0102] Based on the above embodiments, Figure 7 A schematic diagram of a prompt word construction device provided in an embodiment of the present application, the device comprising:

[0103] Processing module 701 is used to determine, according to the field type of each field saved in advance, a target field whose field type is an enumeration type among candidate fields for constructing a prompt word; perform keyword recognition on a target text to be processed, determine the keywords contained in the target text, and determine, according to the keywords, a target enumeration value similar to the keyword in each enumeration value corresponding to the target field;

[0104] The construction module 702 is used to construct a target prompt word according to the target enumeration value and field values ​​corresponding to other fields in the candidate fields except the target field.

[0105] In a possible implementation, the processing module 701 is also used to obtain each enumeration value corresponding to the target field that is pre-saved, concatenate each enumeration value to obtain a target string, and determine a target length of the target string; if the target length exceeds a preset length threshold, a subsequent step of performing keyword recognition on the target text to be processed is performed to determine the keywords contained in the target text.

[0106] In a possible implementation, the processing module 701 is further configured to determine each of the enumeration values ​​as the target enumeration value if the target length does not exceed a preset length threshold.

[0107] In a possible implementation manner, the processing module 701 is specifically configured to determine the enumeration value containing the keyword as the target enumeration value according to the content corresponding to each enumeration value.

[0108] In a possible implementation, the processing module 701 is specifically used to determine the similarity between each enumeration value and the keyword, wherein the number of the keywords is one or more; sorting each similarity according to the numerical value of each similarity corresponding to each enumeration value and each keyword; and determining the enumeration values ​​corresponding to a preset number of similarities that are ranked first in the sorting result as the target enumeration values.

[0109] In a possible implementation, the processing module 701 is specifically used to obtain a predetermined target data table for constructing a prompt word, and determine the enumeration value written into the target field in the target data table; if the enumeration value is a code value, then obtain a pre-saved mapping relationship between the code value and the field value, and update each field value corresponding to each code value in the mapping relationship to each enumeration value.

[0110] In a possible implementation, the construction module 702 is further used to construct an initial prompt word based on the candidate fields and the field values ​​corresponding to the candidate fields; determine the initial character length of the initial prompt word; if the initial character length exceeds a preset prompt word character length threshold, then execute subsequent steps of determining a target field whose field type is an enumeration type in the candidate fields used to construct the prompt word based on the field type of each field saved in advance.

[0111] In a possible implementation, the construction module 702 is further configured to determine the initial prompt word as a target prompt word for generating an SQL statement of the target text if the initial character length does not exceed the prompt word character length threshold.

[0112] In a possible implementation, the device further includes:

[0113] The statement generation module 703 is used to input the target prompt word and the target text into the language model; and obtain the SQL statement corresponding to the target text output by the language model.

[0114] Based on the above embodiments, the present application also provides an electronic device, Figure 8 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application is shown in FIG. Figure 8 As shown, it includes: a processor 801, a communication interface 802, a memory 803 and a communication bus 804, wherein the processor 801, the communication interface 802, and the memory 803 communicate with each other through the communication bus 804;

[0115] The memory 803 stores a computer program. When the program is executed by the processor 801, the processor 801 executes the steps of the prompt word construction method provided in the above embodiments.

[0116] Since the principle of solving the problem by the above electronic device is similar to the method for constructing the prompt word, the implementation of the above electronic device can refer to the embodiment of the method, and the repeated parts will not be repeated.

[0117] The communication bus mentioned in the above electronic device can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus. The communication interface 802 is used for communication between the above electronic device and other devices. The memory may include a random access memory (RAM) and may also include a non-volatile memory (NVM), such as at least one disk storage. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.

[0118] The above-mentioned processor can be a general-purpose processor, including a central processing unit, a network processor (Network Processor, NP), etc.; it can also be a digital signal processing processor (Digital Signal Processing, DSP), an application-specific integrated circuit, a field programmable gate array or other programmable logic device, a discrete gate or transistor logic device, a discrete hardware component, etc.

[0119] Based on the above embodiments, an embodiment of the present invention further provides a computer-readable storage medium, which stores a computer program that can be executed by a processor. When the program runs on the processor, the processor implements the steps of the prompt word construction method provided in the above embodiments.

[0120] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.

[0121] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0122] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0123] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0124] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.

Claims

1. A method for constructing a prompt word, characterized in that: The method comprises: According to the field type of each field saved in advance, determining a target field whose field type is an enumeration type among the candidate fields for constructing the prompt word; Perform keyword recognition on the target text to be processed, determine the keywords contained in the target text, and determine, based on the keywords, a target enumeration value similar to the keyword in each enumeration value corresponding to the target field; A target prompt word is constructed according to the target enumeration value and field values ​​corresponding to other fields in the candidate fields except the target field.

2. The method according to claim 1, characterized in that After determining the target field whose field type is an enumeration type in the candidate fields for constructing the prompt word, and before performing keyword recognition on the target text to be processed and determining the keywords contained in the target text, the method further includes: Obtain each pre-saved enumeration value corresponding to the target field, concatenate each enumeration value to obtain a target string, and determine a target length of the target string; If the target length exceeds the preset length threshold, a subsequent step of performing keyword recognition on the target text to be processed is performed to determine the keywords contained in the target text.

3. The method according to claim 2, characterized in that The method further comprises: If the target length does not exceed the preset length threshold, each of the enumeration values ​​is determined as the target enumeration value.

4. The method according to claim 1, characterized in that: The step of determining, according to the keyword, a target enumeration value similar to the keyword in each enumeration value corresponding to the target field comprises: According to the content corresponding to each enumeration value, the enumeration value containing the keyword is determined as the target enumeration value.

5. The method according to claim 1, characterized in that The step of determining, according to the keyword, a target enumeration value similar to the keyword in each enumeration value corresponding to the target field comprises: Determine the similarity between each enumeration value and the keyword, wherein the number of the keywords is one or more; According to the numerical value of each similarity corresponding to each enumeration value and each keyword, each similarity is sorted; The enumeration values ​​corresponding to the preset number of similarities ranked at the top in the sorting result are determined as the target enumeration values.

6. The method according to claim 1, characterized in that The process of determining each enumeration value corresponding to the target field includes: Obtaining a predetermined target data table for constructing a prompt word, and determining an enumeration value written into the target field in the target data table; If the enumeration value is a code value, a pre-saved mapping relationship between the code value and the field value is obtained, and each field value corresponding to each code value in the mapping relationship is updated to each enumeration value.

7. The method according to claim 1, characterized in that Before determining, according to the field type of each field saved in advance, a target field whose field type is an enumeration type among the candidate fields for constructing the prompt word, the method further includes: Constructing an initial prompt word according to the candidate field and the field value corresponding to the candidate field; Determining the initial character length of the initial prompt word; If the initial character length exceeds the preset prompt word character length threshold, a subsequent step of determining a target field whose field type is an enumeration type in the candidate fields for constructing the prompt word according to the pre-saved field type of each field is performed.

8. The method according to claim 7, characterized in that The method further comprises: If the initial character length does not exceed the prompt word character length threshold, the initial prompt word is determined as a target prompt word for generating an SQL statement of the target text.

9. The method according to claim 1 or 8, characterized in that: The method further comprises: Inputting the target prompt word and the target text into a language macromodel; Obtain the SQL statement corresponding to the target text output by the language model.

10. An electronic device, characterized in that: The electronic device comprises at least a processor and a memory, and the processor is used to implement the steps of the prompt word construction method as claimed in any one of claims 1 to 9 when executing the computer program stored in the memory.

Citation Information

Cited By

  • Government affair data quality check rule generation method and system based on large language model

    CN120012756A

  • Government affair data quality checking rule generation method and system based on large language model

    CN120012756B

  • Intelligent question and answer optimization method and device, computer equipment and medium

    CN120821814A