Model training method and device, computer equipment and computer readable storage medium
By training the formula generation model, mapping the description field and formula fields into indexes, solving the problem of high learning cost of formula generation in the prior art, achieving higher accuracy and scalability.
Patent Information
- Application Number
- CN202411943401.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-24
- Publication Date
- 2025-05-09
AI Technical Summary
In the prior art, formula generation methods are highly dependent on the developer's understanding and familiarity, resulting in high learning costs, high time costs, high probability of errors and low scalability.
By obtaining the training sample, including the description field sample and the corresponding formula field label, based on the preconfigured index map, the description field sample and the formula field label are mapped as an index, and the formula generation model is trained until the preset training end condition is met, and the target formula generation model is obtained. This model is used to map the description field of the description formula into the formula field that constitutes the formula.
It reduces the learning cost of generating formulas, improves the accuracy of model generation, reduces the probability of errors, and improves the scalability of formula generation.
Smart Images

Figure CN119961393A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a model training method, apparatus, computer equipment, computer-readable storage medium, and computer program product. Background Art
[0002] Formula generation is the process of creating and perfecting mathematical expressions based on specific needs in the fields of mathematics, science, and computers. It starts with a clear definition of the purpose of the formula application, and then gradually builds a complete mathematical formula through a series of logically rigorous steps, such as selecting appropriate functions and symbols, accurately inputting parameters and variables, and orderly combining and nesting functions. In this process, every step is crucial, from the initial function and symbol selection, to the subsequent parameter input and variable setting, to the complex function combination and nesting, every detail affects the accuracy and practicality of the formula.
[0003] The current formula generation method is manually input by developers using formula editing tools, which is highly dependent on the developer's understanding and familiarity with functions, as well as their own logical analysis capabilities, resulting in a high learning cost. Summary of the invention
[0004] Based on this, it is necessary to provide a model training method, device, computer equipment, computer-readable storage medium and computer program product that can reduce the learning cost of generating formulas in response to the above technical problems.
[0005] This application provides a model training method, including:
[0006] Acquire a training sample, wherein the training sample includes a plurality of description field samples and corresponding formula field labels;
[0007] Based on the pre-configured index mapping, the description field sample is mapped to a description field sample index, and the formula field label is mapped to a formula field label index;
[0008] The formula generation model is trained with the description field sample index as input and the formula field label index as target output until the training is terminated when a preset training end condition is met, thereby obtaining a target formula generation model, wherein the target formula generation model is used to map the description field of the description formula to the formula field constituting the formula.
[0009] The present application also provides a model training device, characterized in that it includes:
[0010] A first acquisition module, used to acquire training samples, wherein the training samples include a plurality of description field samples and corresponding formula field labels;
[0011] A first mapping module, configured to map the description field sample to a description field sample index and map the formula field label to a formula field label index based on a preconfigured index mapping;
[0012] The model training module is used to train the formula generation model with the description field sample index as input and the formula field label index as target output, until the training is terminated when the preset training end condition is met, and the target formula generation model is obtained. The target formula generation model is used to map the description field of the description formula to the formula field that constitutes the formula.
[0013] A computer device includes a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the above-mentioned model training method when executing the computer program.
[0014] A computer-readable storage medium stores a computer program, which implements the steps of the above-mentioned model training method when executed by a processor.
[0015] A computer program product includes a computer program, which implements the steps of the above-mentioned model training method when executed by a processor.
[0016] The above-mentioned model training method, apparatus, computer equipment, computer-readable storage medium and computer program product obtain training samples, wherein the training samples include multiple description field samples and corresponding formula field labels; based on a pre-configured index mapping, the description field samples are mapped to description field sample indexes, and the formula field labels are mapped to formula field label indexes; the description field sample indexes are used as input, and the formula field label indexes are used as target outputs to train the formula generation model until the training is terminated when the preset training termination conditions are met, thereby obtaining a target formula generation model, wherein the target formula generation model is used to map the description fields of the description formulas to the formula fields that constitute the formulas. The present application maps the description fields and the corresponding formula fields into indexes, trains the formula generation model to learn the relationship between the two indexes, and the trained model can automatically determine the formula fields based on the descriptions in natural language and then generate formulas, thereby reducing the learning cost of generating formulas and improving the accuracy of model generation. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] Figure 1 An application environment diagram of a model training method in an embodiment;
[0018] Figure 2 A schematic diagram of the constituent elements of a formula in one embodiment;
[0019] Figure 3 A schematic diagram of a flow chart of a model training method in one embodiment;
[0020] Figure 4 A schematic diagram of a formula interaction interface in one embodiment;
[0021] Figure 5 is another schematic diagram of a formula interaction interface in one embodiment;
[0022] Figure 6 is another schematic diagram of a formula interaction interface in one embodiment;
[0023] Figure 7 A schematic diagram of a formula generation process in one embodiment;
[0024] Figure 8 Another schematic diagram of a formula generation process in one embodiment;
[0025] Fig. 9 is a structural block diagram of a model training device in one embodiment;
[0026] Fig.10 is a structural block diagram of a model training device in another embodiment;
[0027] Fig.11 is an internal structure diagram of a computer device in one embodiment;
[0028] Fig.12 FIG. 4 is a diagram showing the internal structure of a computer device in another embodiment. DETAILED DESCRIPTION
[0029] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0030] Formulas are expressions or operations used to perform mathematical, logical, and parametric data. Formulas allow users to perform various calculations in the system to produce the desired results.
[0031] See also Figure 1 , Figure 1 A diagram showing the building blocks of a formula, including functions, parameters, and operators.
[0032] Operators are symbols used in formulas to perform calculations. Operators are meaningless when they appear independently and must be combined with parameters, functions, or numbers to form a calculation formula.
[0033] Parameters are parameters required by formulas, which are input values or variables passed to functions to pass actual data. Parameters can be metadata in the system. Parameters can be fixed values, variables, function results or fields. Exemplarily, the data attributes of parameters can include amount, quantity, unit, ratio, date, text, count, etc.
[0034] Functions are used to express the logical relationship of parameters and are composed of operators and parameters. Furthermore, functions can include general functions, enterprise functions, and user-defined functions. A function is a predefined operation or calculation process used to perform a specific data processing task. It accepts one or more inputs and returns a result based on the preset logic. Functions can perform various operations, such as mathematical calculations, text processing, etc.
[0035] When manually constructing a formula consisting of functions and system fields, the following steps are included:
[0036] (1) Function identification and selection: The system provides a list of all available functions. The user browses the list and reads the description of each function until he finds the target function that meets his needs.
[0037] (2) Function parameter learning: After the user selects the target function, the system displays the parameter description document of the function. The user reads the document to understand the meaning and usage of each parameter;
[0038] (3) Parameter entry: According to the function parameter description, the user fills in the parameters required by the objective function one by one in the input interface provided by the system;
[0039] (4) Formula combination: For complex calculation formulas involving multiple functions, the user repeats the above steps and combines multiple functions in the required logical order;
[0040] (5) Syntax check: The system provides basic syntax check function to ensure that the function input format meets the system requirements;
[0041] (6) Save the formula for use: After the user completes editing, save the formula and the formula can be applied in subsequent data processing tasks.
[0042] At present, the way of manually constructing functions is highly dependent on the user's understanding and familiarity with the function library provided by the system, as well as the user's own logical analysis ability, resulting in high time cost, high learning cost, high error probability and low scalability.
[0043] The present application provides a model training method. The model training method provided by the present application is used to train a target formula generation model. Formulas can be automatically generated based on the target formula generation model, saving the time cost and learning cost of formula generation, reducing the error probability, and being highly scalable.
[0044] See also Figure 2 , Figure 2 FIG. 1 is an application environment diagram of a model training method in an embodiment. The model training method provided in the embodiment of the present application can be applied to Figure 2 In the application environment shown, the terminal 102 communicates with the server 104 through a network. The data storage system can store data that the server 104 needs to process. The data storage system can be integrated on the server 104, or placed on the cloud or other servers.
[0045] The terminal 102 may be a smart phone, a tablet computer, a laptop computer, a desktop computer, a smart speaker, a smart watch, an IoT device, and a portable wearable device. The IoT device may be a smart speaker, a smart TV, a smart air conditioner, and a smart vehicle-mounted device, etc. The portable wearable device may be a smart watch, a smart bracelet, a head-mounted device, etc.
[0046] The server 104 may be an independent physical server or a service node in a blockchain system, wherein each service node in the blockchain system forms a peer-to-peer (P2P) network, and the P2P protocol is an application layer protocol running on the Transmission Control Protocol (TCP) protocol. In addition, the server 104 may also be a server cluster composed of multiple physical servers, and may be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDNs), and big data and artificial intelligence platforms.
[0047] The terminal 102 and the server 104 may be connected via Bluetooth, USB (Universal Serial Bus) or a network or other communication connection methods, which are not limited in this application.
[0048] Both the terminal and the server can be used independently to execute the model training method provided in the embodiments of the present application.
[0049] For example, the server obtains a training sample, which includes multiple description field samples and corresponding formula field labels. Based on the pre-configured index mapping, the server maps the description field sample to the description field sample index and the formula field label to the formula field label index. The server uses the description field sample index as input and the formula field label index as the target output to train the formula generation model until the preset training end condition is met, and obtains the target formula generation model, which is used to map the description field of the description formula to the formula field that constitutes the formula.
[0050] In addition, the terminal and the server can also be used together to execute the model training method provided in the embodiments of the present application.
[0051] For example, the terminal obtains a training sample, which includes multiple description field samples and corresponding formula field labels. Based on the pre-configured index mapping, the terminal maps the description field sample to the description field sample index and the formula field label to the formula field label index. The server uses the description field sample index as input and the formula field label index as the target output to train the formula generation model until the preset training end condition is met, and obtains the target formula generation model, which is used to map the description field of the description formula to the formula field that constitutes the formula.
[0052] Please refer to 3, Figure 3 FIG. 1 is a flow chart of a model training method in one embodiment. Figure 3 As shown, a model training method is provided, which is based on Figure 1 The server execution in is taken as an example to illustrate, including the following steps:
[0053] Step S202, obtaining training samples.
[0054] The training samples include multiple description field samples and corresponding formula field labels.
[0055] The training samples are used to train the formula generation model. The formula generation model is a neural network model with deep learning capabilities. By training the formula generation model with training samples, the formula generation model can learn the correspondence between the description field samples and the formula field labels, and has the ability to obtain the formula field through the description field, thereby realizing automatic generation of formulas. The neural network model can be, for example, a Transformer model or a natural language model.
[0056] The description field refers to the words that describe the formula syntax, logic, and parameters, and the description method can be natural language description. The description field of the formula can be called the description word of the formula. When the user needs to generate a formula, he inputs the description text of the formula in the form of natural language through the interactive interface, and the computer can obtain the description field by processing the description text.
[0057] A formula field refers to the field that makes up a formula. A formula field can be an operator, variable, constant, etc. Each formula can be split into multiple formula fields, and multiple formula fields can also be spliced together to form a complete formula.
[0058] Optionally, the description field may be a word segmentation fragment of the description text, and the formula field may be a word segmentation fragment of the formula. For example, before obtaining the training sample, the word segmentation module may be used to perform word segmentation processing on the description text sample to obtain the word segmentation fragment of the description text sample as the description field sample; the word segmentation module may be used to perform word segmentation processing on the formula corresponding to the description text sample to obtain the word segmentation fragment of the formula as the formula field label sample.
[0059] In one embodiment, the correspondence between the description field samples and the formula field labels can be established by manual labeling, and a sample data set can be established based on the labeled training samples. Some of the training samples are used as training samples to form a training set of the formula generation model for training the model; some of the training samples are used as a test set of the formula generation model for statistical model training indicators; some of the training samples are used as a validation set of the formula generation model for adjusting model parameters.
[0060] To ensure sufficient training, the number of training samples in the training set can be much larger than the number of training samples in the test set and validation set. For example, if there are 10,000 training samples in the sample data set, 1,000 of them are used as the test set, 1,000 as the validation set, and the remaining 8,000 as the training set.
[0061] Step S204: Based on the pre-configured index mapping, the description field sample is mapped to the description field sample index, and the formula field label is mapped to the formula field label index.
[0062] After obtaining the training samples, in order to speed up the training of the model and make the model converge faster, this application indexes the description field samples and the corresponding formula field sample labels. The mapping of fields to indexes is achieved by pre-configuring index mapping.
[0063] The preconfigured index mapping may be a preconfigured index table. Please refer to Table 1, Table 2 and Table 3. The index table may include an index table for description fields (Table 1) and an index table for formula fields (Table 2).
[0064] Table 1
[0065] Description Field Description Field Index Pick 1 General Ledger 2 Ending balance 3 The highest budget debit amount in this period 4 Cash Flow 5 2024 6 Month-on-month 7 … …
[0066] In the index table of description fields (Table 1), each description field has a corresponding description field index. For example, the description field "take" corresponds to the description field index "1", the description field "general ledger" corresponds to the description field index "2", the description field "end balance" corresponds to the description field index "3", the description field "highest budget debit amount of this period" corresponds to the description field index "4", the description field "cash flow" corresponds to the description field index "5", the description field "2024" corresponds to the description field index "6", and the description field "month-on-month" corresponds to the description field index "7". Different description fields correspond to different description field indexes. According to the index table, the description field index corresponding to each description field can be obtained.
[0067] Table 2
[0068] Formula fields Formula Field Index ACCT 1 ( 2 " 3 , 4 DY 5 0 6 ) 7 BDG 8 … …
[0069] In some cases, the description field has a corresponding part of speech, and the formula field can also be regarded as a word and also has a corresponding part of speech. The parts of speech to which the description field sample and the corresponding formula field sample belong can also be mapped as indexes. Please refer to Table 3, which is a part of speech index table.
[0070] Table 3
[0071] Part of Speech Part of Speech Index 1073741824 1 536870912 2 268435456 3 134217728 4 67108864 5 33554432 6 16777216 7 4194304 8 2097152 9 1048576 10 524288 11 262144 12 131072 13 65536 14 16384 15 4096 16 8388608 17 2147483648 18 8589934592 19 4294967296 20 … …
[0072] In Table 3, numbers are used to represent the corresponding parts of speech.
[0073] It should be noted that although the indexes in the above three mapping tables are numbered with Arabic numerals starting from 1, the same index represents different meanings in different index tables. Taking index 1 as an example, description field index 1 represents the description field "get", formula field index 1 represents the formula field "ACCT", and part-of-speech index 1 represents the part-of-speech with the digital identifier 1073741824.
[0074] Since index mapping is related to the training of the model, the more mappings included in the configured index mapping, the better, and it needs to be as exhaustive as possible. Optional methods include extracting from the dictionary file of the word segmentation module, extracting from the enterprise's system knowledge base, and manual exhaustive.
[0075] In some cases, when mapping a description field sample to a description field sample index and / or mapping a formula field label to a formula field label index, if no corresponding index is matched, the description field sample index and / or formula field label index that is not matched to the index is filled with 0.
[0076] In some cases, when mapping description field samples to description field sample indexes and / or mapping formula field labels to formula field label indexes, PAD padding is performed on the description field sample indexes and / or formula field label indexes, that is, the maximum length in the description field sample indexes is determined as the maximum input length; the maximum length in the formula field label indexes is determined as the maximum output length; the description field sample indexes are padded to the maximum input length and / or the formula field label indexes are padded to the maximum output length. Thus, the description field sample indexes are unified to the maximum input length, and the formula field label indexes are unified to the maximum output length.
[0077] As a method to make data of different sizes reach a unified scale or dimension, PAD filling can improve data availability and processing efficiency, facilitating subsequent processing and analysis.
[0078] Step S206, taking the description field sample index as input and the formula field label index as target output, trains the formula generation model until the preset training end condition is met, and obtains the target formula generation model.
[0079] After the description field samples and the corresponding formula field labels are indexed, the description field samples and formula field label indexes can be input into the formula generation model to train the formula generation model. The formula generation model uses the description field sample index as input and the formula field label index as target output. It uses the powerful learning ability of the neural network model to learn the mapping relationship between the description field sample index and the corresponding formula field label index.
[0080] When training the formula generation model, the data processing module of the formula generation model will obtain the corresponding output according to the input description field sample index, compare the difference between the corresponding output and the target output, and continuously adjust the parameters of the formula generation model so that the difference between the output of the description field sample index obtained by the formula generation model and the formula field label sample index corresponding to the description field sample index becomes smaller and smaller. Each time the output is obtained, the model performs such a comparison, and returns to obtain the description field sample index and the formula field label index when the preset training end condition is not met, and continues training until the preset training end condition is met to end the training and obtain the target formula generation model.
[0081] Meeting the preset training end conditions may include that the training indicators meet the corresponding indicator conditions, the loss value of the loss function of the formula generation model is less than the loss value threshold, the number of training times reaches the number threshold, etc.
[0082] The target formula generation model is used to map the description field of the description formula to the formula field constituting the formula. Mapping the description field of the description formula to the formula field constituting the formula means that the target generation model can map the description field index to the formula field index, thereby realizing the mapping from the description field to the formula field.
[0083] The target formula generation model maps the description fields of the formula to the formula fields that constitute the formula. Users only need to enter the description of the formula in natural language, and the model can output the corresponding formula fields. The output formula fields can be spliced and combined to obtain the target formula corresponding to the description.
[0084] In the above model training method, a training sample is obtained, and the training sample includes multiple description field samples and corresponding formula field labels; based on the pre-configured index mapping, the description field sample is mapped to the description field sample index, and the formula field label is mapped to the formula field label index; the description field sample index is used as input, and the formula field label index is used as the target output, and the formula generation model is trained until the training is terminated when the preset training end condition is met, and the target formula generation model is obtained, and the target formula generation model is used to map the description field of the description formula to the formula field that constitutes the formula. The present application maps the description field and the corresponding formula field into an index, and trains the formula generation model to learn the relationship between the two indexes. The trained model can automatically determine the formula field based on the description in natural language and then generate the formula, thereby reducing the learning cost of generating the formula and improving the accuracy of the model generation.
[0085] In one embodiment, with the description field sample index as input and the formula field label index as target output, training the formula generation model includes:
[0086] The description field sample index and the formula field label index are vectorized to obtain a vectorized description field sample index and a vectorized formula field label index; the vectorized description field sample index and the vectorized formula field label index are normalized to obtain a normalized description field sample index and a normalized formula field label index; the normalized description field sample index is input into the formula generation model, and the output of the formula generation model is denormalized and dequantized to obtain a predicted formula field index of the description field sample; based on the predicted formula field index of the description field sample and the matched formula field label index, the parameters of the formula generation model are adjusted.
[0087] Index mapping can be regarded as an indexing process, where the description field samples and formula field labels are preprocessed by indexing, vectorization and normalization before being processed by the formula generation model. The indexing process can refer to the description of the above embodiment, and after the description field samples and formula field labels are indexed, the description field sample index and the formula field label index are obtained.
[0088] Subsequently, the description field sample index and the formula field label index are vectorized and converted into dimension vectors acceptable to the formula generation model. For example, the vocabulary with complex categories can be set to 128 dimensions, and the vocabulary with fewer categories can be set to 16 dimensions. After vectorization, the vectorized description field sample index and the vectorized formula field label index are obtained.
[0089] In order to improve the convergence speed of the formula generation model and ensure the stability of model training, after vectorization, the vectorized description field sample index and the vectorized formula field label index are normalized and classified into the interval [0, 1]. The normalization process can be implemented by the following formula (1):
[0090]
[0091] Among them, X is the original data, X min is the minimum value in a set of data, X max is the maximum value in a set of data, and X′ is the normalized data.
[0092] The vectorized description field sample index and the vectorized formula field label index are respectively used as the original data X, and the corresponding X min They point to the minimum value in the sample index of the quantized description field and the minimum value in the label index of the vectorized formula field, respectively. The corresponding X max They point to the maximum value in the quantized description field sample index and the maximum value in the vectorized formula field label index respectively. After normalization, the normalized description field sample index and the normalized formula field label index are obtained.
[0093] In some cases, the description field sample index includes the description field sample content index and the description field sample part of speech index, and the description field sample content index and the description field sample part of speech index are respectively normalized. The same is true for the formula field label index.
[0094] In order to realize the vectorization and normalization processing of the description field sample index and the formula field label index, an embedding layer and a normalization layer can be set in the formula generation model. Before the formula generation model processes the description field sample index and the formula field label index, the embedding layer set in the formula generation model realizes the vectorization processing of the description field sample index and the formula field label index, and the normalization layer set in the formula generation model realizes the normalization processing of the vectorized description field sample index and the vectorized formula field label index. Subsequently, the normalized description field sample index is input into the data processing layer of the formula generation model for processing.
[0095] It can be understood that the vectorization and normalization processing of the description field sample index and the formula field label index can also be a preprocessing step before inputting the model.
[0096] After the normalized description field sample index is processed by the formula generation model, the formula generation model generates a corresponding output. The output of the formula generation model is subjected to a denormalization process corresponding to the normalization process and an inverse quantization process corresponding to the vectorization process to obtain the predicted formula field index of the description field sample. The predicted formula field index is the index corresponding to the formula field predicted by the formula generation model based on the input description field sample index.
[0097] The denormalization process corresponding to the normalization process can be implemented by the following formula (2):
[0098] X=X′(X max -X min )+ X min (2)
[0099] Among them, X′ is the original data, X min is the minimum value in a set of data, X max is the maximum value in a set of data, and X′ is the denormalized data. Formula (2) can be obtained by inverting formula (1).
[0100] Based on the prediction formula field index of the description field sample and the formula field label index matched by the description field sample, the parameters of the formula generation model can be adjusted, including: based on the prediction formula field index of the description field sample and the matched formula field label index, counting the training indicators of the training samples; when the training indicators do not meet the preset training end conditions, adjusting the parameters of the formula generation model.
[0101] The training index is an index used to quantify the performance improvement of the model during the training process, and can be used to determine whether the model has converged. The training index includes at least one of the training accuracy, training recall, and training balance score. When counting the training indicators of the training samples based on the prediction formula field index and the matching formula field label index of the description field sample, the number of description field samples whose prediction formula field index and the matching formula field label index are consistent can be counted as the number of correct predictions; the ratio of the number of correct predictions to the total number of test predictions is the training accuracy, and the total number of test predictions is the total number of description field samples that obtain the prediction formula field index; the ratio of the number of correct predictions to the total number of correct predictions is the training recall, and the total number of correct predictions is the total number of description field samples that match the formula field label index; the harmonic mean of the training accuracy and the training recall is the training balance score.
[0102] For example, the training balance score can be determined using the following formula (3):
[0103]
[0104] Among them, Precision is the accuracy, Recall is the recall rate, and F1 is the balanced score, that is, F1 Score, also known as F1 score or balanced F score.
[0105] Substituting the training accuracy into the Precision of formula (3) and the training recall into the Recall of formula (3), we can get the training balance score of the formula generation model.
[0106] The training indicator does not meet the preset training end condition, including the training indicator meeting the corresponding indicator condition. When the training accuracy reaches the training accuracy threshold, the training accuracy meets the corresponding indicator condition; when the training recall reaches the training recall threshold, the training recall meets the corresponding indicator condition; when the training balance score reaches the training balance score threshold, the training balance score meets the corresponding indicator condition.
[0107] The training indicators can meet the corresponding indicator conditions. The three training indicators can meet the corresponding indicator conditions at the same time, or one or two of the indicators can meet the corresponding indicator conditions. The training accuracy threshold, training recall threshold, and training balance score threshold can be the same or different, and can be set as needed.
[0108] For example, the training accuracy threshold, training recall threshold and training balance score threshold are all set to 95%. When the training accuracy, training recall and training balance score of the formula generation model all reach 95%, it is determined that the preset training end condition is met, the training is ended, and the target formula generation model is obtained.
[0109] In the above embodiment, before the training model learns the mapping relationship between the description field and the formula field, the description field and the formula field are indexed, and the complex text-to-text mapping is simplified to an index-to-index mapping, which reduces the learning difficulty of the model. Before the description field sample index and the formula field sample index are input into the model, the vectorization and normalization data preprocessing method is used to reduce the amount of data processed by the model, which can effectively improve the model training efficiency and accelerate the model convergence speed.
[0110] In one embodiment, after obtaining the target formula generation model, the method further includes:
[0111] Obtain the description text to be processed; perform word segmentation on the description text through the word segmentation module to obtain the description field corresponding to the description text; based on the pre-configured index mapping, map the description field to the description field index; input the description field index into the target formula generation model to obtain the formula field index corresponding to the description field index; based on the formula field corresponding to the formula field index, generate the target formula corresponding to the description text.
[0112] The trained target generation model can realize the mapping from description fields to formula fields. When the user needs to edit the formula, the description text can be entered through the interactive interface. The computer device obtains the description text entered by the user, segment the description text into description fields, and maps the description fields to description field indexes based on the pre-configured index mapping. The index mapping when using the model is the same as the index mapping when training the model.
[0113] After obtaining the description field index, the description field index is input into the target formula generation model to obtain the formula field index corresponding to the description field index; based on the formula field corresponding to the formula field index, a target formula corresponding to the description text is generated.
[0114] After generating the target formula, the user can confirm the target formula. If a confirmation instruction for the target formula is received, the target formula is marked, and the training samples are updated based on the formula field and the corresponding description field of the marked target formula. The target formula generation model is trained based on the updated training samples, thereby realizing dynamic learning of the model.
[0115] In the above embodiment, the automatic processing of the word segmentation results of the description text is realized based on the obtained target formula generation model, and the corresponding target formula can be automatically generated according to the input natural language description text, reducing the difficulty and learning cost of formula writing.
[0116] In one embodiment, before the description text is segmented by a segmentation module to obtain the description field, the following steps are also included:
[0117] Obtain an initial word segmentation module; configure a custom dictionary file for the initial word segmentation module according to the constituent elements of the formula; obtain a word segmentation test sample, debug the initial word segmentation module loaded with the custom dictionary file according to the word segmentation test sample, stop debugging when the debugging index meets the preset index condition, and obtain the word segmentation module.
[0118] Traditional word segmentation modules, such as the Chinese word segmentation module, are mostly based on semantic understanding to achieve word segmentation. When processing natural language, traditional word segmentation modules may not be able to accurately distinguish the formula logic and grammar. In order to enable the word segmentation module to accurately process the description text of the natural language into the description field of the formula, this application debugs the word segmentation module before using it.
[0119] The word segmentation module to be debugged is called the initial word segmentation module. The initial word segmentation module can be a traditional word segmentation module based on language understanding, such as the open source node-segment Chinese word segmentation module. During debugging, you can expand the dictionary file of the initial word segmentation module by configuring a custom dictionary, and debug the initial word segmentation module based on the expanded dictionary file.
[0120] In order to enable the initial word segmentation module to specifically distinguish formula-related words, when expanding the dictionary file of the initial word segmentation module, a custom dictionary file is configured for the initial word segmentation module according to the constituent elements of the formula. For example, the constituent elements of a formula may include functions, operators, and parameters, and the configured custom dictionary file may include various functions, various operators, and various parameters. The custom dictionary file configured according to the constituent elements of the formula can enhance the ability of the original word segmentation module to distinguish formula-related vocabulary. After the custom dictionary file is configured, the custom dictionary file is loaded in the initial word segmentation module, and the initial word segmentation module loaded with the custom dictionary file is debugged according to the word segmentation test sample to test the word segmentation ability of the initial word segmentation module after the custom dictionary file is configured for formula-related vocabulary.
[0121] Optionally, before debugging the initial word segmentation module loaded with the custom dictionary file according to the word segmentation test sample, a preset word segmentation function of the initial word segmentation module can also be called. The preset word segmentation function is used to enable the synonym conversion function, the punctuation removal function, and the stop character removal function.
[0122] In the above embodiment, a custom dictionary file is configured according to the constituent elements of the formula, and the traditional word segmentation module is cleverly debugged into a word segmentation module capable of distinguishing formula-related elements by extending the dictionary file, so as to obtain model input data that meets expectations.
[0123] In one embodiment, according to the constituent elements of the formula, configuring a custom dictionary file for the initial word segmentation module includes:
[0124] According to the constituent elements of the formula, a custom part of speech is added to the part-of-speech file of the initial word segmentation module, and corresponding part-of-speech tags and part-of-speech descriptions are configured for the custom part of speech; for each custom part of speech, descriptive words belonging to the custom part of speech are extracted from the system knowledge base, and associated words of the descriptive words are derived; corresponding part-of-speech tags are configured for the descriptive words and associated words belonging to the custom part of speech, and a custom dictionary file of the custom part of speech is obtained.
[0125] In order to specifically strengthen the word segmentation ability of the initial word segmentation module for formula-related vocabulary, this application expands the part-of-speech file of the initial word segmentation module according to the constituent elements of the formula, including adding the constituent elements of the formula as custom parts of speech, and configuring a custom dictionary file according to the added custom parts of speech. According to the constituent elements of the formula, the custom parts of speech may include functions, operators, and parameters. When adding the custom parts of speech to the part-of-speech file, the part-of-speech identifier and part-of-speech description configured for each custom part of speech are also added to the part-of-speech file accordingly.
[0126] For each custom part of speech, a custom dictionary file is configured respectively. That is, configuring a custom dictionary file according to the added custom part of speech includes: configuring a function custom dictionary file for the function part of speech, configuring an operator custom dictionary file for the operator part of speech, and configuring a parameter custom dictionary file for the parameter part of speech.
[0127] Each custom dictionary file includes words belonging to the custom part of speech, such as descriptive words extracted from an existing system knowledge base. In order to enrich the richness and coverage of the custom dictionary file, corresponding associated words can be derived from the extracted descriptive words. Associated words can be synonyms of the original descriptive words, or words that have a certain association with the original descriptive words. When configuring a custom dictionary file with custom parts of speech, according to the custom parts of speech corresponding to the custom dictionary file, corresponding part of speech identifiers and word weights are configured for the descriptive words and associated words therein.
[0128] The corresponding part-of-speech tag is the part-of-speech tag corresponding to the custom part-of-speech, and the word weight is used to control the frequency of the corresponding description word or association word when debugging the word segmentation module.
[0129] In the above embodiment, custom parts of speech and descriptions are configured based on the constituent elements of the formula and added to the part-of-speech file of the initial word segmentation module, which can improve the accuracy of the word segmentation module in distinguishing common formula-related descriptive words. When constructing a custom dictionary file, not only are descriptive words related to custom parts of speech extracted from the system knowledge base, but a series of associated words are also derived and expanded based on the descriptive words, thereby effectively increasing the coverage of the dictionary file and further improving the word segmentation accuracy of the word segmentation module.
[0130] In one embodiment, the test sample includes a sample to be segmented and a corresponding segmentation label. The initial segmentation module loaded with a custom dictionary file is debugged according to the segmentation test sample. The debugging is stopped when the debugging index meets the preset index condition. The segmentation module includes:
[0131] The samples to be segmented are input into the initial segmentation module loaded with the custom dictionary file to obtain the segmentation results of the samples to be segmented; based on the segmentation results of each sample to be segmented and the corresponding segmentation label, the debugging indicators of the segmentation test samples are counted; when the debugging indicators do not meet the preset indicator conditions, the configurations of the custom dictionary file and the initial segmentation module are adjusted until the debugging indicators meet the preset indicator conditions, and the debugging is stopped to obtain the segmentation module.
[0132] The debugging index is an index for quantifying the word segmentation ability of the word segmentation module for formula-related vocabulary. When the debugging index does not meet the preset index conditions, the configuration of the custom dictionary file and the word segmentation module is adjusted until the debugging index meets the preset index conditions, and the debugging is stopped to obtain the word segmentation module.
[0133] In one embodiment, the debugging index includes at least one of the word segmentation accuracy, word segmentation recall and word segmentation balance score. Based on the word segmentation results of each sample to be segmented and the corresponding word segmentation label, the debugging index of the statistical word segmentation test sample includes:
[0134] The number of correct segmentations in the segmentation results is counted, where the correct segmentation is the segmentation result that is consistent with the segmentation label of the sample to be segmented; the ratio of the number of correct segmentations to the total number of test segmentations is taken as the segmentation accuracy, and the total number of test segmentations is the number of segmentation results obtained from the segmentation test sample; the ratio of the number of correct segmentations to the total number of correct segmentations is taken as the segmentation recall, and the total number of correct segmentations is the number of segmentation labels in the segmentation test sample; the harmonic mean of the segmentation accuracy and the segmentation recall is taken as the segmentation balance score.
[0135] For example, the word segmentation balance score can be determined using the above formula (3):
[0136]
[0137] Among them, Precision is the accuracy, Recall is the recall, and F1 is the balance score.
[0138] Substitute the word segmentation accuracy into the Precision of formula (3), and substitute the word segmentation recall into the Recall of formula (3). The obtained F1 is the word segmentation balance score of the initial word segmentation module.
[0139] The debugging indicator does not meet the preset debugging end condition, including the debugging indicator meeting the corresponding indicator condition. When the word segmentation accuracy reaches the word segmentation accuracy threshold, the word segmentation accuracy meets the corresponding indicator condition; when the word segmentation recall reaches the word segmentation recall threshold, the word segmentation recall meets the corresponding indicator condition; when the word segmentation balance score reaches the word segmentation balance score threshold, the word segmentation balance score meets the corresponding indicator condition.
[0140] The debugging indicators can meet the corresponding indicator conditions. The three debugging indicators can meet the corresponding indicator conditions at the same time, or one or two of them can meet the corresponding indicator conditions. The word segmentation accuracy threshold, word segmentation recall threshold, and word segmentation balance score threshold can be the same or different, and can be set as needed.
[0141] For example, the word segmentation accuracy threshold, word segmentation recall threshold and word segmentation balance score threshold are all set to 95%. When the word segmentation accuracy, word segmentation recall and word segmentation balance score of the initial word segmentation module all reach 95%, it is determined that the preset indicator conditions are met, the debugging is ended, and the debugged word segmentation module is obtained.
[0142] In the above embodiment, the word segmentation accuracy can reflect the overall performance of the word segmentation module on all test samples, the word segmentation recall rate can measure the ability of the word segmentation module to recognize the correct results, and the word segmentation balance score combines the word segmentation accuracy and the word segmentation recall rate, which can evaluate the model cost with a single indicator. The above three debugging indicators can be used to comprehensively measure whether the word segmentation module is debugged in place. In practical applications, more suitable debugging indicators can be freely selected according to needs.
[0143] In one embodiment, the description text is segmented by a word segmentation module, and the description fields corresponding to the description text include:
[0144] The description text is segmented by a word segmentation module to obtain the word segmentation results of the description text and the parts of speech of each word segmentation result, wherein the parts of speech include custom parts of speech, which are defined according to the constituent elements of the formula; the word segmentation results of the description text are cleaned based on the parts of speech of each word segmentation result, wherein the word segmentation results whose parts of speech are preset parts of speech and custom parts of speech are retained; and the cleaned word segmentation results are used as the description fields corresponding to the description text.
[0145] When the word segmentation module performs word segmentation on the description text, in addition to obtaining the word segmentation results of each description text, it can also obtain the part of speech of each word segmentation result. Based on the part of speech of each word segmentation result, each word segmentation result can be cleaned, and the cleaned word segmentation result is used as the description field corresponding to the description text, which is the basis for generating the target formula.
[0146] Since the configuration of the word segmentation module includes a custom part of speech and a custom dictionary file configured based on the constituent elements of the formula, the word segmentation results of the custom part of speech can be selectively retained during cleaning. When the word segmentation results of the description text are cleaned based on the part of speech of each word segmentation result, the cleaning criteria can be seen in Table 4.
[0147] Table 4
[0148] Part of Speech Part of Speech Tags Description Field Example Whether to remove reason adjective 1073741824 Difficult, easy yes Not related to calculation Distinguishing words 536870912 Radial, Stereo yes Not related to calculation conjunction 268435456 In addition, yes Not related to calculation adverb 134217728 Year-on-year, no Related to computing interjection 67108864 What is it, right? yes Not related to calculation Direction words 33554432 Behind, inside yes Not related to calculation idiom 16777216 An Guoning Family yes Not related to calculation numeral 4194304 One hundred percent, one hundred percent no Related to computing Quantifiers 2097152 Half, two hundred no Related to computing noun 1048576 Development Company, Real Estate Company no Related to computing Onomatopoeia 524288 Hahaha, chirp yes Not related to calculation preposition 262144 give, follow, for yes Not related to calculation quantifier 131072 Kilograms, square meters no Related to computing pronoun 65536 people, them yes Not related to calculation Time Words 16384 Previous years, month-end, mid-month no Related to computing verb 4096 Add, divide no Related to computing idiom 8388608 Hello yes Not related to calculation function 2147483648 ACCT, G / L Account no Related to computing parameter 8589934592 Beginning balance, debit ending balance no Related to computing Operators 4294967296 -, +, minus, plus, / no Related to computing … … … … …
[0149] Among them, the word segmentation results of custom part-of-speech functions, parameters, and operators are retained, as are the preset part-of-speech adverbs, numerals, quantifiers, nouns, quantifiers, time words, and verbs. The word segmentation results of other parts of speech are discarded because they are irrelevant to the calculation of the formula.
[0150] In the above embodiment, the word segmentation results are cleaned based on their parts of speech, which can effectively distinguish the key word segmentations that may constitute the formula from other irrelevant word segmentations, improve the purity of the word segmentation results, reduce the amount of data subsequently input into the model and the processing difficulty of the model, and improve the accuracy of the generated target formula.
[0151] In one embodiment, obtaining the description text to be processed includes:
[0152] In response to a request to generate a formula, the description text input in the identification area of the formula interaction interface is detected, the formula interaction interface includes an identification area, a formula area and a guide area, the identification area is used to input the description text, the formula area is used to display and edit the formula, and the guide area is used to guide the adjustment of the description text; after generating a target formula corresponding to the description text based on the formula field corresponding to the formula field index, it also includes: displaying the target formula in the formula area; if a denial instruction for the target formula is received, providing guidance in the guide area, the guidance provided includes at least one of recommending a formula, prompting to re-enter the description and prompting to add a description; in response to a request to generate a formula again, the description text input in the identification area is re-detected, and the return is returned to execute the step of performing word segmentation processing on the description text through the word segmentation module to obtain the description field corresponding to the description text and subsequent steps.
[0153] See also Figure 4 , Figure 4 This is a schematic diagram of the formula interaction interface provided by this application. In this formula interaction interface, there are an identification area, a formula area and a guide area. The identification area is used to enter the description text. Figure 4 In the Identification area, when no description is entered, it displays "Enter your formula requirement here, for example: year-on-year increase in the ending balance of monetary funds in the report; or enter the formula to be identified, for example: ACCT('','1121','Y','',0,0,0)". The formula area is used to display and edit formulas. Figure 4In the formula area, when no formula is generated, it will display "Edit your formula here". The guide area is used to guide the adjustment of the description text. Figure 4 In the boot area, "Unrecognized" is displayed.
[0154] The user can enter the description text of the formula, view the generated target formula, and edit the target formula in the formula interaction interface. The user can provide feedback on the target formula's quality or deny instructions in the interaction interface. Among them, the deny instruction includes the regeneration instruction and the error feedback instruction.
[0155] If a denial instruction for the target formula is received, guidance is provided in the guidance area, and the guidance provided includes at least one of a recommended formula, a prompt to re-enter a description, and a prompt to add a description, such as Figure 5 and Figure 6 As shown, when the description text is not clear enough and the formula generation fails, the user is gradually guided to add a description in the guide area.
[0156] If a request to regenerate the formula is received, the description text input in the recognition area is re-detected in response to the request to regenerate the formula, and the step and subsequent steps of performing word segmentation processing on the description text through the word segmentation module to obtain the description field corresponding to the description text are returned.
[0157] In the above embodiment, an interactive interface and interactive mode of the formula are provided. The user can clearly see the process of model generation and editing, can issue different instructions in the interactive interface, and get feedback, which optimizes the user experience.
[0158] In one embodiment, based on a preconfigured index mapping, mapping the description field to a description field index includes:
[0159] The description field is matched with a preset database, wherein the preset database is formed by loading a custom dictionary file in the word segmentation module, and the preset database includes a function database, a parameter database, and an operator database; if the description field successfully matches part of the preset database, the description field is mapped to a description field index based on a pre-configured index mapping.
[0160] The description field successfully matches some preset databases, including the description field successfully matching the function database but not successfully matching all preset databases.
[0161] Optionally, after matching the description field with the preset database, if the description field matches all preset databases successfully, the target formula is spliced based on the matching results of the description field and each preset database; if the description field does not match all preset databases successfully, the user's historical behavior data is obtained and a formula is recommended based on the user's historical behavior data.
[0162] Among them, user historical behavior data includes historical functions, historical calculation formulas and historical programming languages. Recommending formulas based on user historical behavior includes: extracting data features from user historical behavior data, the data features include function or calculation formula name, parameter type, call frequency, code context; building a user portrait based on the extracted data features, the user portrait includes the user's preferred function or calculation formula type, editing paradigm, library and framework, editing habits; based on the built user portrait, recommending to the user the historical formulas used by the user or the formulas stored in the database.
[0163] In the above embodiment, multiple preset databases are set. If the description field can match the corresponding field from each preset database, it can be directly spliced into the target formula to speed up the generation of the target formula. By setting the steps of field indexing and subsequent input model when one or two specific databases in the preset database are matched successfully, it is possible to avoid wasting resources and time by calling the model when the description is very accurate, and avoid calling the model when the description is very inaccurate to obtain invalid results with low accuracy.
[0164] In one embodiment, the training sample further includes the parts of speech of the description field sample and the formula field label, the index mapping includes description field content mapping, formula field content mapping and part of speech mapping, and based on the pre-configured index mapping, mapping the description field sample to the description field sample index and mapping the formula field label to the formula field label index includes:
[0165] Based on the description field content mapping, the content of the description field sample is mapped, and based on the part-of-speech mapping, the part-of-speech of the description field sample is mapped to obtain a description field sample index including a content index and a part-of-speech index; based on the formula field content mapping, the content of the formula field label is mapped, and based on the part-of-speech mapping, the part-of-speech of the formula field label is mapped to obtain a formula field label index including a content index and a part-of-speech index.
[0166] In some cases, the index mapping includes content mapping and part-of-speech mapping, and the content mapping includes description field content mapping and formula field content mapping. Based on the description field content mapping, the content of the description field sample is mapped to obtain the description field sample content index, and based on the part-of-speech mapping, the part-of-speech of the description field sample is mapped to obtain the description field sample part-of-speech index, so that the description field sample contains both the content mapping and the part-of-speech mapping. Based on the formula field content mapping, the content of the formula field label is mapped to obtain the formula field label content index, and based on the part-of-speech mapping, the part-of-speech of the formula field label is mapped to obtain the formula field label part-of-speech index, so that the formula field label contains both the content mapping and the part-of-speech mapping. When learning the association between the description field sample mapping and the formula field label mapping, the formula generation model learns the association between the description field sample content index and the description field sample part-of-speech index to the formula field label content index and the formula field label part-of-speech index.
[0167] In the above embodiment, parts of speech are cleverly conceived for the formula field, and the traditional content mapping is transformed into a dual mapping of content and part of speech. The part of speech mapping can provide auxiliary positioning for the content mapping. Combined with the aforementioned custom parts of speech and part of speech files defined based on the formula constituent elements, the association between natural language and formula is further accurately strengthened, which can help improve the accuracy of formula generation.
[0168] The present application also provides a specific embodiment, the model training method includes debugging the word segmentation module, training the formula to generate the model, using the debugged word segmentation module and the target formula to generate the model, and displaying and editing the formula. The specific embodiment is as follows:
[0169] (1) Debug the word segmentation module:
[0170] The debugging process includes:
[0171] Get the initial word segmentation module;
[0172] According to the constituent elements of the formula, add a custom part of speech to the part of speech file of the initial word segmentation module, and configure a corresponding part of speech identifier and part of speech description for the custom part of speech, wherein the custom part of speech includes functions, operators and parameters;
[0173] For each custom part of speech, extracting a descriptive word belonging to the custom part of speech from the system knowledge base, and deriving an associated word of the descriptive word;
[0174] Corresponding part-of-speech identifiers are configured for the descriptive words and the associated words belonging to the custom part-of-speech, and a custom dictionary file of the custom part-of-speech is obtained.
[0175] Obtain a word segmentation test sample, input the sample to be segmented into an initial word segmentation module loaded with the custom dictionary file, and obtain a word segmentation result of the sample to be segmented;
[0176] Based on the word segmentation results of each sample to be segmented and the corresponding word segmentation label, the debugging index of the word segmentation test sample is counted;
[0177] When the debugging index does not meet the preset index condition, the configuration of the custom dictionary file and the initial word segmentation module is adjusted until the debugging index meets the preset index condition, then the debugging is stopped to obtain the word segmentation module.
[0178] The description of each step of model debugging can be found in the description of the aforementioned embodiment, which will not be repeated here.
[0179] (2) Training formula generation model
[0180] The training process includes:
[0181] Obtain training samples, which include multiple description field samples and corresponding formula field labels;
[0182] Based on the pre-configured index mapping, the description field sample is mapped to the description field sample index, and the formula field label is mapped to the formula field label index;
[0183] Vectorizing the description field sample index and the formula field label index to obtain a vectorized description field sample index and a vectorized formula field label index;
[0184] Normalizing the vectorized description field sample index and the vectorized formula field label index to obtain a normalized description field sample index and a normalized formula field label index;
[0185] The normalized description field sample index is input into the formula generation model, and the output of the formula generation model is denormalized and dequantized to obtain the prediction formula field index of the description field sample;
[0186] Adjust the parameters of the formula generation model based on the predicted formula field index and the matching formula field label index of the description field sample.
[0187] The training is terminated until a preset training termination condition is met, and a target formula generation model is obtained. The target formula generation model is used to map the description fields of the description formula to the formula fields constituting the formula.
[0188] The description of each step of model training can be found in the description of the above embodiment and will not be repeated here.
[0189] (3) Generate a model using the debugged word segmentation module and target formula
[0190] See also Figure 7 , Figure 7 A schematic diagram of the formula generation process provided in the embodiment of the present application.
[0191] First, in response to a request to generate a formula, the natural language information input in the recognition area of the formula interaction interface is detected, and the natural language information is used to generate the description text to be processed of the formula. The debugged word segmentation module is called, and the word segmentation module is used to perform word segmentation processing on the description text to obtain the description field corresponding to the description text. Among them, the word segmentation module is used to perform word segmentation processing on the description text to obtain the word segmentation result of the description text and the part of speech of each word segmentation result, and the word segmentation result of the description text is cleaned based on the part of speech of each word segmentation result, and the cleaned word segmentation result is used as the description field corresponding to the description text.
[0192] Optionally, part-of-speech tagging, word sense disambiguation, etc. may be performed on the description text in the identification area.
[0193] The extracted description fields may include logical syntax and keywords. After the description fields are extracted, the description fields are matched with the preset databases (function database, parameter database and operator database), and the subsequent steps are continued based on the matching results with each preset database.
[0194] If the description field fails to match a specific preset database, the user can be asked to select a function based on the user's historical behavior data, and more information can be prompted to assist in identification in the prompt area, such as Figure 5 and Figure 6 shown.
[0195] If the description field matches the function database, parameter database and operator database successfully (i.e., a completely successful match), the target formula can be directly spliced out based on the function fragments matched from the function database, the parameter fragments matched from the parameter database, and the operator fragments matched from the operator database.
[0196] If the description field only successfully matches part of the preset database, such as successfully matching the function database and / or parameter database but failing to match the operator database, the target formula generation model is called to generate a target formula corresponding to the description text based on the target formula generation model.
[0197] Optionally, before generating a target formula corresponding to the description text based on the target formula generation model, first map the description field to a description field index based on a pre-configured index mapping, input the description field index into the target formula generation model, obtain a formula field index corresponding to the description field index, and then,
[0198] Based on the formula field corresponding to the formula field index, a target formula corresponding to the description text is generated.
[0199] Call the target formula generation model. For the process of generating the target formula corresponding to the description text based on the target formula generation model, please refer to Figure 8 .
[0200] After the description text is processed into a segmentation result by the segmentation module, the segmentation result is cleaned and filtered based on the part-of-speech screening criteria to obtain the description field of the description text, and then the description field is indexed according to the index table to obtain the description field index. Based on different index mappings, the description field index includes a description field content index and a description field part-of-speech index. The various screening criteria and various index tables can be found in the description of the aforementioned embodiment, which will not be repeated here.
[0201] Before inputting the description field index into the target formula generation model, the description field index is preprocessed by vectorization and normalization to obtain a normalized description field index. The normalized description field index is input into the target formula generation model, and then the output of the model is denormalized corresponding to the previous normalization and dequantized corresponding to the previous vectorization to obtain a formula field index corresponding to the description field index. The formula field index is sequentially decoded to obtain the formula field corresponding to the formula field index, and the formula field is spliced into the target formula corresponding to the description text.
[0202] (4) Display and edit formulas
[0203] After obtaining the target formula, the target formula is displayed in the formula area. The user can manually judge the target formula displayed in the formula area to decide whether to regenerate the formula. If the user feels it is necessary to regenerate the formula, he can interactively issue a denial instruction to the target formula, edit the description text, and request to regenerate the formula. If the computer device receives a denial instruction for the target formula, it provides guidance in the guidance area, responds to the request to regenerate the formula, re-detects the description text input in the recognition area, and determines whether the input content has changed. If the input content has changed, return to execute the step and subsequent steps of performing word segmentation processing on the description text through the word segmentation module to obtain the description field corresponding to the description text. If the input content has not changed, re-run the target formula generation model. Since Transformer can introduce random operations, the target formula generated by the target formula generation model built based on Transformer has a certain degree of randomness, and the user may obtain satisfactory results when regenerated.
[0204] If the user is satisfied with the generated target formula, the target formula can be confirmed. If the computer device receives the confirmation instruction for the target formula, the target formula is marked, and the training sample is updated based on the formula field and the corresponding description field of the marked target formula, and the target formula generation model is trained based on the updated training sample, thereby realizing dynamic learning of the model.
[0205] In the above embodiment, the description field and the corresponding formula field are mapped into indexes, and the formula generation model is trained to learn the relationship between the two indexes. The trained model can automatically determine the formula field based on the natural language description and then generate the formula, thereby reducing the learning cost of generating the formula and improving the accuracy of the model generation.
[0206] It should be understood that, although the steps in the flowcharts involved in the above embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above embodiments may include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0207] Based on the same inventive concept, the embodiment of the present application also provides a model training device for implementing the model training method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in one or more model training device embodiments provided below can refer to the limitations on the model training method above, and will not be repeated here.
[0208] Based on the same inventive concept, the embodiment of the present application also provides a model training device for implementing the model training method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in one or more model training device embodiments provided below can refer to the limitations on the model training method above, and will not be repeated here.
[0209] In one embodiment, Fig. 9 As shown, a model training device is provided, including: a first acquisition module 701, a first mapping module 702 and a model training module 703, wherein:
[0210] A first acquisition module 701 is used to acquire training samples, where the training samples include a plurality of description field samples and corresponding formula field labels;
[0211] A first mapping module 702, configured to map description field samples to description field sample indexes and to map formula field labels to formula field label indexes based on pre-configured index mappings;
[0212] The model training module 703 is used to train the formula generation model with the description field sample index as input and the formula field label index as the target output, until the training is terminated when the preset training end condition is met, and the target formula generation model is obtained. The target formula generation model is used to map the description field of the description formula to the formula field that constitutes the formula.
[0213] In one embodiment, when the formula generation model is trained with the description field sample index as input and the formula field label index as target output, the model training module 703 is further used to:
[0214] Vectorizing the description field sample index and the formula field label index to obtain a vectorized description field sample index and a vectorized formula field label index;
[0215] Normalizing the vectorized description field sample index and the vectorized formula field label index to obtain a normalized description field sample index and a normalized formula field label index;
[0216] The normalized description field sample index is input into the formula generation model, and the output of the formula generation model is denormalized and dequantized to obtain the prediction formula field index of the description field sample;
[0217] Adjust the parameters of the formula generation model based on the predicted formula field index and the matching formula field label index of the description field sample.
[0218] See also Fig.10 In one embodiment, after obtaining the target formula generation model, the model training device further includes:
[0219] The second acquisition module 704 is used to acquire the description text to be processed;
[0220] The word segmentation processing module 705 is used to perform word segmentation processing on the description text through the word segmentation module to obtain the description field corresponding to the description text;
[0221] A second mapping module 706, configured to map the description field to a description field index based on a preconfigured index mapping;
[0222] An index input module 707 is used to input the description field index into the target formula generation model to obtain the formula field index corresponding to the description field index;
[0223] The formula generation module 708 is used to generate a target formula corresponding to the description text based on the formula field corresponding to the formula field index.
[0224] Please continue reading Fig.10 In one embodiment, the model training device further includes a word segmentation debugging module 709. Before the word segmentation module performs word segmentation processing on the description text to obtain the description field, the word segmentation debugging module 709 is used to:
[0225] Get the initial word segmentation module;
[0226] According to the components of the formula, configure a custom dictionary file for the initial word segmentation module;
[0227] A word segmentation test sample is obtained, and an initial word segmentation module loaded with a custom dictionary file is debugged according to the word segmentation test sample. When a debugging index meets a preset index condition, debugging is stopped to obtain a word segmentation module.
[0228] In one embodiment, when configuring a custom dictionary file for the initial word segmentation module according to the constituent elements of the formula, the word segmentation debugging module 709 is further used to:
[0229] According to the constituent elements of the formula, add custom parts of speech to the part-of-speech file of the initial word segmentation module, and configure corresponding part-of-speech identifiers and part-of-speech descriptions for the custom parts of speech. The custom parts of speech include functions, operators, and parameters.
[0230] For each custom part of speech, extract the descriptive words that belong to the custom part of speech from the system knowledge base, and derive the associated words of the descriptive words;
[0231] Corresponding part-of-speech tags are configured for the descriptive words and associated words belonging to the custom part-of-speech, and a custom dictionary file of the custom part-of-speech is obtained.
[0232] In one embodiment, the test sample includes a sample to be segmented and a corresponding segmentation label. The initial segmentation module loaded with the custom dictionary file is debugged according to the segmentation test sample. When the debugging index meets the preset index condition, the debugging is stopped. When the segmentation module is obtained, the segmentation debugging module 709 is further used to:
[0233] Input the sample to be segmented into the initial segmentation module loaded with the custom dictionary file to obtain the segmentation result of the sample to be segmented;
[0234] Based on the segmentation results of each sample to be segmented and the corresponding segmentation label, the debugging indicators of the segmentation test sample are counted;
[0235] When the debugging index does not meet the preset index condition, the configuration of the custom dictionary file and the initial word segmentation module is adjusted until the debugging index meets the preset index condition, the debugging is stopped, and the word segmentation module is obtained.
[0236] In one embodiment, the debugging index includes at least one of the word segmentation accuracy, the word segmentation recall rate and the word segmentation balance score. When the debugging index of the word segmentation test sample is counted based on the word segmentation results of each sample to be segmented and the corresponding word segmentation label, the word segmentation debugging module 709 is further used to:
[0237] Count the number of correct segmentations of the segmentation results, where a correct segmentation is a segmentation result that is consistent with the segmentation label of the sample to be segmented;
[0238] The ratio of the number of correct segmented words to the total number of test segmented words is taken as the segmentation accuracy. The total number of test segmented words is the number of segmentation results obtained from the segmentation test samples.
[0239] The ratio of the number of correct segmentations to the total number of correct segmentations is taken as the segmentation recall rate, and the total number of correct segmentations is the number of segmentation labels in the segmentation test sample;
[0240] The harmonic mean of word segmentation precision and word segmentation recall is taken as the word segmentation balance score.
[0241] In one embodiment, when the word segmentation module performs word segmentation processing on the description text to obtain the description field corresponding to the description text, the word segmentation processing module 705 is further used to:
[0242] The description text is segmented by a segmentation module to obtain the segmentation results of the description text and the parts of speech of each segmentation result, wherein the parts of speech include user-defined parts of speech, which are defined according to the constituent elements of the formula;
[0243] The word segmentation results of the description text are cleaned based on the part of speech of each word segmentation result, wherein the word segmentation results with preset part of speech and custom part of speech are retained;
[0244] The cleaned word segmentation result is used as the description field corresponding to the description text.
[0245] In one embodiment, when acquiring the description text to be processed, the second acquisition module 704 is further used to:
[0246] In response to a request to generate a formula, the description text entered in the identification area of the formula interaction interface is detected. The formula interaction interface includes an identification area, a formula area and a guide area. The identification area is used to enter the description text, the formula area is used to display and edit the formula, and the guide area is used to guide the adjustment of the description text.
[0247] Please continue reading Fig.10In one embodiment, the model training device further includes a formula display module 710. After generating a target formula corresponding to the description text based on a formula field corresponding to the formula field index, the formula display module 710 is used to:
[0248] Display the target formula in the formula area;
[0249] If a denial instruction for the target formula is received, providing guidance in the guidance area, the guidance providing including at least one of recommending a formula, prompting to re-enter a description, and prompting to add a description;
[0250] In response to a request to generate a formula again, the description text input in the recognition area is re-detected, and the step of performing word segmentation processing on the description text through a word segmentation module to obtain a description field corresponding to the description text and subsequent steps are returned.
[0251] In one embodiment, when mapping the description field to the description field index based on the preconfigured index mapping, the second mapping module 706 is further configured to:
[0252] Matching the description field with a preset database, wherein the preset database is formed by loading a custom dictionary file in a word segmentation module, and the preset database includes a function database, a parameter database, and an operator database;
[0253] If the description field successfully matches some of the preset databases, the description field is mapped to a description field index based on the pre-configured index mapping.
[0254] In one embodiment, the training sample further includes the parts of speech of the description field sample and the formula field label, and the index mapping includes description field content mapping, formula field content mapping, and part of speech mapping. When the description field sample is mapped to the description field sample index and the formula field label is mapped to the formula field label index based on the pre-configured index mapping, the first mapping module 702 is further used to:
[0255] Mapping the content of the description field sample based on the description field content mapping, and mapping the part of speech of the description field sample based on the part of speech mapping, to obtain a description field sample index including a content index and a part of speech index;
[0256] The content of the formula field label is mapped based on the formula field content mapping, and the part of speech of the formula field label is mapped based on the part of speech mapping, so as to obtain a formula field label index including a content index and a part of speech index.
[0257] In the above-mentioned model training device, the first acquisition module 701 acquires training samples, and the training samples include multiple description field samples and corresponding formula field labels; the first mapping module 702 maps the description field samples to the description field sample index and the formula field label to the formula field label index based on the pre-configured index mapping; the model training module 703 uses the description field sample index as input and the formula field label index as the target output to train the formula generation model until the training is terminated when the preset training end condition is met, and the target formula generation model is obtained, and the target formula generation model is used to map the description field of the description formula to the formula field constituting the formula. The present application maps the description field and the corresponding formula field into an index, and trains the formula generation model to learn the relationship between the two indexes. The trained model can automatically determine the formula field based on the description in natural language and then generate the formula, thereby reducing the learning cost of generating the formula and improving the accuracy of the model generation.
[0258] Each module in the above-mentioned model training device can be implemented in whole or in part by software, hardware and a combination thereof. Each of the above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory in the computer device in the form of software, so that the processor can call and execute the operations corresponding to each of the above modules.
[0259] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Fig.11 As shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. Among them, the processor, the memory and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a model training method is implemented.
[0260] In one embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as follows: Fig.12As shown. The computer device includes a processor, a memory, an input / output interface, a communication interface, a display unit and an input device. Among them, the processor, the memory and the input / output interface are connected through a system bus, and the communication interface, the display unit and the input device are connected to the system bus through the input / output interface. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner can be implemented through WIFI, a mobile cellular network, NFC (near field communication) or other technologies. When the computer program is executed by the processor, a model training method is implemented. The display unit of the computer device is used to form a visually visible image, and can be a display screen, a projection device or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen. The input device of the computer device can be a touch layer covered on the display screen, or a button, trackball or touchpad set on the computer device casing, or an external keyboard, touchpad or mouse, etc.
[0261] Those skilled in the art will understand that Fig.11 , 12 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0262] In one embodiment, a computer device is further provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps in the above method embodiments when executing the computer program.
[0263] In one embodiment, a computer-readable storage medium is provided, storing a computer program, which implements the steps in the above method embodiments when executed by a processor.
[0264] In one embodiment, a computer program product is provided. The computer program product includes a computer program. When the computer program is executed by a processor, the steps in the above method embodiments are implemented.
[0265] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards of relevant countries and regions.
[0266] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.
[0267] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0268] The above embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A model training method, characterized in that: include: Acquire a training sample, wherein the training sample includes a plurality of description field samples and corresponding formula field labels; Based on the pre-configured index mapping, the description field sample is mapped to a description field sample index, and the formula field label is mapped to a formula field label index; The formula generation model is trained with the description field sample index as input and the formula field label index as target output until the training is terminated when a preset training end condition is met, thereby obtaining a target formula generation model, wherein the target formula generation model is used to map the description field of the description formula to the formula field constituting the formula.
2. The method according to claim 1, characterized in that The training of the formula generation model using the description field sample index as input and the formula field label index as target output includes: Vectorizing the description field sample index and the formula field label index to obtain a vectorized description field sample index and a vectorized formula field label index; Normalizing the vectorized description field sample index and the vectorized formula field label index to obtain a normalized description field sample index and a normalized formula field label index; Inputting the normalized description field sample index into the formula generation model, denormalizing and dequantizing the output of the formula generation model, and obtaining the prediction formula field index of the description field sample; Based on the predicted formula field index of the description field sample and the matched formula field label index, the parameters of the formula generation model are adjusted.
3. The method according to claim 1, characterized in that After obtaining the target formula generation model, the method further includes: Get the description text to be processed; Perform word segmentation processing on the description text by a word segmentation module to obtain a description field corresponding to the description text; Based on a preconfigured index mapping, mapping the description field to a description field index; Inputting the description field index into the target formula generation model to obtain the formula field index corresponding to the description field index; Based on the formula field corresponding to the formula field index, a target formula corresponding to the description text is generated.
4. The method according to claim 3, characterized in that Before the word segmentation processing of the description text is performed by the word segmentation module to obtain the description field, the method further includes: Get the initial word segmentation module; According to the constituent elements of the formula, a custom dictionary file is configured for the initial word segmentation module; A word segmentation test sample is obtained, and an initial word segmentation module loaded with the custom dictionary file is debugged according to the word segmentation test sample. When a debugging index meets a preset index condition, debugging is stopped to obtain the word segmentation module.
5. The method according to claim 4, characterized in that The configuring of a custom dictionary file for the initial word segmentation module according to the constituent elements of the formula includes: According to the constituent elements of the formula, add a custom part of speech to the part of speech file of the initial word segmentation module, and configure a corresponding part of speech identifier and part of speech description for the custom part of speech, wherein the custom part of speech includes functions, operators and parameters; For each custom part of speech, extracting a descriptive word belonging to the custom part of speech from the system knowledge base, and deriving an associated word of the descriptive word; Corresponding part-of-speech identifiers are configured for the descriptive words and the associated words belonging to the custom part-of-speech, and a custom dictionary file of the custom part-of-speech is obtained.
6. The method according to claim 4, characterized in that The test sample includes a sample to be segmented and a corresponding segmentation label. The initial segmentation module loaded with the custom dictionary file is debugged according to the segmentation test sample, and the debugging is stopped when the debugging index meets the preset index condition. The segmentation module includes: Inputting the sample to be segmented into an initial segmentation module loaded with the custom dictionary file to obtain a segmentation result of the sample to be segmented; Based on the word segmentation results of each sample to be segmented and the corresponding word segmentation label, the debugging index of the word segmentation test sample is counted; When the debugging index does not meet the preset index condition, the configuration of the custom dictionary file and the initial word segmentation module is adjusted until the debugging index meets the preset index condition, then the debugging is stopped to obtain the word segmentation module.
7. The method according to claim 6, characterized in that The debugging index includes at least one of the word segmentation accuracy, word segmentation recall and word segmentation balance score. The debugging index of the word segmentation test sample is statistically analyzed based on the word segmentation results of each sample to be segmented and the corresponding word segmentation label, including: Counting the number of correct word segmentations of the word segmentation results, wherein the correct word segmentation is the word segmentation result that is consistent with the word segmentation label of the sample to be segmented; The ratio of the number of correct segmented words to the total number of test segmented words is taken as the segmentation accuracy, and the total number of test segmented words is the number of segmentation results obtained from the segmentation test sample; The ratio of the number of correct segmentations to the total number of correct segmentations is taken as the segmentation recall rate, and the total number of correct segmentations is the number of segmentation labels in the segmentation test sample; The harmonic mean of the word segmentation accuracy and the word segmentation recall is taken as the word segmentation balance score.
8. The method according to claim 3, characterized in that The word segmentation module is used to perform word segmentation processing on the description text to obtain the description field corresponding to the description text, including: Performing word segmentation processing on the description text through a word segmentation module to obtain word segmentation results of the description text and parts of speech of each word segmentation result, wherein the parts of speech include user-defined parts of speech, and the user-defined parts of speech are defined according to constituent elements of a formula; Cleaning the word segmentation results of the description text based on the part of speech of each word segmentation result, wherein the word segmentation results whose part of speech is preset part of speech and custom part of speech are retained; The cleaned word segmentation result is used as the description field corresponding to the description text.
9. The method according to claim 3, characterized in that: The obtaining of the description text to be processed comprises: In response to a request to generate a formula, detecting a description text input in an identification area of a formula interaction interface, the formula interaction interface comprising an identification area, a formula area, and a guide area, the identification area being used to input the description text, the formula area being used to display and edit the formula, and the guide area being used to guide adjustment of the description text; After generating the target formula corresponding to the description text based on the formula field corresponding to the formula field index, the method further includes: Displaying the target formula in the formula area; If a denial instruction for the target formula is received, providing guidance in the guidance area, the providing guidance comprising at least one of recommending a formula, prompting to re-enter a description, and prompting to add a description; In response to a request to generate a formula again, the description text input in the recognition area is re-detected, and the step of performing word segmentation processing on the description text through the word segmentation module to obtain the description field corresponding to the description text and subsequent steps are returned.
10. The method according to claim 3, characterized in that: The mapping of the description field to a description field index based on the preconfigured index mapping includes: Matching the description field with a preset database, wherein the preset database is formed by loading a custom dictionary file in the word segmentation module, and the preset database includes a function database, a parameter database, and an operator database; If the description field successfully matches a part of the preset database, the description field is mapped to a description field index based on a pre-configured index mapping.
11. The method according to any one of claims 1 to 10, characterized in that: The training sample also includes the parts of speech of the description field sample and the formula field label, the index mapping includes description field content mapping, formula field content mapping and part of speech mapping, and mapping the description field sample to a description field sample index and mapping the formula field label to a formula field label index based on the pre-configured index mapping includes: Mapping the content of the description field sample based on the description field content mapping, and mapping the part of speech of the description field sample based on the part of speech mapping, to obtain a description field sample index including a content index and a part of speech index; The content of the formula field tag is mapped based on the formula field content mapping, and the part of speech of the formula field tag is mapped based on the part of speech mapping to obtain a formula field tag index including a content index and a part of speech index.
12. A model training device, characterized in that: include: A first acquisition module, used to acquire training samples, wherein the training samples include a plurality of description field samples and corresponding formula field labels; A first mapping module, configured to map the description field sample to a description field sample index and map the formula field label to a formula field label index based on a preconfigured index mapping; The model training module is used to train the formula generation model with the description field sample index as input and the formula field label index as target output, until the training is terminated when the preset training end condition is met, and the target formula generation model is obtained. The target formula generation model is used to map the description field of the description formula to the formula field that constitutes the formula.
13. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 11 are implemented.
14. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 11 are implemented.
15. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 11 are implemented.
Citation Information
Cited By
Model training data generation method and device applied to table, equipment and medium
CN120930807A