Text classification model with roles and dialogue text classification method and device
By introducing the role selection and sentence matching layers into the text classification model, the problem of role relationships in dialogue texts not being considered in the existing technology is solved, and more accurate risk prediction results are achieved.
Patent Information
- Application Number
- CN202111477810.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-06
- Publication Date
- 2024-09-13
- Estimated Expiration
- 2041-12-06
AI Technical Summary
Existing text classification models fail to effectively consider role relationships when processing dialogue texts, resulting in misalignment errors in risk prediction results, such as predicting "customer" insults as "customer service" insults.
A text classification model with roles is designed, including a sentence encoding layer, a sentence matching layer for role selection, a sentence classification layer, and a dialogue classification layer. The sentence vectors in the dialogue text are encoded, role matched, and context enhanced to generate a text with roles. Statement vectors of information and make risk predictions.
It improves the pertinence and accuracy of risk prediction, solves the problem of recognition misalignment, and improves the effect of dialogue text classification.
Smart Images

Figure CN114416970B
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and more specifically, to a text classification model with roles and a method and device for classifying dialogue texts. Background Art
[0002] In recent years, with the rapid development of the Internet, humans have entered the era of big data, and massive amounts of data are generated every day. Therefore, analyzing massive amounts of data and obtaining valuable information has become a hot topic of common concern in academia and industry. Correspondingly, text processing technology has also become a hot topic of public concern, and many practical applications have been generated. For example, text classification methods are used to output classification labels for documents.
[0003] Figure 1 This is an interface diagram of an intelligent customer service system. The intelligent customer service system obtains the dialogue text 11 and can output the dialogue text 11 to the text classification model, which generates the risk prediction result of the entire text. However, since the existing text classification model treats the dialogue text as ordinary text and does not consider the impact of various roles in the dialogue on the risk prediction result, errors such as prediction misalignment may occur, for example, predicting the "customer" insult in the figure as the "customer service" insult. Summary of the invention
[0004] In view of this, the present disclosure aims to provide a text classification model with roles and a method and device for classifying dialogue texts to solve the problems existing in the prior art.
[0005] According to a first aspect of the present disclosure, there is provided a text classification model with roles, comprising: a sentence encoding layer, a sentence matching layer for role selection, a sentence classification layer, and a dialogue classification layer;
[0006] The dialogue text input to the text classification model passes through the sentence encoding layer, and multiple sentences in the dialogue text are encoded into multiple sentence vectors;
[0007] The multiple sentence vectors are respectively classified into at least two roles after passing through the sentence matching layer selected by the role, a contextual semantic representation corresponding to each sentence vector is constructed, and a corresponding context-enhanced sentence vector classified into the corresponding role is constructed based on each sentence vector and its corresponding contextual semantic representation;
[0008] The context-enhanced sentence vector passes through the sentence classification layer and is concatenated with the corresponding role vector to obtain each sentence vector with role information, and then obtain the risk prediction result of each sentence vector with role information;
[0009] The risk prediction result of each sentence vector with role information passes through the dialogue classification layer and is aggregated to obtain the risk prediction result of the dialogue text.
[0010] In some embodiments, the plurality of sentences in the conversation text are encoded into a plurality of sentence vectors including:
[0011] Using the BiLSTM model, the context information representation of each character in each sentence in the dialogue text is calculated, and the weight of the context information representation of each character in each sentence is calculated through the attention mechanism, and the intermediate sentence vector corresponding to each sentence is obtained accordingly;
[0012] The BiLSTM model is used to calculate the context information representation of each sentence in the dialogue text, and then the final sentence vector is obtained based on the context information representation of each sentence and its corresponding intermediate sentence vector.
[0013] In some embodiments, constructing the context semantic representation corresponding to each sentence vector includes:
[0014] The contextual semantic representation of the sentence vector is obtained by summing the weights of the sentence vectors of roles other than the role corresponding to the sentence vector and related to the role;
[0015] Then, constructing a corresponding context-enhanced sentence vector classified into a corresponding role based on each sentence vector and its corresponding context semantic representation includes:
[0016] Each sentence vector and its corresponding contextual semantic representation are concatenated together to obtain the corresponding context-enhanced sentence vector classified into the corresponding role.
[0017] In some embodiments, obtaining the risk prediction result of each sentence vector with role information includes:
[0018] By inputting each sentence vector with role information into an activation function, a risk prediction result of each sentence vector with role information is obtained, and the activation function obtains corresponding multiple possibility predictions for multiple different types of risks.
[0019] In some embodiments, the aggregating the risk prediction result of the conversation text includes:
[0020] For each risk label, calculate the attention weight of each sentence vector with role information;
[0021] For each risk label, the risk prediction possibility of the conversation text is obtained by weighted summation calculation.
[0022] In some embodiments, it also includes: using the risk label whose risk prediction possibility exceeds a set threshold as the risk label of the conversation text.
[0023] According to a second aspect of the present disclosure, a method for classifying a conversation text is provided, comprising:
[0024] Acquire a dialogue text, wherein the dialogue text includes a round of dialogue between at least two characters;
[0025] The dialogue text is input into the above-mentioned text classification model with roles to obtain the risk prediction result of the dialogue text.
[0026] According to a third aspect of the present disclosure, a conversation text classification device is provided, comprising:
[0027] A dialogue text acquisition module, used to acquire a dialogue text, wherein the dialogue text includes a round of dialogue between at least two characters;
[0028] A text classification module is used to input the dialogue text into a text classification model with roles to obtain a risk prediction result of the dialogue text,
[0029] The text classification model with roles includes a sentence encoding layer, a sentence matching layer for role selection, a sentence classification layer and a dialogue classification layer.
[0030] At the sentence encoding layer, encoding multiple sentences in the dialogue text into multiple sentence vectors;
[0031] In the sentence matching layer of the role selection, the multiple sentence vectors are respectively classified into the at least two roles, a contextual semantic representation corresponding to each sentence vector is constructed, and a corresponding context-enhanced sentence vector classified into the corresponding role is constructed based on each sentence vector and its corresponding contextual semantic representation;
[0032] At the sentence classification layer, each context-enhanced sentence vector is concatenated with the corresponding role vector to obtain each sentence vector with role information, and then the risk prediction result of each sentence vector with role information is obtained;
[0033] At the dialogue classification layer, the risk prediction results of all sentence vectors with role information are aggregated to obtain the risk prediction result of the dialogue text.
[0034] According to a fourth aspect of the present disclosure, an electronic device is provided, comprising a memory and a processor, wherein the memory stores a computer program that can be run on the processor, and when the processor executes the program, the method for classifying conversation text described in any one of the above is implemented.
[0035] According to a fifth aspect of the present disclosure, a computer-readable storage medium is provided, on which a computer program is stored, characterized in that when the computer program is executed by a processor, the method for classifying conversation text described in any one of the above is implemented.
[0036] The disclosed embodiment provides a method for classifying dialogue texts, which associates roles and sentences in dialogue texts and performs risk prediction on sentences with role information, thereby improving the pertinence of risk prediction and solving the problem of misaligned recognition. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] The above and other objects, features and advantages of the present disclosure will become more apparent through the description of the embodiments of the present disclosure with reference to the following drawings, in which:
[0038] Figure 1 This is an interface diagram of an intelligent customer service system.
[0039] Figure 2 A schematic diagram of the scenario of model training and application is shown;
[0040] Figure 3 A structural diagram of a server that can serve as a training device and an execution device is shown;
[0041] Figure 4 A flowchart of a method for classifying conversation text according to an embodiment of the present disclosure is shown;
[0042] Figure 5 It is a structural diagram of a text classification model with roles provided by an embodiment of the present disclosure;
[0043] Figure 6 It is a structural diagram of a conversation text classification device provided by an embodiment of the present disclosure. DETAILED DESCRIPTION
[0044] The present disclosure is described below based on embodiments, but the present disclosure is not limited to these embodiments. In the detailed description of the present disclosure below, some specific details are described in detail. It is possible for a person skilled in the art to fully understand the present disclosure without the description of these details. In order to avoid confusing the essence of the present disclosure, well-known methods, processes, and procedures are not described in detail. In addition, the drawings are not necessarily drawn to scale.
[0045] Application scenarios and application architecture of the present disclosure
[0046] Figure 2A schematic diagram of a scenario of model training and application is shown. The schematic diagram includes a training device 110 and an execution device 120. The training device 110 includes a text classification model with roles to be trained 111 and a model training device 112. The execution device 120 is used to run a trained text classification model with roles 113. The trained text classification model with roles 113 recognizes and classifies the dialogue text and outputs a risk prediction result.
[0047] As is known to all, model training from scratch is performed on a neural network structure with weight parameters as initial values. This process requires a lot of resources, including but not limited to a large number of training samples, a large amount of computer resources and a long training time. However, not all model training processes need to start from scratch. Some training can start from a pre-trained model. The pre-trained model has obtained a set of better weight parameters after previous training, but before applying it to a specific task, the weight parameters need to be fine-tuned (Fine-tune), and the fine-tuning includes modifying the input and output layers, collecting training samples under specific tasks for incremental training, etc. The purpose of fine-tuning is to make the output model better adaptable to the specific task. The text classification model 111 to be trained in the figure can be a pre-trained model, which includes some layers in the existing text classification model and a new layer for integrating role information into the sentence vector obtained according to the dialogue text. After the pre-trained model is available, the model training device 112 can be used to perform incremental training on it. After the incremental training is completed, the trained text classification model 113 with roles is obtained. Here, the model training device 112 is a virtual device implemented by a computer program, and its functions generally include: executing the text classification model to be trained and continuously adjusting the weight parameters of the model according to the loss function. After the text classification model 113 is obtained, it can be deployed on the execution device 120 to recognize and classify the dialogue text in the actual environment.
[0048] Figure 3 3 is a schematic diagram of an exemplary structure of a server 300. The device can be used as a training device 110 and can also be used as an execution device 130. As shown in the figure, the server 300 includes a scheduler 301 coupled via a bus 305, a storage unit 303, an I / O interface 304, and a plurality of model acceleration units 302.
[0049] The storage unit 303 may include a readable medium in the form of a volatile storage unit, such as a random access memory unit (RAM) and / or a cache memory unit. The storage unit 303 may also include a readable medium in the form of a non-volatile storage unit, such as a read-only memory unit (ROM), a flash memory, and various disk memories.
[0050] The storage unit 303 can store various program modules and data, and various program modules include operating systems, applications that provide functions such as text processing, video playback, software editing and compilation. The executable codes of these applications are read out and executed by the scheduler 301 from the storage unit 303 to realize the predetermined operations of these program modules. The scheduler 301 is generally a processor (CPU). In this example, the program modules and data stored in the storage unit 303 include the text classification model 111 with roles to be trained and the text classification model 113 with roles that have been trained. The text classification model 111 with roles and the text classification model 113 with roles that have been trained exist in the form of static files or dynamic code files. In addition, sample data and actual data can be stored in the storage unit 303.
[0051] Bus 305 may represent one or more of several types of bus structures, including a memory unit bus or memory unit controller, a peripheral bus, an accelerated graphics port, a processing unit, or a local bus using any of a variety of bus architectures.
[0052] The server 300 may communicate with one or more external devices (e.g., keyboards, pointing devices, Bluetooth devices, etc.), one or more devices that enable a user to interact with the server 300, and / or any device that enables the server 300 to communicate with one or more other computing devices (e.g., routers, modems, etc.). Such communication may be performed via an input / output (I / O) interface 304. Furthermore, the server 300 may also communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) via a network adapter (not shown). For example, via a network adapter, Figure 1 The terminal 103 in the figure can access the server 300. It should be understood that, although not shown in the figure, other hardware and / or software modules can be used based on the server 300, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0053] As shown in the figure, the server 300 includes a plurality of model acceleration units 302. The traditional processor architecture design is very effective in terms of logic control, but is not efficient enough in terms of large-scale parallel computing, and therefore is not efficient for model computing. For this reason, a model acceleration unit is developed, and different models can be adapted to different model acceleration units. Different model acceleration units are, for example, neural network acceleration units (NPUs). The NPU adopts a data-driven parallel computing architecture, and is a processing unit for processing a large number of operations (such as convolution, pooling, etc.) of each neural network node. Or it may be a graphics processing unit (GPU), which is used to perform image and graphics-related computing work. Since the graphics processing unit uses a large number of computing units specifically for graphics computing, the graphics card reduces its dependence on the CPU and undertakes some of the computationally intensive graphics and image processing work that the CPU originally undertook, thereby greatly improving the processing efficiency of image data.
[0054] The multiple model acceleration units 302 are controlled by the scheduler 301. The scheduler 301 controls the multiple model acceleration units 302 to cooperate in executing the executable code of the model and read data from the storage unit. Figure 3 The server 300 is connected to the model acceleration unit 302, and the prediction result of the training sample is fed back to the scheduler 301, which calculates the loss value and adjusts the weight parameters in the model. If the execution device 130 adopts Figure 3 The server 300 executes the model by the model acceleration unit 302 to obtain, for example, Figure 1 The prediction result of the dialogue text 11 shown is provided to the intelligent customer service system operated by the scheduler 301 so that the intelligent customer service system can take corresponding measures.
[0055] The method for classifying conversation text according to the embodiment of the present disclosure
[0056] According to an embodiment of the present disclosure, a method for classifying conversation text is provided. The operation of the method can be performed by Figure 3 The server execution shown. Figure 4 It is a flow chart of the method, which specifically includes the following steps.
[0057] In step S401, a dialogue text is obtained, where the dialogue text includes a round of dialogue between at least two characters.
[0058] In step S402, the dialogue text is input into a text classification model with roles to obtain a risk prediction result of the dialogue text.
[0059] The text classification model with roles in this embodiment is Figure 2The trained text classification model with roles 113 in the example. The text classification model with roles includes a sentence encoding layer, a sentence matching layer for role selection, a sentence classification layer, and a dialogue classification layer.
[0060] In the sentence encoding layer, multiple sentences in the dialogue text are encoded into multiple sentence vectors.
[0061] In the sentence matching layer of role selection, multiple sentence vectors are classified into at least two roles, a contextual semantic representation corresponding to each sentence vector is constructed, and a corresponding context-enhanced sentence vector classified as the corresponding role is constructed based on each sentence vector and its corresponding contextual semantic representation.
[0062] At the sentence classification layer, the context-enhanced sentence vector classified into the corresponding role is concatenated with the corresponding role vector to obtain a sentence vector with role information, and then the risk prediction result of each sentence vector with role information is obtained.
[0063] At the dialogue classification layer, the risk prediction results of all sentence vectors with role information are aggregated to obtain the risk prediction results of the dialogue text.
[0064] Figure 5 The structure diagram of the text classification model with roles is shown in Figure 2. Figure 5 As shown, the model includes a sentence encoding layer 501, a sentence matching layer 502 for role selection, a sentence classification layer 503, and a dialogue classification layer 504. Among them, the sentence classification layer 503 can be regarded as a multiple role sentence classification layer that can identify and adaptively contain multiple roles that are respectively matched with multiple roles involved in the input dialogue text. For example, the first role sentence classification layer 5031 and the second role sentence classification layer 5032 are shown in the figure.
[0065] The sentence encoding layer 501 is used to encode multiple sentences of the dialogue text into multiple sentence vectors h1,...,h L . Since the traditional method of generating sentence vectors is to obtain sentence vectors based on the weighted average of word vectors, this method does not combine the semantics of the context. For example, the same character may have different meanings in different contexts, but the same sentence vector is generated. Therefore, as a preferred method, the sentence encoding layer 501 is constructed based on BiLSTM, and specifically includes a word encoder based on BiLSTM and a sentence encoder based on BiLSTM. Each dialogue text d∈D includes L sentences [u1,...,u L ]. Each sentence u tCorresponding to a BiLSTM module, each BiLSTM module is used to obtain the sentence vector of the corresponding sentence. Specifically, the implicit state of each character in the sentence is obtained, and the implicit state can be regarded as the context information representation of the corresponding character in the sentence. Then the character-level attention mechanism calculates the weights of the implicit states of all characters, and obtains the sentence vector according to the sum of the weights. L ] to obtain L sentence vectors [x1,...,x L ]. L sentence vectors [x1,...,x L ] is input to another sentence encoder based on BiLSTM, which captures the context information of each sentence in the dialogue text and generates a sentence vector [h1,...,h L ], where BILSTM operates on the input sentence vectors sequentially, h t-1 Represents the context information of the sentence, t∈[1,...,L]. Thus, the sentence encoding layer 501 obtains a sentence vector with the context information of the sentence for each sentence in the dialogue text.
[0066] h t =BiLSTM(x t ,h t-1 ) (1)
[0067] However, there are other implementations of the sentence encoding layer, such as BERT encoding. BERT is a pre-trained model that provides good initial weight parameters, and after fine-tuning, weight parameters suitable for this embodiment can be obtained.
[0068] In the sentence matching layer 502 of role selection, the sentences are first grouped according to the roles. For each sentence vector, the sentence vectors of other roles that are most relevant to it are found through the attention mechanism and the contextual semantic representation of the sentence vector is generated accordingly. Then, a context-enhanced sentence vector is generated based on the sentence vector and its corresponding contextual semantic representation.
[0069] by Figure 1 For example, first assign the vectors to two roles, that is, vectors h1,...,h L Divide into two groups corresponding to the two roles: customer group and customer service group. Assume that the sentence vector of the customer group is: Corresponding to h1,h3,h on the figure t The sentence vector of the customer service group is: Corresponding to h2,h4,h on the figure L Then the sentence matching layer 502 matches any sentence vector in the customer group from the customer service sentence vectors h2, h4, h LSimilarly, for any customer service statement in the customer service group, from customer statements h1, h3, h t In the example above, the context-enhanced customer sentence vector and the context-enhanced customer sentence vector are obtained by vector concatenation in the customer service group and the customer group. That is, the context-enhanced customer sentence vector corresponding to each customer sentence vector is represented by the customer sentence vector set related to the customer sentence vector, and similarly, the context-enhanced customer sentence vector corresponding to each customer sentence vector is represented by the customer sentence vector set related to the customer sentence vector.
[0070] In one embodiment, each sentence vector belonging to the same role can be uniformly represented by a contextual semantic representation generated by a sentence vector of another role related to the role. This is very applicable when there are only two roles in the dialogue text.
[0071] In one embodiment, the formula of the sentence matching layer 502 is expressed as follows. Use the weighted sum of all customer sentence vectors to build a contextual semantic representation
[0072]
[0073]
[0074] Among them, L c represents the number of customer sentences in the conversation text, β k ∈[0,1] represents the attention weight calculated by formula (3), is the sentence vector of the customer group, and The model parameters learned by model training, k is the index. is a one-dimensional real space with shape K, It is a two-dimensional real number space of K*2K, and T is the transpose operation of the parameter matrix v1.
[0075] Means repeat L c Second pair Perform aggregation operations, Indicates L c A vector whose elements are all 1 (all one vector).
[0076] For each customer sentence vector Use all customer service sentence vectors to build a contextual semantic representation
[0077]
[0078]
[0079] Among them, L s is the number of customer service sentences in the conversation text d, L c +L s =L, and γ k ∈[0,1] represents the attention weight calculated by formula (5), and are the model parameters learned by model training, is a one-dimensional real number space, It is a two-dimensional real space, and T is the transpose operation of the parameter matrix v2.
[0080] Then each And its corresponding contextual semantic representation Organized together as:
[0081]
[0082] Among them, the superscript x∈{c,s} represents the customer or customer service. Finally, the context-enhanced sentence vector is obtained: Represents a vector concatenation operation.
[0083] In the sentence classification layer, although the received context-enhanced customer sentence vectors and context-enhanced customer service sentence vectors have been classified according to roles, this layer will continue to consider the role of role information in the classification process, organize the context-enhanced sentence vectors with the corresponding roles, and obtain risk prediction results for the organized vectors. In the figure, the sentence classification layer 503 is exemplarily divided into a customer role sentence classification layer 5031 and a customer service role classification layer 5032. If the customer role is set to [0,1] and the customer service role is set to [1,0], the customer role sentence classification layer 5031 organizes the customer role [0,1] with the received context-enhanced customer sentence vector (for example, splices the vectors together), and the customer service role sentence classification layer 5032 organizes the customer service role [1,0] with the received context-enhanced customer service sentence vector (for example, splices the vectors together), and then obtains the risk prediction results based on the organized sentence vectors.
[0084] In one embodiment, the corresponding formula of the sentence classification layer is expressed as follows: The customer role vector is r c = [0,1] and customer service role vector r s = [1, 0], the output context-enhanced sentence vector O x and the role vector r xAfter vector concatenation, the sentence vector related to the role is obtained, as shown in formula (7), and then the linear transformation function and activation function sigmoid of formula (8) are used to obtain the risk prediction result of each sentence. Therefore, the following formula is obtained:
[0085]
[0086] P=δ(U3O+b3) (8)
[0087] in, is an activation (sigmoid) function, and is the parameter learned through training, P∈R |Ω|×L Characterize the probability prediction of different types of risks, R |Ω|×L The parameter matrix shape is |Ω|×L, where Ω represents a risk type set including multiple risk types, and |Ω| is the number of risk types. That is, for each sentence vector, multiple possibility predictions corresponding to multiple types of risks are obtained.
[0088] At the dialogue classification layer 504, the risk possibility prediction results of the sentence-level sentence vectors are received, and then the sentence-level risk possibility prediction results are aggregated to obtain the risk prediction results of the dialogue text.
[0089] As an implementation, a labeled attention mechanism is used to reward sentence vectors that are more likely to be good risk predictors. The risk probability of each dimension receives different attention. Specifically, the importance of each sentence vector is measured by a forward neural network as follows:
[0090] Q=softmax (Vtanh (U4O+b4)) (9)
[0091] in, and are the parameters learned through model training. is a label-wise attention weight associated with the risk label type, so as to assign different weights to different risk types of each sentence. Finally, the risk prediction result of the dialogue text is obtained based on the risk prediction possibility of each sentence vector using the following formula:
[0092]
[0093] in, The threshold means that the dialogue text has risk type l∈Ω and threshold=0.5.
[0094] In summary, for each risk label, the risk prediction possibility of each sentence vector with role information is calculated. Then, for each risk label, the risk prediction possibility of the dialogue text for the risk label is calculated by weighted summation. Then, the risk labels whose risk prediction possibility is greater than the set threshold are output.
[0095] Regarding the above parameter learning, the model parameters are obtained by sample training to minimize the cross entropy between the risk prediction possibility and the basic facts. The formula is as follows:
[0096]
[0097] in is the training set, Is 1 or 0, indicating whether the lth risk label is the entire dialogue text d is a correct answer. Back propagation can be used here to calculate the gradients of all parameters and the momentum optimizer can be used to update the parameters.
[0098] In some embodiments, since the above embodiments have differentiated sentences according to roles, risk labels for only one or some roles can be generated for the entire dialogue text, for example, Figure 1 The conversation text of the intelligent customer service system is used to predict risks, and only risk labels about customers are analyzed and generated (because the risk of customer service is extremely low).
[0099] Table 1 is a comparison table of the text classification and risk identification results of the conversation text using the model disclosed in this disclosure and other models. Four types of conversation risks are considered: customer complaints CC, customer abuse CA, customer service abuse SA, and risk-free NR, and Fscore-1 (i.e. F1) is used to predict the binary classification performance under each label, while the average results of all labels Macro F1 (i.e. Mac F1) and Precision@4 (i.e. P@4) are considered to evaluate the multi-label classification results.
[0100] Table 1
[0101] Model CC FI CA FI SA FI NR F Mac FI P@4 LSTM 90.69% 76.75% 83.60% 85.71% 84.18% 0.9223 HTrans 91.76% 75.06% 86.56% 85.23% 84.15% 0.9241 HAN 91.59% 77.49% 86.13% 85.51% 85.18% 0.9284 HWN 87.09% 88.97% 93.82% 80.82% 87.67% 0.9359 DRDN 91.17% 92.58% 96.76% 86.27% 91.65% 0.9571
[0102] As can be seen from the table, LSTM and HTrans have the worst performance, because they both ignore the interactive relationship in the dialogue text. HWN considers the interactive relationship in the dialogue text, but ignores the correlation between roles and risk types. DRDN is a model structure built by the present disclosure. As can be seen from the table, it has the best performance because it considers the matching of roles and sentences and the risk prediction based on roles at the same time.
[0103] Figure 66. As shown in the figure, the conversation text classification device 600 includes a conversation text acquisition module 601 and a text classification module 602.
[0104] The dialogue text acquisition module 601 is used to acquire dialogue text, which includes a round of dialogue between at least two characters. The text classification module 602 is used to input the dialogue text into the text classification model with characters to obtain the risk prediction result of the dialogue text.
[0105] Among them, the text classification model with roles includes a sentence encoding layer, a sentence matching layer for role selection, a sentence classification layer and a dialogue classification layer. In the sentence encoding layer, multiple sentences in the dialogue text are encoded into multiple sentence vectors; in the sentence matching layer for role selection, multiple sentence vectors are classified into at least two roles, and the context semantic representation corresponding to each sentence vector is constructed, and the corresponding context-enhanced sentence vector belonging to the corresponding role is constructed based on each sentence vector and its corresponding context semantic representation; in the sentence classification layer, the context-enhanced sentence vector classified into the corresponding role is concatenated with the corresponding role vector to obtain a sentence vector with role information, and then the risk prediction result of each sentence vector with role information is obtained; in the dialogue classification layer, the risk prediction results of all sentence vectors with role information are aggregated to obtain the risk prediction result of the dialogue text.
[0106] Since the implementation details of the text classification model with roles have been introduced in detail in the above embodiments, they will not be described in detail here to save space.
[0107] In addition, the embodiment of the present disclosure also provides a computer-readable medium for storing computer-readable instructions for implementing the above-mentioned dialogue text classification.
[0108] Commercial value of this disclosure
[0109] The disclosed embodiment provides a method for classifying dialogue texts. Compared with the prior art, this method associates roles and sentences in dialogue texts to model and obtain role-related risk prediction results. This model has practical application value and economic value for dialogue text classification and risk identification.
[0110] It should be understood that the above is only a preferred embodiment of the present disclosure and is not intended to limit the present disclosure. For those skilled in the art, there are many variations of the embodiments of this specification. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present disclosure shall be included in the protection scope of the present disclosure.
[0111] It should be understood that the various embodiments in this specification are described in a progressive manner, and the same or similar parts between the various embodiments can be referenced to each other, and each embodiment focuses on the differences from other embodiments.
[0112] It should be understood that the above is a description of a specific embodiment of the present specification. Other embodiments are within the scope of the claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the accompanying drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0113] It should be understood that an element described in singular form herein or shown in the drawings as only one does not limit the number of the element to one. In addition, modules or elements described or shown as separate herein may be combined into a single module or element, and modules or elements described or shown as single herein may be split into multiple modules or elements.
[0114] It should also be understood that the terms and expressions used herein are for description only, and one or more embodiments of this specification should not be limited to these terms and expressions. The use of these terms and expressions does not mean to exclude any equivalent features of the illustrations and descriptions (or parts thereof), and it should be recognized that various modifications that may exist should also be included in the scope of the claims. Other modifications, changes and substitutions may also exist. Accordingly, the claims should be deemed to cover all such equivalents.
Claims
1. A text classification model with roles, comprising: Sentence encoding layer, sentence matching layer for character selection, sentence classification layer, and dialogue classification layer; The dialogue text input to the text classification model passes through the sentence encoding layer, and multiple sentences in the dialogue text are encoded into multiple sentence vectors; The multiple sentence vectors are respectively classified into at least two roles after passing through the sentence matching layer selected by the role, a contextual semantic representation corresponding to each sentence vector is constructed, and a corresponding context-enhanced sentence vector classified into the corresponding role is constructed based on each sentence vector and its corresponding contextual semantic representation; The context-enhanced sentence vector passes through the sentence classification layer and is concatenated with the corresponding role vector to obtain each sentence vector with role information, and then obtain the risk prediction result of each sentence vector with role information; The risk prediction result of each sentence vector with role information passes through the dialogue classification layer and is aggregated to obtain the risk prediction result of the dialogue text.
2. The text classification model according to claim 1, wherein: The multiple sentences in the conversation text are encoded into multiple sentence vectors including: Using the BiLSTM model, the context information representation of each character in each sentence in the dialogue text is calculated, and the weight of the context information representation of each character in each sentence is calculated through the attention mechanism, and the intermediate sentence vector corresponding to each sentence is obtained accordingly; The BiLSTM model is adopted to calculate the context information representation of each sentence in the dialogue text, and then the final sentence vector is obtained based on the context information representation of each sentence and its corresponding intermediate sentence vector.
3. The text classification model according to claim 1, wherein: The constructing of the contextual semantic representation corresponding to each sentence vector includes: The contextual semantic representation of the sentence vector is obtained by summing the weights of the sentence vectors of roles other than the role corresponding to the sentence vector and related to the role; Then, constructing a corresponding context-enhanced sentence vector classified into a corresponding role based on each sentence vector and its corresponding context semantic representation includes: Each sentence vector and its corresponding contextual semantic representation are concatenated together to obtain the corresponding context-enhanced sentence vector classified into the corresponding role.
4. The text classification model according to claim 1, wherein: The risk prediction result of each sentence vector with role information is obtained as follows: By inputting each sentence vector with role information into an activation function, a risk prediction result of each sentence vector with role information is obtained, and the activation function obtains corresponding multiple possibility predictions for multiple different types of risks.
5. The text classification model according to claim 4, wherein: The risk prediction result of the conversation text obtained by aggregation includes: For each risk label, calculate the attention weight of each sentence vector with role information; For each risk label, the risk prediction possibility of the conversation text is obtained by weighted summation calculation.
6. The text classification model according to claim 5, further comprising: The risk label whose risk prediction possibility exceeds the set threshold is used as the risk label of the dialogue text.
7. A method for classifying conversation texts, comprising: Acquire a dialogue text, wherein the dialogue text includes a round of dialogue between at least two characters; The dialogue text is input into the text classification model with roles described in any one of claims 1-6 to obtain a risk prediction result of the dialogue text.
8. A conversation text classification device, comprising: A dialogue text acquisition module, used to acquire a dialogue text, wherein the dialogue text includes a round of dialogue between at least two characters; A text classification module is used to input the dialogue text into a text classification model with roles to obtain a risk prediction result of the dialogue text, The text classification model with roles includes a sentence encoding layer, a sentence matching layer for role selection, a sentence classification layer and a dialogue classification layer. At the sentence encoding layer, encoding multiple sentences in the dialogue text into multiple sentence vectors; In the sentence matching layer of the role selection, the multiple sentence vectors are respectively classified into the at least two roles, a contextual semantic representation corresponding to each sentence vector is constructed, and a corresponding context-enhanced sentence vector classified into the corresponding role is constructed based on each sentence vector and its corresponding contextual semantic representation; At the sentence classification layer, each context-enhanced sentence vector is concatenated with the corresponding role vector to obtain each sentence vector with role information, and then the risk prediction result of each sentence vector with role information is obtained; At the dialogue classification layer, the risk prediction results of all sentence vectors with role information are aggregated to obtain the risk prediction result of the dialogue text.
9. An electronic device comprising a memory and a processor, wherein the memory stores a computer program that can be run on the processor, and when the processor executes the program, the method for classifying conversation text according to claim 7 is implemented.
10. A computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the method for classifying conversation texts according to claim 7.
