CN112396111A - Text intention classification method and device, computer equipment and storage medium - Google Patents

Text intention classification method and device, computer equipment and storage medium Download PDF

Info

Publication number
CN112396111A
CN112396111A CN202011310583.XA CN202011310583A CN112396111A CN 112396111 A CN112396111 A CN 112396111A CN 202011310583 A CN202011310583 A CN 202011310583A CN 112396111 A CN112396111 A CN 112396111A
Authority
CN
China
Prior art keywords
sample
text
classification
preset
detected
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
CN202011310583.XA
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.)
Ping An Puhui Enterprise Management Co Ltd
Original Assignee
Ping An Puhui Enterprise Management 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 Ping An Puhui Enterprise Management Co Ltd filed Critical Ping An Puhui Enterprise Management Co Ltd
Priority to CN202011310583.XA priority Critical patent/CN112396111A/en
Publication of CN112396111A publication Critical patent/CN112396111A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/24Classification techniques
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/23Clustering techniques
    • G06F18/232Non-hierarchical techniques
    • G06F18/2321Non-hierarchical techniques using statistics or function optimisation, e.g. modelling of probability density functions
    • G06F18/23213Non-hierarchical techniques using statistics or function optimisation, e.g. modelling of probability density functions with fixed number of clusters, e.g. K-means clustering
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/30Semantic analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • G06N3/045Combinations of networks
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods

Abstract

The embodiment of the application belongs to the field of artificial intelligence and relates to a text intention classification method which comprises the steps of obtaining a preset detection model, and classifying texts to be detected and samples; inputting the text to be detected and the sample classification into the preset detection model, performing intention recognition on the text to be detected based on a coding layer, a classification layer and a relation layer in the preset detection model, and outputting to obtain a relation score of the text to be detected and the sample classification; and selecting a sample classification corresponding to the highest score in the relation scores according to the one-hot codes, and determining that the sample classification corresponding to the highest score is the intention classification of the text to be detected. The application also provides a text intention classification device, computer equipment and a storage medium. Further, the present application relates to blockchain techniques, and the relationship score may be stored in a blockchain. The text intention classification method and the text intention classification device realize accurate and efficient classification of the text intention.

Description

