Question processing method, device, equipment and storage medium based on large language model
By using the target data model in the large language model to correct the question results, the problem of divergence and uncertainty in the large language model processing of questions is solved, and higher quality parsing results are achieved.
Patent Information
- Application Number
- CN202311507867.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-11-13
- Publication Date
- 2024-10-29
- Estimated Expiration
- 2043-11-13
AI Technical Summary
Large language models have divergence and uncertainty when processing questions, and cannot meet the needs of some scenarios.
By obtaining the target problem to be processed, a prompt statement is generated based on the target data model and the target format information of the specified data format, the large language model is input to obtain the target parsing result of the specified data format, and the target data model is used to correct the results to improve Analytical quality.
It improves the parsing quality of large language models when processing questions, ensuring the stability and accuracy of results.
Smart Images

Figure CN117407513B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of artificial intelligence technology, specifically to the technical fields of deep learning, natural language processing, etc. Specifically, it relates to a question processing method, device, equipment and storage medium based on a large language model. Background Art
[0002] A large language model (LLM) is a generative language model characterized by its large size, large number of parameters and training data. By using more parameters and larger data sets for training, its performance and sample efficiency on various downstream tasks are effectively improved.
[0003] However, the results returned by large models are divergent and uncertain, and cannot meet the needs in some scenarios. Summary of the invention
[0004] The present disclosure provides a question processing method, apparatus, device and storage medium based on a large language model.
[0005] According to one aspect of the present disclosure, a question processing method based on a large language model is provided, comprising:
[0006] Get the target problem to be processed;
[0007] generating a prompt statement based on the target data model to be used, the target format information specifying the data format, and the target question;
[0008] Inputting the prompt sentence into a large language model to obtain a target parsing result in a specified data format output by the large language model;
[0009] Based on the target data model, the target parsing result is modified.
[0010] According to one aspect of the present disclosure, a question processing device based on a large language model is provided, comprising:
[0011] A problem acquisition module is used to acquire the target problem to be processed;
[0012] A prompt generation module, used for generating a prompt statement based on a target data model to be used, target format information specifying a data format, and the target question;
[0013] A question parsing module, used for inputting the prompt sentence into a large language model to obtain a target parsing result in a specified data format output by the large language model;
[0014] A result correction module is used to correct the target parsing result based on the target data model.
[0015] According to another aspect of the present disclosure, there is provided an electronic device, the electronic device comprising:
[0016] at least one processor; and
[0017] a memory communicatively connected to the at least one processor; wherein,
[0018] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method provided by any embodiment of the present disclosure.
[0019] According to another aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to enable a computer to execute the method provided by any embodiment of the present disclosure.
[0020] According to another aspect of the present disclosure, a computer program product is provided, including a computer program, wherein when the computer program is executed by a processor, the method provided according to any embodiment of the present disclosure is implemented.
[0021] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] The accompanying drawings are used to better understand the present solution and do not constitute a limitation of the present disclosure.
[0023] Figure 1 is a flowchart of a question processing method based on a large language model provided according to an embodiment of the present disclosure;
[0024] Figure 2 is a flowchart of another question processing method based on a large language model provided according to an embodiment of the present disclosure;
[0025] Figure 3a is a flowchart of another question processing method based on a large language model provided according to an embodiment of the present disclosure;
[0026] Figure 3b It is a correction schematic diagram for a character type field to be screened according to an embodiment of the present disclosure;
[0027] Figure 4 is a schematic diagram of the structure of a prompt statement provided according to an embodiment of the present disclosure;
[0028] Figure 5It is a structural schematic diagram of a question processing device based on a large language model provided according to an embodiment of the present disclosure;
[0029] Figure 6 The block diagram is a block diagram of an electronic device used to implement the question processing method based on a large language model according to an embodiment of the present disclosure. DETAILED DESCRIPTION
[0030] Figure 1 1 is a flowchart of a method for processing a question based on a large language model according to an embodiment of the present disclosure. The method is applicable to the case where a target parsing result generated by a large language model for a target question is corrected based on a target data model. The method can be executed by a question processing device based on a large language model, which can be implemented in software and / or hardware and can be integrated into an electronic device. Figure 1 As shown, the question processing method based on the large language model of this embodiment may include:
[0031] S101, obtaining the target problem to be processed;
[0032] S102, generating a prompt statement based on the target data model to be used, the target format information of the specified data format, and the target question;
[0033] S103, inputting the prompt sentence into a large language model to obtain a target parsing result in a specified data format output by the large language model;
[0034] S104: Based on the target data model, modify the target parsing result.
[0035] The data fields in the target data model can be dimensions and measures in the target data model. Dimensions can describe the attributes or characteristics of data and are used to group, classify, filter and screen data. Dimensions provide context and classification for data and generally have discrete values. A measure is a measure of a business indicator, which is used to measure, calculate and analyze the numerical indicators or calculation results of data. It is usually a continuous numerical value, which is computable and can be aggregated, calculated and counted. For example, the target data model may include at least one of the following dimensions: order number, order date, region, province, city, product name, product category, product subcategory, customer name, customer type code, shipping date, mailing method; the target data model may also include at least one of the following measures: quantity, sales, cost, profit. The specified data format may be a fixed serialization format, and the target format information of the specified data format is used to describe the specified data format.
[0036] A prompt is an input provided to a large language model. It can be a given question, task, or instruction to guide the model's language generation process. The content of the prompt depends on the user's needs and the type of task. A data model is used to describe, organize, or operate on data. A data model can be considered a simplification and abstraction of the real world, used to describe entities, attributes, and relationships between entities. Specifically, a pre-built data table can be selected as the target data model, so that the large language model can parse the target question into a specified data format based on the target data model.
[0037] The prompt statement can be constructed according to the data fields, target format information and target question in the target data model. By introducing the data fields of the target data model in the prompt statement, the large language model can establish the relationship between the target question and the data fields. By introducing the target format information of the specified data format in the prompt statement, the large language model converts the target question into the specified data format, and the target parsing result of the specified data format can be used to query the target data model to obtain the answer to the target question, that is, the target parsing result can be used as a bridge between the large language model and the target data model, so as to facilitate the parsing of the target parsing result. Therefore, by adopting a prompt statement composed of multiple parts, the large language model understands the meaning of the target question and generates the target parsing result of the specified data format, that is, the large language model parses the target question into a stable specified data format.
[0038] Moreover, the target parsing results output by the large language model vary in quality. By correcting the target parsing results based on the data fields and field values of the data fields (which can be called the detailed values of the data fields) in the target data model, that is, using the data fields in the target data model as a benchmark to compare, verify and correct the target fields in the target parsing results, the quality of the target parsing results can be improved.
[0039] The technical solution provided by the embodiment of the present disclosure generates a prompt statement based on the target data model to be used, the target format information of the specified data format and the target question, so that the large language model establishes a relationship between the target question and the target data model, and parses the target question into a target parsing result in the specified data format based on the relationship, and corrects the target parsing result based on the target data model, thereby further improving the parsing quality of the target question.
[0040] In an optional implementation, the target format information includes dimension fields, metric fields, and filtering conditions; the filtering conditions include fields to be filtered, filtering values of the fields to be filtered, and operators.
[0041] Among them, the target format information of the specified data format may include a format description of the specified data format. The format description of the specified data format may include preset dimension fields "dimensions", measurement fields "measures" and filter conditions "filters". Specifically, the target question can be matched with the dimensions and measurements in the target data model to obtain the target dimensions and target fields hit by the target question, and the filter conditions can also be obtained. The filter conditions may include dimensions to be filtered and / or measurements to be filtered, which can also be called filter conditions. The above target format information enables the large language model to learn to parse the target question into the specified data format.
[0042] Among them, the filtering condition has three elements: the field to be filtered, the filtering value used by the field to be filtered, and the filtering operator. By introducing the first subfield, the second subfield, and the third subfield in the filtering condition, the field to be filtered can be placed in the first subfield, the filtering value used by the field to be filtered can be placed in the second subfield, and the filtering operator can be placed in the third subfield. Among them, the format of the filtering condition can be as follows: "filters":[{"k":"___","linkType":"___","v":["___"]}, k, v, linkType are the first subfield, the second subfield, and the third subfield respectively. Through the filtering conditions of the above array structure, the modeling of the filtering conditions in the specified data format is realized. Correspondingly, the style of the target parsing result can be as follows:
[0043] {"dimensions":["___"],"measures":["___"],"filters":[{"k":"___","linkType":"___","v":["___"]},{"k":"___","linkType":"___","v":["___"]}]}.
[0044] Taking the target problem as the sales in January of this year as an example, the target parsing results can be as follows:
[0045] {"dimensions":[],"measures":["Sales"],"filters":[{"k":"Order Date","linkType":"between","v":["2023-01-01","2023-01-31"]}]}.
[0046] Figure 2 FIG. 1 is a flowchart of another question processing method based on a large language model provided according to an embodiment of the present disclosure. Figure 2 The question processing method based on the large language model of this embodiment may include:
[0047] S201, obtaining the target problem to be processed;
[0048] S202, generating a prompt statement based on the target data model to be used, the target format information of the specified data format, and the target question;
[0049] S203, inputting the prompt sentence into a large language model to obtain a target parsing result in a specified data format output by the large language model;
[0050] S204, determining the field type to which the field to be filtered belongs according to the filtering condition in the target parsing result;
[0051] S205, when the field to be filtered is of character type, obtaining a filtering value of the field to be filtered from the filtering condition;
[0052] S206, matching the screening value of the field to be screened with the field value of the data field in the target data model, and modifying the field to be screened according to the matching result.
[0053] For the filter conditions in the target parsing results, the filter value of the field to be filtered can be used to determine the field type to which the field to be filtered belongs. The field type is character type, date type, or numeric type. Among them, the data field in the target data model can be a dimension or a measure, and the field value of the data field can be obtained from the target data model. A data field can have multiple field values. Taking the "Region" field as an example, the corresponding field value can be Northeast, North China, East China, Central China, South China, Northwest, or Southwest.
[0054] For the fields to be filtered that are of character type, the filter value of the field to be filtered can be obtained from the filter conditions, and the filter value of the field to be filtered can be matched with the field value of the data field in the target data model to obtain a matching result. Based on the matching result, it can be determined whether the field to be filtered is normal. If it is normal, no correction is required; if it is abnormal, the field to be filtered can be corrected, for example, the field to be filtered can be replaced with the corrected data field, thereby improving the quality of the target parsing result.
[0055] In an optional implementation, the target parsing result is corrected based on the target data model, and further includes: when the field to be filtered is of a date type, formatting the filtering value of the field to be filtered to obtain a date type value; matching the date type value with the field value of the field to be filtered in the target data model, and correcting the field to be filtered according to the matching result.
[0056] For the fields to be filtered that are of date type, the standard date format can be used to format the filter value of the field to be filtered to obtain a date type value. For example, if the filter value of the field to be filtered is the date 10-10, the year can be added to obtain 2023-10-10 as the date type value. Get the field values of the field to be filtered from the target data model, match the date type value with each field value to obtain a matching result, and modify the field to be filtered according to the matching result. Formatting the date of the field to be filtered of date type can improve the efficiency of subsequent date matching.
[0057] In addition, since the probability of using numeric fields as filtering conditions is low, no correction is required. Therefore, the numeric fields to be filtered can be directly filtered out without correction. For example, if the fields to be filtered are numeric dimensions such as ID, longitude and latitude coordinates, or if the fields to be filtered are measures, no correction is required for the fields to be filtered.
[0058] The technical solution provided by the embodiment of the present disclosure determines the field type of the field to be filtered according to the filtering value of the field to be filtered in the filtering condition, matches the field to be filtered with the data field in the target data model in combination with the field type of the field to be filtered, and corrects the field to be filtered according to the matching result, thereby improving the quality of the filtering condition in the target parsing result.
[0059] In an optional implementation, the target parsing result is modified based on the target data model, including: for any target dimension in the target parsing result, if the filtering condition uses the target dimension as a field to be filtered, and the operator is equal to or contains, then the target dimension is deleted from the target parsing result.
[0060] The target parsing result can be in the following styles:
[0061] {"dimensions":["___"],"measures":["___"],"filters":[{"k":"___","linkType":"___","v":["___"]}; dimension dimension is used to store the target dimension hit by the target problem in the target data model, and measure measures is used to store the target measure hit by the target problem in the target data model. In the filter condition filters, k represents the field to be filtered, v represents the filter value of the field to be filtered, and linkType represents the operator of the field to be filtered.
[0062] If the operator linkType of any field to be filtered is equal to or contains, and the field to be filtered belongs to the target dimension in dimensions, the field to be filtered is deleted from dimensions, and only the field to be filtered is retained in the filtering condition. By deleting redundant target dimensions in the target parsing result according to the field to be filtered, the target parsing result can be simplified, thereby improving the efficiency of subsequent queries on the target data model using the target parsing result.
[0063] In an optional implementation, the target parsing result is corrected based on the target data model, including: if the field to be filtered in the filtering condition is corrected to a target data field based on the target data model, and the field to be filtered belongs to a target dimension or a target metric in the target parsing result, then the target dimension or target metric in the target parsing result is also corrected to a target data field.
[0064] If the field to be filtered in the filter condition is corrected to the target data field based on the target data model, and the field to be filtered also belongs to the target dimension in dimensions or the field to be filtered also belongs to the target metric in measures, the target dimension or target metric is also corrected to the target data field. In other words, if the field to be filtered in the filter condition is corrected, and the field to be filtered also belongs to the target dimension or target metric in the target parsing result, the target dimension or target metric is corrected synchronously, which can not only improve the quality of the target parsing result, but also avoid the matching between the target dimension or target metric and the target data model, thereby improving the correction efficiency of the target parsing result.
[0065] In an optional implementation, the target parsing result is modified based on the target data model, including: if the to-be-filtered fields in at least two filtering conditions are the same, merging the at least two filtering conditions.
[0066] The target parsing result may include one or more filter conditions. If the fields to be filtered in at least two filter conditions in the target parsing result are the same, the filter values and operators of the at least two filter conditions are merged to obtain a new filter condition. By merging the filter conditions for the same field to be filtered into a new filter condition, the efficiency of subsequent queries on the target data model based on the filter conditions can be improved.
[0067] Figure 3a It is a flowchart of another method for processing questions based on a large language model according to an embodiment of the present disclosure. The method is applicable to modifying the to-be-screened fields of the character type in the screening conditions. Figure 3a The question processing method based on the large language model of this embodiment may include:
[0068] S301, obtaining a target problem to be processed;
[0069] S302, generating a prompt statement based on the target data model to be used, the target format information of the specified data format, and the target question;
[0070] S303, inputting the prompt sentence into a large language model to obtain a target parsing result in a specified data format output by the large language model;
[0071] S304, determining the field type to which the field to be filtered belongs according to the filtering condition in the target parsing result;
[0072] S304, when the field to be filtered is of character type, obtaining a filtering value of the field to be filtered from the filtering condition;
[0073] S305, when the field to be filtered belongs to the data field, obtaining the field value of the field to be filtered from the target data model;
[0074] S306, matching the screening value of the to-be-screened field with the field value of the to-be-screened field to obtain a first matching result;
[0075] S307, if the first matching result is a match failure, matching the screening value of the field to be screened with the field values of other data fields in the target data model to obtain a second matching result;
[0076] S308: If the second matching result is a successful match, the field to be screened is modified to another data field that is a successful match.
[0077] For the character type field to be filtered, the filter value of the field to be filtered is obtained from the filter condition. When the field to be filtered belongs to a data field in the target data model, the field value of the data field (which can be called the detail value of the data field) is also obtained from the target data model as the field value of the field to be filtered. The filter value of the field to be filtered is matched with each field value of the field to be filtered to obtain a first matching result. If the comparison with any field value is successful, that is, the first matching result is a matching success, then the field to be filtered is normal and there is no need to correct the field to be filtered; if the filter value of the field to be filtered fails to match each field value of the field to be filtered, then the first matching result is a matching failure, and the field values of other data fields except the field to be filtered are also obtained from the target data model, and the filter value of the field to be filtered is matched with the field values of other data fields to obtain a second matching result; if the filter value of the field to be filtered successfully matches the field value of any other filtering field, then the second matching result is a matching success, and the field to be filtered can be corrected to the other filtering field.
[0078] For character type fields to be filtered, by matching the filter value of the field to be filtered with the field value (detail value) of the field to be filtered in the target data model or the field value of other data fields, and based on the matching result, if the field to be filtered is abnormal, correct the field to be filtered to other data fields that match successfully, you can get the accurate field to be filtered, thereby improving the quality of the filtering conditions.
[0079] In an optional implementation, the modifying of the field to be filtered according to the matching result also includes: if the second matching result is a matching failure, segmenting the target parsing result to obtain segmentation information; matching the segmentation information with the data field in the target data model, and modifying the field to be filtered to a data field that has been successfully matched.
[0080] If the second matching result is a match failure, that is, the screening value of the field to be screened does not match the field value of each data field in the target data model, then the target parsing result is segmented to obtain segmentation information, and the segmentation information is used to match the data field in the target data model, for example, the segmentation information is compared with the field value of the data field in the target data model. If the match is successful, the field to be screened is corrected to a successfully matched data field. By segmenting the target parsing result and matching the data field in the target data model with the segmentation information, the matching failure caused by the error generated by the large language model can be avoided, thereby improving the success rate of correcting the field to be screened.
[0081] In an optional implementation, based on the target data model, correcting the target parsing result also includes: if the match with the data fields in the target data model fails, using the filtering value of the field to be filtered as a question, and inputting the field value of the data field as an option into the large language model to obtain the target data field selected by the large language model, and correcting the field to be filtered to the target data field.
[0082] If the filter value and word segmentation information of the to-be-filtered field fail to match the data field in the target data model, the large language model can be used to select the data field that needs to be corrected for the to-be-filtered field from the target data model, and the to-be-filtered field is corrected to the data field selected by the large language model, thereby further improving the quality of the filtering conditions. It should be noted that if the large language model does not select any data field, the to-be-filtered field is filtered out from the filtering conditions.
[0083] refer to Figure 3bFor the character type field to be filtered, the filter value of the field to be filtered is obtained from the filter condition, the detail value of the field to be filtered is obtained from the target data model, and the filter value of the field to be filtered is compared with the detail values of the field to be filtered. If the comparison is successful, the field to be filtered is normal and does not need to be modified; if the comparison fails, the field to be filtered is abnormal and needs to be corrected. The detail values of other data fields are also obtained from the target data model, and the filter value of the field to be filtered is compared with the character values of other data fields. If the comparison with the detail value of any other data field is successful, the field to be filtered is corrected to the other data field.
[0084] If the comparison with the detailed values of all other data fields fails, the target parsing result is segmented to obtain the segmentation information, and the segmentation information is compared with the detailed value of the data field in the target data model. If the comparison is successful, other data fields with successful comparison are obtained, and the field to be filtered is corrected to other data fields with successful comparison; if all comparisons fail, the filtering value of the field to be filtered is used as a question, and the field value of the data field is input into the large language model as an option. If the large language model selects the target data field from each data field, the field to be filtered is corrected to the selected target data field. It should also be noted that if the large language model does not make a selection, the field to be filtered is filtered out from the filtering conditions.
[0085] The technical solution provided by the embodiment of the present disclosure obtains the filtering value of the field to be filtered from the filtering condition for the character type field to be filtered, compares the filtering value of the field to be filtered based on the field value of the field to be filtered and the field values of other data fields in the target data model, and corrects the field to be filtered to a data field with successful comparison, which can improve the accuracy of the filtering condition and thus improve the quality of the target parsing result.
[0086] In an optional embodiment, a prompt statement is generated based on a target data model and a target question, including: obtaining data fields in the target data model, and obtaining target format information of a specified data format; constructing a prompt statement according to the data fields in the target data model, the target format information and the target question; wherein the target parsing result is used to establish a relationship between the target question and the data fields in the target data model, and the target parsing result is a serialized result.
[0087] Among them, the specified serialization format can be a specified JSON (JavaScript Object Notation, JS object notation) format. The target parsing result can be a result in a specified JSON format. Therefore, the large language model can convert the target question into a result in a specified JSON format based on the data fields in the target data model. By converting the target question into a target parsing result in a specified serialization format based on the data fields in the target data model, it can be used to query the target data model to obtain an answer to the target question, so that the target parsing result can be used as a bridge between the large language model and the target data model, which is convenient for parsing the target parsing result.
[0088] Figure 4 is a schematic diagram of a structure of a prompt statement provided according to an embodiment of the present disclosure. Figure 4 , the prompt statement may include: data fields in the target data model, sample data for the data fields, target format information, strategies, few-shots, and target questions.
[0089] refer to Figure 4 For data fields (field schema information), since data fields are generally stored in the database with English names, the mapping relationship between the English name and the Chinese name of the data field is obtained by obtaining the field description of the data field or naming the data field in Chinese at the data model layer. The Chinese name of the data field is used for description in the prompt, so that subsequent questions can be asked using the Chinese name of the data field.
[0090] In the case where there is no sample data of the data field introduced in the prompt, when asking [What is the sales volume in Shanghai], the large language model may put Shanghai in the regional dimension, causing a parsing error. By introducing sample data of the data field in the prompt, the large language model is prompted with the name of the data field represented by the sample data, so that the large language model can perform inference learning based on the sample data. For example, when asking about the sales volume of "Shijiazhuang", the large language model can perform inference based on the given sample data and return the "city" dimension, increasing the accuracy of the target parsing result; in addition, if the target question includes sample data of the data field, the accuracy of the target parsing result can also be increased.
[0091] The format description of the data format specified in the target format information is used to tell the large language model the format of the output data, the fields in the specified data format from which information to obtain, and the specific composition of the screening conditions. The target format information can also include the style of the specified data format, so that the result format returned by the large language model is fixed, which is convenient for subsequent analysis of the target analysis results.
[0092] The precautions may include at least one of the following:
[0093] A. The large language model is not very sensitive to time description information. By adding the current specific date in the notes and telling it some possible time description information, it is necessary to perform specific time processing on the time description information to improve its learning ability for time description information. For example, if a user asks "What was the sales volume in Hebei Province last year?", the large language model needs to parse the time description information "last year" into "2022-01-01, 2022-12-31" and put it into the screening conditions.
[0094] B. If the sample data of the data dimension does not appear in the target problem to be processed, do not put the sample data into the "filters" of the returned results. The above processing can avoid data that is not related to the target problem from appearing in the filter conditions.
[0095] C. The second subfield in the filter condition must be exactly the same as the name of the data dimension or data measure in the target data model. For example, for the target question "What is the sales volume in Hebei?", if there is no "sales volume" field in the target data model, but only the "volume" field, then we want it to return the "volume" field, so we describe it here, and hope that it can infer and find the data dimension or data measure that has appeared and is similar when it returns, as the second subfield in the filter condition.
[0096] D. The data content summarized in the target question needs to be converted into a specific array. Taking the target question "What are the products with sales greater than 10,000" as an example, the large language model can return 10,000 as the value of the screening condition, but what is wanted is a specific value such as 10,000, so it is explained in the precautions.
[0097] For small samples, the dimensions and metrics in the sample answers of small samples can be randomly obtained from the target data model and are not fixed. The details are as follows:
[0098] a. For small samples of date type, if there are date and date-time type fields in the dimension field of the target data model, small samples of date type can be added. The corresponding small samples can be as follows:
[0099] Question: Sales in January this year
[0100] Answer: {"dimensions":[],"measures":["Sales"],"filters":[{"k":"Order Date","linkType":"between","v":["2023-01-01","2023-01-31"]}]}
[0101] b. For geographical location-based small samples, if the target data model has geographical location-based data dimensions, geographical location-based small samples can be added. The corresponding small samples can be as follows:
[0102] Question: Show me the sales volume of Shanghai
[0103] Answer: {"dimensions":["Province"],"measures":["Sales"],"filters":[{"k":"Province","linkType":"=","v":"Shanghai"}]}
[0104] c. The filter condition is not a field that must be returned. When there is no filter condition, only the dimension and measure are returned. The corresponding small sample is as follows:
[0105] Question: Sales volume by city
[0106] Answer: {"dimensions":["city"],"measures":["sales"]}
[0107] In addition, two of the three small samples mentioned above have screening conditions that can increase the learning weight of the screening conditions.
[0108] Input the constructed prompt statement into the large language model to obtain the target parsing result in the specified data format output by the large language model; verify and correct the target dimension, target metric, and the to-be-filtered field in the filter condition in the target parsing result based on the data field in the target data model to obtain the corrected target parsing result. For the filter condition in the target parsing result, a query statement can be constructed for the filter condition based on the target dimension and target metric, and the query statement can be used to query the target data model to obtain the corresponding query result data, and the query result data can also be returned to the front end for chart display.
[0109] Figure 5 1 is a schematic diagram of a question processing device based on a large language model according to an embodiment of the present disclosure. This embodiment is applicable to the case where the target parsing result generated by the large language model for the target question is corrected based on the target data model. The device can be implemented in software and / or hardware. Figure 5 As shown, the question processing device 500 based on the large language model of this embodiment may include:
[0110] A question acquisition module 510 is used to acquire a target question to be processed;
[0111] A prompt generating module 520, configured to generate a prompt statement based on a target data model to be used, target format information specifying a data format, and the target question;
[0112] The question parsing module 530 is used to input the prompt sentence into the large language model to obtain a target parsing result in a specified data format output by the large language model;
[0113] The result correction module 540 is used to correct the target parsing result based on the target data model.
[0114] In an optional implementation, the target format information includes dimension fields, metric fields, and filtering conditions; the filtering conditions include fields to be filtered, filtering values of the fields to be filtered, and operators.
[0115] In an optional implementation, the result correction module 540 includes:
[0116] The field type unit is used to determine the field type of the field to be filtered according to the filtering conditions in the target parsing result;
[0117] A screening value unit, used for obtaining a screening value of the field to be screened from the screening condition when the field to be screened is of character type;
[0118] The correction unit is used to match the screening value of the field to be screened with the field value of the data field in the target data model, and to correct the field to be screened according to the matching result.
[0119] In an optional implementation, the correction unit includes:
[0120] A field value subunit, used for obtaining the field value of the field to be filtered from the target data model when the field to be filtered belongs to the data field;
[0121] A first matching subunit, used for matching the screening value of the to-be-screened field with the field value of the to-be-screened field to obtain a first matching result;
[0122] A second matching subunit is used to match the screening value of the field to be screened with the field value of other data fields in the target data model to obtain a second matching result if the first matching result is a matching failure;
[0123] The first correction subunit is used to correct the field to be screened into other data fields that are successfully matched if the second matching result is a successful match.
[0124] In an optional implementation, the correction unit further includes:
[0125] A word segmentation subunit, configured to segment the target parsing result to obtain word segmentation information if the second matching result is a matching failure;
[0126] The second correction subunit is used to match the word segmentation information with the data field in the target data model, and correct the field to be screened to a successfully matched data field.
[0127] In an optional implementation, the result correction module 540 further includes:
[0128] The model correction unit is used to, if the matching with the data fields in the target data model fails, use the filtering value of the field to be filtered as a question, input the field value of the data field as an option into the large language model, obtain the target data field selected by the large language model, and correct the field to be filtered to the target data field.
[0129] In an optional implementation, the result correction module 530 further includes a date correction unit, and the date correction unit includes:
[0130] The date format subunit is used to format the filter value of the to-be-filtered field to obtain a date type value when the to-be-filtered field is of date type;
[0131] The date correction subunit is used to match the date type value with the field value of the field to be filtered in the target data model, and to correct the field to be filtered according to the matching result.
[0132] In an optional implementation manner, the result correction module 530 is specifically used to:
[0133] For any target dimension in the target parsing result, if the filter condition uses the target dimension as the field to be filtered and the operator is equal to or contains, the target dimension will be deleted from the target parsing result.
[0134] In an optional implementation manner, the result correction module 530 is specifically used to:
[0135] If the field to be filtered in the filtering condition is corrected to the target data field based on the target data model, and the field to be filtered belongs to the target dimension or target metric in the target parsing result, the target dimension or target metric in the target parsing result is also corrected to the target data field.
[0136] In an optional implementation manner, the result correction module 530 is specifically used to:
[0137] If the fields to be filtered in at least two filtering conditions are the same, the at least two filtering conditions are merged.
[0138] In an optional implementation, the prompt generation module 520 includes:
[0139] A field format unit is used to obtain a data field in a target data model and obtain target format information of a specified data format;
[0140] A prompt construction unit, configured to construct a prompt statement according to the data fields in the target data model, the target format information and the target question;
[0141] The target parsing result is used to establish the relationship between the target problem and the data fields in the target data model, and the target parsing result is a serialization result.
[0142] The technical solution of the disclosed embodiment adopts a large language model to establish the relationship between the user's target question and the data fields in the target data model, and parses the target question into a serialized target parsing result based on the relationship, and also corrects the target dimension, target metric, and filtering condition in the target parsing result based on the data fields in the target data model, thereby improving the adaptability between the target parsing result and the target data model.
[0143] In the technical solution disclosed herein, the acquisition, storage and application of user personal information involved are in compliance with the provisions of relevant laws and regulations and do not violate public order and good morals.
[0144] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium and a computer program product.
[0145] Figure 6 The block diagram is a block diagram of an electronic device used to implement the question processing method based on a large language model according to an embodiment of the present disclosure.
[0146] Figure 6 A schematic block diagram of an example electronic device 600 that can be used to implement an embodiment of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.
[0147] like Figure 6As shown, the electronic device 600 includes a computing unit 601, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 602 or a computer program loaded from a storage unit 608 into a random access memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the electronic device 600 can also be stored. The computing unit 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.
[0148] Multiple components in the electronic device 600 are connected to the I / O interface 605, including: an input unit 606, such as a keyboard, a mouse, etc.; an output unit 607, such as various types of displays, speakers, etc.; a storage unit 608, such as a disk, an optical disk, etc.; and a communication unit 609, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 609 allows the electronic device 600 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0149] The computing unit 601 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 601 include, but are not limited to, a central processing unit (CPU), an image processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 601 performs the various methods and processes described above, such as a question processing method based on a large language model. For example, in some embodiments, the question processing method based on a large language model may be implemented as a computer software program, which is tangibly included in a machine-readable medium, such as a storage unit 608. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 600 via the ROM 602 and / or the communication unit 609. When the computer program is loaded into the RAM 603 and executed by the computing unit 601, one or more steps of the question processing method based on the large language model described above may be executed. Alternatively, in other embodiments, the computing unit 601 may be configured to execute the question processing method based on a large language model in any other appropriate manner (for example, by means of firmware).
[0150] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0151] The program code for implementing the method of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0152] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, 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), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0153] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0154] The systems and techniques described herein may be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communications network). Examples of communications networks include: a local area network (LAN), a wide area network (WAN), and the Internet.
[0155] A computer system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The relationship of client and server is generated by computer programs running on respective computers and having a client-server relationship with each other. The server may be a cloud server, a server of a distributed system, or a server combined with a blockchain.
[0156] Artificial intelligence is a discipline that studies how to use computers to simulate certain human thought processes and intelligent behaviors (such as learning, reasoning, thinking, planning, etc.). It includes both hardware-level and software-level technologies. Artificial intelligence hardware technologies generally include technologies such as sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, and big data processing; artificial intelligence software technologies mainly include computer vision technology, speech recognition technology, natural language processing technology, machine learning / deep learning technology, big data processing technology, knowledge graph technology, and other major directions.
[0157] Cloud computing refers to a technology system that uses network access to elastically scalable shared physical or virtual resource pools. Resources can include servers, operating systems, networks, software, applications, and storage devices, and can be deployed and managed on demand and in a self-service manner. Cloud computing technology can provide efficient and powerful data processing capabilities for technical applications such as artificial intelligence and blockchain, as well as model training.
[0158] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this disclosure can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and this document does not limit this.
[0159] The above specific implementations do not constitute a limitation on the protection scope of the present disclosure. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present disclosure shall be included in the protection scope of the present disclosure.
Claims
1. Question processing method based on large language model, including: Get the target problem to be processed; generating a prompt statement based on the target data model to be used, the target format information specifying the data format, and the target question; Input the prompt sentence into the large language model to obtain a target parsing result in a specified data format output by the large language model; Based on the target data model, modifying the target parsing result; Wherein, the modifying of the target parsing result based on the target data model includes: According to the filtering conditions in the target parsing results, the field type to which the field to be filtered belongs is determined; according to the field type to which the field to be filtered belongs, the field to be filtered is matched with the data field in the target data model, and the field to be filtered is modified according to the matching result.
2. According to the method of claim 1, the target format information includes dimension fields, metric fields and filtering conditions; the filtering conditions include the field to be filtered, the filtering value of the field to be filtered and the operator.
3. The method according to claim 1 or 2, wherein: The modifying the target parsing result based on the target data model further includes: In the case where the field to be filtered is of character type, obtaining a filtering value of the field to be filtered from the filtering condition; The screening value of the field to be screened is matched with the field value of the data field in the target data model, and the field to be screened is modified according to the matching result.
4. The method according to claim 3, wherein: The step of matching the screening value of the field to be screened with the field value of the data field in the target data model, and modifying the field to be screened according to the matching result, includes: In the case where the field to be filtered belongs to the data field, obtaining the field value of the field to be filtered from the target data model; Matching the screening value of the field to be screened with the field value of the field to be screened to obtain a first matching result; If the first matching result is a match failure, the screening value of the field to be screened is matched with the field values of other data fields in the target data model to obtain a second matching result; If the second matching result is a successful match, the to-be-screened field is modified to be another data field that has successfully matched.
5. The method according to claim 4, wherein the step of modifying the to-be-screened field according to the matching result further comprises: If the second matching result is a match failure, segmenting the target parsing result to obtain segmentation information; The word segmentation information is matched with the data fields in the target data model, and the to-be-screened fields are corrected to be the data fields that have been matched successfully.
6. The method according to claim 3, based on the target data model, correcting the target parsing result further comprises: If the match with the data fields in the target data model fails, the filter value of the field to be filtered is used as a question, and the field value of the data field is input into the large language model as an option to obtain the target data field selected by the large language model, and the field to be filtered is corrected to the target data field.
7. The method according to claim 3, wherein the step of modifying the target parsing result based on the target data model further comprises: In the case where the field to be filtered is of date type, the filtering value of the field to be filtered is formatted to obtain a date type value; The date type value is used to match the field value of the field to be filtered in the target data model, and the field to be filtered is modified according to the matching result.
8. The method according to claim 2, wherein the step of modifying the target parsing result based on the target data model further comprises: For any target dimension in the target parsing result, if the filter condition uses the target dimension as the field to be filtered and the operator is equal to or contains, the target dimension will be deleted from the target parsing result.
9. The method according to claim 2, wherein: The modifying the target parsing result based on the target data model further includes: If the field to be filtered in the filtering condition is corrected to the target data field based on the target data model, and the field to be filtered belongs to the target dimension or target metric in the target parsing result, the target dimension or target metric in the target parsing result is also corrected to the target data field.
10. The method according to claim 2, wherein: The modifying the target parsing result based on the target data model further includes: If the fields to be filtered in at least two filtering conditions are the same, the at least two filtering conditions are merged.
11. The method according to claim 1, wherein: Generate prompt statements based on the target data model and target question, including: Get the data fields in the target data model and get the target format information of the specified data format; Constructing a prompt statement according to the data fields in the target data model, the target format information and the target question; The target parsing result is used to establish a relationship between the target problem and the data fields in the target data model, and the target parsing result is a serialization result.
12. A question processing device based on a large language model, comprising: A problem acquisition module is used to acquire the target problem to be processed; A prompt generation module, used for generating a prompt statement based on a target data model to be used, target format information specifying a data format, and the target question; A question parsing module, used for inputting the prompt sentence into a large language model to obtain a target parsing result in a specified data format output by the large language model; A result correction module, used for correcting the target parsing result based on the target data model; Wherein, the result correction module includes: The field type unit is used to determine the field type of the field to be filtered according to the filtering conditions in the target parsing result; The field matching correction unit is used to match the field to be filtered with the data field in the target data model according to the field type to which the field to be filtered belongs, and to correct the field to be filtered according to the matching result.
13. According to the device of claim 12, the target format information includes dimension fields, metric fields and filtering conditions; the filtering conditions include the field to be filtered, the filtering value of the field to be filtered and the operator.
14. The device according to claim 12 or 13, wherein: The result correction module also includes: A screening value unit, used for obtaining a screening value of the field to be screened from the screening condition when the field to be screened is of character type; The correction unit is used to match the screening value of the field to be screened with the field value of the data field in the target data model, and to correct the field to be screened according to the matching result.
15. The device according to claim 14, wherein: The correction unit comprises: A field value subunit, used for obtaining the field value of the field to be filtered from the target data model when the field to be filtered belongs to the data field; A first matching subunit, used for matching the screening value of the to-be-screened field with the field value of the to-be-screened field to obtain a first matching result; A second matching subunit is used to match the screening value of the field to be screened with the field value of other data fields in the target data model to obtain a second matching result if the first matching result is a matching failure; The first correction subunit is used to correct the field to be screened into other data fields that are successfully matched if the second matching result is a successful match.
16. The device according to claim 15, wherein the correction unit further comprises: A word segmentation subunit, configured to segment the target parsing result to obtain word segmentation information if the second matching result is a matching failure; The second correction subunit is used to match the word segmentation information with the data field in the target data model, and correct the field to be screened to a successfully matched data field.
17. The device according to claim 14, wherein the result correction module further comprises: The model correction unit is used to, if the matching with the data fields in the target data model fails, use the filtering value of the field to be filtered as a question, input the field value of the data field as an option into the large language model, obtain the target data field selected by the large language model, and correct the field to be filtered to the target data field.
18. The device according to claim 14, wherein the result correction module further comprises a date correction unit, wherein the date correction unit comprises: The date format subunit is used to format the filter value of the to-be-filtered field to obtain a date type value when the to-be-filtered field is of date type; The date correction subunit is used to match the date type value with the field value of the field to be filtered in the target data model, and to correct the field to be filtered according to the matching result.
19. The device according to claim 13, wherein the result correction module is specifically used for: For any target dimension in the target parsing result, if the filter condition uses the target dimension as the field to be filtered and the operator is equal to or contains, the target dimension will be deleted from the target parsing result.
20. The device according to claim 13, wherein: The result correction module is specifically used for: If the field to be filtered in the filtering condition is corrected to the target data field based on the target data model, and the field to be filtered belongs to the target dimension or target metric in the target parsing result, the target dimension or target metric in the target parsing result is also corrected to the target data field.
21. The device according to claim 13, wherein: The result correction module is specifically used for: If the fields to be filtered in at least two filtering conditions are the same, the at least two filtering conditions are merged.
22. The device according to claim 12, wherein: The prompt generation module comprises: A field format unit is used to obtain a data field in a target data model and obtain target format information of a specified data format; A prompt construction unit, configured to construct a prompt statement according to the data fields in the target data model, the target format information and the target question; The target parsing result is used to establish a relationship between the target problem and the data fields in the target data model, and the target parsing result is a serialization result.
23. An electronic device comprising: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 11.
24. A non-transitory computer-readable storage medium storing computer instructions, wherein: The computer instructions are used to make a computer execute the method according to any one of claims 1-11.
25. A computer program product comprising a computer program, which, when executed by a processor, implements the method according to any one of claims 1 to 11.
Citation Information
Patent Citations
Virtual machine creation method and device, management equipment and terminal equipment
CN108762885A
Information correction method and device, electronic equipment and storage medium
CN110738997A
