CN111061881A - Text classification method, equipment and storage medium - Google Patents

Text classification method, equipment and storage medium Download PDF

Info

Publication number
CN111061881A
CN111061881A CN201911380054.4A CN201911380054A CN111061881A CN 111061881 A CN111061881 A CN 111061881A CN 201911380054 A CN201911380054 A CN 201911380054A CN 111061881 A CN111061881 A CN 111061881A
Authority
CN
China
Prior art keywords
layer
text
training
text classification
semantic
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.)
Pending
Application number
CN201911380054.4A
Other languages
Chinese (zh)
Inventor
夏鑫
戴海宏
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Inspur General Software Co Ltd
Original Assignee
Inspur General Software Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Inspur General Software Co Ltd filed Critical Inspur General Software Co Ltd
Priority to CN201911380054.4A priority Critical patent/CN111061881A/en
Publication of CN111061881A publication Critical patent/CN111061881A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/35Clustering; Classification

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The embodiment of the disclosure discloses a text classification method, text classification equipment and a storage medium. One embodiment of the method comprises: acquiring text data; inputting the text data into a text classification model pre-trained according to the semantic labels and training sentences corresponding to the semantic labels to obtain classification results; wherein the text classification model comprises: the embedding layer is used for converting the semantic labels and the training sentences into N-order tensors; the characteristic extraction layer is used for extracting characteristics of the N-order tensor; the merging layer is used for merging the output results of the feature extraction layer; and the full connection layer is used for classifying the output result of the merging layer. The implementation mode can improve the processing speed and the precision of the processor for text classification, does not need a large amount of complex analysis operation, and reduces the operation amount of the processor.

Description