Text intention classification method and device, computer equipment and storage medium
Technical Field
The present application relates to the field of artificial intelligence technologies, and in particular, to a text intention classification method and apparatus, a computer device, and a storage medium.
Background
Text classification is a very common processing task in natural language processing. Since the data categories are often uneven long tail distribution or non-label data, a large amount of labor cost is usually required to label the data. For a mature industrial system, the text data to be labeled is often tens of thousands, and the labor and capital costs are enormous.
The existing text classification method generally adopts a down-sampling classification mode, namely a small number of samples are selected from a certain class with a large number of samples, so that the samples in all the text classes are in balanced distribution, but the mode wastes a lot of valuable data. In addition, when the data is a large amount of non-label data, a rule method is generally adopted for processing currently, but the rule classification mode has low generalization. This ultimately leads to a problem of low accuracy in the intended classification of text data.
Disclosure of Invention
An embodiment of the application aims to provide a text intention classification method, a text intention classification device, a computer device and a storage medium, so as to solve the technical problem of low text intention classification accuracy.
In order to solve the above technical problem, an embodiment of the present application provides a text intention classification method, which adopts the following technical solutions:
acquiring a preset detection model, a text to be detected and a sample classification;
inputting the text to be detected and the sample classification into the preset detection model, performing intention recognition on the text to be detected based on a coding layer, a classification layer and a relation layer in the preset detection model, and outputting to obtain a relation score of the text to be detected and the sample classification;
and selecting a sample classification corresponding to the highest score in the relation scores according to the one-hot codes, and determining that the sample classification corresponding to the highest score is the intention classification of the text to be detected.
Further, the step of performing intent recognition on the text to be detected based on the coding layer, the classification layer and the relation layer in the preset detection model specifically includes:
coding the text to be detected and the sample classification based on a coding layer in the preset detection model to obtain a sample representation;
inputting the sample characterization to a classification layer in the preset detection model, and outputting to obtain a classification characterization;
and acquiring a text vector of the text to be detected, inputting the classification characteristic and the text vector to a relation layer in the preset detection model, and outputting to obtain a relation score of the text to be detected and the sample classification.
Further, the step of inputting the classification feature and the text vector to a relationship layer in the preset detection model and outputting to obtain a relationship score between the text to be detected and the sample classification specifically includes:
acquiring a first preset weight value and a second preset weight value;
and calculating the first preset weight value, the second preset weight value, the classification characteristic and the text vector based on an activation function of a relation layer in the preset detection model to obtain a relation score between each sample classification and the text to be detected.
Further, the step of obtaining the preset detection model specifically includes:
constructing a small sample training set and a preset small sample model;
dividing the small sample training set into a first sub-sample set and a second sub-sample set, training the preset small sample model according to the first sub-sample set, calculating a loss function of the preset small sample model, and determining the preset small sample model as a sample model to be verified when the loss function is converged;
and verifying the sample model to be verified according to the second sub-sample set, and determining the sample model to be verified as the preset detection model when the verification passing rate of the sample model to be verified on the second sub-sample set is greater than or equal to a preset threshold value.
Further, the step of training the preset small sample model according to the first sub-sample set and calculating the loss function of the preset small sample model specifically includes:
inputting the first sub-sample set into the preset small sample model, and outputting to obtain prediction intention classification;
and acquiring the real intention classification of the first sub-sample set, and calculating the mean square error of the real intention classification and the prediction intention classification to obtain a loss function of the preset small sample model.
Further, the step of dividing the small sample training set into a first sub-sample set and a second sub-sample set specifically includes:
randomly selecting a first preset number of sample classifications, selecting a second preset number of samples from each sample classification, wherein the number of the samples of the first sub-sample set in the small sample training set is the product of the first preset number and the second preset number;
and obtaining the residual samples in the small sample training set except the first sub-sample set, and randomly selecting a third preset number of samples from the residual samples to serve as the second sub-sample set.
Further, the step of constructing the small sample training set specifically includes:
selecting a plurality of texts from a public database as preselected texts, and randomly selecting a preset number of clustering center points from the preselected texts according to a clustering algorithm;
calculating the Euclidean distance from each preselected text to the clustering central point, and dividing the preselected texts into a plurality of different text categories according to the Euclidean distance;
and selecting a target number of the preselected texts from each text category as the small sample training set.
In order to solve the above technical problem, an embodiment of the present application further provides a text intention classification device, which adopts the following technical solutions:
the acquisition module is used for acquiring a preset detection model, a text to be detected and a sample classification;
the recognition module is used for inputting the text to be detected and the sample classification into the preset detection model, performing intention recognition on the text to be detected based on a coding layer, a classification layer and a relation layer in the preset detection model, and outputting to obtain a relation score of the text to be detected and the sample classification;
and the confirming module is used for selecting the sample classification corresponding to the highest score in the relation scores according to the one-hot codes and determining the sample classification corresponding to the highest score as the intention classification of the text to be detected.
In order to solve the above technical problem, an embodiment of the present application further provides a computer device, which includes a memory and a processor, and computer readable instructions stored in the memory and executable on the processor, and the processor implements the steps of the text intention classification method when executing the computer readable instructions.
In order to solve the above technical problem, an embodiment of the present application further provides a computer-readable storage medium, which stores computer-readable instructions that, when executed by a processor, implement the steps of the text intention classification method described above.
According to the text intention classification method, the text to be detected can be efficiently detected through the preset detection model by acquiring the preset detection model, the text to be detected and the sample classification; secondly, inputting a text to be detected and a sample classification into a preset detection model, performing intention recognition on the text to be detected based on a coding layer, a classification layer and a relation layer in the preset detection model, outputting a relation score for obtaining the text to be detected and the sample classification, and calculating the text to be detected through the coding layer, the classification layer and the relation layer in the preset detection model, so that the accuracy of intention classification of the text to be detected is improved; and finally, according to the sample classification corresponding to the highest score in the one-hot code selection relation scores, determining that the sample classification corresponding to the highest score is the intention classification of the text to be detected, realizing high-efficiency classification of the text intention, improving the efficiency and accuracy of text intention classification, and enabling the preset detection model to be used in different scenes through transfer learning, so that the method has good generalization and improves the applicability of the preset detection model.
Drawings
In order to more clearly illustrate the solution of the present application, the drawings needed for describing the embodiments of the present application will be briefly described below, and it is obvious that the drawings in the following description are some embodiments of the present application, and that other drawings can be obtained by those skilled in the art without inventive effort.
FIG. 1 is an exemplary system architecture diagram in which the present application may be applied;
FIG. 2 is a flow diagram of one embodiment of a text intent classification method according to the present application;
FIG. 3 is a schematic diagram of an embodiment of a textual intent classification apparatus according to the present application;
FIG. 4 is a schematic block diagram of one embodiment of a computer device according to the present application.
Reference numerals: the text intention classification device 300, an acquisition module 301, a recognition module 302 and a confirmation module 303.
Detailed Description
Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs; the terminology used in the description of the application herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the application; the terms "including" and "having," and any variations thereof, in the description and claims of this application and the description of the above figures are intended to cover non-exclusive inclusions. The terms "first," "second," and the like in the description and claims of this application or in the above-described drawings are used for distinguishing between different objects and not for describing a particular order.
Reference herein to "an embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment can be included in at least one embodiment of the application. The appearances of the phrase in various places in the specification are not necessarily all referring to the same embodiment, nor are separate or alternative embodiments mutually exclusive of other embodiments. It is explicitly and implicitly understood by one skilled in the art that the embodiments described herein can be combined with other embodiments.
In order to make the technical solutions better understood by those skilled in the art, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings.
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 user may use the terminal devices 101, 102, 103 to interact with the server 105 via the 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, a shopping application, a search application, an instant messaging tool, a mailbox client, social platform software, and the like.
The terminal devices 101, 102, 103 may be various electronic devices having a display screen and supporting web browsing, 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 portable computers, desktop computers, and the like.
The server 105 may be a server providing various services, such as a background server providing support for pages displayed on the terminal devices 101, 102, 103.
It should be noted that the text intention classification method provided in the embodiments of the present application is generally executed by a server/terminal device, and accordingly, the text intention classification apparatus is generally disposed in the server/terminal device.
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 diagram of one embodiment of a method of textual intent classification in accordance with the present application is shown. The text intention classification method comprises the following steps:
step S201, acquiring a preset detection model, a text to be detected and sample classification;
in this embodiment, the preset detection model is a preset intention classification model, the text to be detected is text data to be subjected to intention classification, the sample classification is a sample intention category obtained by collection, and the obtained sample classification includes all stored sample classifications. The text to be detected and the sample classification are collected and stored in the database in advance, and when the text to be detected is subjected to intention identification classification, the text to be detected and the sample classification can be extracted from the database. The preset detection model can simultaneously carry out intention identification and classification on a plurality of texts to be detected according to the obtained sample classification. And when the preset detection model, the text to be detected and the sample classification are obtained, performing intention identification classification on the text to be detected according to the preset detection model and the sample classification.
Step S202, inputting the text to be detected and the sample classification into the preset detection model, performing intention recognition on the text to be detected based on a coding layer, a classification layer and a relation layer in the preset detection model, and outputting to obtain a relation score of the text to be detected and the sample classification;
in this embodiment, when the text to be detected, the sample classification, and the preset detection model are obtained, the detection text and the sample classification are input into the preset detection model. The preset detection model comprises a coding layer, a classification layer and a relation layer, a text to be detected and a sample classification are coded according to the coding layer to obtain a sample representation, and different network structures such as CNN (Convolutional Neural Networks) and LSTM (Long Short-Term Memory) can be selected according to different application requirements for the structure of the coding layer. When the sample representation is obtained, classifying the sample representation based on a classification layer to obtain a classification representation, wherein the classification representation reflects the contribution of the text to be detected to each vector in different sample classifications; and when the classification representation is obtained, calculating the classification representation based on the relation layer to obtain a relation score, wherein the relation score reflects the association degree between the text to be detected and different sample classifications.
It is emphasized that the relationship score may also be stored in a node of a blockchain in order to further ensure privacy and security of the relationship score.
The block chain referred by the application is a novel application mode of computer technologies such as distributed data storage, point-to-point transmission, a consensus mechanism, an encryption algorithm and the like. A block chain (Blockchain), which is essentially a decentralized database, is a series of data blocks associated by using a cryptographic method, and each data block contains information of a batch of network transactions, so as to verify the validity (anti-counterfeiting) of the information and generate a next block. The blockchain may include a blockchain underlying platform, a platform product service layer, an application service layer, and the like.
Step S203, selecting a sample classification corresponding to the highest score in the relationship scores according to the one-hot codes, and determining that the sample classification corresponding to the highest score is the intention classification of the text to be detected.
In this embodiment, when the relationship score is obtained, the relationship score is subjected to unique hot coding, that is, the sample classification with the largest relationship score between the text to be detected and the sample classification in the relationship score is obtained through unique hot coding. The one-bit effective code is the one-bit effective code, and only the relationship score with the maximum relationship between one bit and the text to be detected can be output through the one-bit effective code, so that the intention type of the current text to be detected can be determined.
According to the embodiment, the text intention is classified efficiently, the efficiency and the accuracy of text intention classification are improved, the preset detection model can be used in different scenes through transfer learning, the generalization performance is good, and the applicability of the preset detection model is improved.
In some embodiments of the present application, the performing intent recognition on the text to be detected based on the coding layer, the classification layer and the relation layer in the preset detection model includes:
coding the text to be detected and the sample classification based on a coding layer in the preset detection model to obtain a sample representation;
inputting the sample characterization to a classification layer in the preset detection model, and outputting to obtain a classification characterization;
and acquiring a text vector of the text to be detected, inputting the classification characteristic and the text vector to a relation layer in the preset detection model, and outputting to obtain a relation score of the text to be detected and the sample classification.
In this embodiment, when the text to be detected and the sample classification are obtained, the text to be detected and the sample classification are encoded according to an encoding layer in a preset detection model, so as to obtain the sample characterization. And inputting the sample characterization into a classification layer, and calculating to obtain a corresponding classification characterization according to the classification layer. And when the classification representation is obtained, acquiring a text vector of the text to be detected, wherein the text vector is a vector characteristic obtained by the text to be detected according to the output of the encoder. And inputting the classification marks and the text vectors into a relation layer, and outputting through the relation layer to obtain the relation marks of the text to be detected for different sample classifications. Wherein, the classification layer adopts a capsule dynamic routing algorithm, and the calculation formula of the classification representation is as follows:
Figure BDA0002789692470000081
wherein the content of the first and second substances,
Figure BDA0002789692470000082
representing the samples output by the encoder, wherein u is dimension, C is the number of classes of sample classification, k is the number of texts to be detected, and CiAnd the output is classified and characterized.
According to the embodiment, the text intentions are efficiently classified, the accuracy of text intention classification is improved, the efficient intention classification of a large amount of unmarked texts is further realized, and the marking cost and the corpus screening cost are reduced.
In some embodiments of the application, the inputting the classification feature and the text vector to a relationship layer in the preset detection model, and the outputting to obtain the relationship score between the text to be detected and the sample classification includes:
acquiring a first preset weight value and a second preset weight value;
and calculating the first preset weight value, the second preset weight value, the classification characteristic and the text vector based on an activation function of a relation layer in the preset detection model to obtain a relation score between each sample classification and the text to be detected.
In this embodiment, a first preset weight value and a second preset weight value are obtained, where the first preset weight value and the second preset weight value are preset weight values, and the first preset weight value and the second preset weight value are general weight values, that is, the first preset weight value between each sample class is the same, and the second preset weight value between each sample class is also the same. And calculating a first preset weight value, a second preset weight value, a classification characteristic and a text vector based on an activation function of a relation layer in a preset detection model to obtain a relation score between each sample classification and the text to be detected. Wherein, the calculation formula of the relationship score is as follows:
Figure BDA0002789692470000091
riq=sigmoid(Wrv(ci,eq)+br)
wherein r isiqIs a relationship score, WrIs a first preset weight value, brIs a second preset weight value, ciFor classification characterization, eqIs a text vector, v (c)i,eq) And M is a transformation matrix, and M can enable the classification representation to be multiplied by the text vector after transformation.
According to the embodiment, the accurate calculation of the relation score between the sample classification and the text to be detected is realized, and the accuracy of text intention classification is further improved.
In some embodiments of the present application, the obtaining of the preset detection model includes:
constructing a small sample training set and a preset small sample model;
dividing the small sample training set into a first sub-sample set and a second sub-sample set, training the preset small sample model according to the first sub-sample set, calculating a loss function of the preset small sample model, and determining the preset small sample model as a sample model to be verified when the loss function is converged;
and verifying the sample model to be verified according to the second sub-sample set, and determining the sample model to be verified as the preset detection model when the verification passing rate of the sample model to be verified on the second sub-sample set is greater than or equal to a preset threshold value.
In this embodiment, before performing intent recognition and classification on an input text to be detected through a preset detection model, a small sample training set needs to be constructed, and a preset small sample model is trained according to the small sample training set, so as to obtain a final preset detection model. Specifically, the small sample training set is a selected representative labeled small sample, the preset small sample model is a preset basic training model, and the training model also comprises a coding layer, a classification layer and a relation layer. Dividing the small sample training set into a first sub-sample set and a second sub-sample set, training a preset small sample model according to the first sub-sample set, calculating a loss function of the preset small sample model, and determining the preset small sample model as a sample model to be verified when the loss function is converged. When the sample model to be verified is obtained, verifying the sample model to be verified according to a second sub-sample set, and if the intention classification of the sample model to be verified on a second sub-sample in the second sub-sample set is the same as the real intention classification, determining that the sample model to be verified passes the verification on the second sub-sample; and when the verification passing rate of the sample model to be verified to the second sub-sample set is greater than or equal to a preset threshold value, determining that the sample model to be verified is a preset detection model.
According to the embodiment, the model is trained to obtain the preset detection model, so that the text to be detected can be accurately detected through the preset detection model, and the intention classification efficiency of the preset detection model is improved.
In some embodiments of the present application, the training the preset small sample model according to the first sub-sample set and calculating the loss function of the preset small sample model includes:
inputting the first sub-sample set into the preset small sample model, and outputting to obtain prediction intention classification;
and acquiring the real intention classification of the first sub-sample set, and calculating the mean square error of the real intention classification and the prediction intention classification to obtain a loss function of the preset small sample model.
In this embodiment, when calculating the loss function of the preset small sample model, the loss function may be calculated by using the prediction intention classification and the true intention classification corresponding to the first sub-sample set. Specifically, the predicted intention classification is an intention classification obtained by outputting a first subsample set through a preset small sample model, the real intention classification is a real intention classification of the first subsample set, and the real intention classification is stored in a database in association with a first subsample in the first subsample set. Inputting a first subsample in the first subsample set into a preset small sample model to obtain a prediction intention classification; when the prediction intention classification is obtained, acquiring the real intention classification of the first subsample, calculating a loss value at the moment according to a calculation formula of a loss function, and determining whether the loss function is converged at the moment; and when the loss function is not converged, adjusting parameters of the preset small sample model, and continuously inputting the first sub-sample in the first sub-sample set into the preset small sample model after the parameters are adjusted until the loss function calculated according to the first sub-sample in the first sub-sample set is converged. The loss function can be obtained by calculating the mean square error of the real intention classification and the prediction intention classification, and the calculation formula of the loss function is as follows:
Figure BDA0002789692470000111
wherein S is a prediction intention classification, Q is a real sample classification, C is the number of classes of the sample classification, riqIs a relationship score, yqClass labels for a training set of small samples.
According to the embodiment, the model loss function is calculated, so that the model can be constrained through the loss function, the parameters of the model can be adjusted, and the adjusted model further meets the requirement of text intention recognition.
In some embodiments of the present application, the dividing the training set of small samples into a first set of subsamples and a second set of subsamples includes:
randomly selecting a first preset number of sample classifications, selecting a second preset number of samples from each sample classification, wherein the number of the samples of the first sub-sample set in the small sample training set is the product of the first preset number and the second preset number;
and obtaining the residual samples in the small sample training set except the first sub-sample set, and randomly selecting a third preset number of samples from the residual samples to serve as the second sub-sample set.
In this embodiment, when the small sample training set is divided, a first preset number of sample classifications, such as C sample classifications, are randomly selected, where the first preset number is smaller than the total number of classes in the small sample training set. Then, each sample classification also selects a second preset number of samples, such as K samples, and the number of the first sub-sample set is a product of the first preset number and the second preset number, i.e., C × K. And selecting the samples except the first subsample set from the small sample training set as residual samples, and randomly selecting a third preset number of samples from the residual samples as a second subsample set.
The embodiment realizes the division of the small sample training set, so that the training process of the model through the small sample training set is more faithful to the test environment, the generalization of the model is improved, and the efficiency of model training is improved.
In some embodiments of the present application, constructing the training set of small samples includes:
selecting a plurality of texts from a public database as preselected texts, and randomly selecting a preset number of clustering center points from the preselected texts according to a clustering algorithm;
calculating the Euclidean distance from each preselected text to the clustering central point, and dividing the preselected texts into a plurality of different text categories according to the Euclidean distance;
and selecting a target number of the preselected texts from each text category as the small sample training set.
In this embodiment, a plurality of texts are selected from a common database as preselected texts, a preset number of cluster center points are randomly selected from the preselected texts according to a clustering algorithm (such as k-means, k-means clustering algorithm), and the euclidean distance between each preselected text and the cluster center point is calculated. And dividing the preselected texts with Euclidean distances smaller than or equal to the preset distance into texts in the same category, so that the preselected texts can be finally divided into a plurality of different text categories, wherein the number of the text categories is equal to that of the clustering center points. And finally, selecting the preselected texts with the target number closest to the corresponding clustering center point from each text category as a small sample training set, thereby obtaining the small sample training set required by training.
The embodiment realizes the construction of the small sample training set, so that the model can be accurately trained through the small sample training set, the time for labeling the model is saved, and the efficiency of model training is improved.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware associated with computer readable instructions, which can be stored in a computer readable storage medium, and when executed, the processes of the embodiments of the methods described above can be included. The storage medium may be a non-volatile storage medium such as a magnetic disk, an optical disk, a Read-Only Memory (ROM), or a Random Access Memory (RAM).
It should be understood that, although the steps in the flowcharts of the figures are shown in order as indicated by the arrows, the steps are not necessarily performed in order as indicated by the arrows. The steps are not performed in the exact order shown and may be performed in other orders unless explicitly stated herein. Moreover, at least a portion of the steps in the flow chart of the figure may include multiple sub-steps or multiple stages, which are not necessarily performed at the same time, but may be performed at different times, which are not necessarily performed in sequence, but may be performed alternately or alternately with other steps or at least a portion of the sub-steps or stages of other steps.
With further reference to fig. 3, as an implementation of the method shown in fig. 2, the present application provides an embodiment of a text intention classification apparatus, which corresponds to the embodiment of the method shown in fig. 2, and which can be applied to various electronic devices.
As shown in fig. 3, the text intention classification apparatus 300 according to the present embodiment includes: an acquisition module 301, an identification module 302, and a confirmation module 303. Wherein:
an obtaining module 301, configured to obtain a preset detection model, a text to be detected, and a sample classification;
wherein the obtaining module 301 comprises:
the construction unit is used for constructing a small sample training set and a preset small sample model;
the dividing unit is used for dividing the small sample training set into a first sub-sample set and a second sub-sample set, training the preset small sample model according to the first sub-sample set, calculating a loss function of the preset small sample model, and determining the preset small sample model as a sample model to be verified when the loss function is converged;
and the verification unit is used for verifying the sample model to be verified according to the second sub-sample set, and when the verification passing rate of the sample model to be verified on the second sub-sample set is greater than or equal to a preset threshold value, determining that the sample model to be verified is the preset detection model.
Wherein the dividing unit includes:
the first calculating subunit is used for inputting the first subsample set into the preset small sample model and outputting to obtain a prediction intention classification;
and the second calculating subunit is configured to obtain a real intention classification of the first subsample set, calculate a mean square error of the real intention classification and the prediction intention classification, and obtain a loss function of the preset small sample model.
The classification subunit is used for randomly selecting a first preset number of sample classifications and selecting a second preset number of samples from each sample classification, wherein the number of the samples in the first sub-sample set in the small sample training set is the product of the first preset number and the second preset number;
and the first obtaining subunit is configured to obtain remaining samples in the small sample training set, except for the first sub-sample set, and randomly select a third preset number of samples from the remaining samples as the second sub-sample set.
Wherein, the construction element still includes:
the clustering subunit is used for selecting a plurality of texts from a public database as preselected texts and randomly selecting clustering central points with preset division numbers from the preselected texts according to a clustering algorithm;
the third calculation subunit is used for calculating the Euclidean distance from each preselected text to the clustering central point, and dividing the preselected texts into a plurality of different text categories according to the Euclidean distance;
and the confirming subunit is used for selecting the preselected texts with the target number from each text category as the small sample training set.
In this embodiment, the preset detection model is a preset intention classification model, the text to be detected is text data to be subjected to intention classification, the sample classification is a sample intention category obtained by collection, and the obtained sample classification includes all stored sample classifications. The text to be detected and the sample classification are collected and stored in the database in advance, and when the text to be detected is subjected to intention identification classification, the text to be detected and the sample classification can be extracted from the database. The preset detection model can simultaneously carry out intention identification and classification on a plurality of texts to be detected according to the obtained sample classification. And when the preset detection model, the text to be detected and the sample classification are obtained, performing intention identification classification on the text to be detected according to the preset detection model and the sample classification.
The identification module 302 is configured to input the text to be detected and the sample classification into the preset detection model, perform intent identification on the text to be detected based on a coding layer, a classification layer and a relation layer in the preset detection model, and output a relation score to obtain the text to be detected and the sample classification;
wherein the identifying module 302 comprises:
the encoding unit is used for encoding the text to be detected and the sample classification based on an encoding layer in the preset detection model to obtain a sample representation;
the classification unit is used for inputting the sample characterization to a classification layer in the preset detection model and outputting to obtain a classification characterization;
and the calculation unit is used for acquiring the text vector of the text to be detected, inputting the classification mark and the text vector to a relation layer in the preset detection model, and outputting to obtain a relation mark of the text to be detected and the sample classification.
Wherein the computing unit further comprises:
the second obtaining subunit is used for obtaining a first preset weight value and a second preset weight value;
and the fourth calculating subunit is configured to calculate the first preset weight value, the second preset weight value, the classification table and the text vector based on an activation function of a relation layer in the preset detection model, so as to obtain a relation score between each sample classification and the text to be detected.
In this embodiment, when the text to be detected, the sample classification, and the preset detection model are obtained, the detection text and the sample classification are input into the preset detection model. The preset detection model comprises a coding layer, a classification layer and a relation layer, a text to be detected and a sample classification are coded according to the coding layer to obtain a sample representation, and different network structures such as CNN (Convolutional Neural Networks) and LSTM (Long Short-Term Memory) can be selected according to different application requirements for the structure of the coding layer. When the sample representation is obtained, classifying the sample representation based on a classification layer to obtain a classification representation, wherein the classification representation reflects the contribution of the text to be detected to each vector in different sample classifications; and when the classification representation is obtained, calculating the classification representation based on the relation layer to obtain a relation score, wherein the relation score reflects the association degree between the text to be detected and different sample classifications.
It is emphasized that the relationship score may also be stored in a node of a blockchain in order to further ensure privacy and security of the relationship score.
The block chain referred by the application is a novel application mode of computer technologies such as distributed data storage, point-to-point transmission, a consensus mechanism, an encryption algorithm and the like. A block chain (Blockchain), which is essentially a decentralized database, is a series of data blocks associated by using a cryptographic method, and each data block contains information of a batch of network transactions, so as to verify the validity (anti-counterfeiting) of the information and generate a next block. The blockchain may include a blockchain underlying platform, a platform product service layer, an application service layer, and the like.
The confirming module 303 is configured to select a sample classification corresponding to the highest score in the relationship scores according to the one-hot code, and determine that the sample classification corresponding to the highest score is the intention classification of the text to be detected.
In this embodiment, when the relationship score is obtained, the relationship score is subjected to unique hot coding, that is, the sample classification with the largest relationship score between the text to be detected and the sample classification in the relationship score is obtained through unique hot coding. The one-bit effective code is the one-bit effective code, and only the relationship score with the maximum relationship between one bit and the text to be detected can be output through the one-bit effective code, so that the intention type of the current text to be detected can be determined.
The text intention classification device that this application provided has realized the high-efficient classification to the text intention, has improved text intention classification's efficiency and rate of accuracy to preset detection model wherein can have better generalization through the migration learning uses in the scene of difference, has improved the suitability of presetting detection model.
In order to solve the technical problem, an embodiment of the present application further provides a computer device. Referring to fig. 4, fig. 4 is a block diagram of a basic structure of a computer device according to the present embodiment.
The computer device 6 comprises a memory 61, a processor 62, a network interface 63 communicatively connected to each other via a system bus. It is noted that only a computer device 6 having components 61-63 is shown, but it is understood that not all of the shown components are required to be implemented, and that more or fewer components may be implemented instead. As will be understood by those skilled in the art, the computer device is a device capable of automatically performing numerical calculation and/or information processing according to a preset or stored instruction, and the hardware includes, but is not limited to, a microprocessor, an Application Specific Integrated Circuit (ASIC), a Programmable Gate Array (FPGA), a Digital Signal Processor (DSP), an embedded device, and the like.
The computer device can be a desktop computer, a notebook, a palm computer, a cloud server and other computing devices. The computer equipment can carry out man-machine interaction with a user through a keyboard, a mouse, a remote controller, a touch panel or voice control equipment and the like.
The memory 61 includes at least one type of readable storage medium including a flash memory, a hard disk, a multimedia card, a card type memory (e.g., SD or DX memory, etc.), a Random Access Memory (RAM), a Static Random Access Memory (SRAM), a Read Only Memory (ROM), an Electrically Erasable Programmable Read Only Memory (EEPROM), a Programmable Read Only Memory (PROM), a magnetic memory, a magnetic disk, an optical disk, etc. In some embodiments, the memory 61 may be an internal storage unit of the computer device 6, such as a hard disk or a memory of the computer device 6. In other embodiments, the memory 61 may also be an external storage device of the computer device 6, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), and the like, which are provided on the computer device 6. Of course, the memory 61 may also comprise both an internal storage unit of the computer device 6 and an external storage device thereof. In this embodiment, the memory 61 is generally used for storing an operating system installed in the computer device 6 and various types of application software, such as computer readable instructions of a text intention classification method. Further, the memory 61 may also be used to temporarily store various types of data that have been output or are to be output.
The processor 62 may be a Central Processing Unit (CPU), controller, microcontroller, microprocessor, or other data Processing chip in some embodiments. The processor 62 is typically used to control the overall operation of the computer device 6. In this embodiment, the processor 62 is configured to execute computer readable instructions stored in the memory 61 or process data, such as executing computer readable instructions of the text intent classification method.
The network interface 63 may comprise a wireless network interface or a wired network interface, and the network interface 63 is typically used for establishing a communication connection between the computer device 6 and other electronic devices.
The computer equipment provided by the embodiment realizes the efficient classification of the text intentions, improves the efficiency and the accuracy of the classification of the text intentions, can be used in different scenes through transfer learning by the preset detection model, has better generalization, and improves the applicability of the preset detection model.
The present application further provides another embodiment, which is to provide a computer-readable storage medium storing computer-readable instructions executable by at least one processor to cause the at least one processor to perform the steps of the text intent classification method as described above.
The computer-readable storage medium provided by the embodiment realizes efficient classification of the text intention, improves efficiency and accuracy of text intention classification, and the preset detection model can be used in different scenes through transfer learning, has better generalization and improves applicability of the preset detection model.
Through the above description of the embodiments, those skilled in the art will clearly understand that the method of the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but in many cases, the former is a better implementation manner. Based on such understanding, the technical solutions of the present application may be embodied in the form of a software product, which is stored in a storage medium (such as ROM/RAM, magnetic disk, optical disk) and includes instructions for enabling a terminal device (such as a mobile phone, a computer, a server, an air conditioner, or a network device) to execute the method according to the embodiments of the present application.
It is to be understood that the above-described embodiments are merely illustrative of some, but not restrictive, of the broad invention, and that the appended drawings illustrate preferred embodiments of the invention and do not limit the scope of the invention. This application is capable of embodiments in many different forms and is provided for the purpose of enabling a thorough understanding of the disclosure of the application. Although the present application has been described in detail with reference to the foregoing embodiments, it will be apparent to one skilled in the art that the present application may be practiced without modification or with equivalents of some of the features described in the foregoing embodiments. All equivalent structures made by using the contents of the specification and the drawings of the present application are directly or indirectly applied to other related technical fields and are within the protection scope of the present application.

