Text classification method and system based on vision generation
By training a visual generator to generate visual images, it solves the problem of lack of matching images in multi-modal processing, improves the accuracy and efficiency of text classification, and provides better interpretability.
Patent Information
- Application Number
- PCT/CN2024/084479
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-04-28
- Filing Date
- 2024-03-28
- Publication Date
- 2024-10-31
AI Technical Summary
In the absence of images that match the text, existing multi-modal text classification methods are difficult to apply to various text classification fields, limiting their accuracy and efficiency in text classification.
By training the visual generator, using the generative model and the discriminative model, the visual image corresponding to the input text is generated, thereby performing multi-modal processing without the need for actual image input, and improving the accuracy and efficiency of text classification.
It improves the accuracy and efficiency of text classification without relying on time-consuming and labor-intensive text and image matching collection work, and provides better interpretability, and enhances the richness of text features through the generated visual images. Modal representation.
Smart Images

Figure CN2024084479_31102024_PF_FP_ABST
Abstract
Description
A text classification method and system integrating generative vision
[0001] This application claims priority to Chinese patent application 202310491247.7, filed on April 28, 2023, and entitled “A text classification method and system for fusion generative vision”. The entire disclosure of this Chinese patent application is incorporated herein by reference. Technical Field
[0002] The present application relates to multimodal processing technology, and more specifically to a text classification method and system for integrating generated vision, a method and system for training a vision generator, and a computer-readable storage medium for implementing the above method. Background Art
[0003] With the development of artificial intelligence, the technology of using machine learning to classify information based on a single modality has become very mature. As information content becomes increasingly rich, it is often necessary to comprehensively judge content classification based on information from multiple modalities. For example, merchants are divided based on multiple modalities of information such as text, images, and structured table data in user reviews. With the development of multimodal processing methods in the field of artificial intelligence, it is expected that multimodal processing methods will be introduced into a variety of classification scenarios.
[0004] Currently, multimodal text classification methods add matching images to the text input as additional information to improve the accuracy of the model's classification results. However, in many scenarios, it is difficult to obtain matching images as additional information for the model, which greatly limits the application of multimodal text classification methods in various text classification fields.
[0005] Summary of the Invention
[0006] In order to solve or at least alleviate the above problems, this application provides the following technical solutions.
[0007] According to a first aspect of the present application, a method for training a visual generator is provided, wherein the visual generator includes a generative model and a discriminative model, and the method includes the following steps: obtaining a text feature vector of each text of a plurality of texts and a visual image corresponding to each text as a generative model training set; using the generative model training set to train the generative model to obtain a trained generative model; using the trained generative model to process the text feature vector of the input text to generate a visual image set corresponding to the text feature vector of the input text; and using at least the visual image set and the annotated image set as a discriminative model training set to train the discriminative model to obtain a trained discriminative model.
[0008] According to the method for training a visual generator described in one embodiment of the present application, obtaining a text feature vector for each of a plurality of texts includes: obtaining a plurality of texts from a text database; preprocessing each of the plurality of texts, wherein the preprocessing is used to filter out symbols and stop words in the text; and generating the text feature vector from the preprocessed text.
[0009] According to the method for training a visual generator according to one embodiment or any of the above embodiments of the present application, the discriminant model training set also includes a label set corresponding to the visual image set and a label set corresponding to the annotated image set.
[0010] According to the method for training a visual generator according to one embodiment of the present application or any of the above embodiments, wherein the generative model is trained using the generative model training set, the generative model is trained using the generative model training set so that the generative model learns to generate a visual image corresponding to the text based on the text feature vector of the text.
[0011] According to the method for training a visual generator according to one embodiment of the present application or any of the above embodiments, the generative model is constructed based on one or more of the following: a generative adversarial network, a variational autoencoder, and a flow-based generative model.
[0012] The method for training a visual generator according to one embodiment or any one of the above embodiments of the present application, wherein at least the visual image set and the annotated image set are used as the discriminant model training set to train the discriminant model, comprises: using the discriminant model training set to train the discriminant model, so that the discriminant model learns to generate a score for each visual image in the visual image set based on the visual image set, the score indicating the quality of each visual image and the correlation between the input text and the corresponding visual image in the visual image set.
[0013] According to the method for training a visual generator according to one embodiment or any one of the above embodiments of the present application, the method further includes: constructing an objective function for training the generative model and the discriminative model, the objective function including a first objective function and a second objective function; using the discriminative model training set to maximize the first objective function and the second objective function when the generative model is fixed, to train the discriminative model, to obtain a trained discriminative model; and using the discriminative model training set to minimize the second objective function when the trained discriminative model is fixed, to obtain a trained generative model.
[0014] According to the method for training a visual generator according to one embodiment of the present application or any of the above embodiments, the first objective function is used to determine the probability that the trained discriminant model discriminates the real samples of the annotated image set in the discriminant model training set as true.
[0015] According to the method for training a visual generator according to one embodiment or any one of the above embodiments of the present application, the second objective function is used to determine the distance between the visual images in the visual image set in the discriminant model training set and the real samples of the labeled image set.
[0016] According to the method for training a visual generator according to one embodiment or any one of the above embodiments of the present application, the method further includes: alternatingly performing the steps of training the discriminant model and training the generative model; obtaining a discriminant model determined in response to the sum of the probability determined by the first objective function and the distance determined by the second objective function being greater than a first threshold; and obtaining a generative model determined in response to the distance determined by the second objective function being less than a second threshold.
[0017] According to the method for training a visual generator according to one embodiment of the present application or any of the above embodiments, the method further includes: obtaining a trained visual generator based on the determined discriminant model and the determined generative model.
[0018] According to a second aspect of the present application, a system for training a visual generator is provided, wherein the visual generator includes a generative model and a discriminative model, and the system includes: an acquisition unit configured to acquire a text feature vector of each of a plurality of texts and a visual image corresponding to each text as a generative model training set; a first training unit configured to train the generative model using the generative model training set to obtain a trained generative model; a processing unit configured to process the text feature vector of an input text using the trained generative model to generate a visual image set corresponding to the text feature vector of the input text; and a second training unit configured to train the discriminative model using at least the visual image set and the annotated image set as a discriminative model training set to obtain a trained discriminative model.
[0019] According to a third aspect of the present application, a computer-readable storage medium is provided, which includes instructions, and the instructions, when run, execute the steps of the method for training a visual generator according to the first aspect of the present application.
[0020] According to the fourth aspect of the present application, a method for classifying text is provided, the method comprising the following steps: obtaining a text feature vector of the text to be processed; generating a visual image based on the text feature vector of the text to be processed and random noise using a visual generator, wherein the visual generator is trained using the method for training a visual generator according to the first aspect of the present application; encoding the text feature vector to obtain a semantic code, and encoding the visual image to obtain a visual code; and combining the semantic code and the visual code and generating a classification result for the text to be processed based on the combination of the semantic code and the visual code.
[0021] According to a fifth aspect of the present application, a system for classifying text is provided, the system comprising: an acquisition unit configured to acquire a text feature vector of a text to be processed; a visual generator configured to generate a visual image based on the text feature vector of the text to be processed and random noise, wherein the visual generator is trained using the method for training a visual generator according to the first aspect of the present application; an encoding unit configured to encode the text feature vector to obtain a semantic encoding, and to encode the visual image to obtain a visual encoding; and a processing unit configured to combine the semantic encoding and the visual encoding and generate a classification result for the text to be processed based on the combination of the semantic encoding and the visual encoding.
[0022] According to a sixth aspect of the present application, a computer-readable storage medium is provided, which includes instructions, and the instructions, when run, execute the steps of the method for classifying text according to the fourth aspect of the present application.
[0023] In some embodiments of the present application, a trained visual generator can be used to generate a visual image corresponding to the text to be processed based on the text feature vector of the text to be processed and random noise, and a classification result for the text to be processed can be generated based on a combination of the semantic encoding of the text feature vector of the text to be processed and the visual encoding of the visual image. As a result, the multimodal processing method can be introduced into the text classification scenario while eliminating the time-consuming and labor-intensive work of collecting text and images matching the text, thereby improving the accuracy and efficiency of text classification. In addition, by using a trained visual generator to generate a visual image corresponding to the text to be processed, multimodal graphic and text data of the text to be processed can be obtained based on the text feature vector of the text to be processed, which has better interpretability than traditional text classification methods. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] The above and / or other aspects and advantages of the present application will become clearer and easier to understand through the following description of various aspects in conjunction with the accompanying drawings, in which the same or similar elements are represented by the same reference numerals. The accompanying drawings include:
[0025] FIG1 shows a flowchart of a method for training a vision generator according to one or more embodiments of the present application.
[0026] FIG2 shows a block diagram of a system for training a vision generator according to one or more embodiments of the present application.
[0027] FIG3 shows a flowchart of a method for classifying text according to one or more embodiments of the present application.
[0028] FIG4 shows a block diagram of a system for classifying text according to one or more embodiments of the present application.
[0029] FIG5 shows a block diagram of a system for classifying text according to one or more embodiments of the present application. DETAILED DESCRIPTION
[0030] The present application is described more fully below with reference to the accompanying drawings, which illustrate exemplary embodiments of the present application. However, the present application may be implemented in various forms and should not be construed as being limited to the embodiments set forth herein. The foregoing embodiments are provided to make the disclosure herein comprehensive and complete, so as to more fully convey the scope of protection of the present application to those skilled in the art.
[0031] In this specification, terms such as "comprise" and "include" indicate that in addition to the units and steps directly and clearly stated in the specification and claims, the technical solution of this application does not exclude the situation where it has other units and steps that are not directly or clearly stated.
[0032] Unless otherwise specified, terms such as "first" and "second" do not indicate the order of units in terms of time, space, size, etc., but are only used to distinguish between units.
[0033] Hereinafter, various exemplary embodiments according to the present application will be described in detail with reference to the accompanying drawings.
[0034] FIG1 shows a flowchart of a method for training a visual generator according to one or more embodiments of the present application, wherein the visual generator includes a generative model and a discriminative model.
[0035] As shown in FIG1 , in step 101 , a text feature vector of each text of a plurality of texts and a visual image corresponding to each text are obtained as a generation model training set.
[0036] Optionally, in step 101, a plurality of texts may be obtained from a text database, each of the plurality of texts may be preprocessed to filter out useless words such as symbols (e.g., punctuation marks) and stop words (e.g., modal particles) in the text, and a text feature vector may be generated from the preprocessed text. For example, the text database may include a patent database (e.g., including text content such as patent titles, specification texts, and abstract texts), a user review database including user review texts, and text databases in various other fields.
[0037] For example, the text feature vectors of multiple texts can be expressed as T = {t1, t2, t3, ... tN}, Where tN represents the text feature vector of the Nth text, N represents the number of training data in the training set of the generated model, dt represents the vector dimension, and Represents a vector of dt dimensions. For example, the visual image corresponding to each text can be represented as X = {x1, x2, ..., xN}, Where xN represents the visual image corresponding to the Nth text, N represents the number of training data in the generative model training set, dm×dn represents the vector dimension, and Represents a vector of dm×dn dimensions. When obtaining T={t1,t2,t3,…tN}, and X = {x1, x2, …, xN}, Afterwards, the generated model training set can be represented as {T,X}.
[0038] In step 103, the generative model is trained using the generative model training set to obtain a trained generative model.
[0039] Optionally, the generative model can be constructed based on generative adversarial networks (GAN), variational auto encoder (VAE), flow-based generation model (FLOW-based Model), etc.
[0040] Optionally, in step 103, the generative model training set may be used to train the generative model, so that the generative model learns to generate a visual image corresponding to the text based on the text feature vector of the text, to obtain a trained generative model.
[0041] In step 105 , the text feature vector of the input text is processed using the trained generative model to generate a set of visual images corresponding to the text feature vector of the input text.
[0042] Optionally, in step 105, a trained generative model may be used to generate a set of visual images corresponding to the text feature vector of the input text based on the text feature vector of the input text after dimension transformation and random noise. For example, the text feature vector of the input text after dimension transformation may be represented as in represents the vector dimension, and express For example, the random noise can be selected to obey the standard normal distribution N(0,1), which can be expressed as where z represents random noise, Represents a vector of d dimensions. For example, the set of visual images generated by the trained generative model can be represented as in represents the visual image generated by the trained generative model processing the text feature vector of the Nth input text, N represents the number of text feature vectors of the input text, dm×dn represents the vector dimension, and Represents a vector of dimensions dm×dn.
[0043] In step 107 , at least the visual image set and the annotated image set are used as a discriminant model training set to train the discriminant model to obtain a trained discriminant model.
[0044] For example, the annotated image set can be represented as X = {x1, x2, ..., xN}, Where xN represents the annotated image corresponding to the Nth text, N represents the number of annotated images, dm×dn represents the vector dimension, and represents a vector of dm×dn dimensions. Optionally, the discriminant model training set may also include a set of visual images corresponding to The label set L1 and the label set L2 corresponding to the annotated image set X. Thus, the discriminant model training set can be expressed as For example, corresponding to the visual image set Each element in the label set L1 of can be set to 0, and each element in the label set L2 corresponding to the annotated image set X can be set to 1.
[0045] Optionally, in step 107, the discriminant model training set can be used to train the discriminant model, so that the discriminant model learns to generate a score for each visual image in the visual image set based on the visual image set, and the score indicates the quality of each visual image and the correlation between the input text and the corresponding visual image in the visual image set.
[0046] Optionally, in the process of training the generative model and the discriminant model, an objective function for training the generative model and the discriminant model can be constructed, and the objective function can include a first objective function and a second objective function. In the process of training the generative model and the discriminant model, the discriminant model can first be trained using the discriminant model training set with the goal of maximizing the first objective function and the second objective function under the condition of a fixed generative model, thereby obtaining a trained discriminant model, thereby improving the discriminant ability of the discriminant model. Then, the generative model can be trained using the discriminant model training set with the goal of minimizing the second objective function under the condition of a fixed trained discriminant model, thereby improving the generative ability of the generative model. Optionally, the first objective function can be used to determine the probability that the trained discriminant model will discriminate the real samples of the annotated image set in the discriminant model training set as true, and the second objective function can be used to determine the distance between the visual images in the visual image set in the discriminant model training set and the real samples of the annotated image set.
[0047] For example, the objective function for training the generative model and the discriminative model can be constructed by the following formula (1):
[0048] in, represents the first objective function, represents the second objective function, D represents the discriminant model, G represents the generative model, x represents each labeled image in the labeled image set X, The text feature vector representing the dimension-transformed input text, Represents a set of visual images generated by a visual generator The various visual images in .
[0049] Optionally, the steps of training the discriminant model and training the generative model can be performed alternately, that is, alternately: using the discriminant model training set to maximize the generative model G while fixing the generative model G To train the discriminant model D as the target, obtain the trained discriminant model; in the case of a fixed trained discriminant model, use the discriminant model training set to minimize As the goal to train the generative model G, the trained generative model is obtained. When the first objective function Determined probability and second objective function When the sum of the determined distances is greater than the first threshold, the training of the discriminant model D can be stopped to obtain a determined discriminant model; when the second objective function When the determined distance is less than the second threshold, the training of the generative model G can be stopped to obtain the determined generative model. Finally, the trained visual generator G can be obtained based on the determined discriminant model and the determined generative model. final, where the trained visual generator G final It can be expressed by formula (2):
[0050] in, z represents random noise, Represents a vector of d dimensions, and N(0,1) represents the standard normal distribution. The text feature vector representing the dimension-transformed input text, in represents the vector dimension, and express A vector of dimensions. Represents the visual generator G final The generated visual image, dm×dn represents the vector dimension, and Represents a vector of dimensions dm×dn.
[0051] According to one or more embodiments of the present application, the method for training a visual generator can divide the visual generator into a generative model and a discriminative model and train them separately. By constructing an objective function including a first objective function and a second objective function for training the generative model and the discriminative model, the generative model and the discriminative model are alternately trained, thereby improving the model training efficiency and the generation ability of the generative model and the discrimination ability of the discriminative model, thereby improving the quality of the visual image corresponding to the text generated by the visual generator and the correlation between the visual image and the text.
[0052] FIG2 shows a block diagram of a system for training a vision generator according to one or more embodiments of the present application.
[0053] As shown in FIG. 2 , a system 200 for training a visual generator may include an acquisition unit 210 , a first training unit 220 , a processing unit 230 , and a second training unit 240 .
[0054] The acquisition unit 210 may be configured to acquire a text feature vector of each text of a plurality of texts and a visual image corresponding to each text as a generation model training set.
[0055] Optionally, the acquisition unit 210 can be configured to acquire multiple texts from a text database, preprocess each of the multiple texts to filter out useless words such as symbols (e.g., punctuation marks) and stop words (e.g., modal particles) in the text, and generate a text feature vector from the preprocessed text. For example, the text database may include a patent database (e.g., including text content such as patent titles, specification texts, and abstract texts), a user review database containing user review texts, and text databases in various other fields.
[0056] The first training unit 220 may be configured to train the generative model using the generative model training set to obtain a trained generative model.
[0057] Optionally, the generative model can be constructed based on generative adversarial networks (GAN), variational auto encoder (VAE), flow-based generation model (FLOW-based Model), etc.
[0058] Optionally, the first training unit 220 can be configured to train the generative model using the generative model training set, so that the generative model learns to generate a visual image corresponding to the text based on the text feature vector of the text, to obtain a trained generative model.
[0059] The processing unit 230 may be configured to process the text feature vector of the input text using the trained generative model to generate a set of visual images corresponding to the text feature vector of the input text.
[0060] Optionally, the processing unit 230 may be configured to generate a visual image set corresponding to the text feature vector of the input text based on the text feature vector of the dimensionally transformed input text and random noise using the trained generative model. For example, the random noise may follow a standard normal distribution.
[0061] The second training unit 240 may be configured to use at least the visual image set and the annotated image set as a discriminant model training set to train the discriminant model to obtain a trained discriminant model.
[0062] Optionally, the discriminant model training set may further include a label set corresponding to the visual image set and a label set corresponding to the annotated image set. For example, each element in the label set corresponding to the visual image set may be set to 0, and each element in the label set corresponding to the annotated image set may be set to 1.
[0063] Optionally, the second training unit 240 can be configured to train the discriminant model using the discriminant model training set, so that the discriminant model learns to generate a score for each visual image in the visual image set based on the visual image set, and the score indicates the quality of each visual image and the correlation between the input text and the corresponding visual image in the visual image set.
[0064] According to one or more embodiments of the present application, the system 200 for training a visual generator may further include a third training unit, which may be configured to construct an objective function for training the generative model and the discriminative model during the process of training the generative model and the discriminative model, and the objective function may include a first objective function and a second objective function.
[0065] In the process of training the generative model and the discriminative model, the third training unit can be configured to first train the discriminative model using the discriminative model training set with the goal of maximizing the first objective function and the second objective function when the generative model is fixed, thereby obtaining a trained discriminative model, thereby improving the discriminative ability of the discriminative model. Then, the third training unit can be configured to train the generative model using the discriminative model training set with the goal of minimizing the second objective function when the discriminative model is fixed, thereby improving the generative ability of the generative model. Optionally, the first objective function can be used to determine the probability that the trained discriminative model will discriminate as true the real samples of the annotated image set in the discriminative model training set, and the second objective function can be used to determine the distance between the visual images in the visual image set in the discriminative model training set and the real samples of the annotated image set.
[0066] Optionally, the third training unit can be further configured to alternately perform the steps of training the discriminant model and training the generative model, that is, alternately perform: in the case of a fixed generative model, use the discriminant model training set to maximize the first objective function and the second objective function to train the discriminant model to obtain a trained discriminant model; in the case of a fixed trained discriminant model, use the discriminant model training set to minimize the second objective function to train the generative model to obtain a trained generative model. When the sum of the probability determined by the first objective function and the distance determined by the second objective function is greater than the first threshold, the third training unit can stop training the discriminant model to obtain a determined discriminant model; when the distance determined by the second objective function is less than the second threshold, the third training unit can stop training the generative model to obtain a determined generative model. Finally, the third training unit can obtain a trained visual generator G based on the determined discriminant model and the determined generative model. final .
[0067] FIG3 shows a flowchart of a method for classifying text according to one or more embodiments of the present application.
[0068] As shown in FIG3 , in step 301 , a text feature vector of a text to be processed is obtained.
[0069] Optionally, in step 301, the text to be processed may be preprocessed to filter out useless words such as symbols (e.g., punctuation marks) and stop words (e.g., modal particles) in the text to be processed, and a text feature vector may be generated from the preprocessed text. For example, the text to be processed may include text from a patent database (e.g., including text content such as patent titles, specification text, and abstract text), a user review database containing user review text, and text databases in various other fields.
[0070] In step 303, a visual generator is used to generate a visual image based on the text feature vector of the text to be processed and random noise, wherein the visual generator can be trained using the method for training a visual generator described in one aspect of the present application, for example, the method for training a visual generator described in conjunction with FIG1 . Optionally, the random noise can follow a standard normal distribution.
[0071] In step 305 , the text feature vector is encoded to obtain a semantic code, and the visual image is encoded to obtain a visual code.
[0072] Optionally, in step 305, a semantic encoder such as a BERT-base model, an ERNIE model, or a GPT model may be used to encode the text feature vector, and a graph encoder such as a VGG model or a ResNet model may be used to encode the visual image.
[0073] In step 307 , the semantic code and the visual code are combined and a classification result for the text to be processed is generated based on the combination of the semantic code and the visual code.
[0074] Optionally, in step 307, the semantic code and the visual code can be combined in a splicing manner, and the combination of the semantic code and the visual code can be input into the classification model to obtain a classification result for the text to be processed, and the classification result indicates the category to which the text to be processed belongs.
[0075] The following will take the classification of patent texts (eg, patent technical briefing documents, patent application documents, etc.) as an example to further describe the specific implementation of the method for classifying texts according to one or more embodiments of the present application.
[0076] In one embodiment, multiple patent texts can be obtained from a patent database, which can include text content of categories such as patent titles, specification texts, and abstract texts. For example, each category can include 1,000 pieces of data, and the actual classification corresponding to the text content of each category can be pre-labeled, of which 80% of the data can be used to train the classification model and 20% of the data can be used to test the classification model. In one embodiment, taking the IPC classification department system as an example, namely A: human life needs, B: operations, transportation, C: chemistry, metallurgy, D: textiles, papermaking, E: fixed structures, F: mechanical engineering, lighting..., G: physics, H: electricity, the above 8 categories can be used to pre-label the actual classification corresponding to the text content of each category.
[0077] Optionally, the obtained multiple patent texts can be preprocessed to filter out useless words such as symbols (e.g., punctuation marks) and stop words (e.g., modal particles) in the patent texts, and a text feature vector T = {t1, t2, t3, ... tN} is generated from the preprocessed patent texts. For example, N = 7000, dt = 512, where tN represents the text feature vector of the Nth text, N represents the number of training data and test data, dt represents the vector dimension, and Represents a vector of dimension dt. Optionally, a label set can be used to annotate each text feature vector in the text feature vector T = {t1, t2, t3, ... tN}, that is, the label set is Y = {A, B, D, ..., F}. Thus, a portion of the text feature vector T = {t1, t2, t3, ... tN} and the label set Y = {A, B, D, ..., F} of each text feature vector can be used as training data, and the remaining portion can be used as test data to train and test the classification model respectively.
[0078] Optionally, a visual image corresponding to each patent text can also be obtained, which can be expressed as X = {x1, x2, ..., xN}, For example, N = 8000, dm = 28, dn = 28, where xN represents the visual image corresponding to the Nth patent text, N represents the number of training data in the training set of the generative model, dm×dn represents the vector dimension, and represents a vector of dm×dn dimensions. Optionally, the generative model training set can be represented as {T, X}, so as to train the generative model using the generative model training set {T, X}.
[0079] Optionally, the generative model obtained by training according to the method for training a visual generator described in one aspect of the present application can be expressed as:
[0080] In formula (3), G represents the generative model obtained through training, z represents random noise, represents a vector of d dimensions, N(0,1) represents the standard normal distribution, The text feature vector representing the dimension-transformed input text, in represents the vector dimension, and express A vector of dimension, represents the visual image generated by the generative model, dm×dn represents the vector dimension, and represents a vector of dm×dn dimensions. In formula (4), represents the fully connected layer parameters, t represents the text feature vector of the input text, Denotes bias. Formula (5) represents the initial layer L0 of the neural network, where represents the output of the initial layer L0 of the neural network, Indicates z and The splicing, Represents a vector of 100+10 dimensions. Formula (6) represents the first layer L of the neural network g1 ,in Represents the first layer L of the neural network g1 The output of Relu(x)=max(0,x), W g1 T represents the fully connected layer parameters, b g1 Indicates the bias of the layer, Represents a 128-dimensional vector. Formula (7) represents the second layer L of the neural network g2 ,in Represents the second layer L of the neural network g2 Output, W g2 T represents the fully connected layer parameters, b g2 Indicates the bias of the layer, Represents a vector of 1024 dimensions. Formula (8) represents the output layer L of the neural network g3 , in represents the generated visual image, e is the natural base, W g3 T represents the fully connected layer parameters, b g3 Indicates the bias of the layer, Represents a vector of 784 dimensions. For example, the visual image set composed of visual images generated by the generative model can be represented as For example, N=8000.
[0081] Optionally, the discriminant model obtained by training according to the method for training a visual generator described in one aspect of the present application can be expressed as:
[0082] In formula (9), D represents the discriminant model obtained by training, Where X represents the annotated image set, represents a set of visual images, The text feature vector representing the dimension-transformed input text, in represents the vector dimension, and express The score represents the vector of the visual image set generated by the discriminant model D. A score for each visual image in the set of visual images, the score indicating the quality of each visual image and the relationship between the input text and the set of visual images The correlation between the corresponding visual images in . Formula (10) represents the initial layer L0 of the neural network, where represents the output of the initial layer L0 of the neural network, Represents x and The splicing, Represents a vector of 784+10 dimensions. Formula (11) represents the first layer L of the neural network d1 , Represents the first layer L of the neural network d1 The output, α=0.01, W d1 T represents the fully connected layer parameters, b d1 Indicates the bias of the layer, Represents a vector of 1024 dimensions. Formula (12) represents the second layer L of the neural network d2 ,in Represents the second layer L of the neural network d2 Output, W d2 T represents the fully connected layer parameters, b d2 Indicates the bias of the layer, Represents a 128-dimensional vector. Formula (13) represents the output layer score of the neural network, where sigmoid represents the activation function of the neural network, and W d3 T represents the fully connected layer parameters, b d3 Indicates the bias of the layer, Represents a 1-dimensional vector.
[0083] Optionally, a trained visual generator G can be obtained based on the trained discriminant model and generative model. final , where the trained visual generator G final It can be expressed by formula (14):
[0084] Where z represents random noise, Represents a vector of d dimensions, and N(0,1) represents the standard normal distribution. The text feature vector representing the dimension-transformed input text, in represents the vector dimension, and express A vector of dimensions. Represents the visual generator G final The generated visual image, dm×dn represents the vector dimension, and Represents a vector of dm×dn dimensions, for example, dm=28,dn=28.
[0085] Using the trained visual generator G final Generate a text feature vector corresponding to the dimensionally transformed input text Visual image After that, the visual image can be encoded using the graph encoder. Encode to obtain visual encoding. For example, the following formula (15) can be used to encode the visual image Encode to get the visual code V embedding :
[0086] Wherein, Vis() represents the graph encoder model, which can be implemented as a single-channel VGG-19 pre-trained graph encoder model, V embedding represents the visual encoding generated by the graph encoder model, Indicates dv e A vector of dimensions, such as dv e =1000.
[0087] Optionally, a semantic encoder may be used to encode the text feature vector to obtain a semantic code. For example, the following formula (16) may be used to encode the text feature vector t to obtain a semantic code T embedding : T embedding ←Text(t) Formula (16)
[0088] Among them, Text() represents a semantic encoder model, which can be implemented as BERT-base, that is, a pre-trained language model of the BERT base type containing 12-Layer, T embedding represents the semantic encoding generated by the semantic encoder, represents dt e A vector of dimensions, such as dt e =768.
[0089] In generating visual encoding V embedding and semantic encoding T embedding Afterwards, the visual encoding V can be combined embedding and semantic encoding T embedding For example, the following formula (17) can be used to combine the visual code V in a splicing manner: embedding and semantic encoding T embedding :
[0090] Among them, V final Represents the visual code V embedding and semantic encoding T embedding The combination of concat() is the feature fusion function, for example, dt e =768 is semantic coding, dv e =1000 is the visual code, It is a patent feature representation after integrating visual and language modalities.
[0091] After obtaining the patent feature representation V after integrating visual and language modalities final After that, V final Input to the classification model to obtain the patent feature representation V final The classification result indicates that the patent feature represents V final For example, the following formula (18) can be used to convert V final Input to the classification model to obtain the patent feature representation V final The classification results are:
[0092] Among them, classifier() represents the classification model, Represents the category of the classification model output.
[0093] Alternatively, the classification model can be implemented as a model where various input features represent the output of a specific category, for example, as a fully connected layer combined with a softmax() function, that is:
[0094] in, j={1,2,…,K}, K represents the number of categories, e represents the natural base, o=W T V final +b o is a K-dimensional vector, o j represents the jth element of o, W T represents the fully connected layer parameters, represents a vector of 7×1768 dimensions, b o Indicates the bias of the layer, represents the K-dimensional probability vector, The subscript of the maximum probability corresponds to a specific category. For example, when classifying patent texts using the IPC classification system, K = 7, i.e., j = {0, 1, 2, ..., 7}. It is understood that K represents the number of classification categories and is not a fixed value. K can be set to different values according to the requirements of different application scenarios.
[0095] It can be understood that the method for classifying text according to one or more embodiments of the present application can be applied to various text classification scenarios, such as the scenario of a merchant classification recommendation system based on user reviews. For example, the merchant quality can be divided into 7 levels, namely A: very good, B: very good, C: good, D: average, E: poor, F: very poor, G: very poor. By obtaining the user review text as the text to be processed from the user review database and obtaining the text feature vector of the text to be processed, a visual generator trained by the method for training a visual generator according to one aspect of the present application can be used to generate a visual image based on the text feature vector of the text to be processed and random noise, so that a classification result for the text to be processed can be generated based on the combination of the semantic encoding of the text feature vector of the text to be processed and the visual encoding of the visual image, that is, a multimodal text processing method can be used to generate a merchant quality classification level based on the user review text.
[0096] According to one or more embodiments of the present application, the method for classifying text can generate a visual image corresponding to the text to be processed based on the text feature vector of the text to be processed and random noise using a trained visual generator, and generate a classification result for the text to be processed based on a combination of the semantic encoding of the text feature vector of the text to be processed and the visual encoding of the visual image. The present application obtains visual image information corresponding to the text by generating, solving or at least alleviating the problem that in many scenarios, it is difficult to obtain pictures that match the text as additional information input for the classification model. In addition, by using a trained visual generator to generate a visual image corresponding to the text to be processed, it is possible to obtain semantic visualization graphic data of the text to be processed based on the text feature vector of the text to be processed, which has better interpretability than traditional text classification methods.
[0097] FIG4 shows a block diagram of a system for classifying text according to one or more embodiments of the present application.
[0098] As shown in FIG. 4 , a system 400 for classifying text includes an acquisition unit 410 , a visual generator 420 , an encoding unit 430 , and a processing unit 440 .
[0099] The acquisition unit 410 may be configured to acquire a text feature vector of the text to be processed.
[0100] Optionally, the acquisition unit 410 can be configured to pre-process the text to be processed to filter out useless words such as symbols (e.g., punctuation marks) and stop words (e.g., modal particles) in the text to be processed, and generate a text feature vector from the pre-processed text. For example, the text to be processed can include text from a patent database (e.g., including text content such as patent titles, specification texts, and abstract texts), a user review database containing user review texts, and text databases in various other fields.
[0101] The visual generator 420 can be configured to generate a visual image based on a text feature vector of the text to be processed and random noise, wherein the visual generator 420 can be trained using the method for training a visual generator described in one aspect of the present application, for example, the method for training a visual generator described in conjunction with FIG1 . Optionally, the random noise can follow a standard normal distribution.
[0102] The encoding unit 430 may be configured to encode the text feature vector to obtain a semantic code, and to encode the visual image to obtain a visual code.
[0103] Optionally, the encoding unit 430 may include a semantic encoder and a graph encoder. The semantic encoder is used to encode the text feature vector to obtain semantic encoding and can be implemented as a semantic encoder such as a BERT-base model, an ERNIE model, a GPT model, etc. The graph encoder is used to encode the visual image to obtain visual encoding and can be implemented as a graph encoder such as a VGG model, a ResNet model, etc.
[0104] The processing unit 440 may be configured to combine the semantic code and the visual code and generate a classification result for the text to be processed based on the combination of the semantic code and the visual code.
[0105] Optionally, the processing unit 440 may be configured to combine the semantic encoding and the visual encoding in a spliced manner. Optionally, the processing unit 440 may include a classification model configured to obtain a classification result for the text to be processed based on the combination of the semantic encoding and the visual encoding, the classification result indicating the category to which the text to be processed belongs.
[0106] FIG5 shows a block diagram of a system for classifying text according to one or more embodiments of the present application.
[0107] As shown in FIG. 5 , a system 500 for classifying text may include a visual generator 510 , a graph encoder 520 , a semantic encoder 530 , and a processor 540 .
[0108] The visual generator 510 can be configured to generate a visual image based on the text feature vector t of the text to be processed and the random noise z, wherein the visual generator 510 can be trained using the method for training a visual generator described in one aspect of the present application, for example, the method for training a visual generator described in conjunction with FIG1 . Optionally, the random noise z can follow a standard normal distribution.
[0109] The graph encoder 520 may be configured to encode the visual image generated by the visual generator 510 to obtain a visual encoding. Optionally, the graph encoder 520 may be implemented as a graph encoder such as a VGG model or a ResNet model.
[0110] The semantic encoder 530 can be configured to encode the text feature vector t of the text to be processed to obtain a semantic code. Optionally, the semantic encoder 530 can be implemented as a semantic encoder such as a BERT-base model, an ERNIE model, or a GPT model.
[0111] The processor 540 may be configured to combine the visual encoding generated by the graph encoder 520 and the semantic encoding generated by the semantic encoder 530 and generate a classification result for the text to be processed based on the combination of the visual encoding and the semantic encoding.
[0112] Optionally, the processor 540 may include a feature fusion function concat() and a classification model classifier(), the feature fusion function concat() is used to combine semantic coding and visual coding in a splicing manner, and the classification model classifier() is used to obtain a classification result for the text to be processed based on the combination of semantic coding and visual coding, and the classification result indicates the category to which the text to be processed belongs.
[0113] In addition, the present application may also be implemented as a computer-readable storage medium, the computer storage medium including instructions, which when run, execute the method for training a visual generator according to one aspect of the present application. In addition, the present application may also be implemented as a computer-readable storage medium, the computer storage medium including instructions, which when run, execute the method for classifying text according to one aspect of the present application.
[0114] In the applicable situation, the combination of hardware, software or hardware and software can be used to realize the various embodiments provided by the application. Moreover, in the applicable situation, without departing from the scope of the application, the various hardware components and / or software components set forth herein can be combined into a composite component comprising software, hardware and / or both. In the applicable situation, without departing from the scope of the application, the various hardware components and / or software components set forth herein can be divided into a subcomponent comprising software, hardware or both. In addition, in the applicable situation, it is contemplated that the software component can be implemented as a hardware component, and vice versa.
[0115] Software according to the present application (such as program code and / or data) can be stored on one or more computer storage media. It is also contemplated that the software identified herein can be implemented using one or more general or special computers and / or systems that are networked and / or otherwise. Where applicable, the order of the various steps described herein can be changed, combined into composite steps and / or divided into sub-steps to provide the features described herein.
[0116] The embodiments and examples set forth herein are provided to best illustrate embodiments according to the present application and its specific applications, and thereby enable those skilled in the art to make and use the present application. However, those skilled in the art will appreciate that the above description and examples are provided for ease of illustration and example only. The descriptions set forth are not intended to be exhaustive of all aspects of the present application or to limit the present application to the precise forms disclosed.
Claims
1. A method for training a visual generator, characterized in that The visual generator includes a generative model and a discriminative model, and the method includes the following steps: Acquire a text feature vector of each of a plurality of texts and a visual image corresponding to each of the texts as a generation model training set; Using the generative model training set to train the generative model to obtain a trained generative model; Processing the text feature vector of the input text using the trained generative model to generate a set of visual images corresponding to the text feature vector of the input text; as well as At least the visual image set and the annotated image set are used as discriminant model training sets to train the discriminant model to obtain a trained discriminant model.
2. The method according to claim 1, wherein obtaining a text feature vector of each of the plurality of texts comprises: Get multiple texts from a text database; Preprocessing each of the plurality of texts, wherein the preprocessing is used to filter out symbols and stop words in the text; as well as The text feature vector is generated from the preprocessed text.
3. The method according to claim 1, wherein the discriminant model training set further comprises a label set corresponding to the visual image set and a label set corresponding to the annotated image set.
4. The method according to claim 1, wherein using the generative model training set to train the generative model comprises: The generative model is trained using the generative model training set, so that the generative model learns to generate a visual image corresponding to the text based on a text feature vector of the text.
5. The method of claim 1, wherein the generative model is constructed based on one or more of the following: a generative adversarial network, a variational autoencoder, and a flow-based generative model.
6. The method according to claim 1, wherein using at least the visual image set and the annotated image set as a discriminant model training set to train the discriminant model comprises: The discriminant model is trained using the discriminant model training set so that the discriminant model learns to generate a score for each visual image in the visual image set based on the visual image set, the score indicating the quality of each visual image and the relationship between the input text and the visual image set. The correlation between corresponding visual images in .
7. The method according to claim 1, wherein the method further comprises: Constructing an objective function for training the generative model and the discriminative model, wherein the objective function includes a first objective function and a second objective function; Under the condition of fixing the generative model, using the discriminant model training set to train the discriminant model with the goal of maximizing the first objective function and the second objective function to obtain a trained discriminant model; as well as The generative model is trained using the discriminant model training set with the goal of minimizing the second objective function while fixing the trained discriminant model, thereby obtaining a trained generative model.
8. The method according to claim 7, wherein the first objective function is used to determine the probability that the trained discriminant model discriminates the real samples of the annotated image set in the discriminant model training set as true.
9. The method of claim 7, wherein the second objective function is used to determine the distance between the visual images in the visual image set in the discriminant model training set and the real samples in the annotated image set.
10. The method according to any one of claims 7 to 9, wherein the method further comprises: Alternatingly performing the step of training the discriminant model and the step of training the generative model; In response to the sum of the probability determined by the first objective function and the distance determined by the second objective function being greater than a first threshold, a discriminant model is determined; as well as The generative model is determined in response to the distance determined by the second objective function being less than a second threshold.
11. The method according to claim 10, wherein the method further comprises: A trained visual generator is obtained based on the determined discriminant model and the determined generative model.
12. A system for training a visual generator, characterized in that: The visual generator includes a generation model and a discrimination model, and the system includes: An acquisition unit configured to acquire a text feature vector of each of a plurality of texts and a visual image corresponding to each of the texts as a generation model training set; A first training unit, configured to train the generative model using the generative model training set to obtain a trained generative model; a processing unit configured to process the text feature vector of the input text using the trained generative model to generate a set of visual images corresponding to the text feature vector of the input text; and The second training unit is configured to use at least the visual image set and the annotated image set as a discriminant model training set to train the discriminant model to obtain a trained discriminant model.
13. The system according to claim 12, wherein the acquisition unit is further configured to: Get multiple texts from a text database; Preprocessing each of the plurality of texts, wherein the preprocessing is used to filter out symbols and stop words in the text; and The text feature vector is generated from the preprocessed text.
14. The system of claim 12, wherein the discriminative model training set further comprises a label set corresponding to the visual image set and a label set corresponding to the annotated image set.
15. The system according to claim 12, wherein the first training unit is further configured to: The generative model is trained using the generative model training set, so that the generative model learns to generate a visual image corresponding to the text based on a text feature vector of the text.
16. The system of claim 12, wherein the generative model is constructed based on one or more of: a generative adversarial network, a variational autoencoder, and a flow-based generative model.
17. The system according to claim 12, wherein the second training unit is further configured to: The discriminant model is trained using the discriminant model training set so that the discriminant model learns to generate a score for each visual image in the visual image set based on the visual image set, wherein the score indicates the quality of each visual image and the association between the input text and the corresponding visual image in the visual image set.
18. The system according to claim 12, wherein the system further comprises a third training unit, wherein the third training unit is configured to: Constructing an objective function for training the generative model and the discriminative model, wherein the objective function includes a first objective function and a second objective function; Under the condition of fixing the generative model, using the discriminant model training set to train the discriminant model with the goal of maximizing the first objective function and the second objective function, to obtain a trained discriminant model; and The generative model is trained using the discriminant model training set with the goal of minimizing the second objective function while fixing the trained discriminant model, thereby obtaining a trained generative model.
19. The system according to claim 18, wherein the first objective function is used to determine the probability that the trained discriminant model discriminates the real samples of the annotated image set in the discriminant model training set as true.
20. The system of claim 18, wherein the second objective function is used to determine the distance between the visual images in the visual image set in the discriminative model training set and the real samples of the annotated image set.
21. The system according to any one of claims 18-20, wherein the third training unit is further configured to: Alternatingly performing the step of training the discriminant model and the step of training the generative model; In response to the sum of the probability determined by the first objective function and the distance determined by the second objective function being greater than a first threshold, a discriminant model is determined; and The generative model is determined in response to the distance determined by the second objective function being less than a second threshold.
22. The system according to claim 21, wherein the third training unit is further configured to: A trained visual generator is obtained based on the determined discriminant model and the determined generative model.
23. A computer-readable storage medium, characterized in that: The computer storage medium includes instructions that, when executed, perform the method for training a visual generator according to any one of claims 1-11.
24. A method for classifying text, characterized in that The method comprises the following steps: Obtaining the text feature vector of the text to be processed; Using a visual generator to generate a visual image based on the text feature vector of the text to be processed and random noise, wherein the visual generator is trained using the method for training a visual generator according to any one of claims 1 to 11; Encoding the text feature vector to obtain a semantic code, and encoding the visual image to obtain a visual code; as well as Combining the semantic code and the visual code and based on the semantic code and the visual code The combination of the codes generates a classification result for the text to be processed.
25. The method according to claim 24, wherein obtaining the text feature vector of the text to be processed comprises: Preprocessing the text to be processed, wherein the preprocessing is used to filter out symbols and stop words in the text to be processed; as well as Generate a text feature vector from the preprocessed text to be processed.
26. The method of claim 24, wherein the random noise follows a standard normal distribution.
27. The method according to claim 24, wherein encoding the text feature vector to obtain a semantic code comprises: The text feature vector is encoded using one or more of the following semantic encoders: BERT-base model, ERNIE model, GPT model.
28. The method of claim 24, wherein encoding the visual image to obtain a visual encoding comprises: The visual image is encoded using one or more of the following graph encoders: a VGG model, a ResNet model.
29. The method of claim 24, wherein combining the semantic encoding and the visual encoding comprises: The semantic code and the visual code are combined in a concatenated manner.
30. The method according to claim 24, wherein generating a classification result for the text to be processed based on a combination of the semantic encoding and the visual encoding comprises: The combination of the semantic code and the visual code is input into a classification model to obtain a classification result for the text to be processed, wherein the classification result indicates the category to which the text to be processed belongs.
31. A system for classifying text, characterized in that The system comprises: An acquisition unit configured to acquire a text feature vector of a text to be processed; A visual generator configured to generate a visual image based on a text feature vector of the text to be processed and random noise, wherein the visual generator is trained using the method for training a visual generator according to any one of claims 1 to 11; an encoding unit configured to encode the text feature vector to obtain a semantic code, and to encode the visual image to obtain a visual code; and A processing unit configured to combine the semantic code and the visual code and based on the semantic The combination of the encoding and the visual encoding generates a classification result for the text to be processed.
32. The system according to claim 31, wherein the acquisition unit is further configured to: Preprocessing the text to be processed, wherein the preprocessing is used to filter out symbols and stop words in the text to be processed; and Generate a text feature vector from the preprocessed text to be processed.
33. The system of claim 31, wherein the random noise follows a standard normal distribution.
34. A system according to claim 31, wherein the encoding unit includes a semantic encoder, which is used to encode the text feature vector to obtain a semantic code and includes one or more of the following: a BERT-base model, an ERNIE model, and a GPT model.
35. The system of claim 31, wherein the encoding unit comprises a graph encoder, which is used to encode the visual image to obtain a visual encoding and comprises one or more of the following: a VGG model, a ResNet model.
36. The system of claim 31 , wherein the processing unit is further configured to: The semantic code and the visual code are combined in a concatenated manner.
37. A system according to claim 31, wherein the processing unit includes a classification model, and the classification model is configured to obtain a classification result for the text to be processed based on a combination of the semantic encoding and the visual encoding, and the classification result indicates the category to which the text to be processed belongs.
38. A computer-readable storage medium, characterized in that: The computer storage medium includes instructions, which, when executed, perform the method for classifying text according to any one of claims 24-30.
Citation Information
Patent Citations
Image generation model training method and image generation method
CN110163267A
A method for generating image based on text
CN111339734A
Model training method and device for generating image based on text and image generation method
CN112990302A
Image generation model training method and device and image generation method and device
CN113590800A
Image generation method and device, equipment and medium
CN114648681A
Cited By
Automatic data classification and grading system and method
CN119691180A
Text image generation method based on semantic alignment and text fusion
CN119722839A
Multi-modal large model-based ship and ocean engineering aided design method
CN120070673A
Long text information processing method and system based on large model, medium, product and terminal
CN121562565A