Text classification method, equipment and storage medium
Technical Field
Embodiments of the present disclosure relate to the field of text classification technologies, and in particular, to a text classification method, device, and storage medium.
Background
With the development of network technology, more and more services need to be processed through the network. The rate of processing network traffic requests in real time is also becoming the bottleneck of the development of enterprise service scale. Meanwhile, the complexity of network service requests also makes many service personnel unable to quickly process related services.
For example, for text data, how to quickly acquire the intention, i.e. semantics, of the server so as to facilitate corresponding countermeasures is also a problem to be solved.
Disclosure of Invention
The embodiment of the disclosure provides a text classification method, text classification equipment and a storage medium.
In a first aspect, an embodiment of the present disclosure provides a text classification method, including: acquiring text data; inputting the text data into a text classification model pre-trained according to the semantic labels and training sentences corresponding to the semantic labels to obtain classification results; wherein, this text classification model includes: the embedding layer is used for converting the semantic labels and the training sentences into N-order tensors; the characteristic extraction layer is used for extracting characteristics of the N-order tensor; the merging layer is used for merging the output results of the feature extraction layer; and the full connection layer is used for classifying the output result of the merging layer.
In some embodiments, the feature extraction layer includes a plurality of feature extraction units with different parameters, and the merging layer is configured to merge respective output results of the plurality of feature extraction units.
In some embodiments, the feature extraction unit includes a convolutional layer and a pooling layer.
In some embodiments, the processing step at the merging layer comprises: splicing the output results of the plurality of feature extraction units at the merging layer to obtain a splicing result; and carrying out flattening treatment on the splicing result.
In some embodiments, the classification result includes probability values that the text data matches the plurality of semantic tags, respectively; the method further comprises the following steps: and determining the semantic label corresponding to the maximum value in the probability value as the semantic label corresponding to the text data.
In some embodiments, the training step of deriving the text classification model comprises: acquiring a training data set, wherein the training data set comprises semantic labels and training sentences corresponding to the semantic labels; sequentially passing the semantic labels and the training sentences through an embedding layer, a feature extraction layer, a merging layer and a full connection layer of an initial neural network model to obtain a prediction classification result, wherein the prediction classification result comprises prediction probabilities of the training sentences respectively matched with a plurality of semantic labels; calculating a loss value of a semantic label matched with the training sentence in the prediction classification result and the training data set based on the loss function; and responding to the loss value within a preset numerical range, and obtaining the neural network model as a text classification model.
In some embodiments, the method further comprises: carrying out random out-of-order processing on training sentences in the training data set; and executing the training step on the training sentences processed out of order in batches.
In some embodiments, obtaining a training data set comprises: carrying out vocabulary segmentation on the sample text to obtain a plurality of vocabularies; removing stop words in the vocabulary to obtain a sample vocabulary; obtaining synonyms of sample vocabularies; combining the synonyms with the residual sample words in the sample text to obtain a sample sentence;
and classifying the sample sentences and the sentences in the sample text to obtain a training data set, wherein the training data set comprises semantic labels and training sentences corresponding to the semantic labels.
In a third aspect, an embodiment of the present disclosure provides an electronic device, including: one or more processors; a storage device having one or more programs stored thereon; when executed by one or more processors, cause the one or more processors to implement a method of text classification as described in any implementation form of the first aspect.
In a fourth aspect, an embodiment of the present disclosure provides a computer-readable medium, on which a computer program is stored, which when executed by a processor implements the text classification method as described in any of the implementations of the first aspect.
The text classification method provided by the embodiment of the disclosure includes the steps of firstly, obtaining text data, and then inputting the text data into a text classification model pre-trained according to a semantic label and a training sentence corresponding to the semantic label to obtain a classification result. The text classification model comprises an embedding layer, a feature extraction layer, a merging layer and a full connection layer. According to the text classification method, the embedded layer of the text classification model can convert input data into the N-order tensor, information contained in the text data can be reserved to a greater extent compared with a single-order tensor, so that the precision of the model can be improved, the feature information is processed and an output result is classified through the feature extraction layer, the merging layer and the full connection layer, the obtained text classification model is high in classification accuracy, and therefore when the text data are classified according to semantic tags, the processing speed and precision of a processor for text classification can be improved through the text classification method, a large amount of complex analysis operation is not needed, and the operation amount of the processor is reduced.
Drawings
Other features, objects and advantages of the disclosure will become more apparent upon reading of the following detailed description of non-limiting embodiments thereof, made with reference to the accompanying drawings in which:
FIG. 1 is an exemplary system architecture diagram in which one embodiment of the present disclosure may be applied;
FIG. 2 is a flow diagram for one embodiment of a text classification method according to the present disclosure;
FIG. 3 is a schematic diagram of an application scenario of a text classification method according to an embodiment of the present disclosure;
FIG. 4 is a flow diagram of yet another embodiment of a text classification method according to the present disclosure;
FIG. 5 is a schematic structural diagram of one embodiment of a text classification apparatus according to the present disclosure;
FIG. 6 is a schematic structural diagram of another embodiment of a text classification apparatus according to the present disclosure;
FIG. 7 is a schematic structural diagram of an electronic device suitable for use in implementing embodiments of the present disclosure.
Detailed Description
The present disclosure is described in further detail below with reference to the accompanying drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the relevant invention and not restrictive of the invention. It should be noted that, for convenience of description, only the portions related to the related invention are shown in the drawings.
It should be noted that, in the present disclosure, the embodiments and features of the embodiments may be combined with each other without conflict. The present disclosure will be described in detail below with reference to the accompanying drawings in conjunction with embodiments.
Fig. 1 illustrates an exemplary architecture 100 to which the text classification method or the text classification apparatus of the present disclosure may be applied.
As shown in fig. 1, the system architecture 100 may include terminal devices 101, 102, 103, a network 104, and a server 105. The network 104 serves as a medium for providing communication links between the terminal devices 101, 102, 103 and the server 105. Network 104 may include various connection types, such as wired, wireless communication links, or fiber optic cables, to name a few.
The terminal devices 101, 102, 103 interact with a server 105 via a network 104 to receive or send messages or the like. The terminal devices 101, 102, 103 may have various communication client applications installed thereon, such as a web browser application, an image processing application, a search application, an instant messaging tool, a mailbox client, social platform software, a text editing application, a reading application, and the like.
The terminal apparatuses 101, 102, and 103 may be hardware or software. When the terminal devices 101, 102, 103 are hardware, they may be various electronic devices having a display screen and supporting communication with a server, including but not limited to smart phones, tablet computers, e-book readers, MP3 players (Moving Picture Experts Group Audio Layer III, mpeg compression standard Audio Layer 3), MP4 players (Moving Picture Experts Group Audio Layer iv, mpeg compression standard Audio Layer 4), laptop and desktop computers, and the like. When the terminal apparatuses 101, 102, 103 are software, they can be installed in the electronic apparatuses listed above. It may be implemented as multiple pieces of software or software modules (e.g., software or software modules used to provide distributed services) or as a single piece of software or software module. And is not particularly limited herein.
The server 105 may be a server that provides various services, such as a background server that performs analysis processing on text data output on the terminal apparatuses 101, 102, 103. The background server can classify the text data and generate a processing result.
The server may be hardware or software. When the server is hardware, it may be implemented as a distributed server cluster formed by multiple servers, or may be implemented as a single server. When the server is software, it may be implemented as multiple pieces of software or software modules (e.g., software or software modules used to provide distributed services), or as a single piece of software or software module. And is not particularly limited herein.
It should be noted that the text classification method provided by the embodiment of the present disclosure is generally executed by the server 105, and accordingly, the text classification apparatus is generally disposed in the server 105.
It should be understood that the number of terminal devices, networks, and servers in fig. 1 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
With continued reference to FIG. 2, a flow 200 of one embodiment of a text classification method according to the present disclosure is shown. The text classification method is applied to a server and comprises the following steps:
step 201, text data is obtained.
In the present embodiment, the execution subject of the text classification method (such as the server 105 shown in fig. 1) may acquire text data. Specifically, the execution main body may acquire text data stored locally in advance, or may acquire text data transmitted by an electronic device (for example, the terminal device shown in fig. 1) connected to the execution main body in communication.
The text data may include words, sentences, or articles, and the present embodiment is not limited thereto.
Step 202, inputting the text data into a text classification model pre-trained according to the semantic tags and training sentences corresponding to the semantic tags to obtain a classification result.
In this embodiment, a text classification model is trained in advance from semantic tags and training sentences corresponding to the semantic tags. It should be noted that, if the input of the text classification model is text data, the output classification result may be the matching probability of the text data and each semantic tag, that is, the probability that the text data belongs to the semantic tag. Of course, the classification result output by the text classification model may also be directly a semantic tag matched with the input text data, which is not limited in this embodiment.
Here, the execution subject for training the text classification model may be the execution subject of the text classification method, or may be another third-party device for training the text classification model according to the semantic tag and the training sentence corresponding to the semantic tag, which is not limited in this embodiment.
Then, the executing entity may input the acquired text data into the text classification model, and the classification result output by the text classification model may be a probability that the text data is respectively matched with the plurality of semantic tags.
As an example, for example, if the text data input into the text classification model is a, the classification result output by the text classification model may be: the probability of a matching semantic label a is 90%, the probability of a matching semantic label b is 85%, the probability of a matching semantic label c is 80%, and the probability of a matching semantic label d is 78% … ….
Preferably, when the classification result is the probability that the text data and the semantic tags are respectively matched, the user can select the classification result according to the requirement of the user, and more reference information can be provided for the user, so that subsequent service processing is facilitated.
In this embodiment, the text classification model may include an embedding layer, a feature extraction layer, a merging layer, and a full-link layer.
The embedding layer is used for converting the semantic labels and the training sentences into N-order tensors. N is here generally understood to be an integer equal to 1. Compared with a single-order tensor, the N-order tensor can retain information contained in the text data to a greater extent, and therefore the classification accuracy of the finally obtained text classification model can be improved. The N-order tensor here may be a 3-order tensor in general, but may be adjusted according to actual circumstances, and this embodiment is not limited to this.
The feature extraction layer is used for performing feature extraction on the N-order tensor, for example, extracting key information of text data.
The merging layer is used for merging the output results of the feature extraction layer, so that the key features are compressed.
And the full connection layer is used for classifying the output result of the merging layer. Through the full connection layer, the features can be classified, and the obtained classification result can comprise a semantic label corresponding to the text data and the probability of matching the text data with the semantic label.
Through the text classification model, the text data can be rapidly subjected to semantic label classification, and for a processor, compared with the prior art in a semantic analysis mode and other modes, the calculation amount of the processor can be reduced, and the processing speed and precision of the processor on the text classification can be improved.
In an optional implementation manner of this embodiment, if the classification result includes probability values that the text data and the plurality of semantic tags respectively match, the executing body may further determine that the semantic tag corresponding to the maximum value in the probability values is the semantic tag corresponding to the text data. For example, the probability of matching the text data with each semantic tag is generally different, and the executing body may select the semantic tag with the highest probability value as the semantic tag that can be classified with the text data.
The semantic tag here may be, for example, a tag that characterizes the intention of the text data. For example, the semantic label that can be classified may be "complaint", or "quality feedback", and the like, and may be set according to actual needs, which is not limited in this embodiment.
In some optional implementations of the present embodiment, the feature extraction layer may include a plurality of feature extraction units with differentiated parameters. Parameter differentiation means that the parameters may be different for each feature extraction unit.
As an example, each feature extraction unit may include a convolutional layer and a pooling layer. The number of the convolutional layers and the pooling layers may not be particularly limited, and for example, each feature extraction unit may include 1 convolutional layer and 1 pooling layer. The convolutional layer can extract key feature information, and the pooling layer can remove redundant feature information in the output of the convolutional layer, so that key features are obtained.
Since there is a difference in the parameter of each feature extraction unit, there is also a difference in the feature information extracted by each feature extraction unit. For example, if there are 3 feature extraction units, each of which includes 1 convolution layer and 1 pooling layer, the execution body may input the N-order tensor into the 3 feature extraction units respectively to obtain 3 feature extraction results respectively.
In some optional implementations of this embodiment, the merging layer is configured to merge respective output results of the plurality of feature extraction units. Specifically, the processing step of the execution subject at the merging layer may include: and splicing the output results of the plurality of feature extraction units on the merging layer to obtain a splicing result, and flattening the splicing result. Splice of concatemate features may be understood as the process of feature fusion.
The execution body may perform feature fusion on a plurality of feature extraction results output by the feature extraction layer in the merging layer, and then perform planarization (Flatten). The flattening process may transform the multi-dimensional tensor into a one-dimensional tensor. After the flattening process, in order to make the text classification model more generalized, the executing body may input the feature tensor after the flattening process into the Dropout layer to compress the non-critical information.
With continued reference to fig. 3, fig. 3 is a schematic diagram of an application scenario of the text classification method according to the present disclosure. In the application scenario of fig. 3, the server 301 obtains "product a is damaged and needs to be returned" 303 sent by the client 302. The server 301 then enters "product A is in stock with a breakage, return needed" 303 into the pre-trained text classification model 304. The text classification model 304 outputs three classification results: the "probability of matching text data with semantic tag ' return" is 98% "305, the" probability of matching text data with semantic tag ' logistics service is 90% "306, and the" probability of matching text data with semantic tag ' quality "is 75%" 307.
According to the method provided by the embodiment of the disclosure, because the embedded layer of the text classification model can convert the input data into the N-order tensor, compared with the single-order tensor, the information contained in the text data can be retained to a greater extent, so that the precision of the model can be improved, the feature information is processed and the output result is classified through the feature extraction layer, the merging layer and the full connection layer, and the obtained text classification model has high classification accuracy.
With further reference to fig. 4, a flow 400 of yet another embodiment of a text classification method is shown. The text classification method is applied to a server and comprises the following steps:
step 401, a training data set is obtained.
In this embodiment, the executing entity (such as the server 105 shown in fig. 1) of the text classification method may directly obtain the training data set from the local, or may receive the training data set sent by other third-party devices. The training data set here comprises semantic labels and training sentences corresponding to the semantic labels.
The semantic tags may include, for example, "quality issue," "time of delivery," "logistics poor service," "return," and so on. The training sentences corresponding to the semantic tags of the quality problem can include 'product a is damaged', 'product a is not good in quality', and the like. The training statements corresponding to the "time to ship" semantic tag may include "several days available", "when to ship", and so on. The training sentences corresponding to the semantic label of 'logistics service difference' can comprise 'packaging breakage when logistics arrive at a good', 'logistics delayed delivery', and the like. The training sentences corresponding to the "return" semantic tags may include "what information needs to be filled in for return", "product does not want to need return", and so on.
In an optional implementation manner of this embodiment, the executing entity may obtain the training data set by:
firstly, segmenting words of a sample text to obtain a plurality of words.
In this implementation manner, the execution subject may perform vocabulary segmentation on the sample text to obtain a plurality of vocabularies.
The sample text may be a sample sentence or a paragraph text including a plurality of sample sentences, for example. After obtaining the sample sentence, the execution subject may perform vocabulary division on the sample sentence. The word division means that the sentences are divided according to words. For example, "i want to catch up to shanghai today", in the sentence, we can divide the words into words and phrases to obtain words such as "i", "today", "want", "go", and "shanghai".
And secondly, removing stop words in the vocabulary to obtain a sample vocabulary.
A sentence usually comprises a plurality of words, some words are prepositions, auxiliary words and the like, and some words are keywords. In this implementation, after the vocabulary of the sample text is segmented to obtain a plurality of vocabularies, the execution subject may remove stop words in the vocabularies to obtain sample vocabularies.
For example, in the above words "me", "today", "want", "go" and "shanghai", the word "want" can be removed, and the rest words "me", "today", "go" and "shanghai" are used as sample words.
And thirdly, obtaining synonyms of sample vocabularies.
In this implementation manner, after the stop word in the vocabulary is removed and the sample vocabulary is obtained, the execution subject may further obtain the synonym of the sample vocabulary. Specifically, the execution subject may perform synonym calculation on the sample vocabulary, and for each vocabulary, obtain at least one synonym.
Synonyms such as "go" may include "to," "reach," and the like.
And fourthly, combining the synonym and the residual sample words in the sample text to obtain a sample sentence.
In this implementation manner, the execution subject may combine the synonym with the remaining sample vocabulary in the sample text to obtain a sample sentence, so as to form a large number of new sentences, thereby reducing the workload of the user for arranging samples, and also improving the coverage of the model.
For example, the synonym "to" may be combined with other words to get the sample sentence "i am today to shanghai".
And fifthly, classifying the sample sentence and the sentences in the sample text to obtain a training data set.
In this implementation manner, the execution subject may classify the sample sentence and the sentences in the sample text to obtain a training data set. The training data set here comprises semantic labels and training sentences corresponding to the semantic labels.
That is, the execution subject can classify the sample sentence and the sentence in the training text. All the sample sentences and the sentences in the training text can be used as training sentences, the training sentences are classified according to the semantic labels, and the quantity of the training sentences under each classification can be increased.
And 402, sequentially passing the semantic labels and the training sentences through an embedding layer, a feature extraction layer, a merging layer and a full connection layer of the initial neural network model to obtain a prediction classification result.
In this embodiment, the execution main body may sequentially and often initialize the embedding layer, the feature extraction layer, the merging layer, and the full-link layer of the neural network model with the semantic tags and the training sentences to obtain a prediction classification result.
The initial neural network model comprises an embedding layer, a feature extraction layer, a merging layer and a full connection layer, and the layer structures of the neural networks can be understood to be the same as or similar to the layer structure of the text classification model, and are not described herein again.
The prediction classification result comprises prediction probabilities of the training sentences respectively matched with the semantic labels. Specifically, when the initial neural network model is trained, the input of the initial neural network model is a semantic label and a training sentence, and the output is the probability of the semantic label to which the training sentence can belong, so that more reference information can be provided for a user to select so as to be convenient for processing in combination with subsequent services.
In an optional implementation manner of this embodiment, the executing body may further perform random out-of-order processing on the training sentences in the training data set, and then perform the training step on the training sentences subjected to the out-of-order processing in batches.
Because the memory of the server is limited, and in order to ensure the unbiased training result, the training sentences are firstly subjected to disorder processing, and then the sentences subjected to disorder processing are subjected to batch training of the neural network model, so that the calculation rate during each training can be ensured, the neural network model can be subjected to one-time parameter adjustment during each batch of training, and then the neural network model subjected to parameter adjustment is continuously trained by the training data of the next batch.
And 403, calculating the loss value of the semantic label matched with the training sentence in the prediction classification result and the training data set based on the loss function.
In this embodiment, the execution subject may further calculate a loss value of the semantic label matching the training sentence in the prediction classification result and the training data set based on a loss function.
Specifically, the neural network parameters can be continuously updated by a minimization method so that the loss value converges to the expected range as soon as possible.
As an example, the loss function may be:
Figure BDA0002341964630000101
in the formula, loss represents a loss function, n represents the number of training sentences input in the batch, x represents the input training sentences and semantic labels, a represents the feature tensor into which the semantic labels are converted, and y represents the predicted classification result (the semantic labels and the probability corresponding to the training sentences).
As can be seen from the above formula, in this embodiment, the calculation of the loss function involves predicting the probability in the classification result, so that the trained model can make the probability that the training sentence matches the corresponding semantic tag higher and higher, thereby improving the classification accuracy of the final training model.
Of course, the loss function may have other loss function forms, and the embodiment is not limited thereto.
In response to the loss value being within the preset value range, the obtained neural network model is a text classification model, step 404.
In this embodiment, if the loss value is within the preset value range, the executing entity may determine that the obtained neural network model is a text classification model.
When the loss value is within the preset value range, the obtained neural network model classification result is more accurate, and the parameters of the neural network model classification result are optimized, so that the executing body can consider the neural network model obtained at the moment as a text classification model.
Step 405, text data is obtained.
Step 406, inputting the text data into a text classification model to obtain a classification result.
In this embodiment, step 405 and step 406 are respectively the same as step 201 and step 202 in the foregoing embodiment, and the above description for step 201 and step 202 also applies to step 405 and step 406, which is not described herein again.
In the text classification method of the embodiment, the initial neural network model is trained, and the parameters of the initial neural network model are adjusted to obtain the text classification model. The initial neural network model comprises an embedding layer, a feature extraction layer, a merging layer and a full connection layer. For the server, the initial neural network model is trained, so that the classification efficiency is high when the text classification model is used, the operation efficiency of the processor is improved, and the operation amount is reduced.
With further reference to fig. 5, as an implementation of the method shown in the above figures, the present disclosure provides an embodiment of a text classification apparatus, which corresponds to the embodiment of the method shown in fig. 2, and which may be specifically applied to various electronic devices.
As shown in fig. 5, the text classification apparatus 500 provided in the present embodiment includes a text data acquisition unit 501 and a processing unit 502. Wherein, the text data obtaining unit 501 is configured to obtain text data; the processing unit 502 is configured to input the text data into a text classification model pre-trained according to a semantic label and a training sentence corresponding to the semantic label, so as to obtain a classification result.
In the present embodiment, in the text classification apparatus 500: the detailed processing of the text data obtaining unit 501 and the processing unit 502 and the technical effects thereof can refer to the related descriptions of step 201 and step 202 in the corresponding embodiment of fig. 2, which are not repeated herein.
Wherein, this text classification model includes: the embedding layer is used for converting the semantic labels and the training sentences into N-order tensors; the characteristic extraction layer is used for extracting characteristics of the N-order tensor; the merging layer is used for merging the output results of the feature extraction layer; and the full connection layer is used for classifying the output result of the merging layer.
In some optional implementations of the present embodiment, the feature extraction layer includes a plurality of feature extraction units with differentiated parameters.
In some optional implementations of the present embodiment, the feature extraction unit includes a convolutional layer and a pooling layer.
In some optional implementations of this embodiment, as shown in fig. 6, the processing unit 502 further includes: a splicing module 5021 and a flattening module 5022 for processing at the merged layer. The splicing module 5021 is used for splicing output results of the plurality of feature extraction units at a merging layer to obtain a splicing result; the planarization module 5022 is used for planarizing the splicing result.
In the apparatus provided in the above embodiment of the present disclosure, the text data is acquired by the text data acquisition unit 501, and the processing unit 502 inputs the text data into a text classification model pre-trained according to a semantic tag and a training sentence corresponding to the semantic tag, so as to obtain a classification result. When the text data is classified according to the semantic labels, the text classification device can improve the processing speed and precision of the processor for classifying the texts, does not need a large amount of complex analysis operation, and reduces the operation amount of the processor.
Referring now to FIG. 7, and referring now to FIG. 7, a block diagram of an electronic device (e.g., server in FIG. 1) 700 suitable for use in implementing embodiments of the present disclosure is shown. The server shown in fig. 7 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present disclosure.
As shown in fig. 7, electronic device 700 may include a processing means (e.g., central processing unit, graphics processor, etc.) 701 that may perform various appropriate actions and processes in accordance with a program stored in a Read Only Memory (ROM)702 or a program loaded from storage 708 into a Random Access Memory (RAM) 703. In the RAM 703, various programs and data necessary for the operation of the electronic apparatus 700 are also stored. The processing device 701, the ROM 702, and the RAM 703 are connected to each other by a bus 704. An input/output (I/O) interface 705 is also connected to bus 704.
Generally, the following devices may be connected to the I/O interface 705: input devices 706 including, for example, a touch screen, touch pad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; an output device 707 including, for example, a Liquid Crystal Display (LCD), a speaker, a vibrator, and the like; storage 708 including, for example, magnetic tape, hard disk, etc.; and a communication device 709. The communication means 709 may allow the electronic device 700 to communicate wirelessly or by wire with other devices to exchange data. While fig. 7 illustrates an electronic device 700 having various means, it is to be understood that not all illustrated means are required to be implemented or provided. More or fewer devices may alternatively be implemented or provided. Each block shown in fig. 7 may represent one device or may represent multiple devices as desired.
In particular, according to an embodiment of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method illustrated in the flow chart. In such embodiments, the computer program may be downloaded and installed from a network via the communication means 709, or may be installed from the storage means 708, or may be installed from the ROM 702. The computer program, when executed by the processing device 701, performs the above-described functions defined in the methods of embodiments of the present disclosure.
It should be noted that the computer readable medium described in the embodiments of the present disclosure may be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
In embodiments of the disclosure, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In embodiments of the present disclosure, however, a computer readable signal medium may comprise a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: electrical wires, optical cables, RF (Radio Frequency), etc., or any suitable combination of the foregoing.
The computer readable medium may be embodied in the electronic device; or may exist separately and not be assembled into the server. The computer readable medium carries one or more programs which, when executed by the server, cause the server to: acquiring text data; inputting text data into a text classification model pre-trained according to semantic labels and training sentences corresponding to the semantic labels to obtain classification results; wherein, this text classification model includes: the embedding layer is used for converting the semantic labels and the training sentences into N-order tensors; the characteristic extraction layer is used for extracting characteristics of the N-order tensor; the merging layer is used for merging the output results of the feature extraction layer; and the full connection layer is used for classifying the output result of the merging layer.
Computer program code for carrying out operations for embodiments of the present disclosure may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C + +, and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units described in the embodiments of the present disclosure may be implemented by software or hardware. The described units may also be provided in a processor, and may be described as: a processor includes a target fundus image acquiring unit, a first image block dividing unit, a first output value acquiring unit, and a first processing unit. Here, the names of these units do not constitute a limitation of the unit itself in some cases, and for example, the target fundus image acquisition unit may also be described as "a unit for acquiring a target fundus image".
The foregoing description is only exemplary of the preferred embodiments of the disclosure and is illustrative of the principles of the technology employed. It will be appreciated by those skilled in the art that the scope of the invention in the embodiments of the present disclosure is not limited to the specific combination of the above-mentioned features, but also encompasses other embodiments in which any combination of the above-mentioned features or their equivalents is made without departing from the inventive concept as defined above. For example, the above features and (but not limited to) technical features with similar functions disclosed in the embodiments of the present disclosure are mutually replaced to form the technical solution.

