String expression generation method, training method, apparatus, device, and medium
By generating cron expressions through word segmentation, encoding, and decoding, the problem of low development efficiency and high error risk caused by the complexity of cron expressions is solved, and efficient periodic task execution is achieved.
Patent Information
- Application Number
- CN202411661770.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-20
- Publication Date
- 2025-11-21
- Estimated Expiration
- 2044-11-20
AI Technical Summary
cron expressions are relatively complex in program development, which increases the risk of errors for developers and affects development efficiency.
By acquiring text data, performing word segmentation, encoding to obtain word vector data, extracting features and decoding to generate target string expressions, and using gated loop units and decoders to improve decoding efficiency, a cron expression is generated.
It simplifies the process of writing cron expressions, improves development efficiency, reduces the risk of errors, and enables efficient execution of periodic tasks.
Smart Images

Figure CN119720949B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] Embodiments of the present disclosure relate to the technical field of computer technology and related technical fields, and in particular, to a string expression generation method, a training method, an apparatus, a device and a medium. BACKGROUND
[0002] A cron expression is a string used to define a schedule, usually for Unix-style scheduling of jobs, mainly composed of six or seven fields representing seconds, minutes, hours, day of month, month, day of week and (optionally) year, and is often used in program development to execute periodic tasks. Based on the characteristics of the cron expression, developers usually add cron expressions in the development process to implement periodic tasks.
[0003] However, due to the complexity of the cron expression, the process of adding the cron expression by the developer in the development process requires a certain amount of time, and it is a challenge for the developer to accurately write the expression. Such complexity not only increases the risk of errors in the development process, but also greatly affects the development efficiency. SUMMARY
[0004] The embodiments described herein provide a string expression generation method, a model training method, an apparatus, a device and a medium to solve the problems existing in the prior art.
[0005] According to a first aspect of the present disclosure, a string expression generation method is provided, comprising:
[0006] Obtaining text data submitted by a target object and performing word segmentation processing on the text data to obtain a plurality of word data, wherein the word data includes description data and string data;
[0007] Encoding the word data to obtain word vector data, wherein one word vector data corresponds to one sequence identifier;
[0008] Extracting features from the word vector data to obtain target input hidden state information, wherein the target input hidden state information includes input hidden state information corresponding to each word vector data;
[0009] Decoding the target input hidden state information to obtain a target string expression.
[0010] In some embodiments of the present disclosure, the extracting features from the word vector data to obtain the target input hidden state information comprises:
[0011] According to the sequence identifier corresponding to each word vector data, determining the input hidden state information corresponding to each time step;
[0012] When the time steps satisfy a preset threshold, the input hidden state information corresponding to the time steps is the target input hidden state information.
[0013] In some embodiments of the present disclosure, the input hidden state information corresponding to each time step is determined according to the sequence identifier corresponding to each word vector data.
[0014] The word vector data input by each time step is determined according to the sequence identifier corresponding to each word vector data.
[0015] The input hidden state information corresponding to the word vector data input by each time step is determined.
[0016] In some embodiments of the present disclosure, the input hidden state information corresponding to the word vector data input by each time step is determined.
[0017] The first weight matrix and the first bias of the update gate in the gated recurrent unit of the encoder and the second weight matrix and the second bias of the reset gate in the gated recurrent unit are obtained.
[0018] The update gate state information of the i th time step is determined according to the word vector data corresponding to the i th time step, the input hidden state information corresponding to the i-1 th time step, the first weight matrix and the first bias.
[0019] The bias gate state information of the i th time step is determined according to the word vector data corresponding to the i th time step, the input hidden state information corresponding to the i-1 th time step, the second weight matrix and the second bias.
[0020] The candidate state information corresponding to the i th time step is determined according to the bias gate state information of the i th time step and the input hidden state information corresponding to the i-1 th time step.
[0021] The input hidden state information corresponding to the i th time step is determined according to the candidate state information corresponding to the i th time step, the input hidden state information corresponding to the i-1 th time step and the update gate state information of the i th time step.
[0022] In some embodiments of the present disclosure, the decoding of the target input hidden state information to obtain the target string expression includes:
[0023] The target input hidden state information is decoded to obtain the output hidden state information corresponding to different time steps.
[0024] The output hidden state information corresponding to each time step is mapped to a dictionary to obtain the target string expression.
[0025] In some embodiments of the present disclosure, the decoding of the target input hidden state information in the target time step obtains output hidden state information corresponding to different time steps, including:
[0026] The target input hidden state information is input into a gated recurrent unit of a decoder to obtain output hidden state information corresponding to a first time step;
[0027] The output hidden state information corresponding to the i-th time step is taken as input to obtain output hidden state information corresponding to an (i+1)-th time step;
[0028] When the output hidden state information corresponding to the (i+1)-th time step is an end label identifier, the decoding of the output hidden state information by the gated recurrent unit of the decoder is stopped and the end label identifier is output again.
[0029] According to a second aspect of the present disclosure, a string expression generation model training method is provided, including:
[0030] A training sample set is obtained, wherein the training sample set includes text data and a target string expression corresponding to the text data;
[0031] The text data of the training sample set is input into a string expression generation model to obtain a test string expression corresponding to the text data of the training sample set;
[0032] According to the target string expression and the test string expression, a first weight matrix of an update gate and a second weight matrix of a reset gate are adjusted and updated until a loss value of the string expression generation model meets a preset loss value, and a target string expression generation model is obtained.
[0033] According to a third aspect of the present disclosure, a string expression generation device is provided, including:
[0034] A word data processing module is configured to obtain text data submitted by a target object and perform word segmentation processing on the text data to obtain a plurality of word data, wherein the word data includes description data and string data;
[0035] A word vector data determination module is configured to encode the word data to obtain word vector data, wherein one word vector data corresponds to one sequence identifier;
[0036] A target input hidden state information determination module is configured to perform feature extraction on the word vector data to obtain target input hidden state information, wherein the target input hidden state information includes input hidden state information corresponding to each word vector data;
[0037] The target character string expression generation module is configured to decode the target input hidden state information to obtain a target character string expression.
[0038] According to a fourth aspect of the present disclosure, a computer device is provided, comprising:
[0039] one or more processors;
[0040] a storage device configured to store one or more programs,
[0041] When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of the first aspect or the second aspect.
[0042] According to a fifth aspect of the present disclosure, a computer readable storage medium is provided, which stores a computer program, and the program is executed by a processor to implement the method according to any one of the first aspect or the second aspect.
[0043] The character string expression generation method, model training method, device, equipment and medium provided by the embodiments of the present disclosure first obtain text data submitted by a target object and perform word segmentation on the text data to obtain a plurality of word data; then encode the word data to obtain word vector data; and perform feature extraction on the word vector data to obtain target input hidden state information; finally, decode the target input hidden state information to obtain a target character string expression. Since the hidden state information of the i th time step includes the candidate state information of the current time step and the hidden state information of the i-1 th time step, and the hidden state information of the i-1 th time step contains the candidate state information of the current time step and the hidden state information of the i-2 th time step, and so on, it can be known that when the time step corresponding to the hidden state information satisfies a preset threshold, the obtained target input hidden state information includes the hidden state information of the 1 st time step, the hidden state information of the 2 nd time step,..., the hidden state information of the i-1 th time step and the candidate state information of the i th time step. Therefore, only one target input hidden state information is output to the decoder, which greatly improves the decoding efficiency of the decoder compared with the prior art which needs to input multiple target input hidden state information. In addition, after obtaining the output hidden state information corresponding to different time steps, a plurality of target character string expressions are obtained by performing dictionary mapping on the output hidden state information output by the gating cycle unit of the decoder, and the plurality of target character string expressions constitute a target character string expression, that is, a periodic task in an application program can be executed based on the target character string expression, and a developer does not need to edit a complex cron expression code to implement a periodic task, thereby improving the development efficiency of the developer. BRIEF DESCRIPTION OF DRAWINGS
[0044] In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the drawings of the embodiments will be briefly described in the following. It should be known that the drawings described below only relate to some of the embodiments of the present disclosure, rather than limit the present disclosure, in which:
[0045] Figure 1 is a flow diagram of a string expression generation method provided by an embodiment of the present disclosure;
[0046] Figure 2 is a flow diagram of a string expression generation model training method provided by an embodiment of the present disclosure;
[0047] Figure 3 is a structural diagram of a string expression generation device provided by an embodiment of the present disclosure;
[0048] Figure 4 is a structural diagram of a computer device provided by an embodiment of the present disclosure. DETAILED DESCRIPTION
[0049] In order to make the objects, technical solutions and advantages of the embodiments of the present disclosure clearer, the technical solutions of the embodiments of the present disclosure will be described clearly and completely below with reference to the drawings. Obviously, the described embodiments are part of the embodiments of the present disclosure, rather than all the embodiments. Based on the described embodiments of the present disclosure, all other embodiments obtained by a person of ordinary skill in the art without creative effort also belong to the scope of protection of the present disclosure.
[0050] Unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this present subject matter belongs. It will be further understood that terms, such as those defined in commonly used dictionaries, should be interpreted as having a meaning that is consistent with their meaning in the context of the specification and relevant art and will not be interpreted in an idealized or overly formal sense unless expressly so defined herein. As used herein, the statement that two or more parts are "connected" or "coupled" together will mean that the parts are joined directly or through one or more intermediate parts.
[0051] In all embodiments of the present disclosure, terms such as "first" and "second" are only used to distinguish one component (or part of a component) from another component (or another part of a component).
[0052] The singular forms "a," "an," and "the" include plural referents unless the context clearly dictates otherwise. Thus, for example, reference to "a" or "the" element or steps includes a single element or step or more than one element or step, and reference to "an" or "the" one or more of two or more means that one or more of two or more is intended. Similarly, expressions such as "at least one of A and B" or "at least one of A or B" mean that A or B, or both A and B, are included. Similarly, expressions such as "at least one of A or B but not both" mean that A or B is included, but not both A and B. As used herein, the term "exemplary" is used merely to identify examples of something, and that the term "exemplary" is not to be construed as indicating that other examples are less exemplary or less desirable.
[0053] Based on the problems existing in the prior art, the string expression generation method provided by the embodiments of the present disclosure, Figure 1 is a flowchart of a string expression generation method provided by the embodiments of the present disclosure, as Figure 1 shown, the string expression generation method comprises:
[0054] S110, obtaining text data submitted by a target object and performing word segmentation processing on the text data to obtain a plurality of word data. Wherein, the word data includes description data and string data.
[0055] To achieve the string data extraction of the text data submitted by the target object, in the string expression generation method provided by the embodiments of the present disclosure, first, the text data submitted by the target object is obtained, and a plurality of word data is obtained by classifying the text data.
[0056] Wherein, the word segmentation processing of the file data is realized based on a word segmenter.
[0057] For example, if the text data submitted by the target object is "every day 0:45:37 start execution", the word data obtained after word segmentation processing by the word segmenter is: every day, 0, point, 45, minute, 37, second, start, execution, and different word data is separated by a separator.
[0058] In the above embodiment, the word data: every day, point, minute, second, start, and execution are description data, and 0, 45, and 37 are string data.
[0059] S120, encoding the word data to obtain word vector data.
[0060] Wherein, one word vector data corresponds to one sequence identifier.
[0061] After the word data is segmented to obtain the word data in step S110, the word data is encoded by an encoder to obtain word vector data, and an association between the word vector data and a sequence identifier is constructed, that is, one word vector data corresponds to one sequence identifier, and through the sequence identifier corresponding to the word vector data, the time step corresponding to each word vector data can be determined when the word vector data is feature extracted.
[0062] In step S130, the word vector data is feature extracted to obtain target input hidden state information.
[0063] The target input hidden state information includes input hidden state information corresponding to each word vector data.
[0064] As a specific implementation, to extract the character string data from the text data, the main implementation steps of the embodiment of the present disclosure are to feature extract the word vector data formed after segmentation and encoding, and then input the extracted target input hidden state information into a decoder to obtain a target character string expression.
[0065] The target input hidden state information obtained by feature extracting the word vector feature data includes input hidden state information corresponding to each word vector data, so that the target input hidden state information output to the decoder is only one, which can improve the decoding efficiency of the decoder.
[0066] In a specific implementation, the target input hidden state information obtained by feature extracting the word vector data includes: determining input hidden state information corresponding to each time step according to the sequence identifier corresponding to each word vector data; when the time step satisfies a preset threshold, the input hidden state information corresponding to the time step is the target input hidden state information.
[0067] It should be noted that the preset threshold in the above embodiment is the same as the number of word vector data.
[0068] Specifically, the input hidden state information corresponding to each time step is determined according to the sequence identifier corresponding to each word vector data, including: determining the word vector data input by each time step according to the sequence identifier corresponding to each word vector data; and determining the input hidden state information corresponding to the word vector data input by each time step.
[0069] The input hidden state information corresponding to the word vector data input at each time step is determined, including: obtaining a first weight matrix and a first bias of an update gate in a gated recurrent unit of the encoder, and a second weight matrix and a second bias of a reset gate in the gated recurrent unit; determining update gate state information at the i-th time step according to the word vector data corresponding to the i-th time step, the input hidden state information corresponding to the (i-1)-th time step, the first weight matrix and the first bias; determining reset gate state information at the i-th time step according to the word vector data corresponding to the i-th time step, the input hidden state information corresponding to the (i-1)-th time step, the second weight matrix and the second bias; determining candidate state information corresponding to the i-th time step according to the reset gate state information at the i-th time step and the input hidden state information corresponding to the (i-1)-th time step; and determining the input hidden state information corresponding to the i-th time step according to the candidate state information corresponding to the i-th time step, the input hidden state information corresponding to the (i-1)-th time step and the update gate state information at the i-th time step.
[0070] In a specific embodiment, the word vector data input at each time step is first determined according to the sequence identifier corresponding to each word vector data, and then the input hidden state information corresponding to the word vector data input at each time step is determined.
[0071] For example, the word vector data corresponding to the word data "every day" is word vector data 1, the word vector data corresponding to the word data "0" is word vector data 2, the word vector data corresponding to the word data "point" is word vector data 3, the word vector data corresponding to the word data "45" is word vector data 4, the word vector data corresponding to the word data "minute" is word vector data 5, the word vector data corresponding to the word data "37" is word vector data 6, the word vector data corresponding to the word data "second" is word vector data 7, the word vector data corresponding to the word data "start" is word vector data 8, the word vector data corresponding to the word data "execute" is word vector data 9, the sequence identifier corresponding to the word vector data 1 is identifier 1, the sequence identifier corresponding to the word vector data 2 is identifier 2, the sequence identifier corresponding to the word vector data 3 is identifier 3, the sequence identifier corresponding to the word vector data 4 is identifier 4, the sequence identifier corresponding to the word vector data 5 is identifier 5, the sequence identifier corresponding to the word vector data 6 is identifier 6, the sequence identifier corresponding to the word vector data 7 is identifier 7, the sequence identifier corresponding to the word vector data 8 is identifier 8, and the sequence identifier corresponding to the word vector data 9 is identifier 9.
[0072] In the first time step, the input word vector data 1 is input, the gated recurrent unit outputs the candidate state information corresponding to the first time step, and the input hidden state information of the first time step is determined according to the candidate state information corresponding to the first time step and the input hidden state information corresponding to the 0th time step (which is a preset fixed value). In the second time step, the input word vector data 2 is input, the gated recurrent unit outputs the candidate state information corresponding to the second time step, and the input hidden state information corresponding to the second time step is determined according to the candidate state information corresponding to the second time step and the input hidden state information corresponding to the first time step. In the ninth time step, the input word vector data 9 is input, the gated recurrent unit outputs the candidate state information corresponding to the ninth time step, and the input hidden state information corresponding to the ninth time step is determined according to the candidate state information corresponding to the ninth time step and the input hidden state information corresponding to the eighth time step. After obtaining the input hidden state information corresponding to the ninth time step, since the number of time steps is the same as the number of word vector data, the input hidden state information corresponding to the ninth time step is determined as the target input hidden state information.
[0073] In the specific implementation process, an example of determining the input hidden state information corresponding to the ith time step according to the candidate state information corresponding to the ith time step and the input hidden state information corresponding to the (i-1)th time step is as follows:
[0074]
[0075] wherein xi represents the word data corresponding to the ith sequence identifier, vi represents the word vector sequence corresponding to the ith sequence identifier, and i takes the number of word data.
[0076]
[0077] wherein zi represents the update gate state information of the ith time step, Wz and Uz are the first weight matrix of the update gate, bz is the first bias of the update gate, the dimension of the update gate state information of the ith time step is consistent with the dimension of the input hidden state information hi-1 of the (i-1)th time step.
[0078]
[0079] wherein ri represents the reset gate state information of the ith time step, Wr and Ur are the second weight matrix of the reset gate, br is the second bias of the reset gate, and the dimension of the reset gate state information of the ith time step is consistent with the dimension of the input hidden state information hi-1 of the (i-1)th time step.
[0080]
[0081] wherein, denotes the candidate state information corresponding to the i-th time step, Wr, Ur are the second weight matrices of the reset gate, br are the second biases of the reset gate, respectively, and denotes the element-wise multiplication.
[0082]
[0083] wherein, hi denotes the input hidden state information corresponding to the i-th time step, (1 - zi) and zi denote how much of the hidden state information of the previous time step and the candidate state information of the current time step, respectively.
[0084] From the above implementation process, it can be seen that the hidden state information of the i-th time step includes the candidate state information of the current time step and the hidden state information of the i-1-th time step, and the hidden state information of the i-1-th time step contains the candidate state information of the current time step and the hidden state information of the i-2-th time step, and so on. It can be seen that when the time step corresponding to the hidden state information meets the preset threshold, the target input hidden state information obtained includes the hidden state information of the 1st time step, the hidden state information of the 2nd time step,..., the hidden state information of the i-1-th time step, and the candidate state information of the i-th time step. Therefore, only one target input hidden state information is output to the decoder, which greatly improves the decoding efficiency of the decoder compared to the prior art which needs to input multiple target input hidden state information.
[0085] S140, decoding the target input hidden state information to obtain a target string expression.
[0086] After obtaining the target input hidden state information in step S130, the target input hidden state information is input to the decoder, and the decoder decodes the target input hidden state information to obtain a target string expression.
[0087] In a specific implementation process, decoding the target input hidden state information to obtain a target string expression includes: decoding the target input hidden state information to obtain output hidden state information corresponding to different time steps; and performing dictionary mapping on the output hidden state information corresponding to each time step to obtain a target string expression.
[0088] Specifically, the target input hidden state information is decoded to obtain output hidden state information corresponding to different time steps, including: inputting the target input hidden state information into the gating cycle unit of the decoder to obtain output hidden state information corresponding to the first time step; taking the output hidden state information corresponding to the i-th time step as input to obtain output hidden state information corresponding to the i+1-th time step; when the output hidden state information corresponding to the i+1-th time step is an end label identifier, controlling the gating cycle unit of the decoder to stop decoding the output hidden state information and outputting the end label identifier again.
[0089] As a specific implementation process, first, the target input hidden state information is input into the gating cycle unit of the decoder to obtain output hidden state information corresponding to the first time step, then the output hidden state information corresponding to the first time step is taken as input of the gating cycle unit of the decoder to obtain output hidden state information corresponding to the second time step, then the output hidden state information corresponding to the second time step is taken as input of the gating cycle unit of the decoder to obtain output hidden state information corresponding to the third time step, and when the output hidden state information output by the gating cycle unit of the decoder at a certain time step is an end label identifier, the end label identifier is input into the gating cycle unit of the decoder to control the gating cycle unit to stop decoding the state information and output the second end label identifier.
[0090] After obtaining the output hidden state information corresponding to different time steps, a plurality of target string expressions are obtained by dictionary mapping the output hidden state information output by the gating cycle unit of the decoder, and the plurality of target string expressions form a target string expression, i.e., the periodic task in the application can be executed based on the target string expression, without the need for the developer to edit complex cron expression code to implement the periodic task, thereby improving the development efficiency of the developer.
[0091] In the implementation process, in combination with the above examples, if the text data submitted by the target object is "start execution at 0:45:37 every day", the target string expression obtained by performing dictionary mapping on the output hidden state information corresponding to each time step is "37 45 0 * * *? *"; if the text data submitted by the target object is "start execution every 2 hours", the target string expression obtained by performing dictionary mapping on the output hidden state information corresponding to each time step is "0 * * / 2 * *? *"; if the text data submitted by the target object is "start execution every 2 minutes", the target string expression obtained by performing dictionary mapping on the output hidden state information corresponding to each time step is "0 * / 2 * * *? *"; and if the text data submitted by the target object is "start execution every 2 seconds", the target string expression obtained by performing dictionary mapping on the output hidden state information corresponding to each time step is "0 / 2 * * * *? *".
[0092] The string expression generation method provided by the embodiments of the present disclosure first obtains text data submitted by a target object, performs word segmentation on the text data, and obtains a plurality of word data; then encodes the word data to obtain word vector data; and extracts features from the word vector data to obtain target input hidden state information; and finally decodes the target input hidden state information to obtain a target string expression. Since the hidden state information of the i th time step includes the candidate state information of the current time step and the hidden state information of the i-1 th time step, and the hidden state information of the i-1 th time step contains the candidate state information of the current time step and the hidden state information of the i-2 th time step, and so on, it can be known that when the time steps corresponding to the hidden state information satisfy a preset threshold, the obtained target input hidden state information includes the hidden state information of the 1 st time step, the hidden state information of the 2 nd time step,..., the hidden state information of the i-1 th time step, and the candidate state information of the i th time step. Therefore, only one target input hidden state information is output to the decoder, which greatly improves the decoding efficiency of the decoder compared with the prior art which needs to input multiple target input hidden state information. In addition, after obtaining the output hidden state information corresponding to different time steps, a plurality of target string expressions are obtained by performing dictionary mapping on the output hidden state information output by the gating cycle unit of the decoder, and the plurality of target string expressions constitute the target string expression, that is, the periodic task in the application program can be executed based on the target string expression, and the developer does not need to edit complex cron expression code to implement the periodic task, thereby improving the development efficiency of the developer.
[0093] On the basis of the above embodiments, the embodiments of the present disclosure also provide a string expression generation model training method, Figure 2is a flowchart of a string expression generation model training method provided by an embodiment of the present disclosure, as shown in Figure 2 The string expression generation model training method comprises the following steps.
[0094] In S210, a training sample set is obtained.
[0095] The training sample set comprises text data and a target string expression corresponding to the text data.
[0096] In S320, the text data of the training sample set is input into the string expression generation model to obtain a test string expression corresponding to the text data of the training sample set.
[0097] In S330, the first weight matrix of the gate and the second weight matrix of the reset gate are updated according to the target string expression and the test string expression until the loss value of the string expression generation model meets a preset loss value, and a target string expression generation model is obtained.
[0098] As a specific implementation, the text data of the training sample set is input into an initial string expression generation model, the Adam optimizer is used to guide the training of the model, the cross-entropy loss function is used as an evaluation index of the performance of the model, the training is ended when the loss value is less than the preset loss value, and a target string expression generation model is obtained; during the process of using the Adam optimizer to guide the training of the model, the learning rate of the Adam optimizer is 0.0001, and the threshold value of the loss value is 0.
[0099] On the basis of the above embodiment, Figure 3 is a structural diagram of a string expression generation device provided by an embodiment of the present disclosure, as shown in Figure 3 The string expression generation device comprises the following modules.
[0100] The word data processing module 310 is configured to obtain text data submitted by a target object and perform word segmentation processing on the text data to obtain a plurality of word data, wherein the word data comprises description data and string data.
[0101] The word vector data determination module 320 is configured to encode the word data to obtain word vector data, wherein one word vector data corresponds to one sequence identifier.
[0102] The target input hidden state information determination module 330 is configured to perform feature extraction on the word vector data to obtain target input hidden state information, wherein the target input hidden state information comprises input hidden state information corresponding to each word vector data.
[0103] The target string expression generation module 340 is configured to decode the target input hidden state information to obtain a target string expression.
[0104] The string expression generation apparatus provided by the embodiments of the present disclosure first acquires text data submitted by a target object and performs word segmentation processing on the text data to obtain a plurality of word data; then encodes the word data to obtain word vector data; and extracts features from the word vector data to obtain target input hidden state information; and finally decodes the target input hidden state information to obtain a target string expression. Since the hidden state information of the i th time step includes the candidate state information of the current time step and the hidden state information of the i-1 th time step, and the hidden state information of the i-1 th time step contains the candidate state information of the current time step and the hidden state information of the i-2 th time step, and so on, it can be known that when the time step corresponding to the hidden state information satisfies a preset threshold, the obtained target input hidden state information includes the hidden state information of the 1 st time step, the hidden state information of the 2 nd time step,..., the hidden state information of the i-1 th time step, and the candidate state information of the i th time step. Therefore, only one target input hidden state information is output to the decoder, which greatly improves the decoding efficiency of the decoder compared with the prior art which needs to input multiple target input hidden state information. In addition, after obtaining the output hidden state information corresponding to different time steps, a plurality of target string expressions are obtained by performing dictionary mapping on the output hidden state information output by the gating cycle unit of the decoder, and the plurality of target string expressions constitute the target string expression, that is, the periodic task in the application program can be executed based on the target string expression, and the developer does not need to edit a complex cron expression code to implement a periodic character, thereby improving the development efficiency of the developer.
[0105] In specific embodiments, the feature extraction of the word vector data to obtain the target input hidden state information comprises:
[0106] According to the sequence identifier corresponding to each word vector data, the input hidden state information corresponding to each time step is determined.
[0107] When the time step satisfies a preset threshold, the input hidden state information corresponding to the time step is the target input hidden state information.
[0108] In specific embodiments, the determination of the input hidden state information corresponding to each time step according to the sequence identifier corresponding to each word vector data comprises:
[0109] According to the sequence identifier corresponding to each word vector data, the input hidden state information corresponding to each time step is determined.
[0110] The input hidden state information corresponding to the word vector data input by each time step is determined.
[0111] In specific embodiments, the determining the input hidden state information corresponding to the word vector data of each time step comprises:
[0112] obtaining a first weight matrix and a first bias of an update gate in a gated recurrent unit of the encoder, and a second weight matrix and a second bias of a reset gate in the gated recurrent unit;
[0113] determining update gate state information of the i-th time step according to the word vector data corresponding to the i-th time step, the input hidden state information corresponding to the (i-1)-th time step, the first weight matrix and the first bias;
[0114] determining bias gate state information of the i-th time step according to the word vector data corresponding to the i-th time step, the input hidden state information corresponding to the (i-1)-th time step, the second weight matrix and the second bias;
[0115] determining candidate state information corresponding to the i-th time step according to the bias gate state information of the i-th time step and the input hidden state information corresponding to the (i-1)-th time step;
[0116] determining input hidden state information corresponding to the i-th time step according to the candidate state information corresponding to the i-th time step, the input hidden state information corresponding to the (i-1)-th time step and the update gate state information of the i-th time step.
[0117] In specific embodiments, the decoding the target input hidden state information to obtain a target string expression comprises:
[0118] decoding the target input hidden state information to obtain output hidden state information corresponding to different time steps;
[0119] performing dictionary mapping on the output hidden state information corresponding to each time step to obtain a target string expression.
[0120] In specific embodiments, the decoding the target input hidden state information to obtain output hidden state information corresponding to different time steps comprises:
[0121] inputting the target input hidden state information into a gated recurrent unit of the decoder to obtain output hidden state information corresponding to a first time step;
[0122] inputting the output hidden state information corresponding to the i-th time step to obtain output hidden state information corresponding to the (i+1)-th time step;
[0123] When the output hidden state information corresponding to the i+1th time step is the end label, the gating cycle unit of the decoder is controlled to stop decoding the output hidden state information and output the end label again.
[0124] The embodiment of the present application further provides a computer device. Please refer to Figure 4 , Figure 4 The basic structure block diagram of the computer device is shown in the figure.
[0125] The computer device comprises a memory 510 and a processor 520 which are connected to each other through a system bus. It should be noted that only the computer device with components 510-520 is shown in the figure, but it should be understood that all the shown components are not required to be implemented, and more or less components can be alternatively implemented. It should be understood by those skilled in the art that the computer device herein is a device capable of automatically performing numerical calculation and / or information processing according to pre-set or stored instructions, and the hardware thereof includes but is not limited to a microprocessor, an application specific integrated circuit (ASIC), a field-programmable gate array (FPGA), a digital signal processor (DSP), an embedded device, etc.
[0126] The computer device can be a desktop computer, a notebook computer, a palm computer, a cloud server and other computing devices. The computer device can interact with a user through a keyboard, a mouse, a remote controller, a touchpad or a voice control device.
[0127] The memory 510 includes at least one type of readable storage medium, including non-volatile memory or volatile memory, for example, flash memory, a hard disk, a multimedia card, a card-type memory (e.g., SD or DX memory, etc.), random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), a magnetic memory, a magnetic disk, an optical disk, etc. The RAM can include static RAM or dynamic RAM. In some embodiments, the memory 510 can be an internal storage unit of the computer device, for example, a hard disk or a memory of the computer device. In other embodiments, the memory 510 can also be an external storage device of the computer device, for example, a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) card, or a flash card, etc. equipped on the computer device. Of course, the memory 510 can include both an internal storage unit and an external storage device of the computer device. In this embodiment, the memory 510 is generally used to store an operating system and various application software installed on the computer device, for example, program codes of the above-described method, etc. In addition, the memory 510 can also be used to temporarily store various data that has been output or will be output.
[0128] The processor 520 is generally used to perform the overall operation of the computer device. In this embodiment, the memory 510 is used to store program codes or instructions, including computer operation instructions, and the processor 520 is used to execute the program codes or instructions stored in the memory 510 or process data, for example, run the program codes of the above-described method.
[0129] In this document, the bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, among others. The bus system can be a system of address, data, and control buses, for example. For the sake of presentation, the detailed wiring for bus transactions has been omitted, except for the interconnection of buses themselves. In practice, the bus transactions are often moved along multiple parallel lines using a variety of bus protocols.
[0130] Another embodiment of the present application further provides a computer readable medium, which can be a computer readable signal medium or a computer readable storage medium. A processor in a computer reads the computer readable program code stored in the computer readable medium, so that the processor can perform the function actions specified in each step or combination of steps in the above method; and generates a device implementing the function actions specified in each block or combination of blocks in the block diagram.
[0131] The computer readable medium includes, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or apparatus, or any suitable combination of the foregoing, for storing program codes or instructions, and the program codes include computer operation instructions. The processor is used to execute the program codes or instructions of the above method stored in the memory.
[0132] The definition of the memory and the processor can refer to the description of the foregoing computer device embodiment, which will not be repeated here.
[0133] In several embodiments provided in the present application, it should be understood that the disclosed system, device and method can be implemented in other ways. For example, the device embodiment described above is only schematic, for example, the division of the module or unit is only a logical function division, and actual implementation can have another division manner, for example, a plurality of units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between the displayed or discussed each other can be indirect coupling or communication connection through some interface, device or unit, which can be electrical, mechanical or other forms.
[0134] The function units or modules in each embodiment of the present application can be integrated in one processing unit, or each unit can be physically present separately, or two or more units can be integrated in one unit. The integrated unit can be realized in the form of hardware or in the form of software function unit.
[0135] If the integrated unit is implemented in the form of a software function unit and sold or used as an independent product, it can be stored in a computer readable storage medium. Based on such understanding, the technical solutions of the present application essentially or the part that contributes to the prior art or the whole or part of the technical solutions can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes a number of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor to execute all or part of the steps of the embodiments of the method of the present application. The aforementioned storage medium includes: a U disk, a mobile hard disk, a read-only memory (Read-Only Memory, ROM), a random access memory (Random Access Memory, RAM), a magnetic disk or an optical disk, and various media that can store program codes.
[0136] Unless the context clearly indicates otherwise, as used herein and in the appended claims, the singular form "a," "an," and "the" include plural references unless the context clearly dictates otherwise. Accordingly, the use of "a" or "an" herein and in the following claims is intended to be interpreted to include the plural, unless the context clearly indicates otherwise. Similarly, the words "comprise," "comprises," and "comprising" are to be interpreted inclusively rather than exclusively. Likewise, the terms "include," "including," and "or" should be construed as inclusive, unless otherwise indicated herein. Where the term "example" is used occurring in this document, particularly with respect to a term in a set of terms, the "example" is merely an example of and is not exhaustive of the term. The "example" should not be considered to be exclusive or extensive.
[0137] Further aspects and scope of adaptation become apparent from the description provided herein. It should be appreciated that various aspects of the present application can be implemented alone or in combination with one or more other aspects. It should also be appreciated that the description and specific examples herein are intended to be for illustrative purposes only and are not intended to limit the scope of the present application.
[0138] The above has been described in detail for several embodiments of the present disclosure, but it is obvious that those skilled in the art can make various modifications and variations to the embodiments of the present disclosure without departing from the spirit and scope of the present disclosure. The protection scope of the present disclosure is defined by the appended claims.
Claims
1. A method for generating string expressions, characterized in that, include: The text data submitted by the target object is obtained and the text data is segmented to obtain multiple word data, wherein the word data includes description data and string data; The word data is encoded to obtain word vector data, wherein one word vector data corresponds to one sequence identifier; Feature extraction is performed on the word vector data to obtain target input hidden state information, wherein the target input hidden state information includes input hidden state information corresponding to each word vector data; The target input hidden state information is decoded to obtain the target string expression.
2. The method according to claim 1, characterized in that, The step of extracting features from the word vector data to obtain the target input hidden state information includes: Based on the sequence identifiers corresponding to each of the aforementioned word vector data, determine the input hidden state information corresponding to each time step; When the time step meets a preset threshold, the input hidden state information corresponding to the time step is the target input hidden state information.
3. The method according to claim 2, characterized in that, The step of determining the input hidden state information corresponding to each time step based on the sequence identifier corresponding to each of the word vector data includes: Based on the sequence identifiers corresponding to each of the aforementioned word vector data, determine the word vector data input at each time step; Determine the input hidden state information corresponding to the word vector data input at each time step.
4. The method according to claim 3, characterized in that, The determination of the input hidden state information corresponding to the word vector data input at each time step includes: The first weight matrix and first bias of the gate are updated in the gate control loop unit of the encoder, and the second weight matrix and second bias of the gate are reset in the gate control loop unit. Based on the word vector data corresponding to the i-th time step, the input hidden state information corresponding to the (i-1)-th time step, the first weight matrix, and the first bias, determine the update gate state information at the i-th time step; Based on the word vector data corresponding to the i-th time step, the input hidden state information corresponding to the (i-1)-th time step, the second weight matrix, and the second bias, determine the bias gate state information of the i-th time step; Based on the bias gate state information of the i-th time step and the input hidden state information corresponding to the (i-1)-th time step, determine the candidate state information corresponding to the i-th time step; Based on the candidate state information corresponding to the i-th time step, the input hidden state information corresponding to the (i-1)-th time step, and the update gate state information of the i-th time step, the input hidden state information corresponding to the i-th time step is determined.
5. The method according to claim 1, characterized in that, Decoding the target input hidden state information to obtain the target string expression includes: The target input hidden state information is decoded at the target time step to obtain the output hidden state information corresponding to different time steps; The output hidden state information corresponding to each time step is mapped to a dictionary to obtain the target string expression.
6. The method according to claim 5, characterized in that, The step of decoding the target input hidden state information at target time steps to obtain the output hidden state information corresponding to different time steps includes: The target input hidden state information is input into the gated loop unit of the decoder to obtain the output hidden state information corresponding to the first time step; Using the output hidden state information corresponding to the i-th time step as input, we obtain the output hidden state information corresponding to the (i+1)-th time step; When the output hidden state information corresponding to the (i+1)th time step is the end tag identifier, the gated loop unit controlling the decoder stops decoding the output hidden state information and outputs the end tag identifier again.
7. A string expression generation device, characterized in that, include: The word data processing module is used to obtain the text data submitted by the target object and perform word segmentation on the text data to obtain multiple word data, wherein the word data includes description data and string data; A word vector data determination module is used to encode the word data to obtain word vector data, wherein one word vector data corresponds to one sequence identifier; The target input hidden state information determination module is used to extract features from the word vector data to obtain target input hidden state information, wherein the target input hidden state information includes the input hidden state information corresponding to each word vector data. The target string expression generation module is used to decode the target input hidden state information to obtain the target string expression.
8. A computer device, characterized in that, include: One or more processors; Storage device for storing one or more programs. When the one or more programs are executed by the one or more processors, the one or more processors implement the method as described in any one of claims 1 to 6.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the method as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Candidate character string processing method and device, electronic equipment and storage medium
CN111665955A