File stylization processing method and device, equipment, medium and program product
By stylizing the target rich text file and using the target style vector to generate a file that matches the user's personal style, the problem of the lack of personal style in the file polishing results in the existing technology is solved, and the user experience is improved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-25
- Publication Date
- 2026-04-07
AI Technical Summary
Existing AI-powered creative products generate files that lack a personal style, requiring users to make frequent revisions to match their personal style, thus impacting the user experience.
By using the target user's target style vector, the target rich text file generated by the large model is stylized. The file style detection model is used to extract style features from the target user's historical edit files to generate a target stylized file that conforms to the user's personal style.
Ensure that the generated files match the target user's personal style, reduce the number of modifications required by the user, and improve the user experience.
Smart Images

Figure CN121809405A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of document processing technology, and in particular to a document stylization processing method, apparatus, electronic device, computer-readable storage medium, and computer program product. Background Technology
[0002] Current creative AI (Artificial Intelligence) products typically use large language models to polish users' original materials. However, due to the general nature of large language models, the generated results do not reflect the user's personal style. When users need to output these materials as their own personal output files, the style of the files does not match their personal style, usually requiring further modifications, which affects the user experience. Summary of the Invention
[0003] This invention provides a method, apparatus, device, medium, and program product for document stylization processing. By stylizing a target rich text file generated from a large model based on the target user's target style vector, a target stylized file is obtained. This ensures that the target stylized file matches the target user's personal style, avoiding frequent modifications by the user. Furthermore, since the target style vector is obtained by style detection of the target user's target historical edit files, the matching between the target style vector and the target user is ensured, and the target user does not need to provide it themselves, thereby significantly improving the user experience.
[0004] To address the aforementioned technical problems, a first aspect of this invention provides a document stylization processing method, comprising: Obtain the target rich text file to be stylized; wherein, the target rich text file is generated by a large model; Based on the target user's target style vector, the target rich text file is stylized to obtain a target stylized file; wherein, the target style vector is obtained by style detection of the target user's target historical edit files; The target stylized file is then sent back to the target user.
[0005] As a preferred embodiment, the method specifically obtains the target style vector through the following steps; Select several target historical edit files that meet the preset editing file filtering conditions from each of the target user's historical files, and obtain the target historical file before editing corresponding to the target historical edit files; Based on the target historical edited file and the target historical file before editing, a file style detection model is used to perform style detection to obtain the target style vector; wherein, the file style detection model is obtained by training with training data having actual style vector labels, and the training data is obtained by filtering from each of the historical files based on the edited file filtering conditions.
[0006] As a preferred embodiment, the document style detection model includes a document normalization processing module, a style extraction module, and an output module; The step of performing style detection using a file style detection model based on the target historical edited file and the target historical unedited file to obtain the target style vector specifically includes: The file normalization processing module performs normalization processing on the target historical edit file and the target historical unedited file to obtain content vectors of different data types corresponding to the target historical edit file and the target historical unedited file; wherein, the content vector includes any first content vector of the target historical edit file after normalization processing and any second content vector of the target historical unedited file after normalization processing, and the data type corresponding to the first content vector is the same as the data type corresponding to the second content vector; The style extraction module performs non-linear compression on the content vector to obtain user style features. The output module performs vectorization transformation on the user style features to obtain the target style vector.
[0007] As a preferred embodiment, the step of normalizing the target historical edit file and the target historical unedited file through the file normalization processing module to obtain content vectors of different data types corresponding to the target historical edit file and the target historical unedited file specifically includes: The file normalization processing module segments the target historical edit file and the target historical pre-edit file according to the data type to obtain one or more sets of file content segments corresponding to different data types; wherein, each set of file content segments includes any first content segment in the target historical edit file and any second content segment in the target historical pre-edit file, and the data type corresponding to the first content segment is the same as the data type corresponding to the second content segment; When the data type corresponding to the content segment is text data, the content segment is converted into a first BERT word vector, and the first BERT word vector is weighted and transformed using at least two neural network layers according to a preset style validity weight, style transfer weight and position coefficient matrix to obtain the content vector corresponding to the content segment. When the data type corresponding to the content segment is image data, the content segment is converted into a first grayscale two-dimensional matrix, and the first grayscale two-dimensional matrix is subjected to convolution operation and vectorization transformation processing to obtain the content vector corresponding to the content segment. When the data type corresponding to the content segment is video data, the content segment is converted into a first three-dimensional matrix, and the first three-dimensional matrix is subjected to convolution operation and vectorization transformation processing to obtain the content vector corresponding to the content segment; wherein, the first three-dimensional matrix is used to represent the grayscale pixel value of any image frame of the content segment.
[0008] As a preferred embodiment, the loss function of the document style detection model is constructed based on the difference between the derived style vector generated by style detection of the training data and the actual style vector label.
[0009] As a preferred embodiment, the editing file filtering conditions are specifically as follows: when the historical file does not belong to the training data, the historical file is a readable file, the editing operation user and the editable user of the historical file are both the target user, the historical file is a unique file and there exists a corresponding historical file before editing, the historical file is determined to be the target historical editing file that meets the editing file filtering conditions.
[0010] As a preferred embodiment, the step of stylizing the target rich text file based on the target user's target style vector to obtain a target stylized file specifically includes: The target rich text file is split into one or more rich text segments according to data type; Based on the target style vector, the rich text segments are stylized using a stylization processing model to obtain one or more stylized rich text segments; wherein, the stylization processing model is obtained by training on each of the target user's historical edit files, as well as the historical pre-edit files and editing style tags corresponding to the historical edit files; The target stylized file is obtained based on each of the stylized rich text segments.
[0011] As a preferred embodiment, the stylization processing model includes an input transformation module, an abstract feature extraction module, a stylization transformation module, and an output module; The step of stylizing the rich text segments based on the target style vector using a stylization processing model to obtain one or more stylized rich text segments specifically includes: The input conversion module performs vector conversion processing on the rich text segments according to the data type to obtain rich text segment vectors. The abstract feature extraction module performs nonlinear compression on the rich text segmentation vector to obtain the rich text connotation feature vector. The stylization conversion module fuses the rich text feature vector with the target style vector to obtain the stylization conversion result corresponding to the rich text segment. The output module performs rich text segmentation restoration on the stylized conversion result according to the data type to obtain the stylized rich text segments.
[0012] As a preferred embodiment, the step of performing vector conversion processing on the rich text segments according to the data type through the input conversion module to obtain rich text segment vectors specifically includes: When the data type of the rich text segment is text data, the rich text segment is converted into a second BERT word vector, and weights, style open weights, style transfer weights, style conversion weights and position coefficient matrices are extracted according to preset styles. The second BERT word vector is weighted and transformed using at least two neural network layers to obtain the rich text segment vector. When the data type of the rich text segment is image data, the rich text segment is converted into a second grayscale two-dimensional matrix, and the second grayscale two-dimensional matrix is subjected to convolution operation and vectorization transformation processing to obtain the rich text segment vector. When the data type of the rich text segment is video data, the rich text segment is converted into a second three-dimensional matrix, and the second three-dimensional matrix is subjected to convolution operation and vectorization transformation processing to obtain the rich text segment vector; wherein, the second three-dimensional matrix is used to represent the grayscale pixel value of any image frame of the rich text segment.
[0013] As a preferred embodiment, obtaining the target stylized file based on each of the stylized rich text segments specifically includes: Based on the file format of the target rich text file, the stylized rich text segments are concatenated to obtain the target stylized file.
[0014] As a preferred embodiment, the loss function of the stylization processing model is constructed based on the difference between the stylized file and the historical edited file; the stylized file is generated by the stylization processing model based on the editing style tags to stylize the historical unedited file.
[0015] A second aspect of the present invention provides a document stylization processing apparatus, comprising: The file acquisition module is used to acquire the target rich text file to be stylized; wherein, the target rich text file is generated by a large model; The file stylization processing module is used to stylize the target rich text file based on the target user's target style vector to obtain a target stylized file; wherein, the target style vector is obtained by style detection of the target user's target historical edit files; The file feedback module is used to send the target stylized file back to the target user.
[0016] As a preferred embodiment, the device obtains the target style vector through the following steps; Select several target historical edit files that meet the preset editing file filtering conditions from each of the target user's historical files, and obtain the target historical file before editing corresponding to the target historical edit files; Based on the target historical edited file and the target historical file before editing, a file style detection model is used to perform style detection to obtain the target style vector; wherein, the file style detection model is obtained by training with training data having actual style vector labels, and the training data is obtained by filtering from each of the historical files based on the edited file filtering conditions.
[0017] As a preferred embodiment, the document style detection model includes a document normalization processing module, a style extraction module, and an output module; The device is used to perform style detection using a file style detection model based on the target historical edited file and the target historical file before editing, to obtain the target style vector, specifically including: The file normalization processing module performs normalization processing on the target historical edit file and the target historical unedited file to obtain content vectors of different data types corresponding to the target historical edit file and the target historical unedited file; wherein, the content vector includes any first content vector of the target historical edit file after normalization processing and any second content vector of the target historical unedited file after normalization processing, and the data type corresponding to the first content vector is the same as the data type corresponding to the second content vector; The style extraction module performs non-linear compression on the content vector to obtain user style features. The output module performs vectorization transformation on the user style features to obtain the target style vector.
[0018] As a preferred embodiment, the device is used to perform normalization processing on the target historical edit file and the target historical unedited file through the file normalization processing module to obtain content vectors of different data types corresponding to the target historical edit file and the target historical unedited file, specifically including: The file normalization processing module segments the target historical edit file and the target historical pre-edit file according to the data type to obtain one or more sets of file content segments corresponding to different data types; wherein, each set of file content segments includes any first content segment in the target historical edit file and any second content segment in the target historical pre-edit file, and the data type corresponding to the first content segment is the same as the data type corresponding to the second content segment; When the data type corresponding to the content segment is text data, the content segment is converted into a first BERT word vector, and the first BERT word vector is weighted and transformed using at least two neural network layers according to a preset style validity weight, style transfer weight and position coefficient matrix to obtain the content vector corresponding to the content segment. When the data type corresponding to the content segment is image data, the content segment is converted into a first grayscale two-dimensional matrix, and the first grayscale two-dimensional matrix is subjected to convolution operation and vectorization transformation processing to obtain the content vector corresponding to the content segment. When the data type corresponding to the content segment is video data, the content segment is converted into a first three-dimensional matrix, and the first three-dimensional matrix is subjected to convolution operation and vectorization transformation processing to obtain the content vector corresponding to the content segment; wherein, the first three-dimensional matrix is used to represent the grayscale pixel value of any image frame of the content segment.
[0019] As a preferred embodiment, the loss function of the document style detection model is constructed based on the difference between the derived style vector generated by style detection of the training data and the actual style vector label.
[0020] As a preferred embodiment, the editing file filtering conditions are specifically as follows: when the historical file does not belong to the training data, the historical file is a readable file, the editing operation user and the editable user of the historical file are both the target user, the historical file is a unique file and there exists a corresponding historical file before editing, the historical file is determined to be the historical editing file that meets the editing file filtering conditions.
[0021] As a preferred embodiment, the file stylization processing module is used to stylize the target rich text file based on the target user's target style vector to obtain a target stylized file, specifically including: The target rich text file is split into one or more rich text segments according to data type; Based on the target style vector, the rich text segments are stylized using a stylization processing model to obtain one or more stylized rich text segments; wherein, the stylization processing model employs... The target stylized file is obtained based on each of the stylized rich text segments.
[0022] As a preferred embodiment, the stylization processing model includes an input transformation module, an abstract feature extraction module, a stylization transformation module, and an output module; The document stylization processing module is used to stylize the rich text segments according to the target style vector using a stylization processing model, to obtain one or more stylized rich text segments, specifically including: The input conversion module performs vector conversion processing on the rich text segments according to the data type to obtain rich text segment vectors. The abstract feature extraction module performs nonlinear compression on the rich text segmentation vector to obtain the rich text connotation feature vector. The stylization conversion module fuses the rich text feature vector with the target style vector to obtain the stylization conversion result corresponding to the rich text segment. The output module performs rich text segmentation restoration on the stylized conversion result according to the data type to obtain the stylized rich text segments.
[0023] As a preferred embodiment, the document stylization processing module is used to perform vector transformation processing on the rich text segments according to the data type through the input conversion module to obtain rich text segment vectors, specifically including: When the data type of the rich text segment is text data, the rich text segment is converted into a second BERT word vector, and weights, style open weights, style transfer weights, style conversion weights and position coefficient matrices are extracted according to preset styles. The second BERT word vector is weighted and transformed using at least two neural network layers to obtain the rich text segment vector. When the data type of the rich text segment is image data, the rich text segment is converted into a second grayscale two-dimensional matrix, and the second grayscale two-dimensional matrix is subjected to convolution operation and vectorization transformation processing to obtain the rich text segment vector. When the data type of the rich text segment is video data, the rich text segment is converted into a second three-dimensional matrix, and the second three-dimensional matrix is subjected to convolution operation and vectorization transformation processing to obtain the rich text segment vector; wherein, the second three-dimensional matrix is used to represent the grayscale pixel value of any image frame of the rich text segment.
[0024] As a preferred embodiment, the file stylization processing module is used to obtain the target stylized file based on each of the stylized rich text segments, specifically including: Based on the file format of the target rich text file, the stylized rich text segments are concatenated to obtain the target stylized file.
[0025] As a preferred embodiment, the loss function of the stylization processing model is constructed based on the difference between the stylized file and the historical edited file; the stylized file is generated by the stylization processing model based on the editing style tags to stylize the historical unedited file.
[0026] A third aspect of the present invention provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the document stylization processing method described in any of the first aspects.
[0027] A fourth aspect of the present invention provides a computer-readable storage medium comprising a stored computer program, wherein, when the computer program is executed, it controls the device where the computer-readable storage medium is located to perform the document stylization processing method described in any of the first aspects.
[0028] A fifth aspect of the present invention provides a computer program product, including a computer program / instructions, wherein when the computer program / instructions are executed by a processor, the computer program / instructions implement the steps of the file stylization processing method described in any of the first aspects.
[0029] Compared with the prior art, the beneficial effects of the embodiments of the present invention are that by stylizing the target rich text file generated by the large model based on the target user's target style vector, a target stylized file can be obtained. This ensures that the target stylized file matches the target user's personal style, avoiding frequent modifications by the user. In addition, since the target style vector is obtained by style detection of the target user's target historical edit files, the matching between the target style vector and the target user can be ensured, and the target user does not need to provide it themselves, thereby significantly improving the user experience. Attached Figure Description
[0030] Figure 1 This is a flowchart illustrating the document stylization processing method in an embodiment of the present invention; Figure 2 This is an architecture diagram of the text data processing channel of the document normalization processing module in this embodiment of the invention; Figure 3 This is an architecture diagram of the image data processing channel of the file normalization processing module in this embodiment of the invention; Figure 4 This is an architecture diagram of the video data processing channel of the file normalization processing module in this embodiment of the invention; Figure 5 This is a schematic diagram of the document stylization processing device in an embodiment of the present invention; Figure 6 This is a schematic diagram of the structure of the electronic device in an embodiment of the present invention. Detailed Implementation
[0031] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0032] Please see Figure 1 The first aspect of this invention provides a document stylization processing method, including the following steps S1 to S3: Step S1: Obtain the target rich text file to be stylized; wherein the target rich text file is generated by a large model; Step S2: Based on the target user's target style vector, the target rich text file is stylized to obtain a target stylized file; wherein, the target style vector is obtained by style detection of the target user's target historical edit files; Step S3: The target stylized file is sent back to the target user.
[0033] Specifically, this embodiment can be executed by the server of a cloud storage application, enabling stylization processing before the rich text file generated and polished by the large model is sent back to the user. This ensures that the final file sent to the user matches the user's personal style, avoiding frequent modifications. For example, this embodiment can be applied to a cloud drive server; however, this embodiment is not specifically limited here. First, this embodiment obtains the target rich text file to be stylized, generated by the large model. The rich text file is in XML format, and its content is categorized by data type, including text, images, and videos. It is understood that the target rich text file in this embodiment is generated by the large model (such as a large language model) based on materials provided by the target user. This embodiment does not specifically limit the specific content of the target rich text file.
[0034] Furthermore, this embodiment uses the target style vector of the target user in the target rich text file to perform stylization processing on the target rich text file, so that the obtained stylized file matches the target user's personal style. It is understood that user personal styles, such as writing style, are usually quite abstract and difficult for users to know and describe themselves. Therefore, users generally do not directly provide their style and characteristic information to cloud storage products. At the same time, some users, considering privacy factors, do not actively maintain their file editing style on cloud storage products. To address the problem of missing target style vectors for target users, this embodiment proactively performs style detection on the target user's target historical edit files to obtain their target style vectors, thus eliminating the need for users to provide them themselves and ensuring a high degree of matching between the obtained target style vectors and the target user's actual style.
[0035] Furthermore, in this embodiment, the target stylized file obtained through stylization processing is fed back to the target user to replace the original target rich text file, so that the target user can directly receive a file that matches their own style, avoiding the need for secondary modification and improving the user experience.
[0036] The document stylization processing method provided in this invention stylizes a target rich text file generated by a large model based on the target user's target style vector, thereby obtaining a target stylized file. This ensures that the target stylized file matches the target user's personal style, avoiding frequent modifications by the user. Furthermore, since the target style vector is obtained by style detection of the target user's target historical edit files, it ensures the matching between the target style vector and the target user, and does not require the target user to provide it themselves, thus significantly improving the user experience.
[0037] As a preferred embodiment, the method specifically obtains the target style vector through the following steps; Select several target historical edit files that meet the preset editing file filtering conditions from each of the target user's historical files, and obtain the target historical file before editing corresponding to the target historical edit files; Based on the target historical edited file and the target historical file before editing, a file style detection model is used to perform style detection to obtain the target style vector; wherein, the file style detection model is obtained by training with training data having actual style vector labels, and the training data is obtained by filtering from each of the historical files based on the edited file filtering conditions.
[0038] Specifically, in order to effectively detect the target style vector, this embodiment first needs to select several target historical edited files from the target user's various historical files that meet the preset editing file selection criteria. It is understood that only historical files edited and modified by the target user can reflect their editing style. To detect the target user's target style vector, it is necessary to simultaneously obtain the target historical file before editing, thus comparing the two versions of the file. When a historical edited file is a newly added file, its corresponding historical file before editing is, by default, an empty file.
[0039] Furthermore, in this embodiment, based on the target historical edited file and the target historical unedited file obtained through screening, a file style detection model is used to perform style detection, thereby obtaining the target style vector. It is worth noting that the file style detection model is obtained by training with training data that has actual style vector labels. Thus, when the file style detection model is trained based on the training data, it can continuously optimize the model parameters based on the difference between the model and the actual style vector labels, so as to achieve good style detection results.
[0040] It is worth noting that the file types of the target historical editing file and the target historical file before editing obtained in this embodiment can be office, ppt, txt, etc., and this embodiment does not make specific limitations here.
[0041] This invention, through filtering historical files of a target user according to preset editing file filtering conditions, ensures that the obtained target historical editing files and the corresponding target historical files before editing reflect the target user's file editing style, thereby ensuring the accuracy of the target style vector obtained by style detection and its matching with the target user.
[0042] As a preferred embodiment, the document style detection model includes a document normalization processing module, a style extraction module, and an output module; The step of performing style detection using a file style detection model based on the target historical edited file and the target historical unedited file to obtain the target style vector specifically includes: The file normalization processing module performs normalization processing on the target historical edit file and the target historical unedited file to obtain content vectors of different data types corresponding to the target historical edit file and the target historical unedited file; wherein, the content vector includes any first content vector of the target historical edit file after normalization processing and any second content vector of the target historical unedited file after normalization processing, and the data type corresponding to the first content vector is the same as the data type corresponding to the second content vector; The style extraction module performs non-linear compression on the content vector to obtain user style features. The output module performs vectorization transformation on the user style features to obtain the target style vector.
[0043] Specifically, the document style detection model in this embodiment further includes a document normalization processing module, a style extraction module, and an output module. Preferably, the document style detection model in this embodiment has a total of 10 layers. The first 5 layers form the document normalization processing module; in the last 5 layers, the first 4 layers form the style extraction module, and the last layer is the output module. The document normalization processing module converts the input according to different format types using the corresponding format type conversion channels into a unified content vector, that is, into a computable vector expression form, and sends it to the style extraction module. The style extraction module performs a non-linear transformation on the computable vector expression, compressing and transforming the vector expression to obtain the abstract user style feature of the vector expression. The user style feature is then sent to the output module, which converts the user style feature into a one-dimensional target style vector.
[0044] The style extraction module consists of four residual fully connected layers, each with 1024 neurons. The calculation logic for the layer is as follows: ; Where, 1≤ ≤4, For the first The fully connected weights of the layer For the first The output of the layer, and This is the content vector output by the document normalization module.
[0045] For the output module, it needs to perform vectorization transformation on the user style features output by the style extraction module to convert them into a one-dimensional vector of length 1024, and then perform the following operations on this one-dimensional vector: ; in, This is the one-dimensional vector mentioned above. The softmax result is divided into 16 groups, with each group containing 64 elements. The maximum value in each group is taken to obtain a one-dimensional target style vector of length 16. Each value in the vector Representing users The mapping relationship between the style vector position, style vector identifier, and actual style name corresponding to the style similarity at vector position i is shown in Table 1 below: Table 1. Mapping relationship between style vector location, style vector identifier, and actual style name.
[0046] This invention, through the design of a file style detection model, can effectively perform style detection based on the input target historical edit file and the target historical unedited file, and obtain a target style vector that matches the actual style of the target user.
[0047] As a preferred embodiment, the step of normalizing the target historical edit file and the target historical unedited file through the file normalization processing module to obtain content vectors of different data types corresponding to the target historical edit file and the target historical unedited file specifically includes: The file normalization processing module segments the target historical edit file and the target historical pre-edit file according to the data type to obtain one or more sets of file content segments corresponding to different data types; wherein, each set of file content segments includes any first content segment in the target historical edit file and any second content segment in the target historical pre-edit file, and the data type corresponding to the first content segment is the same as the data type corresponding to the second content segment; When the data type corresponding to the content segment is text data, the content segment is converted into a first BERT word vector, and the first BERT word vector is weighted and transformed using at least two neural network layers according to a preset style validity weight, style transfer weight and position coefficient matrix to obtain the content vector corresponding to the content segment. When the data type corresponding to the content segment is image data, the content segment is converted into a first grayscale two-dimensional matrix, and the first grayscale two-dimensional matrix is subjected to convolution operation and vectorization transformation processing to obtain the content vector corresponding to the content segment. When the data type corresponding to the content segment is video data, the content segment is converted into a first three-dimensional matrix, and the first three-dimensional matrix is subjected to convolution operation and vectorization transformation processing to obtain the content vector corresponding to the content segment; wherein, the first three-dimensional matrix is used to represent the grayscale pixel value of any image frame of the content segment.
[0048] Specifically, for each set of target historical edit files and target historical pre-edit files, since they may contain content of various data types, such as text data, image data, and video data, it is necessary to segment the content of each set of target historical edit files and target historical pre-edit files to ensure that the data type of each content segment is the same, thus obtaining one or more sets of file content segments: ,in, This represents the total number of segments. Indicates user The target history editing file The first content segment, Indicates user The first target history file before editing The second content segment.
[0049] The document normalization processing module in this embodiment further includes a text data processing channel, an image data processing channel, and a video data processing channel, as described above. Figures 2 to 4 As shown. It can be understood that text data processing is used to normalize content segments of text data type, image data processing is used to normalize content segments of image data type, and video data processing is used to normalize content segments of video data type.
[0050] Furthermore, the text data processing channel includes at least two neural network layers, preferably five layers. When the data type corresponding to the content segment is text data, if the number of layers... If the value is greater than 1, then the input is the output of the previous layer. If the number of floors =1, then the input is the first BERT word vector after the content segment is transcoded by BERT (Bidirectional Encoder Representations from Transformers), that is, for each segment result Its corresponding input ,in, This represents the length of the word vector group corresponding to the text after BERT transformation. For the first The first BERT word vector corresponding to each word is obtained by transcoding using word vectors.
[0051] For the The output of each neural network layer Its calculation logic is as follows: ; in, For the first Layer text channel weights, This is the position coefficient matrix. For the first Layer style validity weights For the first Layer style pass-through weights.
[0052] The final output of the text data processing channel is a floating-point array of length 1024. ,in, This represents the number of neural network layers in the text data processing channel. The unified normalized processing result output is: , This is the last layer of the neural network.
[0053] Furthermore, when the data type corresponding to the content segment is image data, it needs to be normalized through the image data processing channel. The image data processing channel includes at least two convolutional layers, preferably five layers. When the value is greater than 1, the input is the output of the previous layer. When the number of layers When =1, the input is the original image with segmented content. The image, after being scaled to 512×512, is then converted to a grayscale image. And based on the gray level value of each pixel position, the first gray level two-dimensional matrix is calculated: ; in, I ( x , y ) represents a two-dimensional matrix I exist( x , y The value at position ). Grayscale image It is also stored in a two-dimensional matrix.
[0054] For the The output of each convolutional layer Its output position The logic for calculating the output value is as follows: ; in, , For the first The convolution kernel of the layer, Indicates taking The position in the middle is A submatrix of size 2×2.
[0055] The final output of the image data processing channel is a two-dimensional floating-point matrix of length 1024. ,in The layer number in the image data processing channel, when For the last convolutional layer, the result needs to be vectorized and transformed into a one-dimensional content vector of length 1024 before output, which will be the final unified transformation result. .
[0056] Furthermore, when the data type corresponding to the content segment is video data, it needs to be normalized through a video data processing channel. The video data processing channel includes at least two convolutional layers, preferably five layers. When the value is greater than 1, the input is the output of the previous layer. When the number of layers When =1, the input is the original video segmented into content segments. After scaling the video to 512×512, convert the video to grayscale. The first three-dimensional matrix is obtained by calculating the grayscale value at each pixel position: ; in, I ( x , y , z ) indicates the first z In a two-dimensional matrix ( x , y The value at position ) z A two-dimensional matrix is the grayscale video. The z The grayscale matrix of each image frame, grayscale video. It is also stored in a three-dimensional matrix.
[0057] For the The output of each convolutional layer Its output position The logic for calculating the output value is as follows: ; in, , For the first Convolutional kernels of layers.
[0058] The final output of the video data processing channel is a 1024-dimensional floating-point matrix. ,in, The layer number in the video data processing channel, when For the last convolutional layer, the result needs to be vectorized and transformed into a one-dimensional content vector of length 1024 before output, which will be the final unified transformation result. .
[0059] Its transformation logic is as follows: ; in, nf Indicates the original video The number of frames, of which, Indicates taking a three-dimensional matrix The first in f A two-dimensional matrix, This indicates the last convolutional layer, where multiplication is a matrix point multiplication. trans (a,1,1024) means transforming matrix a into a one-dimensional vector with a length of 1024.
[0060] This invention standardizes content segments according to data type, thereby ensuring that file content of different data types can be effectively converted into one-dimensional content vectors, thus guaranteeing the subsequent generation of target style vectors.
[0061] As a preferred embodiment, the loss function of the document style detection model is constructed based on the difference between the derived style vector generated by style detection of the training data and the actual style vector label.
[0062] Specifically, the loss function of the document style detection model is as follows: ; in, To derive the style vector, For actual style vector tags, This represents the summation after bitwise subtraction, and its essence is the binary difference quantity of the style vector.
[0063] As a preferred embodiment, the editing file filtering conditions are specifically as follows: when the historical file does not belong to the training data, the historical file is a readable file, the editing operation user and the editable user of the historical file are both the target user, the historical file is a unique file and there exists a corresponding historical file before editing, the historical file is determined to be the target historical editing file that meets the editing file filtering conditions.
[0064] Specifically, this embodiment periodically performs a style detection task, which iterates through all users. The user's target style vector is obtained through a document style detection model. ,in, Total number of users Indicates the first i One user, Indicates the first i The target style vector for each user.
[0065] Retrieve all historical files of the user from the user space. ,in, Given the total number of historical files in user space, iterate through them. After reviewing the files according to the selection criteria, files that meet the criteria are retained and used as input files for training the file style detection model. And files that can be used for style detection, among which, For users The number of files that meet the editing file filtering criteria, and ≤ .
[0066] The specific criteria for editing and filtering files are as follows: (1) Historical files are not training data. That is, check whether historical files have been used as training data. If they have been used, they do not meet the criteria for editing files. (2) The historical file is a readable file. That is, if the file format of the historical file is unreadable, or the file format is readable but the historical file is unreadable due to encryption or other reasons, or the historical file is partially readable, then it does not meet the criteria for editing the file. (3) The editing operation user and the editable user of the historical file are both the target user. That is, if the executor of the editing operation such as adding or modifying the historical file is not the target user in the metadata of the historical file, then it does not meet the editing file filtering conditions; in addition, if the historical file is a shared file and the editable user with editing permission includes other users besides the target user, then it does not meet the editing file filtering conditions. (4) The historical file is a unique file. That is, if the cloud storage application stores a copy of the current historical file, or the current historical file is a reference file, then it does not meet the file editing filtering criteria. (5) There is a corresponding historical file before editing. If the comparison file data of the two versions before and after editing cannot be found, it does not meet the editing file filtering conditions. For newly added historical files, the file before editing is an empty file by default, which means that the editing file filtering conditions are met by default.
[0067] After the traversal is complete, the input file for training the document style detection model can be obtained. Alternatively, the file data used for style detection, whose corresponding historical file before editing is... When a previously edited file is a newly created file and belongs to the target user, its previous edited files are empty by default. These files collectively constitute the file data. .
[0068] This invention utilizes the above-mentioned editing file filtering conditions to filter historical editing files, thereby ensuring that the filtered historical editing files fully reflect the target user's file editing style, and guaranteeing the training effect and style detection accuracy of the file style detection model.
[0069] As a preferred embodiment, the step of stylizing the target rich text file based on the target user's target style vector to obtain a target stylized file specifically includes: The target rich text file is split into one or more rich text segments according to data type; Based on the target style vector, the rich text segments are stylized using a stylization processing model to obtain one or more stylized rich text segments; wherein, the stylization processing model is obtained by training on each of the target user's historical edit files, as well as the historical pre-edit files and editing style tags corresponding to the historical edit files; The target stylized file is obtained based on each of the stylized rich text segments.
[0070] Specifically, for the content of the target rich text file, the target rich text file is split according to the smallest atomic type, and text, image, and video information are extracted from it. The split rich text segments are then assembled into a rich text segmentation result according to their positions in the target rich text file. ,in, This represents the number of segments.
[0071] Furthermore, by utilizing the target user's target style vector, a stylization processing model is used to stylize each rich text segment, thereby obtaining stylized rich text segments that conform to the target user's personal style. The stylization processing model is trained using each of the target user's historical edit files, the corresponding historical pre-edit files, and editing style tags. During training, the stylization processing model can stylize the historical pre-edit files based on the editing style tags and compare them with the historical edit files, thereby continuously optimizing the model parameters.
[0072] Ultimately, based on each stylized rich text segment, a target stylized file that matches the target user's personal style can be obtained. After the target stylized file is fed back to the target user, it can avoid the target user having to make frequent modifications due to style incompatibility, thus ensuring the user experience.
[0073] As a preferred embodiment, the stylization processing model includes an input transformation module, an abstract feature extraction module, a stylization transformation module, and an output module; The step of stylizing the rich text segments based on the target style vector using a stylization processing model to obtain one or more stylized rich text segments specifically includes: The input conversion module performs vector conversion processing on the rich text segments according to the data type to obtain rich text segment vectors. The abstract feature extraction module performs nonlinear compression on the rich text segmentation vector to obtain the rich text connotation feature vector. The stylization conversion module fuses the rich text feature vector with the target style vector to obtain the stylization conversion result corresponding to the rich text segment. The output module performs rich text segmentation restoration on the stylized conversion result according to the data type to obtain the stylized rich text segments.
[0074] Specifically, the stylization processing model in this embodiment further includes an input conversion module, an abstract feature extraction module, a stylization conversion module, and an output module. Preferably, the stylization processing model has 15 processing layers: layers 1 to 5 form the input conversion module, layers 6 to 9 form the abstract feature extraction module, layer 10 is the stylization conversion module, and the last 5 layers form the output module. The input conversion module converts each input rich text segment into a unified rich text segment vector, i.e., a computable vector expression, according to different data types, using the corresponding data type conversion channel. This vector is then sent to the abstract feature extraction module, which performs a non-linear transformation to compress and convert the vector expression, obtaining the rich text connotation feature vector. This rich text connotation feature vector is then sent to the stylization conversion module, which fuses the rich text connotation feature vector with the target style vector to obtain a stylization conversion result containing the target user's target style vector. The output module restores the stylization conversion result back to rich text segments, resulting in the final stylized rich text segments.
[0075] The abstract feature extraction module comprises four residual fully connected layers, each with 1024 neurons. When the number of layers... When the value is greater than 1, the input is the output of the previous layer. When the number of layers When =1, the input is the output of the input conversion module. The calculation logic for each layer is as follows: ; in, For the first The weights of the residual fully connected layer.
[0076] Furthermore, the stylization transfer module has 1024 neurons, which utilizes the rich textual connotation feature vector output by the abstract feature extraction module. and target style vector As input, its calculation logic is as follows: ; in, Represents the target style vector The matrix is expanded by a factor of 64 to conform to the rules of matrix operations. The specific expansion logic is as follows: ; in, The expanded target style vector has a length of ,1≤ ≤ .
[0077] This invention, through the design of a stylization processing model, can effectively stylize rich text segments based on target style vectors, thereby obtaining stylized rich text segments that match the actual style of the target user.
[0078] As a preferred embodiment, the step of performing vector conversion processing on the rich text segments according to the data type through the input conversion module to obtain rich text segment vectors specifically includes: When the data type of the rich text segment is text data, the rich text segment is converted into a second BERT word vector, and weights, style open weights, style transfer weights, style conversion weights and position coefficient matrices are extracted according to preset styles. The second BERT word vector is weighted and transformed using at least two neural network layers to obtain the rich text segment vector. When the data type of the rich text segment is image data, the rich text segment is converted into a second grayscale two-dimensional matrix, and the second grayscale two-dimensional matrix is subjected to convolution operation and vectorization transformation processing to obtain the rich text segment vector. When the data type of the rich text segment is video data, the rich text segment is converted into a second three-dimensional matrix, and the second three-dimensional matrix is subjected to convolution operation and vectorization transformation processing to obtain the rich text segment vector; wherein, the second three-dimensional matrix is used to represent the grayscale pixel value of any image frame of the rich text segment.
[0079] Specifically, the input conversion module in this embodiment further includes a text data conversion channel, an image data conversion channel, and a video data conversion channel. It can be understood that the text data conversion is performed by vector conversion processing on rich text segments of text data type, the image data conversion channel is used to perform vector conversion processing on rich text segments of image data type, and the video data conversion channel is used to perform vector conversion processing on rich text segments of video data type.
[0080] Furthermore, the text data conversion channel includes at least two neural network layers, preferably five layers. When the data type corresponding to the rich text segment is text data, if the number of layers... If the value is greater than 1, then the input is the output of the previous layer. If the number of floors =1, then the input is the second BERT word vector after the rich text segmentation and BERT transcoding, that is, for each segment result Its corresponding input ,in, This represents the length of the word vector group corresponding to the text after BERT transformation. For the first The second BERT word vector corresponding to each word is obtained by transcoding using word vectors.
[0081] For the The output of each neural network layer Its calculation logic is as follows: ; in, For the first Layer style extraction weights, This is the position coefficient matrix. For the first Layer style open weights, For the first Layer style transfer weights For the first Style transfer weights for layers.
[0082] The final output of the text data conversion channel is a floating-point array of length 1024. ,in, This represents the number of neural network layers in the text data conversion channel. The unified normalization output is as follows: , This is the last layer of the neural network.
[0083] Furthermore, when the data type corresponding to the rich text segment is image data, vector conversion processing is required through an image data conversion channel. The image data conversion channel includes at least two convolutional layers, preferably five layers. When the value is greater than 1, the input is the output of the previous layer. When the number of layers When =1, the input is the original image of the rich text segmentation. The image, after being scaled to 512×512, is then converted to a grayscale image. And based on the grayscale value at each pixel position, a second grayscale two-dimensional matrix is calculated: ; in, I ( x , y ) represents a two-dimensional matrix I exist( x , y The value at position ). Grayscale image It is also stored in a two-dimensional matrix.
[0084] For the The output of each convolutional layer Its output position The logic for calculating the output value is as follows: ; in, , For the first The first convolutional kernel of the layer, For the first The second convolution kernel of the layer, For the first The third convolution kernel of the layer.
[0085] The final output of the image data conversion channel is a two-dimensional floating-point matrix of length 1024. ,in, For the layer number in the image data conversion channel, when For the last convolutional layer, the result needs to be vectorized and transformed into a one-dimensional rich text segment vector of length 1024 before output, which will be the final unified transformation result. .
[0086] Furthermore, when the data type corresponding to the rich text segment is video data, vector conversion processing is required through a video data conversion channel. The video data conversion channel includes at least two convolutional layers, preferably five layers. When the value is greater than 1, the input is the output of the previous layer. When the number of layers When =1, the input is the original video segmented into content segments. After scaling the video to 512×512, convert the video to grayscale. The second three-dimensional matrix is obtained by calculating the grayscale value at each pixel position: ; in, I ( x , y , z ) indicates the first z In a two-dimensional matrix ( x , y The value at position ) z A two-dimensional matrix is the grayscale video. The z The grayscale matrix of each image frame, grayscale video. It is also stored in a three-dimensional matrix.
[0087] For the The output of each convolutional layer Its output position The logic for calculating the output value is as follows: ; in, , For the first The first convolutional kernel of the layer, For the first The second convolution kernel of the layer, For the first The third convolution kernel of the layer.
[0088] The final output of the video data conversion channel is a 1024-dimensional floating-point matrix. ,in, For the layer number in the video data conversion channel, when For the last convolutional layer, the result needs to be vectorized and transformed into a one-dimensional content vector of length 1024 before output, which will be the final unified transformation result. .
[0089] Its transformation logic is as follows: ; in, nf Indicates the original video The number of frames, of which, Indicates taking a three-dimensional matrix The first in f A two-dimensional matrix, This indicates the last convolutional layer, where multiplication is a matrix point multiplication. trans (a,1,1024) means transforming matrix a into a one-dimensional vector with a length of 1024.
[0090] In addition, the output module also includes text data output channels, image data output channels and video data output channels, and the number of structural layers of each channel is the same as the number of structural layers of the corresponding channel in the input conversion module.
[0091] For text data output channels, when the number of layers... When the value is greater than 1, the input is the output of the previous layer. With rich text segmentation When the number of layers When =1, the input is the style conversion result and rich text segmentation. For the first Layer output Its calculation logic is as follows: ; The final stylized rich text segmentation is This indicates that BERT inverse encoding is performed on the last layer output of the text data output channel.
[0092] For image data output channels, when the number of layers... When the value is greater than 1, the input is the output of the previous layer. With rich text segmentation When the number of layers When =1, the input is the style conversion result and rich text segmentation. For the first Layer output Its output position is The logic for calculating the output value is as follows: ; Where, 1≤ m ≤2, 1≤ n ≤2, , For the first The first augmentation matrix of the layer, For the first The second augmentation matrix of the layer, For the first The third augmentation matrix of the layer, For the first The adjustment coefficient matrix of the layer.
[0093] The final stylized rich text segmentation is , This is the last layer output of the image data output channel.
[0094] For video data output channels, when the number of layers... When the value is greater than 1, the input is the output of the previous layer. With rich text segmentation When the number of layers When =1, the input is the style conversion result and rich text segmentation. For the first Layer output Its output position of the f-th frame is The logic for calculating the output value is as follows: ; Where, 1≤ m ≤2, 1≤ n ≤2, , For the first The first augmentation matrix of the layer, For the first The second augmentation matrix of the layer, For the first The third augmentation matrix of the layer, For the first The adjustment coefficient matrix of the layer.
[0095] The final stylized rich text segmentation is , This is the last output layer of the video data output channel.
[0096] As a preferred embodiment, obtaining the target stylized file based on each of the stylized rich text segments specifically includes: Based on the file format of the target rich text file, the stylized rich text segments are concatenated to obtain the target stylized file.
[0097] Specifically, this embodiment adopts the same writing method as the target rich text file, and writes each stylized rich text segment into the output file in the same way, thereby splicing the stylized rich text segments to obtain the target stylized file. While ensuring that the file style matches the target user's personal style, the structural integrity of the original file is preserved.
[0098] As a preferred embodiment, the loss function of the stylization processing model is constructed based on the difference between the stylized file and the historical edited file; the stylized file is generated by the stylization processing model based on the editing style tags to stylize the historical unedited file.
[0099] Specifically, the loss function for the stylization model is shown in the following expression: ; in, This represents the target user's historical edit files. This indicates a stylized document. This represents the summation after bitwise subtraction, essentially representing the binary differences between the files. During model training, the model weights are adjusted via backpropagation while keeping the training data constant, until the difference between the stylized file and the historical edited file obtained through backpropagation is 0, or the number of training iterations reaches the maximum threshold. During model inference, the model weights are kept constant while forward propagation is performed to output stylized rich text segments.
[0100] Please see Figure 5 A second aspect of the present invention provides a document stylization processing apparatus 100, comprising: The file acquisition module 11 is used to acquire the target rich text file to be stylized; wherein the target rich text file is generated by a large model; The file stylization processing module 12 is used to stylize the target rich text file based on the target user's target style vector to obtain a target stylized file; wherein, the target style vector is obtained by style detection of the target user's target historical edit files; The file feedback module 13 is used to send the target stylized file back to the target user.
[0101] As a preferred embodiment, the device obtains the target style vector through the following steps; Select several target historical edit files that meet the preset editing file filtering conditions from each of the target user's historical files, and obtain the target historical file before editing corresponding to the target historical edit files; Based on the target historical edited file and the target historical file before editing, a file style detection model is used to perform style detection to obtain the target style vector; wherein, the file style detection model is obtained by training with training data having actual style vector labels, and the training data is obtained by filtering from each of the historical files based on the edited file filtering conditions.
[0102] As a preferred embodiment, the document style detection model includes a document normalization processing module, a style extraction module, and an output module; The device is used to perform style detection using a file style detection model based on the target historical edited file and the target historical file before editing, to obtain the target style vector, specifically including: The file normalization processing module performs normalization processing on the target historical edit file and the target historical unedited file to obtain content vectors of different data types corresponding to the target historical edit file and the target historical unedited file; wherein, the content vector includes any first content vector of the target historical edit file after normalization processing and any second content vector of the target historical unedited file after normalization processing, and the data type corresponding to the first content vector is the same as the data type corresponding to the second content vector; The style extraction module performs non-linear compression on the content vector to obtain user style features. The output module performs vectorization transformation on the user style features to obtain the target style vector.
[0103] As a preferred embodiment, the device is used to perform normalization processing on the target historical edit file and the target historical unedited file through the file normalization processing module to obtain content vectors of different data types corresponding to the target historical edit file and the target historical unedited file, specifically including: The file normalization processing module segments the target historical edit file and the target historical pre-edit file according to the data type to obtain one or more sets of file content segments corresponding to different data types; wherein, each set of file content segments includes any first content segment in the target historical edit file and any second content segment in the target historical pre-edit file, and the data type corresponding to the first content segment is the same as the data type corresponding to the second content segment; When the data type corresponding to the content segment is text data, the content segment is converted into a first BERT word vector, and the first BERT word vector is weighted and transformed using at least two neural network layers according to a preset style validity weight, style transfer weight and position coefficient matrix to obtain the content vector corresponding to the content segment. When the data type corresponding to the content segment is image data, the content segment is converted into a first grayscale two-dimensional matrix, and the first grayscale two-dimensional matrix is subjected to convolution operation and vectorization transformation processing to obtain the content vector corresponding to the content segment. When the data type corresponding to the content segment is video data, the content segment is converted into a first three-dimensional matrix, and the first three-dimensional matrix is subjected to convolution operation and vectorization transformation processing to obtain the content vector corresponding to the content segment; wherein, the first three-dimensional matrix is used to represent the grayscale pixel value of any image frame of the content segment.
[0104] As a preferred embodiment, the loss function of the document style detection model is constructed based on the difference between the derived style vector generated by style detection of the training data and the actual style vector label.
[0105] As a preferred embodiment, the editing file filtering conditions are specifically as follows: when the historical file does not belong to the training data, the historical file is a readable file, the editing operation user and the editable user of the historical file are both the target user, the historical file is a unique file and there exists a corresponding historical file before editing, the historical file is determined to be the historical editing file that meets the editing file filtering conditions.
[0106] As a preferred embodiment, the file stylization processing module 12 is used to stylize the target rich text file based on the target user's target style vector to obtain a target stylized file, specifically including: The target rich text file is split into one or more rich text segments according to data type; Based on the target style vector, the rich text segments are stylized using a stylization processing model to obtain one or more stylized rich text segments; wherein, the stylization processing model is obtained by training on each of the target user's historical edit files, as well as the historical pre-edit files and editing style tags corresponding to the historical edit files; The target stylized file is obtained based on each of the stylized rich text segments.
[0107] As a preferred embodiment, the stylization processing model includes an input transformation module, an abstract feature extraction module, a stylization transformation module, and an output module; The document stylization processing module 12 is used to stylize the rich text segments according to the target style vector using a stylization processing model, to obtain one or more stylized rich text segments, specifically including: The input conversion module performs vector conversion processing on the rich text segments according to the data type to obtain rich text segment vectors. The abstract feature extraction module performs nonlinear compression on the rich text segmentation vector to obtain the rich text connotation feature vector. The stylization conversion module fuses the rich text feature vector with the target style vector to obtain the stylization conversion result corresponding to the rich text segment. The output module performs rich text segmentation restoration on the stylized conversion result according to the data type to obtain the stylized rich text segments.
[0108] As a preferred embodiment, the document stylization processing module 12 is used to perform vector conversion processing on the rich text segments according to the data type through the input conversion module to obtain rich text segment vectors, specifically including: When the data type of the rich text segment is text data, the rich text segment is converted into a second BERT word vector, and weights, style open weights, style transfer weights, style conversion weights and position coefficient matrices are extracted according to preset styles. The second BERT word vector is weighted and transformed using at least two neural network layers to obtain the rich text segment vector. When the data type of the rich text segment is image data, the rich text segment is converted into a second grayscale two-dimensional matrix, and the second grayscale two-dimensional matrix is subjected to convolution operation and vectorization transformation processing to obtain the rich text segment vector. When the data type of the rich text segment is video data, the rich text segment is converted into a second three-dimensional matrix, and the second three-dimensional matrix is subjected to convolution operation and vectorization transformation processing to obtain the rich text segment vector; wherein, the second three-dimensional matrix is used to represent the grayscale pixel value of any image frame of the rich text segment.
[0109] As a preferred embodiment, the file stylization processing module 12 is used to obtain the target stylized file based on each of the stylized rich text segments, specifically including: Based on the file format of the target rich text file, the stylized rich text segments are concatenated to obtain the target stylized file.
[0110] As a preferred embodiment, the loss function of the stylization processing model is constructed based on the difference between the stylized file and the historical edited file; the stylized file is generated by the stylization processing model based on the editing style tags to stylize the historical unedited file.
[0111] The document stylization processing apparatus 100 provided in this embodiment of the invention stylizes a target rich text file generated by a large model based on the target user's target style vector to obtain a target stylized file. This ensures that the target stylized file matches the target user's personal style, avoiding frequent modifications by the user. Furthermore, since the target style vector is obtained by style detection of the target user's target historical edit files, it ensures the matching between the target style vector and the target user, and does not require the target user to provide it themselves, thereby significantly improving the user experience.
[0112] Please see Figure 6 The third aspect of the present invention provides an electronic device 200, including a memory 22, a processor 21, and a computer program stored in the memory 22 and executable on the processor 21. When the processor 21 executes the computer program, it implements the file stylization processing method described in any embodiment of the first aspect.
[0113] For example, the computer program may be divided into one or more modules / units, which are stored in the memory 22 and executed by the processor 21 to complete the present invention. The one or more modules / units may be a series of computer program instruction segments capable of performing a specific function, which describe the execution process of the computer program in the electronic device 200.
[0114] The electronic device 200 may include, but is not limited to, a processor 21 and a memory 22. Those skilled in the art will understand that the schematic diagram is merely an example of the electronic device 200 and does not constitute a limitation on the electronic device 200. It may include more or fewer components than illustrated, or combine certain components, or different components. For example, the electronic device 200 may also include input / output devices, network access devices, buses, etc.
[0115] The processor 21 can be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor, or the processor 21 can be any conventional processor 21. The processor 21 is the control center of the electronic device 200, connecting various parts of the electronic device 200 via various interfaces and lines.
[0116] The memory 22 can be used to store the computer programs and / or modules. The processor 21 implements various functions of the electronic device 200 by running or executing the computer programs and / or modules stored in the memory 22 and calling the data stored in the memory 22. The memory 22 may mainly include a program storage area and a data storage area. The program storage area may store the operating system, at least one application program required for a function (such as sound playback function, image playback function, etc.), etc.; the data storage area may store data created according to the use of the mobile phone (such as audio data, phonebook, etc.). In addition, the memory 22 may include high-speed random access memory, and may also include non-volatile memory, such as hard disk, memory, plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, at least one disk storage device, flash memory device, or other volatile solid-state storage device.
[0117] A fourth aspect of the present invention provides a computer-readable storage medium comprising a stored computer program, wherein, when the computer program is executed, it controls the device where the computer-readable storage medium is located to perform the document stylization processing method described in any embodiment of the first aspect.
[0118] A fifth aspect of the present invention provides a computer program product, including a computer program / instruction, wherein when the computer program / instruction is executed by a processor, it implements the steps of the file stylization processing method described in any embodiment of the first aspect.
[0119] Wherein, if the modules / units integrated in the electronic device are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the methods of the above embodiments of the present invention can also be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable medium can include: any entity or device capable of carrying the computer program code, recording media, USB flash drives, portable hard drives, magnetic disks, optical disks, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc.
[0120] The above description represents the preferred embodiments of the present invention. It should be noted that those skilled in the art can make various improvements and modifications without departing from the principles of the present invention, and these improvements and modifications are also considered to be within the scope of protection of the present invention.
Claims
1. A method for document stylization, characterized in that, include: Obtain the target rich text file to be stylized; wherein, the target rich text file is generated by a large model; Based on the target user's target style vector, the target rich text file is stylized to obtain a target stylized file; wherein, the target style vector is obtained by style detection of the target user's target historical edit files; The target stylized file is then sent back to the target user.
2. The document stylization processing method as described in claim 1, characterized in that, The method specifically obtains the target style vector through the following steps; Select several target historical edit files that meet the preset editing file filtering conditions from each of the target user's historical files, and obtain the target historical file before editing corresponding to the target historical edit files; Based on the target historical edited file and the target historical file before editing, a file style detection model is used to perform style detection to obtain the target style vector; wherein, the file style detection model is obtained by training with training data having actual style vector labels, and the training data is obtained by filtering from each of the historical files based on the edited file filtering conditions.
3. The document stylization processing method as described in claim 2, characterized in that, The document style detection model includes a document normalization processing module, a style extraction module, and an output module; The step of performing style detection using a file style detection model based on the target historical edited file and the target historical unedited file to obtain the target style vector specifically includes: The file normalization processing module performs normalization processing on the target historical edit file and the target historical unedited file to obtain content vectors of different data types corresponding to the target historical edit file and the target historical unedited file; wherein, the content vector includes any first content vector of the target historical edit file after normalization processing and any second content vector of the target historical unedited file after normalization processing, and the data type corresponding to the first content vector is the same as the data type corresponding to the second content vector; The style extraction module performs non-linear compression on the content vector to obtain user style features. The output module performs vectorization transformation on the user style features to obtain the target style vector.
4. The document stylization processing method as described in claim 3, characterized in that, The step of normalizing the target historical edit file and the target historical unedited file through the file normalization processing module to obtain content vectors of different data types corresponding to the target historical edit file and the target historical unedited file specifically includes: The file normalization processing module segments the target historical edit file and the target historical pre-edit file according to the data type to obtain one or more sets of file content segments corresponding to different data types; wherein, each set of file content segments includes any first content segment in the target historical edit file and any second content segment in the target historical pre-edit file, and the data type corresponding to the first content segment is the same as the data type corresponding to the second content segment; When the data type corresponding to the content segment is text data, the content segment is converted into a first BERT word vector, and the first BERT word vector is weighted and transformed using at least two neural network layers according to a preset style validity weight, style transfer weight and position coefficient matrix to obtain the content vector corresponding to the content segment. When the data type corresponding to the content segment is image data, the content segment is converted into a first grayscale two-dimensional matrix, and the first grayscale two-dimensional matrix is subjected to convolution operation and vectorization transformation processing to obtain the content vector corresponding to the content segment. When the data type corresponding to the content segment is video data, the content segment is converted into a first three-dimensional matrix, and the first three-dimensional matrix is subjected to convolution operation and vectorization transformation processing to obtain the content vector corresponding to the content segment; wherein, the first three-dimensional matrix is used to represent the grayscale pixel value of any image frame of the content segment.
5. The document stylization processing method as described in claim 2, characterized in that, The loss function of the document style detection model is constructed based on the difference between the derived style vector generated by style detection on the training data and the actual style vector label.
6. The document stylization processing method as described in claim 2, characterized in that, The specific conditions for filtering edited files are as follows: when the historical file does not belong to the training data, the historical file is a readable file, the editing operation user and the editable user of the historical file are both the target user, the historical file is a unique file and there exists a corresponding historical file before editing, the historical file is determined to be the target historical edited file that meets the conditions for filtering edited files.
7. The document stylization processing method as described in claim 1, characterized in that, The process of stylizing the target rich text file based on the target user's target style vector to obtain a target stylized file specifically includes: The target rich text file is split into one or more rich text segments according to data type; Based on the target style vector, the rich text segments are stylized using a stylization processing model to obtain one or more stylized rich text segments; wherein, the stylization processing model is obtained by training on each of the target user's historical edit files, as well as the historical pre-edit files and editing style tags corresponding to the historical edit files; The target stylized file is obtained based on each of the stylized rich text segments.
8. The document stylization processing method as described in claim 7, characterized in that, The stylization processing model includes an input transformation module, an abstract feature extraction module, a stylization transformation module, and an output module; The step of stylizing the rich text segments based on the target style vector using a stylization processing model to obtain one or more stylized rich text segments specifically includes: The input conversion module performs vector conversion processing on the rich text segments according to the data type to obtain rich text segment vectors. The abstract feature extraction module performs nonlinear compression on the rich text segmentation vector to obtain the rich text connotation feature vector. The stylization conversion module fuses the rich text feature vector with the target style vector to obtain the stylization conversion result corresponding to the rich text segment. The output module performs rich text segmentation restoration on the stylized conversion result according to the data type to obtain the stylized rich text segments.
9. The document stylization processing method as described in claim 8, characterized in that, The step of performing vector conversion processing on the rich text segments according to the data type through the input conversion module to obtain rich text segment vectors specifically includes: When the data type of the rich text segment is text data, the rich text segment is converted into a second BERT word vector, and weights, style open weights, style transfer weights, style conversion weights and position coefficient matrices are extracted according to preset styles. The second BERT word vector is weighted and transformed using at least two neural network layers to obtain the rich text segment vector. When the data type of the rich text segment is image data, the rich text segment is converted into a second grayscale two-dimensional matrix, and the second grayscale two-dimensional matrix is subjected to convolution operation and vectorization transformation processing to obtain the rich text segment vector. When the data type of the rich text segment is video data, the rich text segment is converted into a second three-dimensional matrix, and the second three-dimensional matrix is subjected to convolution operation and vectorization transformation processing to obtain the rich text segment vector; wherein, the second three-dimensional matrix is used to represent the grayscale pixel value of any image frame of the rich text segment.
10. The document stylization processing method as described in claim 7, characterized in that, The step of obtaining the target stylized file based on each of the stylized rich text segments specifically includes: Based on the file format of the target rich text file, the stylized rich text segments are concatenated to obtain the target stylized file.
11. The document stylization processing method as described in claim 7, characterized in that, The loss function of the stylization model is constructed based on the difference between the stylized file and the historical edited file; the stylized file is generated by the stylization model based on the editing style tags to stylize the historical unedited file.
12. A document stylization processing device, characterized in that, include: The file acquisition module is used to acquire the target rich text file to be stylized; wherein, the target rich text file is generated by a large model; The file stylization processing module is used to stylize the target rich text file based on the target user's target style vector to obtain a target stylized file; wherein, the target style vector is obtained by style detection of the target user's target historical edit files; The file feedback module is used to send the target stylized file back to the target user.
13. The document stylization processing apparatus as described in claim 12, characterized in that, The device obtains the target style vector through the following steps: Select several target historical edit files that meet the preset editing file filtering conditions from each of the target user's historical files, and obtain the target historical file before editing corresponding to the target historical edit files; Based on the target historical edited file and the target historical file before editing, a file style detection model is used to perform style detection to obtain the target style vector; wherein, the file style detection model is obtained by training with training data having actual style vector labels, and the training data is obtained by filtering from each of the historical files based on the edited file filtering conditions.
14. The document stylization processing apparatus as described in claim 13, characterized in that, The document style detection model includes a document normalization processing module, a style extraction module, and an output module; The device is used to perform style detection using a file style detection model based on the target historical edited file and the target historical file before editing, to obtain the target style vector, specifically including: The file normalization processing module performs normalization processing on the target historical edit file and the target historical unedited file to obtain content vectors of different data types corresponding to the target historical edit file and the target historical unedited file; wherein, the content vector includes any first content vector of the target historical edit file after normalization processing and any second content vector of the target historical unedited file after normalization processing, and the data type corresponding to the first content vector is the same as the data type corresponding to the second content vector; The style extraction module performs non-linear compression on the content vector to obtain user style features. The output module performs vectorization transformation on the user style features to obtain the target style vector.
15. The document stylization processing apparatus as described in claim 14, characterized in that, The device is used to perform normalization processing on the target historical edit file and the target historical unedited file through the file normalization processing module, to obtain content vectors of different data types corresponding to the target historical edit file and the target historical unedited file, specifically including: The file normalization processing module segments the target historical edit file and the target historical pre-edit file according to the data type to obtain one or more sets of file content segments corresponding to different data types; wherein, each set of file content segments includes any first content segment in the target historical edit file and any second content segment in the target historical pre-edit file, and the data type corresponding to the first content segment is the same as the data type corresponding to the second content segment; When the data type corresponding to the content segment is text data, the content segment is converted into a first BERT word vector, and the first BERT word vector is weighted and transformed using at least two neural network layers according to a preset style validity weight, style transfer weight and position coefficient matrix to obtain the content vector corresponding to the content segment. When the data type corresponding to the content segment is image data, the content segment is converted into a first grayscale two-dimensional matrix, and the first grayscale two-dimensional matrix is subjected to convolution operation and vectorization transformation processing to obtain the content vector corresponding to the content segment. When the data type corresponding to the content segment is video data, the content segment is converted into a first three-dimensional matrix, and the first three-dimensional matrix is subjected to convolution operation and vectorization transformation processing to obtain the content vector corresponding to the content segment; wherein, the first three-dimensional matrix is used to represent the grayscale pixel value of any image frame of the content segment.
16. The document stylization processing apparatus as described in claim 13, characterized in that, The loss function of the document style detection model is constructed based on the difference between the derived style vector generated by style detection on the training data and the actual style vector label.
17. The document stylization processing apparatus as described in claim 13, characterized in that, The specific conditions for filtering edited files are as follows: when the historical file does not belong to the training data, the historical file is a readable file, the user who performs the editing operation and the user who can edit the historical file are both the target user, the historical file is a unique file and there exists a corresponding historical file before editing, the historical file is determined to be a historical edited file that meets the conditions for filtering edited files.
18. The document stylization processing apparatus as described in claim 12, characterized in that, The file stylization processing module is used to stylize the target rich text file based on the target user's target style vector to obtain a target stylized file, specifically including: The target rich text file is split into one or more rich text segments according to data type; Based on the target style vector, the rich text segments are stylized using a stylization processing model to obtain one or more stylized rich text segments; wherein, the stylization processing model is obtained by training on each of the target user's historical edit files, as well as the historical pre-edit files and editing style tags corresponding to the historical edit files; The target stylized file is obtained based on each of the stylized rich text segments.
19. The document stylization processing apparatus as described in claim 18, characterized in that, The stylization processing model includes an input transformation module, an abstract feature extraction module, a stylization transformation module, and an output module; The document stylization processing module is used to stylize the rich text segments according to the target style vector using a stylization processing model, to obtain one or more stylized rich text segments, specifically including: The input conversion module performs vector conversion processing on the rich text segments according to the data type to obtain rich text segment vectors. The abstract feature extraction module performs nonlinear compression on the rich text segmentation vector to obtain the rich text connotation feature vector. The stylization conversion module fuses the rich text feature vector with the target style vector to obtain the stylization conversion result corresponding to the rich text segment. The output module performs rich text segmentation restoration on the stylized conversion result according to the data type to obtain the stylized rich text segments.
20. The document stylization processing apparatus as described in claim 19, characterized in that, The document stylization processing module is used to perform vector transformation processing on the rich text segments according to the data type through the input conversion module to obtain rich text segment vectors, specifically including: When the data type of the rich text segment is text data, the rich text segment is converted into a second BERT word vector, and weights, style open weights, style transfer weights, style conversion weights and position coefficient matrices are extracted according to preset styles. The second BERT word vector is weighted and transformed using at least two neural network layers to obtain the rich text segment vector. When the data type of the rich text segment is image data, the rich text segment is converted into a second grayscale two-dimensional matrix, and the second grayscale two-dimensional matrix is subjected to convolution operation and vectorization transformation processing to obtain the rich text segment vector. When the data type of the rich text segment is video data, the rich text segment is converted into a second three-dimensional matrix, and the second three-dimensional matrix is subjected to convolution operation and vectorization transformation processing to obtain the rich text segment vector; wherein, the second three-dimensional matrix is used to represent the grayscale pixel value of any image frame of the rich text segment.
21. The document stylization processing apparatus as described in claim 18, characterized in that, The file stylization processing module is used to obtain the target stylized file based on each of the stylized rich text segments, specifically including: Based on the file format of the target rich text file, the stylized rich text segments are concatenated to obtain the target stylized file.
22. The document stylization processing apparatus as described in claim 18, characterized in that, The loss function of the stylization model is constructed based on the difference between the stylized file and the historical edited file; the stylized file is generated by the stylization model based on the editing style tags to stylize the historical unedited file.
23. An electronic device, characterized in that, The system includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the computer program, implements the document stylization processing method according to any one of claims 1 to 11.
24. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a stored computer program, wherein, when the computer program is executed, it controls the device on which the computer-readable storage medium is located to perform the document stylization processing method according to any one of claims 1 to 11.
25. A computer program product, characterized in that, Includes a computer program / instruction that, when executed by a processor, implements the steps of the document stylization processing method according to any one of claims 1 to 11.