WO2020140633A1 - 文本主题提取方法、装置、电子设备及存储介质 - Google Patents
文本主题提取方法、装置、电子设备及存储介质 Download PDFInfo
- Publication number
- WO2020140633A1 WO2020140633A1 PCT/CN2019/118287 CN2019118287W WO2020140633A1 WO 2020140633 A1 WO2020140633 A1 WO 2020140633A1 CN 2019118287 W CN2019118287 W CN 2019118287W WO 2020140633 A1 WO2020140633 A1 WO 2020140633A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- text
- layer
- matrix
- output
- attention mechanism
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Ceased
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06N—COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06N3/00—Computing arrangements based on biological models
- G06N3/02—Neural networks
- G06N3/08—Learning methods
- G06N3/09—Supervised learning
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/30—Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
- G06F16/34—Browsing; Visualisation therefor
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F17/00—Digital computing or data processing equipment or methods, specially adapted for specific functions
- G06F17/10—Complex mathematical operations
- G06F17/16—Matrix or vector computation, e.g. matrix-matrix or matrix-vector multiplication, matrix factorization
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06N—COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06N3/00—Computing arrangements based on biological models
- G06N3/02—Neural networks
- G06N3/04—Architecture, e.g. interconnection topology
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06N—COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06N3/00—Computing arrangements based on biological models
- G06N3/02—Neural networks
- G06N3/04—Architecture, e.g. interconnection topology
- G06N3/0464—Convolutional networks [CNN, ConvNet]
Definitions
- the present application relates to the field of artificial intelligence technology, and in particular, to a text subject extraction method, device, electronic equipment, and storage medium.
- the present application provides a text subject extraction method, device and storage medium based on a convolutional neural network and attention mechanism to improve the efficiency of text subject extraction and reduce the computational burden of the text subject extraction model.
- one aspect of the present application is to provide a text topic extraction method, including: constructing a text topic extraction model; training the text topic extraction model; obtaining a text word vector corresponding to a text sample; and converting the text word vector Input a trained text topic extraction model; output a text topic corresponding to the text sample, wherein the constructed text topic extraction model includes a convolutional neural network and an attention mechanism, the convolutional neural network includes an input layer, Convolution layer, activation layer and fully connected layer.
- the input layer is used to input text word vectors.
- the convolution layer is used to perform convolution operations on the text word vectors to extract text features to obtain text feature vectors.
- the activation layer is used In order to activate the text feature vector;
- the attention mechanism includes a position attention mechanism and a channel attention mechanism, the position attention mechanism and the channel attention mechanism are established in parallel, and are connected to the activation layer ,
- the position attention weight is applied to the output matrix of the activation layer through the position attention mechanism to obtain a position attention feature matrix, and the position attention feature matrix and the output matrix of the activation layer are added to obtain The output result of the location attention mechanism; applying the channel attention weight to the output matrix of the activation layer through the channel attention mechanism to obtain a channel attention feature matrix, and combining the channel attention feature matrix with the activation layer
- the output matrix of is added to obtain the output of the channel attention mechanism; both the output of the location attention mechanism and the output of the channel attention mechanism are input into the fully connected layer, and through the fully connected Layer output text theme.
- a text subject extraction device including:
- a model training module to train the text topic extraction model
- the obtaining module obtains the text word vector corresponding to the text sample
- An input module input the text word vector into a trained text subject extraction model
- An output module which outputs a text theme corresponding to the text sample
- the text topic extraction model includes a convolutional neural network and attention mechanism
- the model building module includes:
- the convolutional neural network constructs a submodule to construct a convolutional neural network.
- the convolutional neural network includes an input layer, a convolutional layer, an activation layer, and a fully connected layer.
- the input layer is used to input text word vectors
- the convolutional layer is used to Performing a convolution operation on the text word vector to extract text features to obtain a text feature vector
- the activation layer is used to activate the text feature vector
- the weight application submodule applies weights to the convolutional neural network through an attention mechanism, the attention mechanism includes a position attention mechanism and a channel attention mechanism, and the position attention mechanism and the channel attention mechanism are established in parallel , Are connected to the activation layer, and the location attention weight is applied to the output matrix of the activation layer through the location attention mechanism to obtain a location attention feature matrix, and the location attention feature matrix is connected to the activation layer
- the output matrix of the summation is used to obtain the output result of the location attention mechanism
- the channel attention weight is applied to the output matrix of the activation layer through the channel attention mechanism to obtain the channel attention feature matrix, and the channel attention
- the force feature matrix is added to the output matrix of the activation layer to obtain the output result of the channel attention mechanism; the output results of the position attention mechanism and the channel attention mechanism are both input into the full
- the connection layer outputs text topics through the fully connected layer.
- a third aspect of the present application is to provide an electronic device including: a processor; a memory, the memory including a text subject extraction program, the text subject extraction program is used by the processor When executed, the steps of the text subject extraction method described below are implemented:
- the constructed text subject extraction model includes a convolutional neural network and an attention mechanism.
- the convolutional neural network includes an input layer, a convolutional layer, an activation layer, and a fully connected layer.
- the input layer is used to input text word vectors.
- the product layer is used to perform a convolution operation on the text word vector to extract text features to obtain a text feature vector.
- the activation layer is used to activate the text feature vector;
- the attention mechanism includes a position attention mechanism And the channel attention mechanism, the location attention mechanism and the channel attention mechanism are established in parallel, and are both connected to the activation layer, and the location attention weight is applied to the output matrix of the activation layer through the location attention mechanism
- To obtain a location attention feature matrix add the location attention feature matrix and the output matrix of the activation layer to obtain the output result of the location attention mechanism; through the channel attention mechanism to the activation layer
- the channel attention weight is applied to the output matrix of to obtain the channel attention feature matrix, and the channel attention feature matrix and the output matrix of the activation layer are added to obtain the output result of the channel attention mechanism; the position Both the output result of the attention mechanism and the output result of the channel attention mechanism are input to the fully connected layer, and the text topic is output through the fully connected layer.
- another aspect of the present application is to provide a computer non-volatile readable storage medium, the computer readable storage medium includes a text subject extraction program, when the text subject extraction program is executed by a processor To implement the steps of the text subject extraction method as described above.
- This application combines a convolutional neural network and an attention mechanism to construct a text topic extraction model, extract text topics corresponding to the text, improve the accuracy of the text topic extraction model, and at the same time improve the operation efficiency of the text topic extraction model, thereby improving the The efficiency of subject extraction for text samples through the text subject extraction model.
- FIG. 1 is a schematic flowchart of a text subject extraction method described in this application
- FIG. 2 is a schematic diagram of modules of a text subject extraction program in the present application.
- FIG. 1 is a schematic flowchart of the text subject extraction method described in this application. As shown in FIG. 1, the text subject extraction method described in this application includes the following steps:
- Step S1 construct a text subject extraction model
- Step S2 Train the text topic extraction model
- Step S3 Obtain the text word vector corresponding to the text sample
- Step S4 Input the text word vector into a trained text subject extraction model
- Step S5 Output a text theme corresponding to the text sample
- the text topic extraction model constructed in step S1 includes a convolutional neural network and an attention mechanism.
- the convolutional neural network includes an input layer, a convolutional layer, an activation layer, and a fully connected layer.
- the input layer is used to input text Word vector
- the convolutional layer is used to perform convolution operation on the text word vector to extract text features to obtain the text feature vector
- the activation layer is used to activate the text feature vector
- the attention mechanism includes A position attention mechanism and a channel attention mechanism, the position attention mechanism and the channel attention mechanism are established in parallel, are both connected to the activation layer, and are applied to the output matrix of the activation layer through the position attention mechanism
- Position attention weights to obtain a position attention feature matrix adding the position attention feature matrix and the output matrix of the activation layer to obtain the output result of the position attention mechanism; through the channel attention mechanism to The channel attention weight is applied to the output matrix of the activation layer to obtain a channel attention feature matrix, and the channel attention feature matrix and the output matrix of the activation layer are added
- This application combines a convolutional neural network and an attention mechanism to construct a text topic extraction model, extract text topics corresponding to the text, and can be used for keyword extraction of comments.
- the text topic extraction model performs convolution operations through a convolutional neural network, and assigns different weights to different semantics by establishing a parallel position attention mechanism and channel attention mechanism, while improving the accuracy of the text topic extraction model, The operation efficiency of the text subject extraction model is improved, thereby improving the efficiency of subject extraction of text samples through the text subject extraction model.
- the convolutional layer of the convolutional neural network includes multiple one-dimensional convolution kernels, each of which has 128 channels, and the steps of the multiple convolution kernels are 1, 3, and 5, respectively.
- the convolution kernels of each step size each account for 1/3 of the total number of convolution kernels, and the input and output dimensions of the convolution layer are consistent through the setting of padding.
- the greater the number of convolution kernels the more text features are extracted through the convolution layer, and the more accurate the text topic will be obtained by subsequent processing of the text feature vectors.
- the more the number of convolution kernels the faster the text subject extraction model will be. Therefore, the convolution kernels should not be excessive.
- the activation function of the activation layer in the convolutional neural network uses the ReLU function, but the present application is not limited to this, and may also be other forms of activation functions, such as Sigmoid function or Tanh function.
- the output of the activation layer is used as the output of the convolutional neural network.
- the step of training the text topic extraction model includes:
- the parameters include: connection weights of the input layer and the convolutional layer, connection weights of the convolutional layer and the activation layer, connection weights of the activation layer and the fully connected layer;
- the training of the text topic extraction model determines whether the training of the text topic extraction model reaches the convergence condition. If the convergence condition is reached, the training is ended to obtain the trained text topic extraction model. If the convergence condition is not reached, update the parameters of the text topic extraction model to continue Training, wherein the convergence condition is that the change of the loss function value is less than a preset threshold. Generally, the preset threshold can be taken as 0.02, and the training learning rate is 0.001.
- text samples can be converted into text word vectors corresponding to them in various ways.
- the topic extraction model further includes an embedding layer, the embedding layer is located in the first layer of the text topic extraction model, the text samples are converted into text word vectors through the embedding layer, and the resulting text word vectors are input The input layer of the convolutional neural network.
- the present application is not limited to this.
- the present application can also convert text samples into corresponding text word vectors by using various word vector models, for example, Word2Vec model, CBOW model, etc.
- the step of obtaining the text word vector corresponding to the text sample includes:
- a text word vector corresponding to the text sample is output.
- the text length is determined according to the text sample, and the text sample is segmented according to the determined text length.
- the text length determined according to the text sample is 100, which is divided equally by the word segmentation library (eg, jieba, Jcseg, and HanLP) Thesaurus) segment the text samples, the dimension of the text word vector is 300.
- the attention mechanism includes a position attention mechanism and a channel attention mechanism.
- the position attention mechanism applies attention to the output matrix of the activation layer according to the text position characteristics and performs weight distribution;
- the channel attention mechanism Attention is paid to the output of the activation layer according to the convolution kernel channel to perform weight distribution.
- the text topic extraction model further includes a plurality of fully connected hidden layers, a plurality of fully connected hidden layers are set in parallel, and each fully connected hidden layer is connected to the activation layer through different fully connected
- the hidden layer converts the output matrix of the activation layer into a position attention weight matrix and a channel attention weight matrix, respectively, and weights the output of the activation layer according to the position attention weight matrix and the channel attention weight matrix, respectively. distribution.
- the output matrix of the active layer outputs a first conversion matrix through a fully connected hidden layer, and performs matrix multiplication of the first conversion matrix and the position attention weight matrix to obtain a position attention feature matrix, Adding the location attention feature matrix and the output matrix of the activation layer to obtain the output result of the channel attention mechanism and inputting to the fully connected layer; the output matrix of the activation layer is hidden through another fully connected
- the layer-containing output second conversion matrix, matrix multiplication of the second conversion matrix and the channel attention weight matrix to obtain a channel attention feature matrix, and the channel attention feature matrix and the output of the activation layer The matrix is added to obtain the output result of the channel attention mechanism and input to the fully connected layer.
- the convolution kernel of the convolutional neural network is a single-dimensional convolution kernel, the total number of channels of the convolution kernel is k, and the output matrix of the activation layer is k*m*1.
- the output matrix of is converted into k*m, and the output matrix of the active layer is extracted through different fully connected hidden layers connected to the active layer, and the output matrix of the active layer is converted into dimensions of m*k and k*m, respectively.
- the two matrices are multiplied to obtain a positional attention weight matrix of dimension m*m. According to the positional attention weight matrix, the weight of the output of the activation layer is assigned so that the semantics at different positions are obtained. Different weights to extract text topics more accurately.
- feature extraction is performed on the output of the active layer through different fully connected hidden layers connected to the active layer, and the output matrix of the active layer is converted into two matrices with dimensions k*m and m*k, respectively, and The two matrices are multiplied to obtain a channel attention weight matrix of dimension k*k, and the output of the active layer is weighted according to the channel attention weight matrix.
- the convolution kernel of the convolutional neural network is a single-dimensional convolution kernel
- the total number of channels of the convolution kernel is 384
- the output matrix of the activation layer of the convolutional neural network is a three-dimensional matrix of 384*100*1.
- For the positional attention mechanism first convert the output matrix of the active layer into a two-dimensional matrix of 384*100, and through two parallel fully connected hidden layer output matrices with dimensions of 100*384 and 384*100, and The two matrices are subjected to matrix multiplication and softmax mapping to obtain a position attention weight matrix with a dimension of 100*100.
- the first conversion matrix and position attention weight matrix are subjected to matrix multiplication to obtain a dimension of 384*100
- the location attention feature matrix is converted into a 384*100*1 three-dimensional matrix and added to the 384*100*1 three-dimensional matrix output by the activation layer as the output result of the location attention mechanism.
- For the channel attention mechanism first convert the output matrix of the active layer into a two-dimensional matrix of 384*100, and through two parallel fully connected hidden layer output matrices with dimensions of 384*100 and 100*384, and The two matrices are subjected to matrix multiplication and softmax mapping to obtain a channel attention weight matrix with dimensions of 384*384.
- the second conversion matrix and the channel attention weight matrix are matrix multiplied to obtain a channel with a dimension of 100*384
- the attention matrix is converted into a 384*100*1 three-dimensional matrix and added to the 384*100*1 three-dimensional matrix output by the active layer as the output result of the channel attention mechanism.
- the output results of the location attention mechanism and the channel attention mechanism are input to the fully connected layer to complete the output of the entire text topic extraction model.
- the output dimension of the text topic extraction model is 100, which is the same as the text length determined by the text sample, corresponding to the input Keyword annotation for each word in the text sample.
- different attention weights are applied to the output matrix of the activation layer through the attention mechanism, and the position attention feature matrix and channel attention feature matrix are obtained through the attention mechanism, and the position attention feature matrix and channel attention feature matrix Sum with the output matrix of the convolutional neural network respectively.
- the text word vector is obtained by a convolutional neural network activation layer to obtain a 10-dimensional output matrix
- the position attention mechanism is applied to the 10-dimensional output matrix to obtain a 10-dimensional position attention feature matrix
- the channel attention mechanism is used to
- a 10-dimensional output matrix is applied with channel attention to obtain a 10-dimensional channel attention feature matrix.
- the 10-dimensional position attention feature matrix is added to the 10-dimensional output matrix of the convolutional neural network to obtain a 20-dimensional output matrix, which is input to the fully connected layer.
- the 10-dimensional channel attention feature matrix is added to the 10-dimensional output matrix of the convolutional neural network to obtain a 20-dimensional output matrix, which is input to the fully connected layer and the text topic is output via the fully connected layer.
- the text subject extraction method described in this application is applied to electronic devices, and the electronic devices may be terminal devices such as televisions, smart phones, tablet computers, and computers.
- the electronic device includes: a processor; a memory for storing a text subject extraction program, and the processor executes the text subject extraction program to implement the following steps of the text subject extraction method: construct a text subject extraction model; train the text subject Extract the model; obtain the text word vector corresponding to the text sample; input the text word vector into the trained text topic extraction model; output the text topic corresponding to the text sample.
- the constructed text topic extraction model includes a convolutional neural network and an attention mechanism.
- the convolutional neural network includes an input layer, a convolutional layer, an activation layer, and a fully connected layer.
- the input layer is used to input text word vectors.
- the convolution layer is used to perform a convolution operation on the text word vector to extract text features to obtain a text feature vector.
- the activation layer is used to activate the text feature vector;
- the attention mechanism includes positional attention Mechanism and channel attention mechanism, the location attention mechanism and the channel attention mechanism are established in parallel, and are both connected to the activation layer, and the location attention is applied to the output matrix of the activation layer through the location attention mechanism Weighting to obtain a location attention feature matrix, adding the location attention feature matrix and the output matrix of the activation layer to obtain the output result of the location attention mechanism; through the channel attention mechanism to the activation
- the channel attention weight is applied to the output matrix of the layer to obtain the channel attention feature matrix, and the channel attention feature matrix is added to the output matrix of the activation layer to obtain the output result of the channel attention mechanism, and the The output results of the location attention mechanism and the channel attention mechanism are both input to the fully connected layer, and the text topic is output through the fully connected layer.
- the electronic device also includes a network interface and a communication bus.
- the network interface may include a standard wired interface and a wireless interface
- the communication bus is used to implement connection communication between various components.
- the memory includes at least one type of readable storage medium, which may be a non-volatile storage medium such as a flash memory, a hard disk, an optical disk, or a plug-in hard disk, etc., and is not limited thereto, and may be stored in a non-transitory manner
- the software program stored in the memory includes a text subject extraction program, and the text subject extraction program can be provided to the processor, so that the processor can execute the text subject extraction program to implement the steps of the text subject extraction method.
- the processor may be a central processing unit, a microprocessor, or other data processing chips, etc., and may run a stored program in the memory, for example, may execute a text subject extraction program in this application.
- the electronic device may further include a display, and the display may also be called a display screen or a display unit.
- the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, an organic light-emitting diode (OLED) touch device, or the like.
- the display is used to display information processed in the electronic device and to display a visual work interface.
- the electronic device may further include a user interface, and the user interface may include an input unit (such as a keyboard), a voice output device (such as a stereo, a headset), and the like.
- a user interface may include an input unit (such as a keyboard), a voice output device (such as a stereo, a headset), and the like.
- the convolutional layer of the convolutional neural network in the text topic extraction model includes multiple one-dimensional convolution kernels, each of which has 128 channels, and the steps of the multiple convolution kernels are respectively For 1, 3 and 5, each step of the convolution kernel accounts for 1/3 of the total number of convolution kernels, and the input and output dimensions of the convolution layer are consistent through the setting of padding.
- the step of training the text topic extraction model includes:
- the parameters include: connection weights of the input layer and the convolutional layer, connection weights of the convolutional layer and the activation layer, connection weights of the activation layer and the fully connected layer;
- the training of the text topic extraction model determines whether the training of the text topic extraction model reaches the convergence condition. If the convergence condition is reached, the training is ended to obtain the trained text topic extraction model. If the convergence condition is not reached, update the parameters of the text topic extraction model to continue Training, wherein the convergence condition is that the change of the loss function value is less than a preset threshold. Generally, the preset threshold can be taken as 0.02, and the training learning rate is 0.001.
- text samples can be converted into text word vectors corresponding to them in various ways.
- the topic extraction model further includes an embedding layer, the embedding layer is located in the first layer of the text topic extraction model, the text samples are converted into text word vectors through the embedding layer, and the resulting text word vectors are input The input layer of the convolutional neural network.
- the present application is not limited to this.
- the present application can also convert text samples into corresponding text word vectors by using various word vector models, for example, Word2Vec model, CBOW model, etc.
- the step of obtaining the text word vector corresponding to the text sample includes:
- a text word vector corresponding to the text sample is output.
- the text length is determined according to the text sample, and the text sample is segmented according to the determined text length.
- the text length determined according to the text sample is 100, which is divided equally by the word segmentation library (eg, jieba, Jcseg, and HanLP) Thesaurus) segment the text samples, the dimension of the text word vector is 300.
- the text topic extraction model further includes a plurality of fully connected hidden layers, a plurality of fully connected hidden layers are set in parallel, and each fully connected hidden layer is connected to the activation layer through different fully connected
- the hidden layer converts the output matrix of the activation layer into a position attention weight matrix and a channel attention weight matrix, respectively, and weights the output of the activation layer according to the position attention weight matrix and the channel attention weight matrix, respectively. Assignment, the input of the location attention mechanism and the channel attention mechanism all come from the output of the activation layer.
- the output matrix of the active layer outputs a first conversion matrix through a fully connected hidden layer, and performs matrix multiplication of the first conversion matrix and the position attention weight matrix to obtain a position attention feature matrix, Adding the location attention feature matrix and the output matrix of the activation layer to obtain the output result of the channel attention mechanism and inputting to the fully connected layer; the output matrix of the activation layer is hidden through another fully connected
- the layer-containing output second conversion matrix, matrix multiplication of the second conversion matrix and the channel attention weight matrix to obtain a channel attention feature matrix, and the channel attention feature matrix and the output of the activation layer The matrix is added to obtain the output result of the channel attention mechanism and input to the fully connected layer.
- the convolution kernel of the convolutional neural network is a single-dimensional convolution kernel, the total number of channels of the convolution kernel is k, and the output matrix of the activation layer is k*m*1.
- the output matrix of is converted into k*m, and the output matrix of the active layer is extracted through different fully connected hidden layers connected to the active layer, and the output matrix of the active layer is converted into dimensions of m*k and k*m, respectively.
- the two matrices are multiplied to obtain a positional attention weight matrix of dimension m*m. According to the positional attention weight matrix, the weight of the output of the activation layer is assigned so that the semantics at different positions are obtained. Different weights to extract text topics more accurately.
- feature extraction is performed on the output of the active layer through different fully connected hidden layers connected to the active layer, and the output matrix of the active layer is converted into two matrices with dimensions k*m and m*k, respectively, and The two matrices are multiplied to obtain a channel attention weight matrix of dimension k*k, and the output of the active layer is weighted according to the channel attention weight matrix.
- the text subject extraction program may also be divided into one or more modules, and the one or more modules are stored in the memory and executed by the processor to complete the application.
- the module referred to in this application refers to a series of computer program instruction segments capable of performing specific functions.
- FIG. 2 is a schematic diagram of modules of a text subject extraction program in the present application. As shown in FIG. 2, the text subject extraction program can be divided into: model building module 1, model training module 2, acquisition module 3, input module 4, and output Module 5. The functions or operation steps implemented by the above modules are similar to the above, and will not be described in detail here, for example, for example:
- the model building module 1 builds a text topic extraction model, where the constructed text topic extraction model includes a convolutional neural network and an attention mechanism, the specific composition is as described above, and will not be repeated here;
- Model training module 2 training the text topic extraction model
- the obtaining module 3 obtains the text word vector corresponding to the text sample
- Input module 4 input the text word vector into a trained text subject extraction model
- the output module 5 outputs text topics corresponding to the text samples.
- a text subject extraction device includes:
- Model building module 1 constructing a text subject extraction model, where the constructed text subject extraction model includes a convolutional neural network and attention mechanism;
- Model training module 2 training the text topic extraction model
- the obtaining module 3 obtains the text word vector corresponding to the text sample
- Input module 4 input the text word vector into a trained text subject extraction model
- the output module 5 outputs the text subject corresponding to the text sample
- the text topic extraction model includes a convolutional neural network and attention mechanism
- the model building module 1 includes:
- the convolutional neural network constructs a submodule to construct a convolutional neural network.
- the convolutional neural network includes an input layer, a convolutional layer, an activation layer, and a fully connected layer.
- the input layer is used to input text word vectors
- the convolutional layer is used to Performing a convolution operation on the text word vector to extract text features to obtain a text feature vector
- the activation layer is used to activate the text feature vector
- the weight application submodule applies weights to the convolutional neural network through an attention mechanism, the attention mechanism includes a position attention mechanism and a channel attention mechanism, and the position attention mechanism and the channel attention mechanism are established in parallel , Are connected to the activation layer, and the location attention weight is applied to the output matrix of the activation layer through the location attention mechanism to obtain a location attention feature matrix, and the location attention feature matrix is connected to the activation layer
- the output matrix of the summation is used to obtain the output result of the location attention mechanism
- the channel attention weight is applied to the output matrix of the activation layer through the channel attention mechanism to obtain the channel attention feature matrix, and the channel attention
- the force feature matrix is added to the output matrix of the activation layer to obtain the output result of the channel attention mechanism; the output results of the position attention mechanism and the channel attention mechanism are both input into the full
- the connection layer outputs text topics through the fully connected layer.
- the weight applying sub-module includes:
- a position attention applying unit the output matrix of the activation layer outputs a first conversion matrix through a fully connected hidden layer, and performs matrix multiplication of the first conversion matrix and the position attention weight matrix to obtain position attention Feature matrix
- a channel attention applying unit the output matrix of the active layer outputs a second conversion matrix through another fully connected hidden layer, and performs matrix multiplication of the second conversion matrix and the channel attention weight matrix to obtain channel attention Force characteristic matrix.
- the acquisition module comprises:
- a word vector model building unit constructing a word vector model, and training the word vector model according to a corpus
- Word segmentation unit which performs word segmentation on the text sample
- the training unit trains the word vector model constructed by the word vector model construction unit
- the word vector obtaining unit inputs a text sample after word segmentation into a trained word vector model, and outputs a text word vector corresponding to the text sample.
- the above model training module includes:
- the initialization unit initializes the parameters of the text subject extraction model, the parameters include: connection weights of the input layer and the convolutional layer, connection weights of the convolutional layer and the activation layer, connection weights of the activation layer and the fully connected layer ;
- a training sample set construction unit to construct a training sample set, which includes text word vectors and text topics;
- the updating unit inputs a training sample in the training sample set into the text topic extraction model and outputs a text topic corresponding to the training sample; updates the parameters based on the loss function of the text topic extraction model; according to the update After the parameters training the next training sample;
- the judging unit judges whether the training of the text topic extraction model reaches the convergence condition. If the convergence condition is reached, the training is ended to obtain the trained text topic extraction model. If the convergence condition is not reached, the text topic extraction model is updated Parameters, continue training, where the convergence condition is that the change in loss function value is less than a preset threshold.
- the convolutional neural network further includes a plurality of fully connected hidden layers, the plurality of fully connected hidden layers are arranged in parallel, and each fully connected hidden layer is connected to the activation layer, and through the fully connected
- the hidden layer converts the output matrix of the activation layer into a position attention weight matrix and a channel attention weight matrix, respectively.
- the convolutional neural network further includes an embedding layer, which is located at the first layer of the text subject extraction model, and converts text samples into text word vectors through the embedding layer.
- the convolutional layer of the convolutional neural network in the text topic extraction model includes multiple one-dimensional convolution kernels, each of which has 128 channels, and the steps of the multiple convolution kernels are: 1, 3 and 5, each step of the convolution kernel accounts for 1/3 of the total number of convolution kernels, and the input and output dimension of the convolution layer is achieved through the setting of the inner margin.
- the computer-readable storage medium may be any tangible medium that contains or stores programs or instructions, where the programs can be executed, and the corresponding functions are realized by hardware related to the stored program instructions.
- the computer-readable storage medium may be a computer disk, hard disk, random access memory, read-only memory, or the like.
- the present application is not limited to this, and may be any device that stores instructions or software and any related data files or data structures in a non-transitory manner and can be provided to the processor to cause the processor to execute the programs or instructions therein.
- the computer-readable storage medium includes a text subject extraction program. When the text subject extraction program is executed by a processor, the following text subject extraction method is implemented:
- Construct a text topic extraction model train the text topic extraction model; obtain text word vectors corresponding to text samples; input the text word vectors into a trained text topic extraction model; output text topics corresponding to the text samples.
- the constructed text topic extraction model includes a convolutional neural network and an attention mechanism.
- the convolutional neural network includes an input layer, a convolutional layer, an activation layer, and a fully connected layer.
- the input layer is used to input text word vectors.
- the convolution layer is used to perform a convolution operation on the text word vector to extract text features to obtain a text feature vector.
- the activation layer is used to activate the text feature vector;
- the attention mechanism includes positional attention Mechanism and channel attention mechanism, the location attention mechanism and the channel attention mechanism are established in parallel, and are both connected to the activation layer, and the location attention is applied to the output matrix of the activation layer through the location attention mechanism Weighting to obtain a location attention feature matrix, adding the location attention feature matrix and the output matrix of the activation layer to obtain the output result of the location attention mechanism; through the channel attention mechanism to the activation
- the channel attention weight is applied to the output matrix of the layer to obtain the channel attention feature matrix, and the channel attention feature matrix is added to the output matrix of the activation layer to obtain the output result of the channel attention mechanism, and the The output results of the location attention mechanism and the channel attention mechanism are both input to the fully connected layer, and the text topic is output through the fully connected layer.
- the technical solution of the present application can be embodied in the form of a software product in essence or part that contributes to the prior art, and the computer software product is stored in a storage medium (such as ROM/RAM) as described above , Magnetic disk, optical disk), including several instructions to enable a terminal device (which may be a mobile phone, computer, server, or network device, etc.) to perform the method described in each embodiment of the present application.
- a storage medium such as ROM/RAM
- ROM/RAM Read Only Memory/RAM
- magnetic disk Magnetic disk
- optical disk including several instructions to enable a terminal device (which may be a mobile phone, computer, server, or network device, etc.) to perform the method described in each embodiment of the present application.
Landscapes
- Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- Theoretical Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Mathematical Physics (AREA)
- Data Mining & Analysis (AREA)
- General Engineering & Computer Science (AREA)
- Computing Systems (AREA)
- Software Systems (AREA)
- Biophysics (AREA)
- General Health & Medical Sciences (AREA)
- Molecular Biology (AREA)
- Evolutionary Computation (AREA)
- Computational Linguistics (AREA)
- Biomedical Technology (AREA)
- Artificial Intelligence (AREA)
- Life Sciences & Earth Sciences (AREA)
- Health & Medical Sciences (AREA)
- Databases & Information Systems (AREA)
- Computational Mathematics (AREA)
- Mathematical Analysis (AREA)
- Mathematical Optimization (AREA)
- Pure & Applied Mathematics (AREA)
- Algebra (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
- Machine Translation (AREA)
- Image Analysis (AREA)
Abstract
一种文本主题提取方法,属于人工智能技术领域,包括:构建文本主题提取模型(S1);训练文本主题提取模型(S2);获取文本样本对应的文本词向量(S3);将文本词向量输入经过训练的文本主题提取模型(S4);输出与所述文本样本相应的文本主题(S5),其中,文本主题提取模型包括卷积神经网络和注意力机制,注意力机制包括位置注意力机制和通道注意力机制,位置注意力机制和通道注意力机制并行建立,均与卷积神经网络的激活层连接,分别施加位置注意力权重和通道注意力权重,将位置注意力机制的输出结果和通道注意力机制的输出结果均输入卷积神经网路的全连接层。还公开了一种装置、电子设备和存储介质。该方法提高了文本主题提取模型运算效率,提高了文本主题提取的精度。
Description
本申请要求申请号为201910008265.9,申请日为2019年1月4日,发明创造名称为“文本主题提取方法、装置及存储介质”的专利申请的优先权。
本申请涉及人工智能技术领域,尤其涉及一种文本主题提取方法、装置、电子设备及存储介质。
随着互联网的迅速发展,越来越多的用户通过网络进行信息的共享,通过电子文本记载网络信息资源,因此,若需要快速在海量的电子文本中找到所需电子信息,则需要在文本中提取文本主题以表征该电子文本。在一个文本中提取文本主题可以帮助用户判断是否需要查看文本的全文。而海量的电子文本存在多个主题文本,包含丰富的主题信息。对于文本主题的提取大多是基于人工智能技术,利用计算机通过文本主题提取模型,从文本中自动提取内容生成文本主题。现有多数文本主题提取模型主要基于循环神经网络,而循环神经网络模型的运算效率较低,导致文本主题提取模型的运算效率较低,增加运算负担,且导致通过该文本主题提取模型进行文本主题提取的效率较低。
申请内容
本申请提供一种基于卷积神经网络和注意力机制的文本主题提取方法、装置及存储介质,以提高文本主题提取的效率,降低文本主题提取模型的运算负担。
为了实现上述目的,本申请的一个方面是提供一种文本主题提取方法,包括:构建文本主题提取模型;训练所述文本主题提取模型;获取文本样本对应的文本词向量;将所述文本词向量输入经过训练的文本主题提取模型;输出与所述文本样本相应的文本主题,其中,构建的所述文本主题提取模型包括卷积神经网络和注意力机制,所述卷积神经网络包括输入层、卷积层、激活层和全连接层,输入层用于输入文本词向量,卷积层用于对所述文本词向量进行卷积运算,提取文本特征,得到文本特征向量,所述激活层用于对所述文本特征向量进行激活作用;所述注意力机制包括位置注意力机制和通道注意力机制,所述位置注意力机制和所述通道注意力机制并行建立,均与所述激活层连接,通过所述位置注意力机制向所述激活层的输出矩阵施加位置注意力权重,得到位置注意力特征矩阵,将所述位置注意力特征矩阵与所述激活层的输出矩阵加和,得到所述位置注意力机制的输出结果;通过所述通道注意力机制向所述激活层的输出矩阵施加通道注意力权重,得到通道注意力特征矩阵,将所述通道注意力特征矩阵与所述激活层的输出矩阵加和,得到所述通道注意力机制的输出结果;将所述位置注意力机制的输出结果和所述通道注意力机制的输出结果均输入所述全连接层,通过所述全连接层输 出文本主题。
为了实现上述目的,本申请的另一个方面是提供一种文本主题提取装置,包括:
模型构建模块,构建文本主题提取模型,其中,构建的文本主题提取模型包括卷积神经网络和注意力机制;
模型训练模块,训练所述文本主题提取模型;
获取模块,获取文本样本对应的文本词向量;
输入模块,将所述文本词向量输入经过训练的文本主题提取模型;
输出模块,输出与所述文本样本相应的文本主题,
其中,所述文本主题提取模型包括卷积神经网络和注意力机制,所述模型构建模块包括:
卷积神经网络构建子模块,构建卷积神经网络,所述卷积神经网络包括输入层、卷积层、激活层和全连接层,输入层用于输入文本词向量,卷积层用于对所述文本词向量进行卷积运算,提取文本特征,得到文本特征向量,所述激活层用于对所述文本特征向量进行激活作用;
权重施加子模块,通过注意力机制向所述卷积神经网络施加权重,所述注意力机制包括位置注意力机制和通道注意力机制,所述位置注意力机制和所述通道注意力机制并行建立,均与所述激活层连接,通过所述位置注意力机制向所述激活层的输出矩阵施加位置注意力权重,得到位置注意力特征矩阵,将所述位置注意力特征矩阵与所述激活层的输出矩阵加和,得到所述位置注意力机制的输出结果;通过所述通道注意力机制向所述激活层的输出矩阵施加通道注意力权重,得到通道注意力特征矩阵,将所述通道注意力特征矩阵与所述激活层的输出矩阵加和,得到所述通道注意力机制的输出结果;将所述位置注意力机制的输出结果和所述通道注意力机制的输出结果均输入所述全连接层,通过所述全连接层输出文本主题。
为了实现上述目的,本申请的第三个方面是提供一种电子设备,该电子设备包括:处理器;存储器,所述存储器中包括文本主题提取程序,所述文本主题提取程序被所述处理器执行时实现如下所述的文本主题提取方法的步骤:
构建文本主题提取模型;训练所述文本主题提取模型;获取文本样本对应的文本词向量;将所述文本词向量输入经过训练的文本主题提取模型;输出与所述文本样本相应的文本主题,其中,构建的所述文本主题提取模型包括卷积神经网络和注意力机制,所述卷积神经网络包括输入层、卷积层、激活层和全连接层,输入层用于输入文本词向量,卷积层用于对所述文本词向量进行卷积运算,提取文本特征,得到文本特征向量,所述激活层用于对所述文本特征向量进行激活作用;所述注意力机制包括位置注意力机制和通道注意力机制,所述位置注意力机制和所述通道注意力机制并行建立,均与所述激活层连接,通过所述位置注意力机制向所述激活层的输出矩阵施加位置注意力权重,得到位置注意力特征矩阵,将所述位置注意力特征矩阵与所述 激活层的输出矩阵加和,得到所述位置注意力机制的输出结果;通过所述通道注意力机制向所述激活层的输出矩阵施加通道注意力权重,得到通道注意力特征矩阵,将所述通道注意力特征矩阵与所述激活层的输出矩阵加和,得到所述通道注意力机制的输出结果;将所述位置注意力机制的输出结果和所述通道注意力机制的输出结果均输入所述全连接层,通过所述全连接层输出文本主题。
为了实现上述目的,本申请的再一个方面是提供一种计算机非易失性可读存储介质,所述计算机可读存储介质中包括文本主题提取程序,所述文本主题提取程序被处理器执行时,实现如上所述的文本主题提取方法的步骤。
相对于现有技术,本申请具有以下优点和有益效果:
本申请通过卷积神经网络与注意力机制相结合构建文本主题提取模型,提取与文本相应的文本主题,提高了文本主题提取模型的精度,同时提高了文本主题提取模型的运算效率,从而提高了通过所述文本主题提取模型对文本样本进行主题提取的效率。
图1为本申请所述文本主题提取方法的流程示意图;
图2为本申请中文本主题提取程序的模块示意图。
本申请目的的实现、功能特点及优点将结合实施例,参照附图做进一步说明。
下面将参考附图来描述本申请所述的实施例。本领域的普通技术人员可以认识到,在不偏离本申请的精神和范围的情况下,可以用各种不同的方式或其组合对所描述的实施例进行修正。因此,附图和描述在本质上是说明性的,仅仅用以解释本申请,而不是用于限制权利要求的保护范围。此外,在本说明书中,附图未按比例画出,并且相同的附图标记表示相同的部分。
图1为本申请所述文本主题提取方法的流程示意图,如图1所示,本申请所述文本主题提取方法,包括以下步骤:
步骤S1、构建文本主题提取模型;
步骤S2、训练所述文本主题提取模型;
步骤S3、获取文本样本对应的文本词向量;
步骤S4、将所述文本词向量输入经过训练的文本主题提取模型;
步骤S5、输出与所述文本样本相应的文本主题,
其中,步骤S1中构建的所述文本主题提取模型包括卷积神经网络和注意力机制,所述卷积神经网络包括输入层、卷积层、激活层和全连接层,输入层用于输入文本词向量,卷积层用于对所述文本词向量进行卷积运算,提取文本特征,得到文本特征向量,所述激活层用于对所述文本特征向量进行激活作用;所述注意力机制包括位置注意力机制和通道注意力机制,所述位置注意力机制和所述通道注意力机制并行建立,均与所述激活层连接,通过所述位置注意力机制向所述激活层的输出矩阵施加位置注意力权重,得到位置 注意力特征矩阵,将所述位置注意力特征矩阵与所述激活层的输出矩阵加和,得到所述位置注意力机制的输出结果;通过所述通道注意力机制向所述激活层的输出矩阵施加通道注意力权重,得到通道注意力特征矩阵,将所述通道注意力特征矩阵与所述激活层的输出矩阵加和,得到所述通道注意力机制的输出结果,将所述位置注意力机制的输出结果和所述通道注意力机制的输出结果均输入所述全连接层,通过所述全连接层输出文本主题。
本申请通过卷积神经网络与注意力机制相结合构建文本主题提取模型,提取与文本相应的文本主题,可以用于评语的关键词摘取。所述文本主题提取模型通过卷积神经网络进行卷积运算,并通过建立并行的位置注意力机制和通道注意力机制为不同的语义分配不同的权重,在提高文本主题提取模型的精度的同时,提高了文本主题提取模型的运算效率,从而提高了通过所述文本主题提取模型对文本样本进行主题提取的效率。
本申请中,所述卷积神经网络的卷积层包括多个一维卷积核,每个卷积核均有128通道,多个所述卷积核的步长分别为1、3和5,每种步长的卷积核各占卷积核总量的1/3,通过内边距(padding)的设置实现卷积层输入和输出维度一致。卷积核的数量越多,通过卷积层提取的文本特征越多,后续通过对文本特征向量的处理得到的文本主题越精确。但卷积核的数量越多,会影响文本主题提取模型的运行速度,所以,卷积核不宜过量。
本申请的一个实施例中,卷积神经网络中激活层的激活函数采用ReLU函数,但本申请并不限于此,也可以是其他的激活函数形式,例如,Sigmoid函数或Tanh函数等形式。本申请中,将激活层的输出作为卷积神经网络的输出。
优选地,训练所述文本主题提取模型的步骤包括:
初始化所述文本主题提取模型的参数,所述参数包括:输入层与卷积层的连接权值、卷积层与激活层的连接权值、激活层和全连接层的连接权值;
构建训练样本集,训练样本包括文本词向量和文本主题;
将所述训练样本集中的一个训练样本输入所述文本主题提取模型中,输出与所述训练样本对应的文本主题;
基于所述文本主题提取模型的损失函数更新所述参数,其中,损失函数为交叉熵函数;
根据更新后的参数训练下一个训练样本,并计算所述文本主题提取模型的损失函数值;
判断所述文本主题提取模型的训练是否达到收敛条件,若达到收敛条件,则结束训练,得到训练后的文本主题提取模型,若未达到收敛条件,则更新所述文本主题提取模型的参数,继续训练,其中,所述收敛条件为损失函数值的变化小于预设阈值。一般,预设阈值可以取为0.02,训练学习率为0.001。
本申请中可以通过多种方式将文本样本转化为与其相对应的文本词向量。优选地,所述主题提取模型还包括嵌入层,所述嵌入层位于所述文本主题提取模型的第一层,通过所述嵌入层将文本样本转化为文本词向量,将得到的文本词向量输入所述卷积神经网络的输入层。但本申请并不限于此,本申请 还可以通过采用各种词向量模型将文本样本转化为与其对应的文本词向量,例如,Word2Vec模型、CBOW模型等。优选地,所述步骤S3中,获取文本样本对应的文本词向量的步骤包括:
构建词向量模型,并根据语料库对所述词向量模型进行训练,其中,用于训练的语料库可以是中文维基百科语料库;
对所述文本样本进行分词;
将分词后的文本样本输入经过训练的词向量模型;
输出与所述文本样本对应的文本词向量。
根据文本样本确定文本长度,根据确定的文本长度对文本样本进行分词,本申请的一个实施例中,根据文本样本确定的文本长度为100,通过分词库(例如,jieba、Jcseg和HanLP等分词库)对文本样本进行分词,文本词向量的维度为300。
本申请中,注意力机制包括位置注意力机制和通道注意力机制,所述位置注意力机制根据文本位置特征对所述激活层的输出矩阵施加注意力,进行权重分配;所述通道注意力机制根据卷积核通道对所述激活层的输出施加注意力,进行权重分配。
所述位置注意力机制和所述通道注意力机制并行建立,且均与所述激活层连接,所述位置注意力机制和所述通道注意力机制的输入均来源于所述激活层的输出,优选地,所述文本主题提取模型还包括多个全连接隐含层,多个全连接隐含层并行设置,且每个全连接隐含层均与所述激活层连接,通过不同的全连接隐含层将所述激活层的输出矩阵分别转化为位置注意力权重矩阵和通道注意力权重矩阵,根据所述位置注意力权重矩阵和通道注意力权重矩阵分别对所述激活层的输出进行权重分配。
进一步地,所述激活层的输出矩阵通过一个全连接隐含层输出第一转化矩阵,将所述第一转化矩阵与所述位置注意力权重矩阵进行矩阵乘法运算,得到位置注意力特征矩阵,将所述位置注意力特征矩阵与所述激活层的输出矩阵加和,得到所述通道注意力机制的输出结果,输入所述全连接层;所述激活层的输出矩阵通过另一个全连接隐含层输出第二转化矩阵,将所述第二转化矩阵与所述通道注意力权重矩阵进行矩阵乘法运算,得到通道注意力特征矩阵,将所述通道注意力特征矩阵与所述激活层的输出矩阵加和,得到所述通道注意力机制的输出结果,输入所述全连接层。
本申请的一个实施例中,卷积神经网络的卷积核为单维卷积核,卷积核通道数总量为k,激活层的输出矩阵为k*m*1,处理时将激活层的输出矩阵转化为k*m,通过与激活层连接的不同的全连接隐含层对激活层的输出矩阵进行特征提取,将激活层的输出矩阵分别转化为维度为m*k和k*m的两个矩阵,并将两个矩阵进行乘法运算,得到维度为m*m的位置注意力权重矩阵,根据该位置注意力权重矩阵对激活层的输出进行权重分配,使得处于不同位置的语义得到不同的权重,以更加精确地提取文本主题。类似地,通过与激活层连接的不同的全连接隐含层对激活层的输出进行特征提取,将激活层的输出 矩阵分别转化为维度为k*m和m*k的两个矩阵,并将两个矩阵进行乘法运算,得到维度为k*k的通道注意力权重矩阵,根据该通道注意力权重矩阵对激活层的输出进行权重分配。
例如,卷积神经网络的卷积核为单维卷积核,卷积核通道数总量为384,卷积神经网络激活层的输出矩阵为384*100*1的三维矩阵。对于位置注意力机制,首先将激活层的输出矩阵转化为384*100的二维矩阵,通过两个并行的全连接隐含层输出维度为100*384与384*100的两个矩阵,并将两个矩阵进行矩阵乘法运算及softmax映射,得到维度为100*100的位置注意力权重矩阵。在此基础上,通过另一个并行的全连接隐含层输出维度为384*100的第一转化矩阵,将第一转化矩阵与位置注意力权重矩阵进行矩阵乘法运算,得到维度为384*100的位置注意力特征矩阵并将其转化为384*100*1的三维矩阵,并与激活层输出的384*100*1的三维矩阵加和,作为位置注意力机制的输出结果。对于通道注意力机制,首先将激活层的输出矩阵转化为384*100的二维矩阵,通过两个并行的全连接隐含层输出维度为384*100与100*384的两个矩阵,并将两个矩阵进行矩阵乘法运算及softmax映射,得到维度为384*384的通道注意力权重矩阵。在此基础上,通过另一个并行的全连接隐含层输出维度为100*384的第二转化矩阵,将第二转化矩阵与通道注意力权重矩阵进行矩阵乘法,得到维度为100*384的通道注意力矩阵并将其转化为384*100*1的三维矩阵,并与激活层输出的384*100*1的三维矩阵加和,作为通道注意力机制的输出结果。将位置注意力机制和通道注意力机制的输出结果,输入全连接层,完成整个文本主题提取模型的输出,文本主题提取模型的输出维度为100,与文本样本确定的文本长度相同,对应输入的文本样本中每个词语的关键词标注。
本申请中,通过注意力机制向激活层的输出矩阵施加不同的注意力权重,经过注意力机制得到位置注意力特征矩阵和通道注意力特征矩阵,将位置注意力特征矩阵和通道注意力特征矩阵分别与卷积神经网络的输出矩阵加和。例如,文本词向量经卷积神经网络激活层的作用得到10维输出矩阵,通过位置注意力机制向10维输出矩阵施加位置注意力得到10维的位置注意力特征矩阵,通过通道注意力机制向10维输出矩阵施加通道注意力得到10维的通道注意力特征矩阵,将10维的位置注意力特征矩阵与卷积神经网络的10维输出矩阵加和得到20维的输出矩阵,输入全连接层。类似地,将10维的通道注意力特征矩阵与卷积神经网络的10维输出矩阵加和得到20维的输出矩阵,输入全连接层,经全连接层输出文本主题。
本申请所述文本主题提取方法应用于电子设备,所述电子设备可以是电视机、智能手机、平板电脑、计算机等终端设备。
所述电子设备包括:处理器;存储器,用于存储文本主题提取程序,处理器执行所述文本主题提取程序,实现以下的文本主题提取方法的步骤:构建文本主题提取模型;训练所述文本主题提取模型;获取文本样本对应的文本词向量;将所述文本词向量输入经过训练的文本主题提取模型;输出与所 述文本样本相应的文本主题。
其中,构建的所述文本主题提取模型包括卷积神经网络和注意力机制,所述卷积神经网络包括输入层、卷积层、激活层和全连接层,输入层用于输入文本词向量,卷积层用于对所述文本词向量进行卷积运算,提取文本特征,得到文本特征向量,所述激活层用于对所述文本特征向量进行激活作用;所述注意力机制包括位置注意力机制和通道注意力机制,所述位置注意力机制和所述通道注意力机制并行建立,均与所述激活层连接,通过所述位置注意力机制向所述激活层的输出矩阵施加位置注意力权重,得到位置注意力特征矩阵,将所述位置注意力特征矩阵与所述激活层的输出矩阵加和,得到所述位置注意力机制的输出结果;通过所述通道注意力机制向所述激活层的输出矩阵施加通道注意力权重,得到通道注意力特征矩阵,将所述通道注意力特征矩阵与所述激活层的输出矩阵加和,得到所述通道注意力机制的输出结果,将所述位置注意力机制的输出结果和所述通道注意力机制的输出结果均输入所述全连接层,通过所述全连接层输出文本主题。
所述电子设备还包括网络接口和通信总线等。其中,网络接口可以包括标准的有线接口、无线接口,通信总线用于实现各个组件之间的连接通信。
存储器包括至少一种类型的可读存储介质,可以是闪存、硬盘、光盘等非易失性存储介质,也可以是插接式硬盘等,且并不限于此,可以是以非暂时性方式存储指令或软件以及任何相关联的数据文件并向处理器提供指令或软件程序以使该处理器能够执行指令或软件程序的任何装置。本申请中,存储器存储的软件程序包括文本主题提取程序,并可以向处理器提供该文本主题提取程序,以使得处理器可以执行该文本主题提取程序,实现文本主题提取方法的步骤。
处理器可以是中央处理器、微处理器或其他数据处理芯片等,可以运行存储器中的存储程序,例如,可以执行本申请中的文本主题提取程序。
所述电子设备还可以包括显示器,显示器也可以称为显示屏或显示单元。在一些实施例中显示器可以是LED显示器、液晶显示器、触控式液晶显示器以及有机发光二极管(Organic Light-Emitting Diode,OLED)触摸器等。显示器用于显示在电子设备中处理的信息以及用于显示可视化的工作界面。
所述电子设备还可以包括用户接口,用户接口可以包括输入单元(比如键盘)、语音输出装置(比如音响、耳机)等。
本申请中,所述文本主题提取模型中的卷积神经网络的卷积层包括多个一维卷积核,每个卷积核均有128通道,多个所述卷积核的步长分别为1、3和5,每种步长的卷积核各占卷积核总量的1/3,通过内边距(padding)的设置实现卷积层输入和输出维度一致。
优选地,训练所述文本主题提取模型的步骤包括:
初始化所述文本主题提取模型的参数,所述参数包括:输入层与卷积层的连接权值、卷积层与激活层的连接权值、激活层和全连接层的连接权值;
构建训练样本集,训练样本包括文本词向量和文本主题;
将所述训练样本集中的一个训练样本输入所述文本主题提取模型中,输出与所述训练样本对应的文本主题;
基于所述文本主题提取模型的损失函数更新所述参数,其中,损失函数为交叉熵函数;
根据更新后的参数训练下一个训练样本,并计算所述文本主题提取模型的损失函数值;
判断所述文本主题提取模型的训练是否达到收敛条件,若达到收敛条件,则结束训练,得到训练后的文本主题提取模型,若未达到收敛条件,则更新所述文本主题提取模型的参数,继续训练,其中,所述收敛条件为损失函数值的变化小于预设阈值。一般,预设阈值可以取为0.02,训练学习率为0.001。
本申请中可以通过多种方式将文本样本转化为与其相对应的文本词向量。优选地,所述主题提取模型还包括嵌入层,所述嵌入层位于所述文本主题提取模型的第一层,通过所述嵌入层将文本样本转化为文本词向量,将得到的文本词向量输入所述卷积神经网络的输入层。但本申请并不限于此,本申请还可以通过采用各种词向量模型将文本样本转化为与其对应的文本词向量,例如,Word2Vec模型、CBOW模型等。优选地,获取文本样本对应的文本词向量的步骤包括:
构建词向量模型,并根据语料库对所述词向量模型进行训练,其中,用于训练的语料库可以是中文维基百科语料库;
对所述文本样本进行分词;
将分词后的文本样本输入经过训练的词向量模型;
输出与所述文本样本对应的文本词向量。
根据文本样本确定文本长度,根据确定的文本长度对文本样本进行分词,本申请的一个实施例中,根据文本样本确定的文本长度为100,通过分词库(例如,jieba、Jcseg和HanLP等分词库)对文本样本进行分词,文本词向量的维度为300。
优选地,所述文本主题提取模型还包括多个全连接隐含层,多个全连接隐含层并行设置,且每个全连接隐含层均与所述激活层连接,通过不同的全连接隐含层将所述激活层的输出矩阵分别转化为位置注意力权重矩阵和通道注意力权重矩阵,根据所述位置注意力权重矩阵和通道注意力权重矩阵分别对所述激活层的输出进行权重分配,所述位置注意力机制和所述通道注意力机制的输入均来源于所述激活层的输出。
进一步地,所述激活层的输出矩阵通过一个全连接隐含层输出第一转化矩阵,将所述第一转化矩阵与所述位置注意力权重矩阵进行矩阵乘法运算,得到位置注意力特征矩阵,将所述位置注意力特征矩阵与所述激活层的输出矩阵加和,得到所述通道注意力机制的输出结果,输入所述全连接层;所述激活层的输出矩阵通过另一个全连接隐含层输出第二转化矩阵,将所述第二转化矩阵与所述通道注意力权重矩阵进行矩阵乘法运算,得到通道注意力特征矩阵,将所述通道注意力特征矩阵与所述激活层的输出矩阵加和,得到所 述通道注意力机制的输出结果,输入所述全连接层。
本申请的一个实施例中,卷积神经网络的卷积核为单维卷积核,卷积核通道数总量为k,激活层的输出矩阵为k*m*1,处理时将激活层的输出矩阵转化为k*m,通过与激活层连接的不同的全连接隐含层对激活层的输出矩阵进行特征提取,将激活层的输出矩阵分别转化为维度为m*k和k*m的两个矩阵,并将两个矩阵进行乘法运算,得到维度为m*m的位置注意力权重矩阵,根据该位置注意力权重矩阵对激活层的输出进行权重分配,使得处于不同位置的语义得到不同的权重,以更加精确地提取文本主题。类似地,通过与激活层连接的不同的全连接隐含层对激活层的输出进行特征提取,将激活层的输出矩阵分别转化为维度为k*m和m*k的两个矩阵,并将两个矩阵进行乘法运算,得到维度为k*k的通道注意力权重矩阵,根据该通道注意力权重矩阵对激活层的输出进行权重分配。
在其他实施例中,文本主题提取程序还可以被分割为一个或者多个模块,一个或者多个模块被存储于存储器中,并由处理器执行,以完成本申请。本申请所称的模块是指能够完成特定功能的一系列计算机程序指令段。图2为本申请中文本主题提取程序的模块示意图,如图2所示,所述文本主题提取程序可以被分割为:模型构建模块1、模型训练模块2、获取模块3、输入模块4和输出模块5。上述模块所实现的功能或操作步骤均与上文类似,此处不再详述,示例性地,例如其中:
模型构建模块1,构建文本主题提取模型,其中,构建的文本主题提取模型包括卷积神经网络和注意力机制,具体构成如上文所述,在此不再赘述;
模型训练模块2,训练所述文本主题提取模型;
获取模块3,获取文本样本对应的文本词向量;
输入模块4,将所述文本词向量输入经过训练的文本主题提取模型;
输出模块5,输出与所述文本样本相应的文本主题。
本申请的一个实施例中,一种文本主题提取装置,包括:
模型构建模块1,构建文本主题提取模型,其中,构建的文本主题提取模型包括卷积神经网络和注意力机制;
模型训练模块2,训练所述文本主题提取模型;
获取模块3,获取文本样本对应的文本词向量;
输入模块4,将所述文本词向量输入经过训练的文本主题提取模型;
输出模块5,输出与所述文本样本相应的文本主题,
其中,所述文本主题提取模型包括卷积神经网络和注意力机制,所述模型构建模块1包括:
卷积神经网络构建子模块,构建卷积神经网络,所述卷积神经网络包括输入层、卷积层、激活层和全连接层,输入层用于输入文本词向量,卷积层用于对所述文本词向量进行卷积运算,提取文本特征,得到文本特征向量,所述激活层用于对所述文本特征向量进行激活作用;
权重施加子模块,通过注意力机制向所述卷积神经网络施加权重,所述 注意力机制包括位置注意力机制和通道注意力机制,所述位置注意力机制和所述通道注意力机制并行建立,均与所述激活层连接,通过所述位置注意力机制向所述激活层的输出矩阵施加位置注意力权重,得到位置注意力特征矩阵,将所述位置注意力特征矩阵与所述激活层的输出矩阵加和,得到所述位置注意力机制的输出结果;通过所述通道注意力机制向所述激活层的输出矩阵施加通道注意力权重,得到通道注意力特征矩阵,将所述通道注意力特征矩阵与所述激活层的输出矩阵加和,得到所述通道注意力机制的输出结果;将所述位置注意力机制的输出结果和所述通道注意力机制的输出结果均输入所述全连接层,通过所述全连接层输出文本主题。
优选地,上述,所述权重施加子模块包括:
位置注意力施加单元,所述激活层的输出矩阵通过一个全连接隐含层输出第一转化矩阵,将所述第一转化矩阵与所述位置注意力权重矩阵进行矩阵乘法运算,得到位置注意力特征矩阵;
通道注意力施加单元,所述激活层的输出矩阵通过另一个全连接隐含层输出第二转化矩阵,将所述第二转化矩阵与所述通道注意力权重矩阵进行矩阵乘法运算,得到通道注意力特征矩阵。
14.根据权利要求10所述的文本主题提取装置,其特征在于,所述获取模块包括:
词向量模型构建单元,构建词向量模型,并根据语料库对所述词向量模型进行训练;
分词单元,对所述文本样本进行分词;
训练单元,对词向量模型构建单元构建的词向量模型进行训练;
词向量获得单元,将分词后的文本样本输入经过训练的词向量模型,输出与所述文本样本对应的文本词向量。
优选地,上述模型训练模块包括:
初始化单元,初始化所述文本主题提取模型的参数,所述参数包括:输入层与卷积层的连接权值、卷积层与激活层的连接权值、激活层和全连接层的连接权值;
训练样本集构建单元,构建训练样本集,训练样本包括文本词向量和文本主题;
更新单元,将所述训练样本集中的一个训练样本输入所述文本主题提取模型中,输出与所述训练样本对应的文本主题;基于所述文本主题提取模型的损失函数更新所述参数;根据更新后的参数训练下一个训练样本;
判断单元,判断所述文本主题提取模型的训练是否达到收敛条件,若达到收敛条件,则结束训练,得到训练后的文本主题提取模型,若未达到收敛条件,则更新所述文本主题提取模型的参数,继续训练,其中,所述收敛条件为损失函数值的变化小于预设阈值。
优选地,所述卷积神经网络还包括多个全连接隐含层,多个全连接隐含层并行设置,且每个全连接隐含层均与所述激活层连接,通过所述全连接隐 含层将所述激活层的输出矩阵分别转化为位置注意力权重矩阵和通道注意力权重矩阵。
优选地,所述卷积神经网络还包括嵌入层,所述嵌入层位于所述文本主题提取模型的第一层,通过所述嵌入层将文本样本转化为文本词向量。
优选地,所述文本主题提取模型中的卷积神经网络的卷积层包括多个一维卷积核,每个卷积核均有128通道,多个所述卷积核的步长分别为1、3和5,每种步长的卷积核各占卷积核总量的1/3,通过内边距的设置实现卷积层输入和输出维度一。
本申请的一个实施例中,计算机可读存储介质可以是任何包含或存储程序或指令的有形介质,其中的程序可以被执行,通过存储的程序指令相关的硬件实现相应的功能。例如,计算机可读存储介质可以是计算机磁盘、硬盘、随机存取存储器、只读存储器等。本申请并不限于此,可以是以非暂时性方式存储指令或软件以及任何相关数据文件或数据结构并且可提供给处理器以使处理器执行其中的程序或指令的任何装置。所述计算机可读存储介质中包括文本主题提取程序,所述文本主题提取程序被处理器执行时,实现如下的文本主题提取方法:
构建文本主题提取模型;训练所述文本主题提取模型;获取文本样本对应的文本词向量;将所述文本词向量输入经过训练的文本主题提取模型;输出与所述文本样本相应的文本主题。
其中,构建的所述文本主题提取模型包括卷积神经网络和注意力机制,所述卷积神经网络包括输入层、卷积层、激活层和全连接层,输入层用于输入文本词向量,卷积层用于对所述文本词向量进行卷积运算,提取文本特征,得到文本特征向量,所述激活层用于对所述文本特征向量进行激活作用;所述注意力机制包括位置注意力机制和通道注意力机制,所述位置注意力机制和所述通道注意力机制并行建立,均与所述激活层连接,通过所述位置注意力机制向所述激活层的输出矩阵施加位置注意力权重,得到位置注意力特征矩阵,将所述位置注意力特征矩阵与所述激活层的输出矩阵加和,得到所述位置注意力机制的输出结果;通过所述通道注意力机制向所述激活层的输出矩阵施加通道注意力权重,得到通道注意力特征矩阵,将所述通道注意力特征矩阵与所述激活层的输出矩阵加和,得到所述通道注意力机制的输出结果,将所述位置注意力机制的输出结果和所述通道注意力机制的输出结果均输入所述全连接层,通过所述全连接层输出文本主题。
本申请之计算机可读存储介质的具体实施方式与上述文本主题提取方法、电子设备的具体实施方式大致相同,在此不再赘述。
需要说明的是,在本文中,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、装置、物品或者方法不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、装置、物品或者方法所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括该要素的过 程、装置、物品或者方法中还存在另外的相同要素。
上述本申请实施例序号仅仅为了描述,不代表实施例的优劣。通过以上的实施方式的描述,本领域的技术人员可以清楚地了解到上述实施例方法可借助软件加必需的通用硬件平台的方式来实现,当然也可以通过硬件,但很多情况下前者是更佳的实施方式。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品存储在如上所述的一个存储介质(如ROM/RAM、磁碟、光盘)中,包括若干指令用以使得一台终端设备(可以是手机,计算机,服务器,或者网络设备等)执行本申请各个实施例所述的方法。
以上仅为本申请的优选实施例,并非因此限制本申请的专利范围,凡是利用本申请说明书及附图内容所作的等效结构或等效流程变换,或直接或间接运用在其他相关的技术领域,均同理包括在本申请的专利保护范围内。
Claims (20)
- 一种文本主题提取方法,其特征在于,包括以下步骤:构建文本主题提取模型;训练所述文本主题提取模型;获取文本样本对应的文本词向量;将所述文本词向量输入经过训练的文本主题提取模型;输出与所述文本样本相应的文本主题,其中,构建的所述文本主题提取模型包括卷积神经网络和注意力机制,所述卷积神经网络包括输入层、卷积层、激活层和全连接层,输入层用于输入文本词向量,卷积层用于对所述文本词向量进行卷积运算,提取文本特征,得到文本特征向量,所述激活层用于对所述文本特征向量进行激活作用;所述注意力机制包括位置注意力机制和通道注意力机制,所述位置注意力机制和所述通道注意力机制并行建立,均与所述激活层连接,通过所述位置注意力机制向所述激活层的输出矩阵施加位置注意力权重,得到位置注意力特征矩阵,将所述位置注意力特征矩阵与所述激活层的输出矩阵加和,得到所述位置注意力机制的输出结果;通过所述通道注意力机制向所述激活层的输出矩阵施加通道注意力权重,得到通道注意力特征矩阵,将所述通道注意力特征矩阵与所述激活层的输出矩阵加和,得到所述通道注意力机制的输出结果;将所述位置注意力机制的输出结果和所述通道注意力机制的输出结果均输入所述全连接层,通过所述全连接层输出文本主题。
- 根据权利要求1所述的文本主题提取方法,其特征在于,所述文本主题提取模型还包括多个全连接隐含层,多个全连接隐含层并行设置,且每个全连接隐含层均与所述激活层连接,通过所述全连接隐含层将所述激活层的输出矩阵分别转化为位置注意力权重矩阵和通道注意力权重矩阵。
- 根据权利要求2所述的文本主题提取方法,其特征在于,得到所述位置注意力特征矩阵的步骤包括:所述激活层的输出矩阵通过一个全连接隐含层输出第一转化矩阵,将所述第一转化矩阵与所述位置注意力权重矩阵进行矩阵乘法运算,得到位置注意力特征矩阵;得到所述通道注意力特征矩阵的步骤包括:所述激活层的输出矩阵通过另一个全连接隐含层输出第二转化矩阵,将所述第二转化矩阵与所述通道注意力权重矩阵进行矩阵乘法运算,得到通道注意力特征矩阵。
- 根据权利要求1所述的文本主题提取方法,其特征在于,所述文本主题提取模型还包括嵌入层,所述嵌入层位于所述文本主题提取模型的第一层,通过所述嵌入层将文本样本转化为文本词向量。
- 根据权利要求1所述的文本主题提取方法,其特征在于,获取文本样 本对应的文本词向量的步骤包括:构建词向量模型,并根据语料库对所述词向量模型进行训练;对所述文本样本进行分词;将分词后的文本样本输入经过训练的词向量模型;输出与所述文本样本对应的文本词向量。
- 根据权利要求1所述的文本主题提取方法,其特征在于,训练所述文本主题提取模型的步骤包括:初始化所述文本主题提取模型的参数,所述参数包括:输入层与卷积层的连接权值、卷积层与激活层的连接权值、激活层和全连接层的连接权值;构建训练样本集,训练样本包括文本词向量和文本主题;将所述训练样本集中的一个训练样本输入所述文本主题提取模型中,输出与所述训练样本对应的文本主题;基于所述文本主题提取模型的损失函数更新所述参数;根据更新后的参数训练下一个训练样本,并计算所述文本主题提取模型的损失函数值;判断所述文本主题提取模型的训练是否达到收敛条件,若达到收敛条件,则结束训练,得到训练后的文本主题提取模型,若未达到收敛条件,则更新所述文本主题提取模型的参数,继续训练,其中,所述收敛条件为损失函数值的变化小于预设阈值。
- 根据权利要求6所述的文本主题提取方法,其特征在于,所述预设阈值为0.02,所述训练学习率为0.001。
- 根据权利要求1所述的文本主题提取方法,其特征在于,所述文本主题提取模型中的卷积神经网络的卷积层包括多个一维卷积核,每个卷积核均有128通道,多个所述卷积核的步长分别为1、3和5,每种步长的卷积核各占卷积核总量的1/3,通过内边距的设置实现卷积层输入和输出维度一。
- 根据权利要求2所述的文本主题提取方法,其特征在于,卷积神经网络的卷积核为单维卷积核,卷积核通道数总量为k,激活层的输出矩阵为k*m*1,处理时将激活层的输出矩阵转化为k*m,通过与激活层连接的不同的全连接隐含层对激活层的输出矩阵进行特征提取,将激活层的输出矩阵分别转化为维度为m*k和k*m的两个矩阵,并将两个矩阵进行乘法运算,得到维度为m*m的位置注意力权重矩阵,根据该位置注意力权重矩阵对激活层的输出进行权重分配,使得处于不同位置的语义得到不同的权。
- 一种文本主题提取装置,其特征在于,包括:模型构建模块,构建文本主题提取模型,其中,构建的文本主题提取模型包括卷积神经网络和注意力机制;模型训练模块,训练所述文本主题提取模型;获取模块,获取文本样本对应的文本词向量;输入模块,将所述文本词向量输入经过训练的文本主题提取模型;输出模块,输出与所述文本样本相应的文本主题,其中,所述文本主题提取模型包括卷积神经网络和注意力机制,所述模型构建模块包括:卷积神经网络构建子模块,构建卷积神经网络,所述卷积神经网络包括输入层、卷积层、激活层和全连接层,输入层用于输入文本词向量,卷积层用于对所述文本词向量进行卷积运算,提取文本特征,得到文本特征向量,所述激活层用于对所述文本特征向量进行激活作用;权重施加子模块,通过注意力机制向所述卷积神经网络施加权重,所述注意力机制包括位置注意力机制和通道注意力机制,所述位置注意力机制和所述通道注意力机制并行建立,均与所述激活层连接,通过所述位置注意力机制向所述激活层的输出矩阵施加位置注意力权重,得到位置注意力特征矩阵,将所述位置注意力特征矩阵与所述激活层的输出矩阵加和,得到所述位置注意力机制的输出结果;通过所述通道注意力机制向所述激活层的输出矩阵施加通道注意力权重,得到通道注意力特征矩阵,将所述通道注意力特征矩阵与所述激活层的输出矩阵加和,得到所述通道注意力机制的输出结果;将所述位置注意力机制的输出结果和所述通道注意力机制的输出结果均输入所述全连接层,通过所述全连接层输出文本主题。
- 根据权利要求10所述的文本主题提取装置,其特征在于,所述卷积神经网络还包括多个全连接隐含层,多个全连接隐含层并行设置,且每个全连接隐含层均与所述激活层连接,通过所述全连接隐含层将所述激活层的输出矩阵分别转化为位置注意力权重矩阵和通道注意力权重矩阵。
- 根据权利要求10所述的文本主题提取装置,其特征在于,所述权重施加子模块包括:位置注意力施加单元,所述激活层的输出矩阵通过一个全连接隐含层输出第一转化矩阵,将所述第一转化矩阵与所述位置注意力权重矩阵进行矩阵乘法运算,得到位置注意力特征矩阵;通道注意力施加单元,所述激活层的输出矩阵通过另一个全连接隐含层输出第二转化矩阵,将所述第二转化矩阵与所述通道注意力权重矩阵进行矩阵乘法运算,得到通道注意力特征矩阵。
- 根据权利要求10所述的文本主题提取装置,其特征在于,所述卷积神经网络还包括嵌入层,所述嵌入层位于所述文本主题提取模型的第一层,通过所述嵌入层将文本样本转化为文本词向量。
- 根据权利要求10所述的文本主题提取装置,其特征在于,所述获取模块包括:词向量模型构建单元,构建词向量模型,并根据语料库对所述词向量模型进行训练;分词单元,对所述文本样本进行分词;训练单元,对词向量模型构建单元构建的词向量模型进行训练;词向量获得单元,将分词后的文本样本输入经过训练的词向量模型,输出与所述文本样本对应的文本词向量。
- 根据权利要求10所述的文本主题提取装置,其特征在于,所述模型训练模块包括:初始化单元,初始化所述文本主题提取模型的参数,所述参数包括:输入层与卷积层的连接权值、卷积层与激活层的连接权值、激活层和全连接层的连接权值;训练样本集构建单元,构建训练样本集,训练样本包括文本词向量和文本主题;更新单元,将所述训练样本集中的一个训练样本输入所述文本主题提取模型中,输出与所述训练样本对应的文本主题;基于所述文本主题提取模型的损失函数更新所述参数;根据更新后的参数训练下一个训练样本;判断单元,判断所述文本主题提取模型的训练是否达到收敛条件,若达到收敛条件,则结束训练,得到训练后的文本主题提取模型,若未达到收敛条件,则更新所述文本主题提取模型的参数,继续训练,其中,所述收敛条件为损失函数值的变化小于预设阈值。
- 根据权利要求10所述的文本主题提取装置,其特征在于,所述文本主题提取模型中的卷积神经网络的卷积层包括多个一维卷积核,每个卷积核均有128通道,多个所述卷积核的步长分别为1、3和5,每种步长的卷积核各占卷积核总量的1/3,通过内边距的设置实现卷积层输入和输出维度一。
- 一种电子设备,其特征在于,该电子设备包括:处理器;存储器,所述存储器中包括文本主题提取程序,所述文本主题提取程序被所述处理器执行时实现如下所述的文本主题提取方法的步骤:构建文本主题提取模型;训练所述文本主题提取模型;获取文本样本对应的文本词向量;将所述文本词向量输入经过训练的文本主题提取模型;输出与所述文本样本相应的文本主题,其中,构建的所述文本主题提取模型包括卷积神经网络和注意力机制,所述卷积神经网络包括输入层、卷积层、激活层和全连接层,输入层用于输入文本词向量,卷积层用于对所述文本词向量进行卷积运算,提取文本特征,得到文本特征向量,所述激活层用于对所述文本特征向量进行激活作用;所述注意力机制包括位置注意力机制和通道注意力机制,所述位置注意力机制和所述通道注意力机制并行建立,均与所述激活层连接,通过所述位置注意力机制向所述激活层的输出矩阵施加位置注意力权重,得到位置注意力特征矩阵,将所述位置注意力特征矩阵与所述激活层的输出矩阵加和,得到所述位置注意力机制的输出结果;通过所述通道注意力机制向所述激活层的输出矩阵施加通道注意力权重,得到通道注意力特征矩阵,将所述通道注意力特征矩阵与所述激活层的输出 矩阵加和,得到所述通道注意力机制的输出结果;将所述位置注意力机制的输出结果和所述通道注意力机制的输出结果均输入所述全连接层,通过所述全连接层输出文本主题。
- 根据权利要求17所述的电子设备,其特征在于,所述文本主题提取模型还包括多个全连接隐含层,多个全连接隐含层并行设置,且每个全连接隐含层均与所述激活层连接,通过所述全连接隐含层将所述激活层的输出矩阵分别转化为位置注意力权重矩阵和通道注意力权重矩阵。
- 根据权利要求18所述的电子设备,其特征在于,所述文本主题提取模型还包括嵌入层,所述嵌入层位于所述文本主题提取模型的第一层,通过所述嵌入层将文本样本转化为文本词向量。
- 一种计算机非易失性可读存储介质,其特征在于,所述计算机可读存储介质中包括文本主题提取程序,所述文本主题提取程序被处理器执行时,实现如权利要求1至9中任一项所述的文本主题提取方法的步骤。
Applications Claiming Priority (2)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201910008265.9A CN109871532B (zh) | 2019-01-04 | 2019-01-04 | 文本主题提取方法、装置及存储介质 |
| CN201910008265.9 | 2019-01-04 |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| WO2020140633A1 true WO2020140633A1 (zh) | 2020-07-09 |
Family
ID=66917528
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| PCT/CN2019/118287 Ceased WO2020140633A1 (zh) | 2019-01-04 | 2019-11-14 | 文本主题提取方法、装置、电子设备及存储介质 |
Country Status (2)
| Country | Link |
|---|---|
| CN (1) | CN109871532B (zh) |
| WO (1) | WO2020140633A1 (zh) |
Cited By (23)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN111881260A (zh) * | 2020-07-31 | 2020-11-03 | 安徽农业大学 | 基于方面注意力和卷积记忆神经网络情感分析方法及装置 |
| CN111985551A (zh) * | 2020-08-14 | 2020-11-24 | 湖南理工学院 | 一种基于多重注意力网络的立体匹配算法 |
| CN111986730A (zh) * | 2020-07-27 | 2020-11-24 | 中国科学院计算技术研究所苏州智能计算产业技术研究院 | 一种预测siRNA沉默效率的方法 |
| CN112231562A (zh) * | 2020-10-15 | 2021-01-15 | 北京工商大学 | 一种网络谣言识别方法及系统 |
| CN112232746A (zh) * | 2020-11-03 | 2021-01-15 | 金陵科技学院 | 基于注意力加权的冷链物流需求估计方法 |
| CN112329766A (zh) * | 2020-10-14 | 2021-02-05 | 北京三快在线科技有限公司 | 文字识别方法、装置、电子设备及存储介质 |
| CN112580782A (zh) * | 2020-12-14 | 2021-03-30 | 华东理工大学 | 基于通道增强的双注意力生成对抗网络及图像生成方法 |
| CN112905751A (zh) * | 2021-03-19 | 2021-06-04 | 常熟理工学院 | 一种结合主题模型和孪生网络模型的话题演化跟踪方法 |
| CN113111970A (zh) * | 2021-04-30 | 2021-07-13 | 陕西师范大学 | 通过构建全局嵌入式注意力残差网络对图像分类的方法 |
| CN113191134A (zh) * | 2021-05-31 | 2021-07-30 | 平安科技(深圳)有限公司 | 基于注意力机制的文档质量验证方法、装置、设备及介质 |
| CN113311406A (zh) * | 2021-05-28 | 2021-08-27 | 西安电子科技大学 | 基于多通道注意力网络的飞机时频域旋翼参数估计方法 |
| CN113469335A (zh) * | 2021-06-29 | 2021-10-01 | 杭州中葳数字科技有限公司 | 一种利用不同卷积层特征间关系为特征分配权重的方法 |
| CN113468874A (zh) * | 2021-06-09 | 2021-10-01 | 大连理工大学 | 一种基于图卷积自编码的生物医学关系抽取方法 |
| CN113538675A (zh) * | 2021-06-30 | 2021-10-22 | 同济人工智能研究院(苏州)有限公司 | 一种为激光点云计算注意力权重的神经网络及训练方法 |
| CN113806534A (zh) * | 2021-09-03 | 2021-12-17 | 电子科技大学 | 一种面向社交网络的热点事件预测方法 |
| CN113837445A (zh) * | 2021-08-27 | 2021-12-24 | 合肥工业大学 | 基于注意力机制的人格预测方法及系统 |
| CN114547296A (zh) * | 2022-01-28 | 2022-05-27 | 北京邮电大学 | 识别在线产品社区高价值用户创意的系统及方法 |
| CN114881029A (zh) * | 2022-06-09 | 2022-08-09 | 合肥工业大学 | 基于混合神经网络的中文文本可读性评价方法 |
| CN114911926A (zh) * | 2021-12-07 | 2022-08-16 | 天翼数字生活科技有限公司 | 一种引入注意力机制的卷积神经网络与支持向量机分类器结合的文本分类方法 |
| CN114925197A (zh) * | 2022-03-28 | 2022-08-19 | 中南大学 | 基于主题注意力的深度学习文本分类模型训练方法 |
| CN116025765A (zh) * | 2023-01-17 | 2023-04-28 | 浙江德卡控制阀仪表有限公司 | 轴流式调节阀及其控制方法 |
| CN118338386A (zh) * | 2024-06-12 | 2024-07-12 | 深圳市中创星通科技有限公司 | 一种工业物联网传感器接入网关方法 |
| CN119148598A (zh) * | 2024-11-15 | 2024-12-17 | 济南深览电子科技有限公司 | 一种数字音响电信号优化处理方法 |
Families Citing this family (9)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN109871532B (zh) * | 2019-01-04 | 2022-07-08 | 平安科技(深圳)有限公司 | 文本主题提取方法、装置及存储介质 |
| CN110322453B (zh) * | 2019-07-05 | 2023-04-18 | 西安电子科技大学 | 基于位置注意力和辅助网络的3d点云语义分割方法 |
| CN110705268B (zh) * | 2019-09-02 | 2024-06-25 | 平安科技(深圳)有限公司 | 基于人工智能的文章主旨提取方法、装置及计算机可读存储介质 |
| CN111274892B (zh) * | 2020-01-14 | 2020-12-18 | 北京科技大学 | 一种鲁棒的遥感影像变化检测方法及系统 |
| CN113378556B (zh) * | 2020-02-25 | 2023-07-14 | 华为技术有限公司 | 提取文本关键字的方法及装置 |
| CN111597333B (zh) * | 2020-04-27 | 2022-08-02 | 国家计算机网络与信息安全管理中心 | 一种面向区块链领域的事件与事件要素抽取方法及装置 |
| CN112818687B (zh) * | 2021-03-25 | 2022-07-08 | 杭州数澜科技有限公司 | 一种用于构建标题识别模型的方法、装置、电子设备以及存储介质 |
| US20250252711A1 (en) * | 2022-05-16 | 2025-08-07 | Intel Corporation | Multi-dimensional attention for dynamic convolutional kernel |
| CN116383652B (zh) * | 2023-04-03 | 2024-02-06 | 华院计算技术(上海)股份有限公司 | 模型训练方法、可控文本的生成方法、系统、设备及介质 |
Citations (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN107239446A (zh) * | 2017-05-27 | 2017-10-10 | 中国矿业大学 | 一种基于神经网络与注意力机制的情报关系提取方法 |
| CN108829719A (zh) * | 2018-05-07 | 2018-11-16 | 中国科学院合肥物质科学研究院 | 一种非事实类问答答案选择方法及系统 |
| CN108984526A (zh) * | 2018-07-10 | 2018-12-11 | 北京理工大学 | 一种基于深度学习的文档主题向量抽取方法 |
| CN109871532A (zh) * | 2019-01-04 | 2019-06-11 | 平安科技(深圳)有限公司 | 文本主题提取方法、装置及存储介质 |
Family Cites Families (7)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US8239397B2 (en) * | 2009-01-27 | 2012-08-07 | Palo Alto Research Center Incorporated | System and method for managing user attention by detecting hot and cold topics in social indexes |
| CN103559193B (zh) * | 2013-09-10 | 2016-08-31 | 浙江大学 | 一种基于选择单元的主题建模方法 |
| US9904874B2 (en) * | 2015-11-05 | 2018-02-27 | Microsoft Technology Licensing, Llc | Hardware-efficient deep convolutional neural networks |
| CN106528655A (zh) * | 2016-10-18 | 2017-03-22 | 百度在线网络技术(北京)有限公司 | 文本主题识别方法和装置 |
| US20180329884A1 (en) * | 2017-05-12 | 2018-11-15 | Rsvp Technologies Inc. | Neural contextual conversation learning |
| CN108364023A (zh) * | 2018-02-11 | 2018-08-03 | 北京达佳互联信息技术有限公司 | 基于注意力模型的图像识别方法和系统 |
| CN108986797B (zh) * | 2018-08-06 | 2021-07-06 | 中国科学技术大学 | 一种语音主题识别方法及系统 |
-
2019
- 2019-01-04 CN CN201910008265.9A patent/CN109871532B/zh active Active
- 2019-11-14 WO PCT/CN2019/118287 patent/WO2020140633A1/zh not_active Ceased
Patent Citations (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN107239446A (zh) * | 2017-05-27 | 2017-10-10 | 中国矿业大学 | 一种基于神经网络与注意力机制的情报关系提取方法 |
| CN108829719A (zh) * | 2018-05-07 | 2018-11-16 | 中国科学院合肥物质科学研究院 | 一种非事实类问答答案选择方法及系统 |
| CN108984526A (zh) * | 2018-07-10 | 2018-12-11 | 北京理工大学 | 一种基于深度学习的文档主题向量抽取方法 |
| CN109871532A (zh) * | 2019-01-04 | 2019-06-11 | 平安科技(深圳)有限公司 | 文本主题提取方法、装置及存储介质 |
Cited By (37)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN111986730A (zh) * | 2020-07-27 | 2020-11-24 | 中国科学院计算技术研究所苏州智能计算产业技术研究院 | 一种预测siRNA沉默效率的方法 |
| CN111881260B (zh) * | 2020-07-31 | 2024-05-17 | 安徽农业大学 | 基于方面注意力和卷积记忆神经网络情感分析方法及装置 |
| CN111881260A (zh) * | 2020-07-31 | 2020-11-03 | 安徽农业大学 | 基于方面注意力和卷积记忆神经网络情感分析方法及装置 |
| CN111985551A (zh) * | 2020-08-14 | 2020-11-24 | 湖南理工学院 | 一种基于多重注意力网络的立体匹配算法 |
| CN111985551B (zh) * | 2020-08-14 | 2023-10-27 | 湖南理工学院 | 一种基于多重注意力网络的立体匹配算法 |
| CN112329766A (zh) * | 2020-10-14 | 2021-02-05 | 北京三快在线科技有限公司 | 文字识别方法、装置、电子设备及存储介质 |
| CN112231562A (zh) * | 2020-10-15 | 2021-01-15 | 北京工商大学 | 一种网络谣言识别方法及系统 |
| CN112231562B (zh) * | 2020-10-15 | 2023-07-14 | 北京工商大学 | 一种网络谣言识别方法及系统 |
| CN112232746A (zh) * | 2020-11-03 | 2021-01-15 | 金陵科技学院 | 基于注意力加权的冷链物流需求估计方法 |
| CN112232746B (zh) * | 2020-11-03 | 2023-08-22 | 金陵科技学院 | 基于注意力加权的冷链物流需求估计方法 |
| CN112580782A (zh) * | 2020-12-14 | 2021-03-30 | 华东理工大学 | 基于通道增强的双注意力生成对抗网络及图像生成方法 |
| CN112580782B (zh) * | 2020-12-14 | 2024-02-09 | 华东理工大学 | 基于通道增强的双注意力生成对抗网络及图像生成方法 |
| CN112905751B (zh) * | 2021-03-19 | 2024-03-29 | 常熟理工学院 | 一种结合主题模型和孪生网络模型的话题演化跟踪方法 |
| CN112905751A (zh) * | 2021-03-19 | 2021-06-04 | 常熟理工学院 | 一种结合主题模型和孪生网络模型的话题演化跟踪方法 |
| CN113111970B (zh) * | 2021-04-30 | 2023-12-26 | 陕西师范大学 | 通过构建全局嵌入式注意力残差网络对图像分类的方法 |
| CN113111970A (zh) * | 2021-04-30 | 2021-07-13 | 陕西师范大学 | 通过构建全局嵌入式注意力残差网络对图像分类的方法 |
| CN113311406A (zh) * | 2021-05-28 | 2021-08-27 | 西安电子科技大学 | 基于多通道注意力网络的飞机时频域旋翼参数估计方法 |
| CN113311406B (zh) * | 2021-05-28 | 2023-06-30 | 西安电子科技大学 | 基于多通道注意力网络的飞机时频域旋翼参数估计方法 |
| CN113191134A (zh) * | 2021-05-31 | 2021-07-30 | 平安科技(深圳)有限公司 | 基于注意力机制的文档质量验证方法、装置、设备及介质 |
| CN113468874B (zh) * | 2021-06-09 | 2024-04-16 | 大连理工大学 | 一种基于图卷积自编码的生物医学关系抽取方法 |
| CN113468874A (zh) * | 2021-06-09 | 2021-10-01 | 大连理工大学 | 一种基于图卷积自编码的生物医学关系抽取方法 |
| CN113469335A (zh) * | 2021-06-29 | 2021-10-01 | 杭州中葳数字科技有限公司 | 一种利用不同卷积层特征间关系为特征分配权重的方法 |
| CN113469335B (zh) * | 2021-06-29 | 2024-05-10 | 杭州中葳数字科技有限公司 | 一种利用不同卷积层特征间关系为特征分配权重的方法 |
| CN113538675A (zh) * | 2021-06-30 | 2021-10-22 | 同济人工智能研究院(苏州)有限公司 | 一种为激光点云计算注意力权重的神经网络及训练方法 |
| CN113837445A (zh) * | 2021-08-27 | 2021-12-24 | 合肥工业大学 | 基于注意力机制的人格预测方法及系统 |
| CN113806534B (zh) * | 2021-09-03 | 2023-04-18 | 电子科技大学 | 一种面向社交网络的热点事件预测方法 |
| CN113806534A (zh) * | 2021-09-03 | 2021-12-17 | 电子科技大学 | 一种面向社交网络的热点事件预测方法 |
| CN114911926A (zh) * | 2021-12-07 | 2022-08-16 | 天翼数字生活科技有限公司 | 一种引入注意力机制的卷积神经网络与支持向量机分类器结合的文本分类方法 |
| CN114547296A (zh) * | 2022-01-28 | 2022-05-27 | 北京邮电大学 | 识别在线产品社区高价值用户创意的系统及方法 |
| CN114925197A (zh) * | 2022-03-28 | 2022-08-19 | 中南大学 | 基于主题注意力的深度学习文本分类模型训练方法 |
| CN114925197B (zh) * | 2022-03-28 | 2024-06-11 | 中南大学 | 基于主题注意力的深度学习文本分类模型训练方法 |
| CN114881029B (zh) * | 2022-06-09 | 2024-03-01 | 合肥工业大学 | 基于混合神经网络的中文文本可读性评价方法 |
| CN114881029A (zh) * | 2022-06-09 | 2022-08-09 | 合肥工业大学 | 基于混合神经网络的中文文本可读性评价方法 |
| CN116025765B (zh) * | 2023-01-17 | 2024-01-19 | 浙江德卡控制阀仪表有限公司 | 轴流式调节阀及其控制方法 |
| CN116025765A (zh) * | 2023-01-17 | 2023-04-28 | 浙江德卡控制阀仪表有限公司 | 轴流式调节阀及其控制方法 |
| CN118338386A (zh) * | 2024-06-12 | 2024-07-12 | 深圳市中创星通科技有限公司 | 一种工业物联网传感器接入网关方法 |
| CN119148598A (zh) * | 2024-11-15 | 2024-12-17 | 济南深览电子科技有限公司 | 一种数字音响电信号优化处理方法 |
Also Published As
| Publication number | Publication date |
|---|---|
| CN109871532A (zh) | 2019-06-11 |
| CN109871532B (zh) | 2022-07-08 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| WO2020140633A1 (zh) | 文本主题提取方法、装置、电子设备及存储介质 | |
| US10839790B2 (en) | Sequence-to-sequence convolutional architecture | |
| US10650311B2 (en) | Suggesting resources using context hashing | |
| US20220083868A1 (en) | Neural network training method and apparatus, and electronic device | |
| US20170150235A1 (en) | Jointly Modeling Embedding and Translation to Bridge Video and Language | |
| CN113987154B (zh) | 基于UniLM与对比学习的相似句生成模型训练方法及相关设备 | |
| WO2021051513A1 (zh) | 基于神经网络的中英翻译方法、及其相关设备 | |
| CN115455171B (zh) | 文本视频的互检索以及模型训练方法、装置、设备及介质 | |
| WO2020248495A1 (zh) | 模型训练方法、装置及计算机可读存储介质 | |
| CN110941698A (zh) | 一种基于bert下卷积神经网络的服务发现方法 | |
| CN113239176B (zh) | 语义匹配模型训练方法、装置、设备及存储介质 | |
| JP2025538027A (ja) | ヒューマンコンピュータインタラクション方法、装置、電子機器及び記憶媒体 | |
| WO2023015841A1 (zh) | 基于人工智能的 sql 语句生成方法、装置、设备及存储介质 | |
| CN113361629A (zh) | 一种训练样本生成的方法、装置、计算机设备及存储介质 | |
| JP2024515199A (ja) | 要素テキスト処理方法、装置、電子機器及び記憶媒体 | |
| CN112749364B (zh) | 基于人工智能的网页生成方法、装置、设备及存储介质 | |
| CN113157900A (zh) | 意图识别方法、装置、计算机设备及存储介质 | |
| WO2021253938A1 (zh) | 一种神经网络的训练方法、视频识别方法及装置 | |
| CN116186326A (zh) | 视频推荐方法、模型训练方法、电子设备及存储介质 | |
| CN110598210B (zh) | 实体识别模型训练、实体识别方法、装置、设备及介质 | |
| CN116312489A (zh) | 一种模型训练方法及其相关设备 | |
| WO2020000715A1 (zh) | 基于指数特征提取的股指预测方法、服务器及存储介质 | |
| CN115587597B (zh) | 基于子句级关系图的方面词的情感分析方法以及装置 | |
| CN110222144B (zh) | 文本内容提取方法、装置、电子设备及存储介质 | |
| CN116910201A (zh) | 一种对话数据生成方法及其相关设备 |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| 121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 19906946 Country of ref document: EP Kind code of ref document: A1 |
|
| NENP | Non-entry into the national phase |
Ref country code: DE |
|
| 122 | Ep: pct application non-entry in european phase |
Ref document number: 19906946 Country of ref document: EP Kind code of ref document: A1 |