Claims (10)

1. A method of text classification, comprising:
acquiring text data;
inputting the text data into a text classification model pre-trained according to semantic labels and training sentences corresponding to the semantic labels to obtain classification results;
wherein the text classification model comprises: an embedding layer for converting the semantic labels and the training sentences into N-order tensors; the characteristic extraction layer is used for extracting characteristics of the N-order tensor; the merging layer is used for merging the output results of the feature extraction layer; and the full connection layer is used for classifying the output result of the merging layer.
2. The text classification method according to claim 1, wherein the feature extraction layer includes a plurality of feature extraction units of parameter differentiation;
the merging layer is used for merging the output results of the plurality of feature extraction units.
3. The text classification method according to claim 2, characterized in that the feature extraction unit comprises a convolutional layer and a pooling layer.
4. The text classification method according to claim 2, characterized in that the processing step at the merging layer comprises:
splicing the output results of the plurality of feature extraction units at the merging layer to obtain a splicing result;
and carrying out flattening treatment on the splicing result.
5. The text classification method according to claim 1, wherein the classification result includes probability values that the text data are respectively matched with the plurality of semantic tags; the method further comprises the following steps:
and determining the semantic label corresponding to the maximum value in the probability value as the semantic label corresponding to the text data.
6. The text classification method according to claim 1, wherein the training step of deriving the text classification model comprises:
acquiring a training data set, wherein the training data set comprises the semantic tags and training sentences corresponding to the semantic tags;
sequentially passing the semantic labels and the training sentences through an embedding layer, a feature extraction layer, a merging layer and a full connection layer of an initial neural network model to obtain a prediction classification result, wherein the prediction classification result comprises prediction probabilities of the training sentences respectively matched with the semantic labels;
calculating a loss value of the semantic label matched with the training sentence in the training data set and the prediction classification result based on a loss function;
and responding to the loss value within a preset numerical range, and obtaining the neural network model as the text classification model.
7. The method of text classification according to claim 6, characterized in that the method further comprises:
carrying out random out-of-order processing on the training sentences in the training data set;
and executing the training step on the training sentences processed out of order in batches.
8. The text classification method of claim 6, wherein the obtaining a training data set comprises:
carrying out vocabulary segmentation on the sample text to obtain a plurality of vocabularies;
removing stop words in the vocabulary to obtain a sample vocabulary;
obtaining synonyms of the sample vocabulary;
combining the synonyms with the residual sample vocabularies in the sample text to obtain sample sentences;
classifying the sample sentences and the sentences in the sample text to obtain a training data set, wherein the training data set comprises semantic labels and training sentences corresponding to the semantic labels.
9. An electronic device, comprising:
one or more processors;
a storage device having one or more programs stored thereon;
the one or more programs, when executed by the one or more processors, cause the one or more processors to implement the text classification method of any of claims 1-8.
10. A computer-readable medium, on which a computer program is stored which, when being executed by a processor, carries out the method for text classification according to any one of claims 1 to 8.
CN201911380054.4A 2019-12-27 2019-12-27 Text classification method, equipment and storage medium Pending CN111061881A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911380054.4A CN111061881A (en) 2019-12-27 2019-12-27 Text classification method, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911380054.4A CN111061881A (en) 2019-12-27 2019-12-27 Text classification method, equipment and storage medium