Claims (10)

1. A text intention classification method is characterized by comprising the following steps:
acquiring a preset detection model, a text to be detected and a sample classification;
inputting the text to be detected and the sample classification into the preset detection model, performing intention recognition on the text to be detected based on a coding layer, a classification layer and a relation layer in the preset detection model, and outputting to obtain a relation score of the text to be detected and the sample classification;
and selecting a sample classification corresponding to the highest score in the relation scores according to the one-hot codes, and determining that the sample classification corresponding to the highest score is the intention classification of the text to be detected.
2. The text intention classification method according to claim 1, wherein the step of performing intention recognition on the text to be detected based on a coding layer, a classification layer and a relation layer in the preset detection model specifically comprises:
coding the text to be detected and the sample classification based on a coding layer in the preset detection model to obtain a sample representation;
inputting the sample characterization to a classification layer in the preset detection model, and outputting to obtain a classification characterization;
and acquiring a text vector of the text to be detected, inputting the classification characteristic and the text vector to a relation layer in the preset detection model, and outputting to obtain a relation score of the text to be detected and the sample classification.
3. The text intention classification method according to claim 2, wherein the step of inputting the classification scores and the text vectors to a relationship layer in the preset detection model and outputting the relationship scores obtained by classifying the text to be detected and the sample specifically comprises:
acquiring a first preset weight value and a second preset weight value;
and calculating the first preset weight value, the second preset weight value, the classification characteristic and the text vector based on an activation function of a relation layer in the preset detection model to obtain a relation score between each sample classification and the text to be detected.
4. The text intention classification method according to claim 1, characterized in that the step of obtaining a preset detection model specifically comprises:
constructing a small sample training set and a preset small sample model;
dividing the small sample training set into a first sub-sample set and a second sub-sample set, training the preset small sample model according to the first sub-sample set, calculating a loss function of the preset small sample model, and determining the preset small sample model as a sample model to be verified when the loss function is converged;
and verifying the sample model to be verified according to the second sub-sample set, and determining the sample model to be verified as the preset detection model when the verification passing rate of the sample model to be verified on the second sub-sample set is greater than or equal to a preset threshold value.
5. The text intention classification method according to claim 4, wherein the step of training the preset small sample model according to the first sub-sample set and calculating the loss function of the preset small sample model specifically comprises:
inputting the first sub-sample set into the preset small sample model, and outputting to obtain prediction intention classification;
and acquiring the real intention classification of the first sub-sample set, and calculating the mean square error of the real intention classification and the prediction intention classification to obtain a loss function of the preset small sample model.
6. The text intent classification method according to claim 4, characterized in that the step of dividing the training set of small samples into a first set of subsamples and a second set of subsamples specifically comprises:
randomly selecting a first preset number of sample classifications, selecting a second preset number of samples from each sample classification, wherein the number of the samples of the first sub-sample set in the small sample training set is the product of the first preset number and the second preset number;
and obtaining the residual samples in the small sample training set except the first sub-sample set, and randomly selecting a third preset number of samples from the residual samples to serve as the second sub-sample set.
7. The text intention classification method according to claim 4, characterized in that the step of constructing a training set of small samples comprises in particular:
selecting a plurality of texts from a public database as preselected texts, and randomly selecting a preset number of clustering center points from the preselected texts according to a clustering algorithm;
calculating the Euclidean distance from each preselected text to the clustering central point, and dividing the preselected texts into a plurality of different text categories according to the Euclidean distance;
and selecting a target number of the preselected texts from each text category as the small sample training set.
8. A text intention classifying apparatus, comprising:
the acquisition module is used for acquiring a preset detection model, a text to be detected and a sample classification;
the recognition module is used for inputting the text to be detected and the sample classification into the preset detection model, performing intention recognition on the text to be detected based on a coding layer, a classification layer and a relation layer in the preset detection model, and outputting to obtain a relation score of the text to be detected and the sample classification;
and the confirming module is used for selecting the sample classification corresponding to the highest score in the relation scores according to the one-hot codes and determining the sample classification corresponding to the highest score as the intention classification of the text to be detected.
9. A computer device comprising a memory having computer readable instructions stored therein and a processor which when executed implements the steps of the text intent classification method of any of claims 1-7.
10. A computer-readable storage medium, having computer-readable instructions stored thereon, which, when executed by a processor, implement the steps of the text intent classification method according to any of claims 1 to 7.
CN202011310583.XA 2020-11-20 2020-11-20 Text intention classification method and device, computer equipment and storage medium Pending CN112396111A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011310583.XA CN112396111A (en) 2020-11-20 2020-11-20 Text intention classification method and device, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011310583.XA CN112396111A (en) 2020-11-20 2020-11-20 Text intention classification method and device, computer equipment and storage medium

