Contract template generation method and device, equipment, storage medium and computer program product
The preset text semantic understanding model automatically determines the control position in the electronic contract template, solving the error problem introduced by manual operations, and achieving efficient control filling and contract signing.
Patent Information
- Application Number
- CN202510669532.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-22
- Publication Date
- 2025-08-29
AI Technical Summary
In the prior art, in the process of generating electronic contract templates, the controls are dragged to the corresponding position by relying on manual operations, which is prone to errors and is not efficient.
The preset text semantic understanding model converts the input text into character feature vectors, splicing vectors based on text order, determines the target control label sequence corresponding to the control to be filled, and automatically fills the control according to the control label sequence.
It improves the accuracy and efficiency of electronic contract template generation, reduces the error introduced by manual operations, and improves the efficiency of contract signing.
Smart Images

Figure CN120562394A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a contract template generation method, apparatus, device, storage medium, and computer program product. Background Art
[0002] With the adoption of paperless systems, electronic signatures are increasingly required in more and more business scenarios. Furthermore, the widespread adoption of mobile devices has accelerated the development and expansion of these businesses, leading to widespread use of the e-Contract Wangputong service on mobile devices. Since this service typically requires processing and signing both business agreements and electronic versions of different contracts, the use of e-contracts is becoming increasingly widespread.
[0003] Currently, the generation of electronic contract templates often requires manual operation, where users drag and drop controls such as ID numbers, mobile phone numbers, names, and time to the corresponding locations within the contract for them to fill in. However, manual operation inevitably leads to errors and is often inefficient, which in turn affects the efficiency of contract signing. Summary of the Invention
[0004] The main purpose of this application is to provide a contract template generation method, device, equipment, storage medium and computer program product, aiming to solve the technical problem in the prior art that the generation process of electronic contract templates relies on manual operation to drag the controls in the contract to the corresponding positions, which is prone to errors and inefficient.
[0005] To achieve the above objectives, this application proposes a contract template generation method, which includes:
[0006] Inputting the input text into a preset text semantic understanding model, wherein the preset text semantic understanding model is provided with a pre-training layer and a feature fusion layer;
[0007] Converting the input text into a character feature vector through the pre-training layer;
[0008] Performing vector concatenation on the character feature vectors based on the text order corresponding to the input text by the feature fusion layer to obtain a sequential text feature vector;
[0009] A target control label sequence corresponding to the control to be filled is determined based on the sequential text feature vector, and controls are filled according to the target control label sequence.
[0010] In one embodiment, the step of performing vector concatenation on the character feature vectors based on the text order corresponding to the input text by the feature fusion layer to obtain a sequential text feature vector includes:
[0011] splicing the character feature vectors through the feature fusion layer based on the dimension sequence numbers corresponding to the character feature vectors to obtain character feature vectors with consistent dimensions;
[0012] Based on the text order corresponding to the input text, the character feature vectors with consistent dimensions are vector-concatenated through the feature fusion layer to obtain a sequential text feature vector.
[0013] In one embodiment, the preset text semantic understanding model is further provided with a text classification layer; the step of determining a target control label sequence corresponding to a to-be-filled control based on the sequential text feature vector includes:
[0014] Determining a forward hidden sequence and a backward hidden sequence corresponding to the sequential text feature vector through the text classification layer;
[0015] Combining and encoding the forward hidden sequence and the backward hidden sequence to generate a target sequence text feature vector;
[0016] A target control label sequence corresponding to the control to be filled is determined based on the target sequential text feature vector.
[0017] In one embodiment, the preset text semantic understanding model is further provided with an attention layer and an output layer; the step of determining a target control label sequence corresponding to a to-be-filled control based on the target sequential text feature vector includes:
[0018] Encoding the target sequential text feature vector through the attention layer to obtain an intermediate semantic code;
[0019] Decoding the intermediate semantic code and outputting an attention text feature vector;
[0020] Determine the final state of the attention layer based on the forward final hidden state value and the backward final state hidden value corresponding to each feature text in the attention text feature vector;
[0021] Determine a semantic information context vector and a fill control context vector based on the final state of the attention layer and the attention probability distribution corresponding to the final state of the attention layer;
[0022] The target control label sequence corresponding to the to-be-filled control is determined through the output layer based on the semantic information context vector and the filling control context vector.
[0023] In one embodiment, the step of determining, by the output layer, a target control label sequence corresponding to the to-be-filled control based on the semantic information context vector and the fill control context vector includes:
[0024] Taking the semantic information context vector and the filled control context vector as inputs of the control to be identified, generating a bidirectional enhanced joint weight vector;
[0025] Determining, by the output layer, a semantic label corresponding to the attention text feature vector based on a sequence information hidden state, the semantic information context vector, and the joint weight vector, wherein the sequence information hidden state is a hidden state carrying sequence information of the attention text feature vector;
[0026] A target control tag sequence corresponding to the to-be-filled control is determined based on the semantic tag.
[0027] In one embodiment, the step of determining a target control label sequence corresponding to the to-be-filled control based on the semantic label includes:
[0028] Determining a plurality of control label sequences corresponding to the attention text feature vector;
[0029] Determine a control score for each control label sequence based on the semantic label, the preset control label scoring matrix, and the preset control label transfer feature matrix;
[0030] A target control label sequence corresponding to the to-be-filled control is determined from the control label sequences based on the control score.
[0031] In addition, to achieve the above-mentioned purpose, the present application also proposes a contract template generation device, which includes:
[0032] A text input module, configured to input the input text into a preset text semantic understanding model, wherein the preset text semantic understanding model is provided with a pre-training layer and a feature fusion layer;
[0033] A text conversion module, configured to convert the input text into a character feature vector through the pre-training layer;
[0034] a vector splicing module, configured to perform vector splicing on the character feature vectors based on the text order corresponding to the input text through the feature fusion layer to obtain a sequential text feature vector;
[0035] The control filling module is used to determine a target control label sequence corresponding to the control to be filled based on the sequential text feature vector, and fill the control according to the target control label sequence.
[0036] In addition, to achieve the above-mentioned purpose, the present application also proposes a contract template generation device, which includes: a memory, a processor, and a computer program stored on the memory and executable on the processor, wherein the computer program is configured to implement the steps of the contract template generation method as described above.
[0037] In addition, to achieve the above-mentioned purpose, the present application also proposes a storage medium, which is a computer-readable storage medium. A computer program is stored on the storage medium, and when the computer program is executed by the processor, the steps of the contract template generation method described above are implemented.
[0038] In addition, to achieve the above-mentioned purpose, the present application also provides a computer program product, which includes a computer program, and when the computer program is executed by a processor, it implements the steps of the contract template generation method described above.
[0039] The present application provides a method for generating a contract template. The present application discloses inputting input text into a preset text semantic understanding model, wherein the preset text semantic understanding model is provided with a pre-training layer and a feature fusion layer; converting the input text into a character feature vector by the pre-training layer; performing vector splicing on the character feature vectors based on the text order corresponding to the input text by the feature fusion layer to obtain a sequential text feature vector; determining a target control label sequence corresponding to the control to be filled based on the sequential text feature vector, and filling the control according to the target control label sequence; compared with the prior art method of manually dragging the controls in the contract one by one to corresponding positions to generate an electronic contract template, which is prone to errors and inefficiency, the present invention can splice the character feature vector representation of the input text based on the text order through the preset text semantic understanding model to obtain sequential text features, and determine the control label sequence corresponding to the control to be filled based on the sequential text features, and finally fill the control according to the control label sequence, thereby solving the technical problem of manually dragging the controls in the contract to corresponding positions in the prior art during the generation of the electronic contract template, which is prone to errors and inefficiency, thereby improving the efficiency of contract signing. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0041] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0042] Figure 1 A flowchart of the first embodiment of the method for generating a contract template for this application is provided;
[0043] Figure 2 A flowchart of the second embodiment of the method for generating a contract template for this application is provided;
[0044] Figure 3 This is a structural diagram of the text classification layer in the contract template generation method of this application;
[0045] Figure 4 This is a structural diagram of the attention layer in the contract template generation method of this application;
[0046] Figure 5 A flowchart of the third embodiment of the method for generating a contract template for this application is provided;
[0047] Figure 6 This is a module structure diagram of the preset text semantic understanding model in the contract template generation method of this application;
[0048] Figure 7 This is a flowchart for processing text semantic understanding in the contract template generation method of this application;
[0049] Figure 8 This is a schematic diagram of the module structure of the contract template generation device according to an embodiment of the present application;
[0050] Figure 9 This is a schematic diagram of the device structure of the hardware operating environment involved in the contract template generation method in the embodiment of this application.
[0051] The purpose, features and advantages of this application will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0052] It should be understood that the specific embodiments described herein are merely used to explain the technical solutions of the present application and are not intended to limit the present application.
[0053] In order to better understand the technical solution of the present application, a detailed description will be given below in conjunction with the accompanying drawings and specific implementation methods.
[0054] The main solution of the embodiment of the present application is: inputting the input text into a preset text semantic understanding model, in which a pre-training layer and a feature fusion layer are provided; converting the input text into a character feature vector through the pre-training layer; performing vector splicing on the character feature vector based on the text order corresponding to the input text through the feature fusion layer to obtain a sequential text feature vector; determining the target control label sequence corresponding to the control to be filled based on the sequential text feature vector, and filling the control according to the target control label sequence.
[0055] Since the existing technology relies on manual operation to drag controls one by one to corresponding positions in the contract to generate an electronic contract template, errors are prone to occur and the efficiency is low.
[0056] The present application provides a solution that can splice the character feature vector representation of the input text based on the text order through a preset text semantic understanding model to obtain sequential text features, and determine the control label sequence corresponding to the control to be filled based on the sequential text features, and finally fill the control according to the control label sequence, thereby solving the technical problem in the prior art of relying on manual operation to drag the controls in the contract to the corresponding positions during the generation of electronic contract templates, which is prone to errors and inefficient, thereby improving the efficiency of contract signing.
[0057] It should be noted that the execution entity of this embodiment may be a computing service device with data processing, network communication, and program execution capabilities, such as a tablet computer, personal computer, or mobile phone, or an electronic device or contract template generation device capable of performing the aforementioned functions. This embodiment and the following embodiments will be described below using a contract template generation device as an example (hereinafter referred to as the device).
[0058] Based on this, the embodiment of the present application provides a method for generating a contract template, referring to Figure 1 , Figure 1 This is a flow chart of the first embodiment of the contract template generation method of this application.
[0059] In this embodiment, the contract template generation method includes steps S10 to S40:
[0060] Step S10: inputting the input text into a preset text semantic understanding model, wherein the preset text semantic understanding model is provided with a pre-training layer and a feature fusion layer.
[0061] It should be understood that the above-mentioned preset text semantic understanding model can be a model for semantic understanding of the input text, wherein the input text can be all the texts in the electronic contract template that needs to be generated this time, for example, a new traffic package was processed today, a new traffic package was applied for today, etc. This embodiment does not limit this.
[0062] Step S20: converting the input text into a character feature vector through the pre-training layer.
[0063] It should be noted that the above-mentioned character feature vector can be a numerical vector obtained by converting each character (such as a letter, Chinese character, symbol, etc.) in the input text into a numerical value. In this embodiment, the text input to the model can be converted into a corresponding character feature vector representation through a pre-training layer set in a preset text semantic understanding model.
[0064] In the specific implementation, the text sentence pair can be input to the preset text semantic understanding model. At this time, the pre-training layer in the preset text semantic understanding model can map the two input sentences to low-dimensional word vectors P′={p′1, p′2, …, p′ m} and Q′={q′1,q′2,…,q′ m}, we get the sentence pairs P′={p′1,p′2,…,p′ m} and Q′={q′1,q′2,…,q′ m Then, the sentence pairs P′ and Q′ represented by the input vectors can be put into the embedding layer, and then the character feature representation corresponding to the input text can be obtained by the unpooled convolution operation. For example, the character feature representation of these two sentences can be:
[0065] p′ 1:m =p′1⊕p′2⊕…⊕p′ m ;
[0066] q′ 1:m =q′1⊕q′2⊕…⊕q′ m ;
[0067] Where p′1, p′2, …, p′ m and q′1,q′2,…,q′ m Both represent the word vector representations obtained after pre-training of the input sentences;
[0068] Then, at position i and position j, a nonlinear function can be used. The two sub-networks respectively combine the embedded words and the convolution kernel to calculate the character feature representation corresponding to the input text to obtain the new features after convolution. The calculation formula is as follows:
[0069] h′ i =φ(σ·p′ i:i+k-1 +b);
[0070] g′ j =φ(σ·q′ j:j+k-1 +b);
[0071] Where φ represents a nonlinear function, p′ i:i+k-1 and q′ j:j+k-1 are the embedded words corresponding to the two input sentences, σ is the convolution kernel, b is the bias term, k is the context length, and h′ i and g′ j They represent the new feature vectors obtained by convolving the character feature representation corresponding to the input text. These two feature vectors can be represented by a general symbol for dimension i: That is, the character feature vector mentioned above, and the feature is used as the input of the feature fusion layer of the preset text semantic understanding model.
[0072] Step S30: performing vector concatenation on the character feature vectors based on the text order corresponding to the input text through the feature fusion layer to obtain a sequential text feature vector.
[0073] It should be understood that the above-mentioned text order can be the order of arrangement of sentences in the input text. Correspondingly, the above-mentioned sequential text feature vector can be a feature vector with sequential information of the sentences in the input text. In this embodiment, the preset text semantic understanding model can perform a convolution operation on the character feature vector corresponding to the input text in the direction of the sentence order dimension. At this time, the output obtained can be processed by feature fusion and feature splicing, so as to form features with semantics and maintain the original sentence order, which is conducive to improving the accuracy of semantic understanding of the input text.
[0074] Specifically, step S30 includes: splicing the character feature vectors through the feature fusion layer based on the dimension serial number corresponding to the character feature vector to obtain a character feature vector with consistent dimension; and splicing the character feature vectors with consistent dimension through the feature fusion layer based on the text order corresponding to the input text to obtain a sequential text feature vector.
[0075] It can be understood that the dimension number corresponding to the character feature vector can be the index position of each character in the character feature vector; accordingly, splicing the character feature vector based on the dimension number corresponding to the character feature vector can be a process of splicing multiple character feature vectors at the same dimension number position. In this embodiment, the feature fusion in the feature fusion layer does not only match the word vector with the semantic information, but also splices the character feature vectors, so that the word vectors can be recombined into the original sentence order after splicing to form a sequential text feature vector with semantics and maintaining the original sentence order, thereby improving the accuracy of text semantic understanding.
[0076] In the specific implementation, the character feature vector output by the pre-training layer can be As the input of the feature fusion layer, the feature fusion layer can concatenate the character feature vectors according to their dimension numbers. For example, the fusion corresponding to the i-th dimension is the concatenation of the i-th dimension elements of each feature map (that is, the multidimensional array generated by the convolution layer after the input data is convolved). It can be specifically expressed as:
[0077]
[0078] Where, Indicates the vector of dimension i corresponding to the first feature map, T i Indicates the concatenation of vectors of dimension i, where all Ti By splicing them in the order of the sentences, the semantics of the sentence order can be maintained. Since each convolution kernel of each size in this embodiment has a total of n feature maps, the dimension of T is consistent with the input length of the convolution layer, both of which are M.
[0079] In this embodiment, the output O of the feature fusion layer can be expressed as:
[0080]
[0081] Where, O i represents the i-th dimension of O, where the dimension of O is consistent with the dimension of the character feature vector, both of which are M. In this embodiment, the feature fusion layer can convert each paragraph of text into a feature vector representation with sentence order information that is consistent with the matrix dimension length of the character feature vector corresponding to the text, that is, the sequential text feature vector mentioned above, and use the sequential text feature vector as the input of the subsequent text classification layer.
[0082] Step S40: determining a target control label sequence corresponding to the control to be filled based on the sequential text feature vector, and filling the control according to the target control label sequence.
[0083] It should be understood that the above-mentioned controls to be filled in can be controls that need to be filled in the electronic contract template generated this time, such as name, ID number, mobile phone number, etc., and this embodiment does not limit this.
[0084] It should be noted that the target control label sequence may be a sequence obtained by arranging the labels corresponding to the controls to be filled from high to low according to the correlation between the semantic understanding content of the input text and the controls to be filled.
[0085] In this embodiment, since the sequential text feature vector carries the semantics of the input text and maintains the sentence order of the input text, the preset text semantic understanding model can perform semantic understanding of the input text based on the sequential text feature vector. Then, based on the understood semantic content, the improved BBCR (BERT-BiLSTM-CR, bidirectional correlation semantic coding) control extraction method can be used to generate a target control label sequence corresponding to the control to be filled, and automatically fill in the control corresponding to the understood semantics at the corresponding position according to the target control label sequence. After the control is filled, an electronic contract template can be obtained. Among them, the BBCR control extraction method is a control extraction method that combines a pre-trained language model, a sequence encoder, and a conditional random field. It is mainly used to extract user interface controls (such as buttons, text boxes, etc.) from text. This method can capture the contextual associations of controls through multi-level semantic coding to achieve accurate extraction of complex associations of controls.
[0086] This embodiment provides a contract template generation method, which discloses inputting input text into a preset text semantic understanding model, wherein the preset text semantic understanding model is provided with a pre-training layer and a feature fusion layer; converting the input text into a character feature vector by the pre-training layer; performing vector concatenation of the character feature vectors based on the text order corresponding to the input text by the feature fusion layer to obtain a sequential text feature vector; determining a target control label sequence corresponding to the control to be filled based on the sequential text feature vector, and filling the control according to the target control label sequence; compared with the prior art method of manually dragging the controls in the contract one by one to corresponding positions to generate an electronic contract template, which is prone to errors and inefficiency, this embodiment can use the preset text semantic understanding model to concatenate the character feature vector representations of the input text based on the text order to obtain sequential text features, and determine the control label sequence corresponding to the control to be filled based on the sequential text features, and finally fill the control according to the control label sequence, thereby solving the technical problem of manually dragging the controls in the contract to corresponding positions in the prior art during the generation of the electronic contract template, which is prone to errors and inefficiency, thereby improving the efficiency of contract signing.
[0087] Based on the first embodiment of the present application, in the second embodiment of the present application, the same or similar contents as those in the above embodiment 1 can be referred to the above introduction and will not be described in detail later. Figure 2 , Figure 2 This is a flow chart of the second embodiment of the method for generating a contract template for this application.
[0088] In this embodiment, the preset text semantic understanding model is further provided with a text classification layer; step S40 further includes steps S401 to S403:
[0089] Step S401: Determine the forward hidden sequence and the backward hidden sequence corresponding to the sequential text feature vector through the text classification layer.
[0090] It should be noted that the forward hidden sequence can be the sequence of hidden states generated at each time step when processing the sequential text feature vectors forward in chronological order; the backward hidden sequence can be the sequence of hidden states generated at each time step when processing the sequential text feature vectors backward in chronological order. In a neural network, a hidden state is the internal state generated by the network after each step of input processing, which can capture the historical information of the sequence.
[0091] Step S402: performing combined encoding on the forward hidden sequence and the backward hidden sequence to generate a target sequential text feature vector.
[0092] It should be understood that the target sequential text feature vector may be a feature vector obtained by merging and encoding the hidden sequences of the forward and backward sequences corresponding to the sequential text feature vector.
[0093] In the specific implementation, refer to Figure 3 , Figure 3 This is the structural diagram of the text classification layer in the contract template generation method of this application. Figure 3 As shown, in this embodiment, the sequential text feature vector O output by the feature fusion layer can be used as the input x of the text classification layer. t , for each x in the input sequence t (i.e. Figure 3 w0, w1, w2, w3, ..., w n ), x can be processed forward in time order through the forward hidden layer t , get the forward hidden sequence And process x in reverse chronological order through the backward hidden layer t , and get the backward hidden sequence Then the forward hidden sequence and the backward hidden sequence Merge encoding is performed so that the target sequence text feature vector obtained in the end can truly rely on context information, thereby improving the semantic capture ability of the model. Specifically, for a given n-dimensional text input sequence (x1, x2, x3, x4, ..., x n-1 ), at time t, h can be output t , the specific calculation formula is:
[0094]
[0095] Where, is the weight matrix, is the bias vector, σ is the activation function, h t It is the new hidden state obtained by merging the output of the last node of the forward and backward directions.
[0096] It is understandable that the existing conventional text classification layer usually only pays attention to unidirectional sequences and can therefore only predict the next word based on forward or backward information. However, the text classification layer in this embodiment can merge and encode the forward and backward hidden sequences of the word, so that the final encoding truly depends on the contextual information, thereby improving the semantic capture ability of the model.
[0097] Step S403: determining a target control label sequence corresponding to the control to be filled based on the target sequential text feature vector.
[0098] Furthermore, the preset text semantic understanding model is further provided with an attention layer and an output layer; the step S403 further includes:
[0099] Step S403a: Encode the target sequential text feature vector through the attention layer to obtain an intermediate semantic code.
[0100] It should be understood that the above-mentioned intermediate semantic encoding can be a fusion of the semantic information of all elements (such as words, sentences) in the target sequential text feature vector, which can highlight the key parts related to the control filling task through attention weights.
[0101] Step S403b: Decode the intermediate semantic code and output the attention text feature vector.
[0102] It should be noted that the above-mentioned attention text feature vector is also the feature vector obtained after decoding the intermediate semantic code. In practical applications, in the decoding stage, the decoder in the attention layer can use the intermediate semantic code and the previously generated output to gradually generate the target sequence. Each time an output is generated, the decoder updates its hidden state, and uses this hidden state as a query vector to perform attention calculation with the key-value pair of the input sequence to obtain a new context vector, which is used to calculate the output of the current time step. In this embodiment, the attention text feature vector output after decoding the intermediate semantic code can be a context vector generated at each decoding time step, which not only contains the key information of the target sequence text feature vector, but also takes into account the previously generated output and the current state of the decoder.
[0103] In the specific implementation, refer to Figure 4 , Figure 4 This is the structural diagram of the attention layer in the contract template generation method of this application. Figure 4 As shown in the figure, assuming that the length of the input text sequence input to the attention layer is 4, the text input sequence X = (x1, x2, x3, x4) can be encoded first to obtain the intermediate semantic code c, where c includes all the information of the input data. Then, the semantic code c can be decoded and the final output sequence Y = (y1, y2, y3).
[0104] In this embodiment, y in the model j The calculation formula can be:
[0105] y j =D(C j ,y1,…,y j-1 );
[0106] For each output y j , has its corresponding unique intermediate semantic code C j, C j The calculation method is:
[0107]
[0108] Where x i is the element in the input sequence, M is the length of the input sequence, S(x i ) represents the input data x i Function transformation, α ij Represents x i y j The attention probability distribution value, D is the decoding function, which is used to convert the current context information C j and the previously generated outputs y1,…,y j-1 Convert to the next output y j .
[0109] Step S403c: Determine the final state of the attention layer based on the forward final hidden state value and the backward final state hidden value corresponding to each feature text in the attention text feature vector.
[0110] It should be understood that the forward final hidden state value can be the final hidden state value generated when the sequential text feature vector is processed forward in chronological order; and the backward final hidden state value can be the final hidden state value generated when the sequential text feature vector is processed backward in chronological order. In this embodiment, the final state of the attention layer is generated by concatenating the forward final hidden state value and the backward final hidden state value.
[0111] Step S403d: Determine the semantic information context vector and the fill control context vector based on the final state of the attention layer and the attention probability distribution corresponding to the final state of the attention layer.
[0112] It should be noted that the above-mentioned semantic information context vector can be the intermediate semantic representation obtained after encoding the input text sequence through the attention layer, which captures the key semantic information in the input text; the above-mentioned filled control context vector can be the context vector obtained by the decoder after decoding the semantic information output by the encoder through the attention layer when generating each control, which can be used to calculate the control output probability of the current time step.
[0113] In the specific implementation, the calculation formula for the attention probability distribution of the output of the attention layer at time i to the final state F is as follows:
[0114]
[0115] Where, α iis the attention probability distribution of the output of the attention layer i at the final state F, N is the input data length, U is the weight matrix, and h i The forward state at time i is and backward state The concatenated feature vector, h j The forward state at time j is and backward state The concatenated feature vector, F is the final state of the attention layer, c l is the semantic information context vector obtained by weighting the final state F of the attention layer by a, and a is the attention probability distribution of each hidden state to the final state F. In addition, in this embodiment, the control context vector is filled It takes the words around the filled control as the local context, extracts its word vector and aggregates it. Its calculation method is the same as the semantic information context vector c l The calculation method is the same and will not be described here.
[0116] In a specific implementation, this solution can apply the attention mechanism to semantic information and fill space. In this case, the attention layer encodes and distributes the vector formed by splicing the forward final hidden state value and the backward final hidden state value. The introduction of this attention mechanism can use the state combination at each moment as the final state, thereby calculating the attention probability distribution of each moment state with respect to the final state. In this embodiment, the results can be improved by optimizing the attention distribution. After the introduction of the attention mechanism, the key points can be highlighted while taking into account the context information. While retaining the information that is effective for classification, the non-effective information is discarded, thereby enhancing the correlation between the text semantics and the control, and improving the accuracy of filling the control.
[0117] Step S403e: Determine, through the output layer, a target control label sequence corresponding to the control to be filled based on the semantic information context vector and the filling control context vector.
[0118] Specifically, step S403e includes:
[0119] Step S41: taking the semantic information context vector and the filled control context vector as inputs of the control to be identified, and generating a bidirectional enhanced joint weight vector.
[0120] It should be noted that the above-mentioned joint weight vector can be a vector generated by fusing the information of the semantic information context vector and the fill control context vector. In this embodiment, the joint weight vector can improve the connection between semantic information recognition and control filling, thereby filling the control more accurately. In practical applications, the semantic information context vector can capture the global semantic information of the input text (such as text type, relationship between texts, etc.), while the fill control context vector can dynamically focus on local information related to the current control (such as specific values, positions, etc.), so that the model can consider global semantics and local information at the same time, thereby filling the control more accurately.
[0121] In the specific implementation, the semantic information context vector c l , fill the control context vector As the target control input, a bidirectional enhanced joint weight vector r is generated. The larger r is, the greater the proportion of overlap between the semantic information and the filling control attention layer in the sequence. As a result, the correlation between the semantic information and the filling control is higher, and the connection is closer. The calculation formula of r is as follows:
[0122]
[0123] In the formula, v, W are trainable weights, r is c l 、 The joint weight representation of is the linear weight matrix, W l is a weighted weight matrix. After the joint weight matrix is obtained by calculation in this embodiment, r can be used as a weight feature together with the context vector and the hidden state for semantic information recognition and filling tasks requiring controls.
[0124] Step S42: Determine the semantic label corresponding to the attention text feature vector through the output layer based on the sequence information hidden state, the semantic information context vector and the joint weight vector, wherein the sequence information hidden state is the hidden state carrying the sequence information of the attention text feature vector.
[0125] It should be noted that the semantic label can be the label that the attention text feature vector uniquely corresponds to at the output layer. In this embodiment, the output layer can map the input sequence to a semantic label, wherein each word in the input sequence corresponds to a semantic label.
[0126] In the specific implementation, for the input sequence X = (x1, x2, x3, x4), the output layer can predict its corresponding semantic label y l , an input sequence corresponds to only one semantic type, then the hidden state h carrying the entire sequence information can be t , semantic context vector cl And the joint weight r is used as the input of the semantic recognition task, and the calculation formula is as follows:
[0127]
[0128] Where y l is a semantic label, is the linear transformation matrix, h t It is the sequence information hidden state.
[0129] Step S43: determining a target control tag sequence corresponding to the control to be filled based on the semantic tag.
[0130] In practical applications, the semantic information context vector c l and fill the control context vector As the target control input, a bidirectionally enhanced joint weight vector r is generated. The output of the input layer can be the scores of the words in the input sequence and the corresponding controls to be filled. The control label sequence with the highest score is used as the final output sequence, that is, the target control label sequence. Finally, the control corresponding to the target control label sequence can be filled into the corresponding semantically analyzed sentence to achieve control filling. In this embodiment, by introducing an attention mechanism between semantics and controls, the correlation between text semantics and controls can be enhanced, while improving the accuracy of filling controls.
[0131] In this embodiment, it is disclosed that a forward hidden sequence and a backward hidden sequence corresponding to a sequential text feature vector are determined through a text classification layer; the forward hidden sequence and the backward hidden sequence are merged and encoded to generate a target sequential text feature vector; and a target control label sequence corresponding to a control to be filled is determined based on the target sequential text feature vector; because the text classification layer in this embodiment can merge and encode the forward and backward hidden sequences and the backward hidden sequences of words in the input text, the final encoding is truly dependent on contextual information, thereby improving the semantic capture ability of the model and further improving the filling accuracy of the control.
[0132] Based on the first embodiment and / or the second embodiment of the present application, in the third embodiment of the present application, the same or similar contents as those in the above embodiments can be referred to the above introduction and will not be described in detail later. Figure 5 , Figure 5 This is a flow chart of the third embodiment of the method for generating a contract template for this application.
[0133] In this embodiment, step S43 further includes steps S43a to S43c:
[0134] Step S43a: Determine several control label sequences corresponding to the attention text feature vector.
[0135] It should be noted that the above control label sequence can be all possible control label sequences corresponding to the attention text feature vector input to the output layer.
[0136] Step S43b: Determine the control score of each control label sequence based on the semantic label, the preset control label scoring matrix, and the preset control label transfer feature matrix.
[0137] It should be noted that the above-mentioned preset control label scoring matrix can be a matrix for scoring a control label when a sentence in the input sequence corresponds to a certain control label. In this embodiment, the preset control label scoring matrix can be a scoring matrix P output by an LSTM (Long Short-Term Memory) association model, which can be used to score the control label. For example, the elements of the matrix is the score when the i-th sentence in the input sequence X corresponds to the j-th control label, P i The i-th column of the feature representation matrix is the score vector of all possible control labels corresponding to the i-th sentence of the input sequence.
[0138] It should be noted that the above-mentioned preset control label transfer feature matrix can be a matrix used to represent the score of transferring from a certain control label to another control label. For example, if the control label transfer feature matrix is represented by A, then A can be used. i,j Indicates that the control label Move to the Controls tab score.
[0139] In a specific implementation, the control score of each control label sequence can be calculated based on the semantic label, the preset control label scoring matrix and the preset control label transfer feature matrix. For example, when the output sequence corresponding to the input sequence X is y slot The score when slot ), the specific calculation formula can be:
[0140]
[0141] Where, P i Represents the score vector of all possible control labels corresponding to the i-th sentence of the input sequence, is the splicing transformation matrix, h t is the sequence information hidden state, To fill the control context vector, r is c l 、 The joint weight representation of Indicates that the control label Move to the Controls tab The score, Represents the score when the i-th sentence in the input sequence corresponds to the j-th control label.
[0142] Step S43c: determining a target control label sequence corresponding to the control to be filled from the control label sequences based on the control score.
[0143] In practical applications, after obtaining all possible control label sequences corresponding to the input sequence, the model can be trained to maximize the probability of the correct label sequence. During prediction, the control label sequence with the highest score is used as the final output sequence. The control label sequence obtained at this time is the optimal output sequence, that is, the target control label sequence mentioned above. The calculation formula is as follows:
[0144]
[0145] Where, is all possible control label sequences corresponding to the input sequence, y slot* for After obtaining the target control label sequence with the highest score, the device can fill the control corresponding to the target control label sequence into the corresponding semantically analyzed sentence, thereby completing the filling of the control in the electronic contract template.
[0146] In the specific implementation, refer to Figure 6 , Figure 6 This is a module structure diagram of the preset text semantic understanding model in the contract template generation method of this application. Figure 6 As shown, the preset text semantic understanding model in this solution can be set with a pre-training layer, a feature fusion layer, a text classification layer, an attention layer and an output layer. When filling in the control, refer to Figure 7 , Figure 7 This is a flowchart of the text semantic understanding process in the contract template generation method of this application. Figure 7 As shown, first, the input text can be input into the preset text semantic understanding model. At this time, the pre-training layer in the preset text semantic understanding model can convert the input text into a character feature vector representation and input it into the feature fusion layer. The feature fusion layer can splice the character feature vectors with the same dimension according to the sentence order in the text to obtain a sequential text feature vector, and input the sequential text feature vector into the text classification layer. After receiving the sequential text feature vector, the text classification layer can merge and encode the forward hidden sequence and backward hidden sequence corresponding to the sequential text feature vector to obtain the target sequential text feature vector that truly depends on the context information, and input it into the attention layer. The attention layer can encode the input text sequence, obtain the intermediate semantic code, decode the intermediate semantic code, and finally output the attention text feature vector. The output layer can convert the semantic information context vector cl , fill the control context vector As the target control input, a bidirectional enhanced joint weight vector r is generated, and the hidden state h carrying the entire sequence information is converted to t , semantic context vector c l And the joint weight r is used as the input of the semantic recognition task, and the words of the input sequence and the scores of the corresponding target controls are used as output, so that the target control label sequence with the highest score can be output. Finally, the output layer can fill the control corresponding to the target control label sequence with the highest score into the corresponding sentence after semantic analysis, completing the control filling task and generating an electronic contract template.
[0147] In this embodiment, it is disclosed that several control label sequences corresponding to the attention text feature vectors are determined from the control to be filled; the control score of each control label sequence is determined based on the semantic label, the preset control label scoring matrix, and the preset control label transfer feature matrix; based on the control score, the target control label sequence corresponding to the control to be filled is determined from each control label sequence, so that the target control label sequence with the highest score can be determined from each control label sequence based on the control score to perform control filling, thereby improving the accuracy of control filling.
[0148] It should be noted that the above examples are only used to understand this application and do not constitute a limitation on the contract template generation method of this application. More simple transformations based on this technical concept are all within the scope of protection of this application.
[0149] This application also provides a contract template generation device, please refer to Figure 8 , the contract template generating device includes:
[0150] A text input module 10 is used to input the input text into a preset text semantic understanding model, wherein the preset text semantic understanding model is provided with a pre-training layer and a feature fusion layer;
[0151] A text conversion module 20, configured to convert the input text into a character feature vector through the pre-training layer;
[0152] A vector splicing module 30 is configured to perform vector splicing on the character feature vectors based on the text order corresponding to the input text through the feature fusion layer to obtain a sequential text feature vector;
[0153] The control filling module 40 is configured to determine a target control label sequence corresponding to the control to be filled based on the sequential text feature vector, and perform control filling according to the target control label sequence.
[0154] The contract template generation device provided in this application utilizes the contract template generation method described in the aforementioned embodiments, resolving the technical issues in the prior art of electronic contract template generation, which relies on manual dragging of contract controls to corresponding locations, resulting in errors and low efficiency. Compared to the prior art, the beneficial effects of the contract template generation device provided in this application are the same as those of the contract template generation method described in the aforementioned embodiments. Other technical features of the contract template generation device are the same as those disclosed in the aforementioned embodiments and are not further elaborated here.
[0155] The present application provides a contract template generation device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the contract template generation method in the above-mentioned embodiment one.
[0156] Reference below Figure 9 , which shows a schematic diagram of the structure of a contract template generation device suitable for implementing the embodiments of the present application. The contract template generation device in the embodiments of the present application may include, but is not limited to, mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Descriptions), PMPs (Portable Media Players), and in-vehicle terminals (such as in-vehicle navigation terminals), as well as fixed terminals such as digital TVs and desktop computers. Figure 9 The contract template generation device shown is merely an example and should not impose any limitations on the functions and scope of use of the embodiments of the present application.
[0157] like Figure 9As shown, the contract template generation device may include a processing device 1001 (e.g., a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes based on programs stored in a read-only memory 1002 or programs loaded from a storage device 1003 into a random access memory 1004. Random access memory 1004 also stores various programs and data required for the operation of the contract template generation device. Processing device 1001, read-only memory 1002, and random access memory 1004 are interconnected via a bus 1005. An input / output interface 1006 is also connected to the bus. Typically, the following systems may be connected to the input / output interface 1006: an input device 1007 including, for example, a touch screen, touchpad, keyboard, mouse, image sensor, microphone, accelerometer, gyroscope, etc.; an output device 1008 including, for example, a liquid crystal display (LCD), speaker, vibrator, etc.; a storage device 1003 including, for example, a magnetic tape, hard disk, etc.; and a communication device 1009. Communication device 1009 can allow the contract template generation device to communicate wirelessly or wired with other devices to exchange data. Although the figure shows a contract template generation device with various systems, it should be understood that it is not required to implement or have all of the systems shown. More or fewer systems may be implemented or provided instead.
[0158] In particular, according to the embodiments disclosed in the present application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, the embodiments disclosed in the present application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program comprising program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network via a communication device, or installed from a storage device 1003, or installed from a read-only memory 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the method of the embodiment disclosed in the present application are performed.
[0159] The contract template generation device provided in this application utilizes the contract template generation method described in the aforementioned embodiment to address the technical issue of control filling. Compared to the prior art, the contract template generation device provided in this application achieves the same beneficial effects as the contract template generation method described in the aforementioned embodiment. Other technical features of the contract template generation device are the same as those disclosed in the aforementioned embodiment and are not further elaborated here.
[0160] It should be understood that the various parts disclosed in this application can be implemented using hardware, software, firmware, or a combination thereof. In the description of the above embodiments, specific features, structures, materials, or characteristics can be combined in any one or more embodiments or examples in a suitable manner.
[0161] The above description is merely a specific embodiment of the present application, but the scope of protection of the present application is not limited thereto. Any changes or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in this application should be included in the scope of protection of this application. Therefore, the scope of protection of this application should be based on the scope of protection of the claims.
[0162] The present application provides a computer-readable storage medium having computer-readable program instructions (ie, a computer program) stored thereon, and the computer-readable program instructions are used to execute the contract template generation method in the above embodiment.
[0163] The computer-readable storage medium provided in this application may be, for example, a USB flash drive, but is not limited to electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems or devices, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In this embodiment, the computer-readable storage medium may be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system or device. The program code contained on the computer-readable storage medium may be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination thereof.
[0164] The above-mentioned computer-readable storage medium may be included in the contract template generation device; or it may exist independently without being assembled into the contract template generation device.
[0165] The above-mentioned computer-readable storage medium carries one or more programs. When the above-mentioned one or more programs are executed by the contract template generation device, the contract template generation device: inputs the input text into a preset text semantic understanding model, which is provided with a pre-training layer and a feature fusion layer; converts the input text into a character feature vector through the pre-training layer; performs vector splicing on the character feature vector based on the text order corresponding to the input text through the feature fusion layer to obtain a sequential text feature vector; determines the target control label sequence corresponding to the control to be filled based on the sequential text feature vector, and fills the control according to the target control label sequence.
[0166] Computer program code for performing the operations of the present application may be written in one or more programming languages, or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a stand-alone software package, partially on the user's computer and partially on a remote computer, or entirely on the remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).
[0167] The flow charts and block diagrams in the accompanying drawings illustrate the possible architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present application. In this regard, each box in the flow chart or block diagram can represent a module, program segment or a part of code, and the module, program segment or a part of code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order than that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flow chart, and the combination of the boxes in the block diagram and / or flow chart can be implemented by a dedicated hardware-based system that performs the specified function or operation, or can be implemented by a combination of dedicated hardware and computer instructions.
[0168] The modules described in the embodiments of the present application may be implemented in software or hardware, wherein the name of a module does not necessarily limit the unit itself.
[0169] The computer-readable storage medium provided in this application stores computer-readable program instructions (i.e., a computer program) for executing the aforementioned contract template generation method. This computer-readable storage medium can address the prior art problem of manually dragging and dropping control elements in the contract to their corresponding positions, which is prone to errors and inefficient. Compared to the prior art, the beneficial effects of the computer-readable storage medium provided in this application are the same as those of the contract template generation method provided in the aforementioned embodiment, and are not further elaborated here.
[0170] The present application also provides a computer program product, comprising a computer program, which implements the steps of the above-mentioned contract template generation method when executed by a processor.
[0171] The computer program product provided in this application can address the technical issues in the prior art of electronic contract template generation, which relies on manual dragging of contract controls to corresponding locations, which is prone to errors and inefficient. Compared to the prior art, the beneficial effects of the computer program product provided in this application are the same as those of the contract template generation method provided in the aforementioned embodiment, and are not further elaborated here.
[0172] The above description is only part of the embodiments of the present application and does not limit the patent scope of the present application. All equivalent structural transformations made by using the contents of the present application specification and drawings under the technical concept of the present application, or direct / indirect application in other related technical fields are included in the patent protection scope of the present application.
Claims
1. A method for generating a contract template, characterized in that: The method comprises: Inputting the input text into a preset text semantic understanding model, wherein the preset text semantic understanding model is provided with a pre-training layer and a feature fusion layer; Converting the input text into a character feature vector through the pre-training layer; Performing vector concatenation on the character feature vectors based on the text order corresponding to the input text by the feature fusion layer to obtain a sequential text feature vector; A target control label sequence corresponding to the control to be filled is determined based on the sequential text feature vector, and controls are filled according to the target control label sequence.
2. The method according to claim 1, wherein The step of performing vector splicing on the character feature vectors based on the text order corresponding to the input text through the feature fusion layer to obtain a sequential text feature vector includes: splicing the character feature vectors through the feature fusion layer based on the dimension sequence numbers corresponding to the character feature vectors to obtain character feature vectors with consistent dimensions; Based on the text order corresponding to the input text, the character feature vectors with consistent dimensions are vector-concatenated through the feature fusion layer to obtain a sequential text feature vector.
3. The method according to claim 1, wherein The preset text semantic understanding model is further provided with a text classification layer; the step of determining a target control label sequence corresponding to a to-be-filled control based on the sequential text feature vector includes: Determining a forward hidden sequence and a backward hidden sequence corresponding to the sequential text feature vector through the text classification layer; Combining and encoding the forward hidden sequence and the backward hidden sequence to generate a target sequence text feature vector; A target control label sequence corresponding to the control to be filled is determined based on the target sequential text feature vector.
4. The method according to claim 3, wherein The preset text semantic understanding model is further provided with an attention layer and an output layer; the step of determining a target control label sequence corresponding to a to-be-filled control based on the target sequential text feature vector includes: Encoding the target sequential text feature vector through the attention layer to obtain an intermediate semantic code; Decoding the intermediate semantic code and outputting an attention text feature vector; Determine the final state of the attention layer based on the forward final hidden state value and the backward final state hidden value corresponding to each feature text in the attention text feature vector; Determine a semantic information context vector and a fill control context vector based on the final state of the attention layer and the attention probability distribution corresponding to the final state of the attention layer; The target control label sequence corresponding to the to-be-filled control is determined through the output layer based on the semantic information context vector and the filling control context vector.
5. The method according to claim 4, wherein The step of determining, through the output layer, a target control label sequence corresponding to the to-be-filled control based on the semantic information context vector and the fill control context vector includes: Taking the semantic information context vector and the filled control context vector as inputs of the control to be identified, generating a bidirectional enhanced joint weight vector; Determining, through the output layer, a semantic label corresponding to the attention text feature vector based on a sequence information hidden state, the semantic information context vector, and the joint weight vector, wherein the sequence information hidden state is a hidden state carrying sequence information of the attention text feature vector; A target control tag sequence corresponding to the to-be-filled control is determined based on the semantic tag.
6. The method according to claim 5, wherein The step of determining a target control label sequence corresponding to the control to be filled based on the semantic label includes: Determining a plurality of control label sequences corresponding to the attention text feature vector; Determine a control score for each control label sequence based on the semantic label, the preset control label scoring matrix, and the preset control label transfer feature matrix; A target control label sequence corresponding to the to-be-filled control is determined from the control label sequences based on the control score.
7. A contract template generating device, characterized in that: The device comprises: A text input module, configured to input the input text into a preset text semantic understanding model, wherein the preset text semantic understanding model is provided with a pre-training layer and a feature fusion layer; A text conversion module, configured to convert the input text into a character feature vector through the pre-training layer; a vector splicing module, configured to perform vector splicing on the character feature vectors based on the text order corresponding to the input text through the feature fusion layer to obtain a sequential text feature vector; The control filling module is used to determine a target control label sequence corresponding to the control to be filled based on the sequential text feature vector, and fill the control according to the target control label sequence.
8. A contract template generating device, characterized in that: The device includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the contract template generation method according to any one of claims 1 to 6.
9. A storage medium, characterized in that: The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the contract template generation method according to any one of claims 1 to 6 are implemented.
10. A computer program product, characterized in that The computer program product comprises a computer program, and when the computer program is executed by a processor, the steps of the contract template generation method according to any one of claims 1 to 6 are implemented.