Publications (1)

Publication Number Publication Date
CN111061881A true CN111061881A (en) 2020-04-24

Family

ID=70304425

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911380054.4A Pending CN111061881A (en) 2019-12-27 2019-12-27 Text classification method, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN111061881A (en)

Cited By (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111651497A (en) * 2020-04-30 2020-09-11 北京大米科技有限公司 User label mining method and device, storage medium and electronic equipment
CN111738014A (en) * 2020-06-16 2020-10-02 北京百度网讯科技有限公司 Drug classification method, device, equipment and storage medium
CN112084337A (en) * 2020-09-17 2020-12-15 腾讯科技(深圳)有限公司 Training method of text classification model, and text classification method and equipment
CN112347779A (en) * 2020-11-23 2021-02-09 军工保密资格审查认证中心 Method and device for automatically judging security level of confidential text
CN112487149A (en) * 2020-12-10 2021-03-12 浙江诺诺网络科技有限公司 Text auditing method, model, equipment and storage medium
US11010692B1 (en) * 2020-12-17 2021-05-18 Exceed AI Ltd Systems and methods for automatic extraction of classification training data
CN112883189A (en) * 2021-01-26 2021-06-01 浙江香侬慧语科技有限责任公司 Text classification method and device based on label description, storage medium and equipment
CN113157927A (en) * 2021-05-27 2021-07-23 中国平安人寿保险股份有限公司 Text classification method and device, electronic equipment and readable storage medium
CN113780066A (en) * 2021-07-29 2021-12-10 苏州浪潮智能科技有限公司 Pedestrian re-identification method and device, electronic equipment and readable storage medium
CN116306673A (en) * 2023-03-16 2023-06-23 之江实验室 Text feature extraction method and system, electronic equipment and medium
CN118307108A (en) * 2024-06-11 2024-07-09 陕西省水务集团水处理设备有限公司 Dosing control method and device in water treatment process, medium and electronic equipment

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108227565A (en) * 2017-12-12 2018-06-29 深圳和而泰数据资源与云技术有限公司 A kind of information processing method, terminal and computer-readable medium
CN109325114A (en) * 2018-07-24 2019-02-12 武汉理工大学 A kind of text classification algorithm merging statistical nature and Attention mechanism
CN109871444A (en) * 2019-01-16 2019-06-11 北京邮电大学 A kind of file classification method and system
CN110069252A (en) * 2019-04-11 2019-07-30 浙江网新恒天软件有限公司 A kind of source code file multi-service label mechanized classification method

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108227565A (en) * 2017-12-12 2018-06-29 深圳和而泰数据资源与云技术有限公司 A kind of information processing method, terminal and computer-readable medium
CN109325114A (en) * 2018-07-24 2019-02-12 武汉理工大学 A kind of text classification algorithm merging statistical nature and Attention mechanism
CN109871444A (en) * 2019-01-16 2019-06-11 北京邮电大学 A kind of file classification method and system
CN110069252A (en) * 2019-04-11 2019-07-30 浙江网新恒天软件有限公司 A kind of source code file multi-service label mechanized classification method

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
何伟等: ""基于张量空间模型的中文文本分类"", 《合肥工业大学学报(自然科学版)》 *

Cited By (18)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111651497A (en) * 2020-04-30 2020-09-11 北京大米科技有限公司 User label mining method and device, storage medium and electronic equipment
CN111651497B (en) * 2020-04-30 2023-11-14 北京大米科技有限公司 User tag mining method and device, storage medium and electronic equipment
CN111738014B (en) * 2020-06-16 2023-09-08 北京百度网讯科技有限公司 Drug classification method, device, equipment and storage medium
CN111738014A (en) * 2020-06-16 2020-10-02 北京百度网讯科技有限公司 Drug classification method, device, equipment and storage medium
CN112084337A (en) * 2020-09-17 2020-12-15 腾讯科技(深圳)有限公司 Training method of text classification model, and text classification method and equipment
CN112084337B (en) * 2020-09-17 2024-02-09 腾讯科技(深圳)有限公司 Training method of text classification model, text classification method and equipment
CN112347779A (en) * 2020-11-23 2021-02-09 军工保密资格审查认证中心 Method and device for automatically judging security level of confidential text
CN112487149A (en) * 2020-12-10 2021-03-12 浙江诺诺网络科技有限公司 Text auditing method, model, equipment and storage medium
US20220198316A1 (en) * 2020-12-17 2022-06-23 Exceed AI Ltd, Tel-Aviv Systems and Methods for Automatic Extraction of Classification Training Data
US11010692B1 (en) * 2020-12-17 2021-05-18 Exceed AI Ltd Systems and methods for automatic extraction of classification training data
CN112883189A (en) * 2021-01-26 2021-06-01 浙江香侬慧语科技有限责任公司 Text classification method and device based on label description, storage medium and equipment
CN113157927A (en) * 2021-05-27 2021-07-23 中国平安人寿保险股份有限公司 Text classification method and device, electronic equipment and readable storage medium
CN113157927B (en) * 2021-05-27 2023-10-31 中国平安人寿保险股份有限公司 Text classification method, apparatus, electronic device and readable storage medium
CN113780066A (en) * 2021-07-29 2021-12-10 苏州浪潮智能科技有限公司 Pedestrian re-identification method and device, electronic equipment and readable storage medium
CN113780066B (en) * 2021-07-29 2023-07-25 苏州浪潮智能科技有限公司 Pedestrian re-recognition method and device, electronic equipment and readable storage medium
CN116306673A (en) * 2023-03-16 2023-06-23 之江实验室 Text feature extraction method and system, electronic equipment and medium
CN116306673B (en) * 2023-03-16 2023-10-24 之江实验室 Text feature extraction method and system, electronic equipment and medium
CN118307108A (en) * 2024-06-11 2024-07-09 陕西省水务集团水处理设备有限公司 Dosing control method and device in water treatment process, medium and electronic equipment

Similar Documents

Publication Publication Date Title
CN111061881A (en) Text classification method, equipment and storage medium
CN112699991B (en) Method, electronic device, and computer-readable medium for accelerating information processing for neural network training
CN108416310B (en) Method and apparatus for generating information
US11308942B2 (en) Method and apparatus for operating smart terminal
CN111523640B (en) Training method and device for neural network model
CN113360660B (en) Text category recognition method, device, electronic equipment and storage medium
CN109190123B (en) Method and apparatus for outputting information
CN113378855A (en) Method for processing multitask, related device and computer program product
CN111368551A (en) Method and device for determining event subject
CN111444335B (en) Method and device for extracting central word
CN109840072B (en) Information processing method and device
CN111078849A (en) Method and apparatus for outputting information
CN112906368B (en) Industry text increment method, related device and computer program product
CN111858916B (en) Method and device for clustering sentences
CN115204150B (en) Information verification method and device, electronic equipment and computer readable medium
CN116450943A (en) Artificial intelligence-based speaking recommendation method, device, equipment and storage medium
CN113360672B (en) Method, apparatus, device, medium and product for generating knowledge graph
CN110472055B (en) Method and device for marking data
CN109857838B (en) Method and apparatus for generating information
CN113806541A (en) Emotion classification method and emotion classification model training method and device
CN113780239A (en) Iris recognition method, iris recognition device, electronic equipment and computer readable medium
CN113392215A (en) Training method of production problem classification model, and production problem classification method and device
CN113111897A (en) Alarm receiving and warning condition type determining method and device based on support vector machine
CN116911714B (en) Method, apparatus, electronic device, and computer-readable medium for transporting articles
CN113656573B (en) Text information generation method, device and terminal equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication

Application publication date: 20200424