Publications (1)

Publication Number Publication Date
CN112396111A true CN112396111A (en) 2021-02-23

Family

ID=74607724

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011310583.XA Pending CN112396111A (en) 2020-11-20 2020-11-20 Text intention classification method and device, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN112396111A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112966108A (en) * 2021-03-08 2021-06-15 北京百度网讯科技有限公司 Method, apparatus, device and storage medium for detecting data and training classification model

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2017113232A1 (en) * 2015-12-30 2017-07-06 中国科学院深圳先进技术研究院 Product classification method and apparatus based on deep learning
CN111078847A (en) * 2019-11-27 2020-04-28 中国南方电网有限责任公司 Power consumer intention identification method and device, computer equipment and storage medium
WO2020155766A1 (en) * 2019-01-31 2020-08-06 平安科技(深圳)有限公司 Method, device and apparatus for identification rejection in intention identification, and storage medium

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2017113232A1 (en) * 2015-12-30 2017-07-06 中国科学院深圳先进技术研究院 Product classification method and apparatus based on deep learning
WO2020155766A1 (en) * 2019-01-31 2020-08-06 平安科技(深圳)有限公司 Method, device and apparatus for identification rejection in intention identification, and storage medium
CN111078847A (en) * 2019-11-27 2020-04-28 中国南方电网有限责任公司 Power consumer intention identification method and device, computer equipment and storage medium

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112966108A (en) * 2021-03-08 2021-06-15 北京百度网讯科技有限公司 Method, apparatus, device and storage medium for detecting data and training classification model
CN112966108B (en) * 2021-03-08 2024-03-12 北京百度网讯科技有限公司 Method, apparatus, device and storage medium for detecting data and training classification model

