CN113704413A - Multi-sample-based intention classification method, device, equipment and storage medium - Google Patents

Multi-sample-based intention classification method, device, equipment and storage medium Download PDF

Info

Publication number
CN113704413A
CN113704413A CN202111016963.7A CN202111016963A CN113704413A CN 113704413 A CN113704413 A CN 113704413A CN 202111016963 A CN202111016963 A CN 202111016963A CN 113704413 A CN113704413 A CN 113704413A
Authority
CN
China
Prior art keywords
sample
intention
gradient
target
training
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
CN202111016963.7A
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 CN202111016963.7A priority Critical patent/CN113704413A/en
Publication of CN113704413A publication Critical patent/CN113704413A/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/33Querying
    • G06F16/3331Query processing
    • G06F16/334Query execution
    • G06F16/3346Query execution using probabilistic model
    • 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
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/21Design or setup of recognition systems or techniques; Extraction of features in feature space; Blind source separation
    • G06F18/214Generating training patterns; Bootstrap methods, e.g. bagging or boosting
    • 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

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • General Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • Artificial Intelligence (AREA)
  • Evolutionary Computation (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Evolutionary Biology (AREA)
  • Bioinformatics & Computational Biology (AREA)
  • Bioinformatics & Cheminformatics (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Probability & Statistics with Applications (AREA)
  • Databases & Information Systems (AREA)
  • Computational Linguistics (AREA)
  • Health & Medical Sciences (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • General Health & Medical Sciences (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention relates to the field of artificial intelligence and digital medical treatment, and discloses an intention classification method, device, equipment and storage medium based on multiple samples. The method comprises the following steps: acquiring a text sample in telephone voice and identifying a target sample of unbalanced intention categories; generating a new target sample based on a k-mean clustering algorithm according to the target sample, and forming a training sample set by the new target sample and the text sample of the balanced intention category; inputting a training sample set into a pre-constructed intention classification model in batches to obtain a prediction result of each training sample, calculating and calculating a loss function according to the prediction result, and training the intention classification model by adopting the loss function to obtain a target intention classification model; and acquiring a text sample to be detected, and inputting the text sample to be detected into the target intention classification model to obtain the intention category of the text sample to be detected. The method and the device can solve the problems that the recognition precision of the intention classification model is reduced and the intention of the client cannot be recognized accurately due to the fact that multi-sample data are unbalanced.

Description

Multi-sample-based intention classification method, device, equipment and storage medium
Technical Field
The invention relates to the technical field of artificial intelligence and digital medical treatment, in particular to an intention classification method, device, equipment and storage medium based on multiple samples.
Background
The conversation intention identification is to finally identify the purpose and even emotion contained in the conversation of the user by understanding the language material information of the chatting between people and searching, filtering, classifying and the like of intention characteristics in the text, and the core of the intention identification is to understand the semantics. The machine learning-based dialog intention recognition method includes rule-and statistic-based dialog intention recognition, machine learning classifier-based dialog intention recognition, generative model-based dialog intention recognition, and the like.
The recognition of whether the subsequent business development is accurately influenced or not based on the conversation intention of the machine learning classifier in the telephone sales is also very important for the user experience of the client. The distribution of the customer's intentions often appears to be an unbalanced state in different service scenarios and different service nodes. After a period of steady traffic operation, we can accumulate a large amount of data, even if the amount of data is large, but the distribution of different intended samples is still unbalanced. The unbalanced data limits the recognition precision of the intention classification model, so that telephone sales personnel cannot accurately recognize the intention of the client through the intention classification model, communication experience is influenced, and the effect of accurate sales cannot be achieved.
Disclosure of Invention
The invention provides an intention classification method, device, equipment and storage medium based on multiple samples, which can solve the problems that the recognition precision of an intention classification model is reduced and the intention of a client cannot be recognized accurately due to unbalanced data of the multiple samples.
In order to solve the technical problems, the invention adopts a technical scheme that: provided is a multi-sample-based intention classification method, including:
acquiring a text sample in telephone voice, performing labeling processing on the category attribute of the text sample, identifying the intention category of the text sample according to a labeling processing result, acquiring the text sample of an unbalanced intention category and the text sample of an balanced intention category, and identifying the text sample of the unbalanced intention category as a target sample;
generating a new target sample according to the target sample based on a k-mean clustering algorithm, and forming a training sample set according to the new target sample and the text sample of the balanced intention category;
inputting a training sample set into a pre-constructed intention classification model in batches to obtain a prediction result of each training sample, calculating the gradient modular length of each training sample according to the prediction result, dividing a gradient interval according to all the gradient modular lengths, classifying the training samples according to the gradient interval, calculating the density of the gradient interval according to the classification processing result, calculating a loss function according to the density of the gradient interval, and training the intention classification model by adopting the loss function to obtain a target intention classification model;
and acquiring a text sample to be detected, and inputting the text sample to be detected into the target intention classification model to obtain the intention category of the text sample to be detected.
According to one embodiment of the invention, the step of generating a new target sample from the target sample based on a k-mean clustering algorithm comprises:
determining the number of the target samples needing to be balanced according to the number of the text samples of the balance intention category;
dividing the target sample into a plurality of sample clusters by adopting a k-mean clustering algorithm;
and repeatedly selecting a sample cluster from the sample clusters, randomly selecting a plurality of different subsamples from the selected sample cluster each time, obtaining the center of each subsample, and taking the center as a new target sample until the number of the new target samples reaches the number of the target samples to be balanced.
According to one embodiment of the invention, the step of dividing the target sample into a plurality of sample clusters by using a k-mean clustering algorithm comprises the following steps:
randomly selecting a plurality of different target samples, and taking the selected target samples as a clustering center;
and calculating the distance from each target sample to each clustering center, traversing all the target samples, and distributing each target sample to the clustering center closest to the target sample according to the distance calculation result to form a sample cluster.
According to an embodiment of the present invention, the step of repeatedly performing the random selection of one sample cluster from the sample clusters, randomly selecting a plurality of different subsamples from the selected sample cluster each time, and obtaining the center of each subsample, and using the center as a new target sample until the number of new target samples reaches the number of target samples to be balanced includes:
randomly selecting a sample cluster from the sample clusters, randomly selecting a plurality of different subsamples from the selected sample cluster, and calculating the weighted average of each subsample;
associating the weighted average with a sample center, and taking the sample center as a new target sample;
and repeating the step of generating new target samples to obtain a plurality of new target samples until the number of the new target samples reaches the number of the target samples to be balanced.
According to an embodiment of the present invention, a training sample set is input to a pre-constructed intention classification model in batches, a prediction result of each training sample is obtained, a gradient modular length of each training sample is calculated according to the prediction result, gradient intervals are divided according to all the gradient modular lengths, the training samples are classified according to the gradient intervals, gradient interval density is calculated according to the classification result, a loss function is calculated according to the gradient interval density, the intention classification model is trained by using the loss function, and a target intention classification model is obtained, including the steps of:
inputting a training sample set into a pre-constructed intention classification model in batches to obtain a prediction result of each training sample, and calculating the gradient modular length of each training sample according to the labeling processing result and the prediction result of each training sample;
obtaining a gradient module length interval according to the calculation result of the gradient module length, dividing the gradient module length interval into a plurality of gradient intervals, and calculating the density of the gradient intervals according to the number of training samples of the gradient module length in the gradient intervals;
calculating a loss function according to the density of the gradient interval;
and training an intention classification model by adopting the loss function, and adjusting parameters of the intention classification model based on a back propagation algorithm to obtain the target intention classification model.
According to one embodiment of the invention, the calculation formula of the loss function is as follows:
Figure BDA0003240215190000031
Figure BDA0003240215190000032
wherein the content of the first and second substances,
Figure BDA0003240215190000033
represents the gradient interval density corresponding to the gradient interval to which the gradient modular length of the training sample belongs,
Figure BDA0003240215190000034
is the gradient mode length, NbatchFor the number of training samples of the input batch, NresThe number of the intention categories to be classified; y isnFor the labeled result of the training sample, the vector size is 1 XNres,ynjDenotes ynThe value of the jth element in the vector, ResnjRepresents ResnThe value of the jth element in the vector, ResnThe vector size of the predicted result of the intention classification model is 1 XNres
According to an embodiment of the present invention, the step of obtaining a text sample to be tested, inputting the text sample to be tested into the target intention classification model, and obtaining the intention type of the text sample to be tested includes:
extracting intention characteristics from the text sample to be tested and learning the intention characteristics;
classifying and predicting the text sample to be tested based on the learning result;
converting the classification prediction result into an intention category probability distribution through normalization processing;
and identifying the intention type of the text sample to be detected according to the intention type probability distribution and outputting the intention type.
In order to solve the technical problem, the invention adopts another technical scheme that: provided is a multi-sample-based intention classification device including:
the system comprises an acquisition module, a processing module and a processing module, wherein the acquisition module is used for acquiring a text sample in telephone voice, labeling the category attribute of the text sample, identifying the intention category of the text sample according to the labeling processing result, acquiring the text sample of the unbalanced intention category and the text sample of the balanced intention category, and identifying the text sample of the unbalanced intention category as a target sample;
the generating module is used for generating a new target sample according to the target sample based on a k-mean clustering algorithm and forming a training sample set according to the new target sample and the text sample of the balanced intention category;
the training module is used for inputting a training sample set into a pre-constructed intention classification model in batches to obtain a prediction result of each training sample, calculating the gradient modular length of each training sample according to the prediction result, dividing a gradient interval according to all the gradient modular lengths, classifying the training samples according to the gradient interval, calculating the density of the gradient interval according to the classification processing result, calculating a loss function according to the density of the gradient interval, and training the intention classification model by adopting the loss function to obtain a target intention classification model;
and the classification module is used for obtaining a text sample to be detected, inputting the text sample to be detected into the target intention classification model and obtaining the intention type of the text sample to be detected.
In order to solve the technical problems, the invention adopts another technical scheme that: there is provided a computer device comprising: a memory, a processor, and a computer program stored on the memory and executable on the processor, the processor implementing the multi-sample based intent classification method when executing the computer program.
In order to solve the technical problems, the invention adopts another technical scheme that: there is provided a computer storage medium having stored thereon a computer program which, when executed by a processor, implements the multi-sample based intent classification method described above.
The invention has the beneficial effects that: the new samples are regenerated by using a k-mean clustering algorithm to reduce the number of samples, the problem that the accuracy of the intention classification model obtained by training for the intention recognition of the client is low due to unbalanced multi-sample data is solved, the recognition precision of the intention classification model is effectively improved and the intention of the client is accurately recognized by adjusting the wrong classification weight in the loss function, so that the telemarketer can improve the telemarketing precision, improve the communication experience and reduce the communication cost.
Drawings
FIG. 1 is a flow chart diagram of a multi-sample based intent classification method according to an embodiment of the present invention;
FIG. 2 is a flowchart illustrating step S101 according to an embodiment of the present invention;
FIG. 3 is a flowchart illustrating step S102 according to an embodiment of the present invention;
FIG. 4 is a flowchart illustrating step S302 according to an embodiment of the present invention;
FIG. 5 is a flowchart illustrating step S103 according to an embodiment of the present invention;
FIG. 6 is a schematic structural diagram of a target intent classification model of an embodiment of the present invention;
FIG. 7 is a flowchart illustrating step S104 according to an embodiment of the present invention;
FIG. 8 is a schematic structural diagram of a multi-sample-based intent classification apparatus according to an embodiment of the present invention;
FIG. 9 is a schematic structural diagram of a computer device according to an embodiment of the present invention;
fig. 10 is a schematic structural diagram of a computer storage medium according to an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The terms "first", "second" and "third" in the present invention are used for descriptive purposes only and are not to be construed as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first," "second," or "third" may explicitly or implicitly include at least one of the feature. In the description of the present invention, "a plurality" means at least two, e.g., two, three, etc., unless specifically limited otherwise. All directional indicators (such as up, down, left, right, front, and rear … …) in the embodiments of the present invention are only used to explain the relative positional relationship between the components, the movement, and the like in a specific posture (as shown in the drawings), and if the specific posture is changed, the directional indicator is changed accordingly. Furthermore, the terms "include" and "have," as well as any variations thereof, are intended to cover non-exclusive inclusions. For example, a process, method, system, article, or apparatus that comprises a list of steps or elements is not limited to only those steps or elements listed, but may alternatively include other steps or elements not listed, or inherent to such process, method, article, or apparatus.
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 invention. 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.
Fig. 1 is a flowchart illustrating a multi-sample-based intent classification method according to an embodiment of the present invention. It should be noted that the method of the present invention is not limited to the flow sequence shown in fig. 1 if the results are substantially the same. As shown in fig. 1, the method comprises the steps of:
step S101: the method comprises the steps of obtaining a text sample in telephone voice, carrying out labeling processing on the type attribute of the text sample, identifying the intention type of the text sample according to the labeling processing result, obtaining the text sample of the unbalanced intention type and the text sample of the balanced intention type, and identifying the text sample of the unbalanced intention type as a target sample.
In step S101, the voice message of the telemarketer communicating with the customer is parsed into text message. The number of text samples in this embodiment is large enough to meet the number requirement of model training, but the number of texts in different intention categories has a large deviation, so there is a problem of data imbalance. The intent categories of the present embodiment include: an equilibrium intent category and an unbalanced intent category. The unbalanced intention category is a category in which the number of text samples is excessive, and therefore, it is necessary to solve the data unbalance problem by reducing the number of text samples of the unbalanced intention category.
Further, in the embodiment, label labeling is performed on each text sample manually, the intention type of each text sample is identified according to a labeling result, the number of the text samples in each intention type is counted, the intention type with a large text sample number difference is determined as an unbalanced intention type, the text samples in the unbalanced intention type are target samples, and the number of the text samples in the unbalanced intention type to be balanced is determined according to the number of the text samples in the balanced intention type.
In a telemarketing scene, identifying the product category which is intended to be purchased by a client as the intention category according to labels for each text sample, and assuming that the number of the text samples is 10 ten thousand, wherein 5 ten thousand text samples identify the product A which is intended to be purchased by the client, 3 ten thousand text samples identify the product B which is intended to be purchased by the client, 1.1 ten thousand text samples identify the product C which is intended to be purchased by the client, and 0.9 ten thousand text samples identify the product D which is intended to be purchased by the client, the product A and the product B are considered as the unbalanced intention category, and the product C and the product D are considered as the balanced intention category.
Further, referring to fig. 2, step S101 further includes the following steps:
step S201: the method comprises the steps of obtaining text samples in telephone voice, extracting features of the text samples based on a Bert model, fusing full-text semantic information according to the feature extraction result, and outputting sentence vectors of the text samples.
In step S201, the Bert model is trained using a large-scale label-free prediction to obtain a semantic representation of the text sample that includes rich semantic information. The Bert model takes a word vector in a text sample as input, inserts a [ CLS ] character in front of the text sample, and takes an output vector of the character correspondingly fused with full-text semantic information as a sentence vector of each text sample.
Step S202: and labeling each text sample by adopting one-hot coding.
In step S202, one-hot encoding is typically used when labeling a dataset in supervised learning. In this embodiment, category features are extracted from a text sample, and one-hot encoding is adopted to perform encoding processing on the category features, for example: in this embodiment, a text sample is (X, Y), X is a sentence vector of the text sample, if there are 5 extracted category features and there are 5 corresponding intention categories, then Y has 5 values, Y is a one-hot code of the first category and is [1,0,0,0,0], that is, the position where the category feature exists is marked as "1", and other positions are all "0".
Step S203: and identifying the intention type of each text sample according to the labeling processing result, classifying each text sample according to the identification result, and counting the number of the text samples under each intention type.
Step S204: and determining the unbalanced intention category and the balanced intention category according to the statistical result, extracting text samples in the unbalanced intention category and identifying the text samples as target samples.
In step S204, the present embodiment classifies the intention category with a large text sample number deviation as an unbalanced intention category and classifies the intention category with a normal text sample number as an equalized intention category according to the statistical result of step S203. When the total number of text samples is large, all the unbalanced intention categories are considered to be the cases that the number of text samples is too large, and the cases that the number of samples is too small are not considered at all. Therefore, the present embodiment needs to reduce the number of samples to achieve data equalization for all unbalanced intention categories. The embodiment determines the text sample needing to be balanced as the target sample
Step S102: and based on a k-mean clustering algorithm, generating a new target sample according to the target sample, and forming a training sample set according to the new target sample and the text sample of the balanced intention category.
In step S102, for a given target sample, the K-mean algorithm divides the target sample into K clusters according to the distance between the target samples, so that the distance between the target samples in the clusters is as small as possible, and the distance between the target samples in the clusters is as large as possible.
Further, referring to fig. 3, step S102 further includes the following steps:
step S301: and determining the number of target samples to be balanced according to the number of the text samples of the balance intention category.
Step S302: and dividing the target sample into a plurality of sample clusters by adopting a k-mean clustering algorithm.
In step S302, a plurality of different target samples are randomly selected, and the selected target samples are used as a clustering center; and calculating the distance from each target sample to each clustering center, traversing all the target samples, and distributing each target sample to the clustering center closest to the target sample according to the distance calculation result to form a sample cluster.
Specifically, in this embodiment, the euclidean distance from each target sample to each cluster center is calculated, the cluster center closest to the target sample is determined according to the euclidean distance, the target sample is allocated to the sample cluster corresponding to the cluster center, the cluster center of each sample cluster is recalculated according to the allocation result, the average value of all target samples in the sample cluster is used as a new cluster center, if the distance between the newly calculated cluster center and the original cluster center is smaller than a preset value, it indicates that the position of the recalculated cluster center does not change greatly, and tends to be stable or converged, it can be considered that the clustering has reached an expected result, and the algorithm is terminated; if the distance between the new cluster center and the original cluster center is greatly changed, the step of dividing the sample cluster needs to be executed iteratively until the position of the new cluster center is not changed any more.
Step S303: and repeatedly selecting a sample cluster from the sample clusters, randomly selecting a plurality of different subsamples from the selected sample cluster each time, obtaining the center of each subsample, and taking the center as a new target sample until the number of the new target samples reaches the number of the target samples to be balanced.
In step S303, the number of newly generated target samples is smaller than the number of text samples of the unbalanced intention category, and the number of new target samples is the same as the number of text samples of the unbalanced intention category.
Further, referring to fig. 4, step S303 further includes the following steps:
step S401: randomly selecting a sample cluster from the sample clusters, randomly selecting a plurality of different subsamples from the selected sample cluster, and calculating the weighted average of each subsample.
Step S402: and associating the weighted average with the sample center, and taking the sample center as a new target sample.
Step S403: steps S401-402 are repeatedly performed to obtain a plurality of new target samples until the number of new target samples reaches the number of target samples to be equalized.
Assume that N sample clusters are obtained by dividing in step S301, one sample cluster is randomly selected from the N sample clusters, P different subsamples are randomly selected from the sample clusters, a weighted average of the P different subsamples is calculated, the weighted average is used as a new target sample, and the above steps are repeated multiple times to generate a plurality of new target samples. The number of new target samples is smaller than the number of text samples of the original unbalanced category, and specifically, the number of new target samples may be equal to the number of text samples of the balanced intention category. If the number of text samples of the unbalanced intention category is M, the unbalanced intention category needs to generate M new target samples, that is, step S402 is repeatedly executed M times to obtain M new target samples, and the other unbalanced intention categories perform new target sample generation in the above manner, so as to solve the data balancing problem. The embodiment combines the new target samples regenerated by all unbalanced intention categories and the text samples which do not need to be balanced originally into a training sample set, and the training sample set comprises a plurality of training samples.
Further, the training sample set of the present embodiment is represented as follows:
Data={Xk=(xk,yk) 1,2,3,4, …, n }, where x iskA sentence vector representing a kth training sample; yk is the labeling processing result of the kth training sample, namely labeling label, and the vector size is 1 XNres,NresIs the number of intents to be classified. x is the number ofkThe vector dimension of (a) is 1 × 768. For example: the number of intents to be classified is 10, then Nres=10,x1When (1,0,0,0,0, 0), y 11, the intention category of the first training sample is represented as the first category.
Step S103: inputting a training sample set into a pre-constructed intention classification model in batches to obtain a prediction result of each training sample, calculating the gradient modular length of each training sample according to the prediction result, dividing gradient intervals according to all the gradient modular lengths, classifying the training samples according to the gradient intervals, calculating the density of the gradient intervals according to the classification processing result, calculating a loss function according to the density of the gradient intervals, and training the intention classification model by adopting the loss function to obtain a target intention classification model.
In step S103, the training samples in the training sample set are divided into a plurality of batches and input into the intention classification model based on the artificial intelligence classification algorithm, one prediction result is output by the intention classification model for each training sample. Assume that there is N for each batchbatchFor each training sample, the training data for the batch can be represented as:
Data′={X′n=(xn,yn)|n=1,2,3,4,…,Nbatchin which xnSentence direction representing the nth training sampleAn amount; y isnLabeling the result of the N-th training sample, i.e. labeling label, with a vector size of 1 XNres,NresIs the number of intents to be classified. x is the number ofnThe vector dimension of (a) is 1 × 768.
Further, referring to fig. 5, step S103 further includes the following steps:
step S501: inputting the training sample set into a pre-constructed intention classification model in batches to obtain a prediction result of each training sample, and calculating the gradient modular length of the training sample according to the labeling processing result and the prediction result of each training sample.
In step S501, the gradient modulo length is calculated as follows:
Figure BDA0003240215190000101
wherein the content of the first and second substances,
Figure BDA0003240215190000102
is the gradient mode length, Res, of the nth training samplenFor the prediction of the nth training sample, ynFor the labeling process result (labeling label) of the nth training sample, | is the modulus length of the vector.
Step S502: and obtaining a gradient module length interval according to the calculation result of the gradient module length, dividing the gradient module length interval into a plurality of gradient intervals, and calculating the density of the gradient intervals according to the number of training samples of the gradient module length in the gradient intervals.
In step S502, assuming that the gradient modulo length interval is [0,1 ], the gradient modulo length interval is divided into a plurality of gradient intervals in an equal or unequal manner. The present embodiment equally divides the gradient modulo length interval into a plurality of gradient intervals, and each gradient interval range can be expressed as:
sec={secτ=[τb,(τ+1)b)|τ=0,1,2,…Ndenwhere b is the interval between each gradient interval, NdenFor the number of divided gradient intervals, b is 1/Nden,secτIs the interval range of the tau-th gradient interval.
The gradient interval density calculation formula of each gradient interval is as follows:
Figure BDA0003240215190000111
wherein the content of the first and second substances,
Figure BDA0003240215190000112
for the gradient mode length of the nth training sample,
Figure BDA0003240215190000113
and DisτIs calculated according to the following formula:
Figure BDA0003240215190000114
Disτ=(τ+1)b-τb=b;
wherein b is the interval of each gradient interval,
Figure BDA0003240215190000115
is a gradient mode length
Figure BDA0003240215190000116
Training samples falling within the gradient interval, DisτIs the density of the τ -th gradient interval.
Step S503: a loss function is calculated from the gradient interval density.
In step S503, the calculation formula of the loss function is as follows:
Figure BDA0003240215190000117
Figure BDA0003240215190000118
wherein the content of the first and second substances,
Figure BDA0003240215190000119
representing the gradient mode length of the training sample
Figure BDA00032402151900001110
The gradient interval density corresponding to the gradient interval to which the sensor belongs; n is a radical ofbatchFor the number of training samples of the input batch, NresThe number of the intention categories to be classified; y isnFor the labeled result of the training sample, the vector size is 1 XNres,ynjDenotes ynValue of the jth element, ResnjRepresents ResnValue of the jth element, ResnThe vector size of the prediction result of the intention classification model is 1 XNres
Step S504: and training the intention classification model by adopting a loss function, and adjusting parameters of the intention classification model based on a back propagation algorithm to obtain a target intention classification model.
In the embodiment, the accuracy of the model of the unbalanced sample for classifying the intention category is effectively improved by adjusting the misclassification weight in the loss function and reversely adjusting the parameters of the model by using a back propagation algorithm and a gradient descent method.
Step S104: and acquiring a text sample to be detected, and inputting the text sample to be detected into the target intention classification model to obtain the intention category of the text sample to be detected.
In step S104, referring to fig. 6, the structure of the target intention classification model 60 includes a GRU layer 61, a first sense layer 62, a second sense layer 63 and a Softmax layer 64 which are sequentially spliced, and the training sample X input by the target intention classification model 60kIs of characteristic size Nbatch×1×768,NbatchTo input the number of training samples for a batch, the GRU layer 61 is used to extract the training samples X fromkThe output of the GRU layer 61 has a feature size NbatchX 128, the first sense layer 62 is used for learning the intention feature, and the feature size output by the first sense layer 62 is NbatchX512, the second Dense layer 63 is used for training sample X based on the learning resultkPerforming classification prediction, and outputting a characteristic size N from the second Dense layer 63batch×NresThe Softmax layer 64 is used for converting the classification prediction result into an intention class probability distribution through a normalization process, and the characteristic size output by the Softmax layer 64 is Nbatch×NresThe object intent classification model 60 is the most importantFinal output Res ═ Resi|i=1,2,3,…,Nbatch},ResiIs 1 XNres,NresThe number of intent classes to be classified.
Further, referring to fig. 7, step S104 further includes the following steps:
step S701: and extracting intention characteristics from the text sample to be tested and learning the intention characteristics.
Step S702: and carrying out classification prediction on the text sample to be detected based on the learning result.
Step S703: the classification prediction results are converted into an intention class probability distribution by a normalization process.
Step S704: and identifying and outputting the intention type of the text sample to be detected according to the intention type probability distribution.
In this embodiment, after converting the classification prediction result into an intention category probability distribution through normalization processing, a maximum intention category probability is selected and compared with a preset threshold, and if the maximum intention category probability exceeds the preset threshold, an intention category corresponding to the maximum intention category probability is output as an intention recognition result of the training sample.
In a telephone sales scene, the intention of a customer to purchase a product C is identified through the target intention classification model, so that a salesperson can introduce the product C in detail, the customer can know the advantages of the product C more, and the purchase desire of the customer is further enhanced; if the target intention classification model identifies that the product C is not the product which the customer intends to buy, the salesperson can adjust the selling strategy in time and introduce interested products to the customer so as to achieve the effect of accurate selling. Further, the intention classification method of the embodiment can be applied to identifying the intention of the patient during online inquiry, so that online medicine and health care product sale and the like are realized.
According to the intention classification method based on multiple samples, the number of samples is reduced by regenerating new samples through a k-mean clustering algorithm, the problem that accuracy of intention classification models obtained through training is low in recognition of the intentions of clients due to unbalanced data of the multiple samples is solved, recognition accuracy of the intention classification models is effectively improved and the intentions of the clients are accurately recognized by adjusting wrong classification weights in loss functions, so that telephone sales personnel can improve telephone sales accuracy, communication experience is improved, and communication cost is reduced.
Fig. 8 is a schematic structural diagram of a multi-sample-based intention classification apparatus according to an embodiment of the present invention. As shown in fig. 8, the apparatus 80 includes an acquisition module 81, a generation module 82, a training module 83, and a classification module 84.
The obtaining module 81 is configured to obtain a text sample in the phone voice, perform labeling processing on the category attribute of the text sample, identify an intention category of the text sample according to a labeling processing result, obtain a text sample of an unbalanced intention category and a text sample of an balanced intention category, and identify the text sample of the unbalanced intention category as a target sample.
The generating module 82 is configured to generate a new target sample according to the target sample based on a k-mean clustering algorithm, and form a training sample set according to the new target sample and the text sample of the balanced intention category.
The training module 83 is configured to input the training sample set into a pre-constructed intent classification model in batches to obtain a prediction result of each training sample, calculate a gradient length of each training sample according to the prediction result, divide a gradient interval according to all the gradient lengths, classify the training samples according to the gradient interval, calculate a gradient interval density according to the classification result, calculate a loss function according to the gradient interval density, and train the intent classification model by using the loss function to obtain a target intent classification model.
The classification module 84 is configured to obtain a text sample to be detected, input the text sample to be detected into the target intention classification model, and obtain an intention category of the text sample to be detected.
Referring to fig. 9, fig. 9 is a schematic structural diagram of a computer device according to an embodiment of the present invention. As shown in fig. 9, the computer device 90 includes a processor 91 and a memory 92 coupled to the processor 91.
The memory 92 stores program instructions for implementing the multi-sample based intent classification method described in any of the above embodiments.
Processor 91 is operative to execute program instructions stored in memory 92 to retrieve intent classifications.
The processor 91 may also be referred to as a CPU (Central Processing Unit). The processor 91 may be an integrated circuit chip having signal processing capabilities. The processor 91 may also be a general purpose processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), an off-the-shelf programmable gate array (FPGA) or other programmable logic device, discrete gate or transistor logic, discrete hardware components. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
Referring to fig. 10, fig. 10 is a schematic structural diagram of a computer storage medium according to an embodiment of the present invention. The computer storage medium of the embodiment of the present invention stores a program file 101 capable of implementing all the methods described above, where the program file 101 may be stored in the computer storage medium in the form of a software product, and includes several instructions to enable a computer device (which may be a personal computer, a server, or a network device) or a processor (processor) to execute all or part of the steps of the methods described in the embodiments of the present invention. And the aforementioned computer storage media include: various media capable of storing program codes, such as a usb disk, a mobile hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, or terminal devices, such as a computer, a server, a mobile phone, and a tablet.
In the embodiments provided in the present invention, it should be understood that the disclosed system, apparatus and method may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, a division of a unit is merely a logical division, and an actual implementation may have another division, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The above description is only an embodiment of the present invention, and not intended to limit the scope of the present invention, and all modifications of equivalent structures and equivalent processes, which are made by using the contents of the present specification and the accompanying drawings, or directly or indirectly applied to other related technical fields, are included in the scope of the present invention.

Claims (10)

1. A multi-sample-based intent classification method is characterized by comprising the following steps:
acquiring a text sample in telephone voice, performing labeling processing on the category attribute of the text sample, identifying the intention category of the text sample according to a labeling processing result, acquiring the text sample of an unbalanced intention category and the text sample of an balanced intention category, and identifying the text sample of the unbalanced intention category as a target sample;
generating a new target sample according to the target sample based on a k-mean clustering algorithm, and forming a training sample set according to the new target sample and the text sample of the balanced intention category;
inputting a training sample set into a pre-constructed intention classification model in batches to obtain a prediction result of each training sample, calculating the gradient modular length of each training sample according to the prediction result, dividing a gradient interval according to all the gradient modular lengths, classifying the training samples according to the gradient interval, calculating the density of the gradient interval according to the classification processing result, calculating a loss function according to the density of the gradient interval, and training the intention classification model by adopting the loss function to obtain a target intention classification model;
and acquiring a text sample to be detected, and inputting the text sample to be detected into the target intention classification model to obtain the intention category of the text sample to be detected.
2. The intent classification method according to claim 1, characterized in that the step of generating a new target sample from the target samples based on a k-mean clustering algorithm comprises:
determining the number of the target samples needing to be balanced according to the number of the text samples of the balance intention category;
dividing the target sample into a plurality of sample clusters by adopting a k-mean clustering algorithm;
and repeatedly selecting a sample cluster from the sample clusters, randomly selecting a plurality of different subsamples from the selected sample cluster each time, obtaining the center of each subsample, and taking the center as a new target sample until the number of the new target samples reaches the number of the target samples to be balanced.
3. The intent classification method according to claim 2, characterized in that the step of dividing the target sample into a plurality of sample clusters using a k-mean clustering algorithm comprises:
randomly selecting a plurality of different target samples, and taking the selected target samples as a clustering center;
and calculating the distance from each target sample to each clustering center, traversing all the target samples, and distributing each target sample to the clustering center closest to the target sample according to the distance calculation result to form a sample cluster.
4. The intent classification method according to claim 2, wherein the step of repeatedly selecting a sample cluster from the sample clusters at random, randomly selecting a plurality of different subsamples from the selected sample cluster each time, and obtaining a center of each subsample, and using the center as a new target sample until the number of new target samples reaches the number of target samples to be balanced comprises:
randomly selecting a sample cluster from the sample clusters, randomly selecting a plurality of different subsamples from the selected sample cluster, and calculating the weighted average of each subsample;
associating the weighted average with a sample center, and taking the sample center as a new target sample;
and repeating the step of generating new target samples to obtain a plurality of new target samples until the number of the new target samples reaches the number of the target samples to be balanced.
5. The intention classification method according to claim 1, wherein the step of inputting a training sample set into a pre-constructed intention classification model in batches to obtain a prediction result of each training sample, calculating a gradient modular length of each training sample according to the prediction result, dividing a gradient interval according to all the gradient modular lengths, classifying the training samples according to the gradient interval, calculating a gradient interval density according to a classification result, calculating a loss function according to the gradient interval density, and training the intention classification model by using the loss function to obtain a target intention classification model comprises:
inputting a training sample set into a pre-constructed intention classification model in batches to obtain a prediction result of each training sample, and calculating the gradient modular length of each training sample according to the labeling processing result and the prediction result of each training sample;
obtaining a gradient module length interval according to the calculation result of the gradient module length, dividing the gradient module length interval into a plurality of gradient intervals, and calculating the density of the gradient intervals according to the number of training samples of the gradient module length in the gradient intervals;
calculating a loss function according to the density of the gradient interval;
and training an intention classification model by adopting the loss function, and adjusting parameters of the intention classification model based on a back propagation algorithm to obtain the target intention classification model.
6. The intent classification method according to claim 5, characterized in that the loss function is calculated as follows:
Figure FDA0003240215180000031
Figure FDA0003240215180000032
wherein the content of the first and second substances,
Figure FDA0003240215180000033
represents the gradient interval density corresponding to the gradient interval to which the gradient modular length of the training sample belongs,
Figure FDA0003240215180000034
is the gradient mode length, NbatchFor the number of training samples of the input batch, NresThe number of the intention categories to be classified; y isnFor the labeled result of the training sample, the vector size is 1 XNres,ynjDenotes ynThe value of the jth element in the vector, ResnjRepresents ResnThe value of the jth element in the vector, ResnThe vector size of the predicted result of the intention classification model is 1 XNres
7. The intention classification method according to claim 1, wherein the step of obtaining a text sample to be tested, inputting the text sample to be tested into the target intention classification model, and obtaining the intention category of the text sample to be tested comprises:
extracting intention characteristics from the text sample to be tested and learning the intention characteristics;
classifying and predicting the text sample to be tested based on the learning result;
converting the classification prediction result into an intention category probability distribution through normalization processing;
and identifying the intention type of the text sample to be detected according to the intention type probability distribution and outputting the intention type.
8. A multi-sample based intent classification device, comprising:
the system comprises an acquisition module, a processing module and a processing module, wherein the acquisition module is used for acquiring a text sample in telephone voice, labeling the category attribute of the text sample, identifying the intention category of the text sample according to the labeling processing result, acquiring the text sample of the unbalanced intention category and the text sample of the balanced intention category, and identifying the text sample of the unbalanced intention category as a target sample;
the generating module is used for generating a new target sample according to the target sample based on a k-mean clustering algorithm and forming a training sample set according to the new target sample and the text sample of the balanced intention category;
the training module is used for inputting a training sample set into a pre-constructed intention classification model in batches to obtain a prediction result of each training sample, calculating the gradient modular length of each training sample according to the prediction result, dividing a gradient interval according to all the gradient modular lengths, classifying the training samples according to the gradient interval, calculating the density of the gradient interval according to the classification processing result, calculating a loss function according to the density of the gradient interval, and training the intention classification model by adopting the loss function to obtain a target intention classification model;
and the classification module is used for obtaining a text sample to be detected, inputting the text sample to be detected into the target intention classification model and obtaining the intention type of the text sample to be detected.
9. A computer device, comprising: memory, processor and computer program stored on the memory and executable on the processor, characterized in that the processor implements the method of multi-sample based intent classification according to any of claims 1-7 when executing the computer program.
10. A computer storage medium on which a computer program is stored, which, when being executed by a processor, carries out a multi-sample based intent classification method according to any one of claims 1-7.
CN202111016963.7A 2021-08-31 2021-08-31 Multi-sample-based intention classification method, device, equipment and storage medium Pending CN113704413A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111016963.7A CN113704413A (en) 2021-08-31 2021-08-31 Multi-sample-based intention classification method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111016963.7A CN113704413A (en) 2021-08-31 2021-08-31 Multi-sample-based intention classification method, device, equipment and storage medium

Publications (1)

Publication Number Publication Date
CN113704413A true CN113704413A (en) 2021-11-26

Family

ID=78658415

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111016963.7A Pending CN113704413A (en) 2021-08-31 2021-08-31 Multi-sample-based intention classification method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN113704413A (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20200065384A1 (en) * 2018-08-26 2020-02-27 CloudMinds Technology, Inc. Method and System for Intent Classification
CN111753870A (en) * 2020-04-16 2020-10-09 杭州海康威视数字技术股份有限公司 Training method and device of target detection model and storage medium
CN112232407A (en) * 2020-10-15 2021-01-15 杭州迪英加科技有限公司 Neural network model training method and device for pathological image sample
CN112633359A (en) * 2020-12-18 2021-04-09 成都艾特能电气科技有限责任公司 Multi-class model training method, medium and equipment based on gradient balance

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20200065384A1 (en) * 2018-08-26 2020-02-27 CloudMinds Technology, Inc. Method and System for Intent Classification
CN111753870A (en) * 2020-04-16 2020-10-09 杭州海康威视数字技术股份有限公司 Training method and device of target detection model and storage medium
CN112232407A (en) * 2020-10-15 2021-01-15 杭州迪英加科技有限公司 Neural network model training method and device for pathological image sample
CN112633359A (en) * 2020-12-18 2021-04-09 成都艾特能电气科技有限责任公司 Multi-class model training method, medium and equipment based on gradient balance

Similar Documents

Publication Publication Date Title
CN107301225B (en) Short text classification method and device
US11270225B1 (en) Methods and apparatus for asynchronous and interactive machine learning using word embedding within text-based documents and multimodal documents
CN106951422B (en) Webpage training method and device, and search intention identification method and device
CN108363790A (en) For the method, apparatus, equipment and storage medium to being assessed
CN106506327B (en) Junk mail identification method and device
CN111125354A (en) Text classification method and device
CN106156163B (en) Text classification method and device
CN108985133B (en) Age prediction method and device for face image
CN108228622A (en) The sorting technique and device of traffic issues
KR20200127947A (en) A document classification method with an explanation that provides words and sentences with high contribution in document classification
CN107247728B (en) Text processing method and device and computer storage medium
CN112800225B (en) Microblog comment emotion classification method and system
CN111538841B (en) Comment emotion analysis method, device and system based on knowledge mutual distillation
CN110637321A (en) Dynamic claims submission system
CN114419378B (en) Image classification method and device, electronic equipment and medium
CN114610865A (en) Method, device and equipment for recommending recalled text and storage medium
CN111274388A (en) Text clustering method and device
CN114357184A (en) Item recommendation method and related device, electronic equipment and storage medium
CN109727091A (en) Products Show method, apparatus, medium and server based on dialogue robot
CN113722486A (en) Intention classification method, device and equipment based on small samples and storage medium
CN113704413A (en) Multi-sample-based intention classification method, device, equipment and storage medium
CN115269846A (en) Text processing method and device, electronic equipment and storage medium
Reddy et al. Classification of Spam Text using SVM
CN114529191A (en) Method and apparatus for risk identification
CN113010664A (en) Data processing method and device and computer 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