Similar Documents

Publication Publication Date Title
CN112685565B (en) Text classification method based on multi-mode information fusion and related equipment thereof
CN113127633B (en) Intelligent conference management method and device, computer equipment and storage medium
CN112632278A (en) Labeling method, device, equipment and storage medium based on multi-label classification
CN113220734A (en) Course recommendation method and device, computer equipment and storage medium
CN112836521A (en) Question-answer matching method and device, computer equipment and storage medium
CN112863683A (en) Medical record quality control method and device based on artificial intelligence, computer equipment and storage medium
CN112287069A (en) Information retrieval method and device based on voice semantics and computer equipment
CN113947095A (en) Multilingual text translation method and device, computer equipment and storage medium
CN111695337A (en) Method, device, equipment and medium for extracting professional terms in intelligent interview
CN114780701A (en) Automatic question-answer matching method, device, computer equipment and storage medium
CN113283222B (en) Automatic report generation method and device, computer equipment and storage medium
CN112434746B (en) Pre-labeling method based on hierarchical migration learning and related equipment thereof
CN114359582A (en) Small sample feature extraction method based on neural network and related equipment
CN112598039B (en) Method for obtaining positive samples in NLP (non-linear liquid) classification field and related equipment
CN112396111A (en) Text intention classification method and device, computer equipment and storage medium
CN115373634A (en) Random code generation method and device, computer equipment and storage medium
CN114358023B (en) Intelligent question-answer recall method, intelligent question-answer recall device, computer equipment and storage medium
CN113657104A (en) Text extraction method and device, computer equipment and storage medium
CN112395450A (en) Picture character detection method and device, computer equipment and storage medium
CN112417886A (en) Intention entity information extraction method and device, computer equipment and storage medium
CN112699213A (en) Speech intention recognition method and device, computer equipment and storage medium
CN112949320A (en) Sequence labeling method, device, equipment and medium based on conditional random field
CN112199954A (en) Disease entity matching method and device based on voice semantics and computer equipment
CN113065354A (en) Method for identifying geographic position in corpus and related equipment thereof
CN112733645A (en) Handwritten signature verification method and device, computer equipment and storage medium

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