Multi-label text classification method and device, chip and terminal

Through multi-head attention and cross-attention calculation combined with label-related attention weights, the problem of multi-label text classification in the existing technology failing to fully utilize the original text content is solved, and higher classification accuracy and text label association are achieved. Engagement.

CN118733769AActive Publication Date: 2024-10-01UNIV OF ELECTRONICS SCI & TECH OF CHINA

Patent Information

Application Number
CN202410767310.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-14
Publication Date
2024-10-01
Estimated Expiration
2044-06-14

Smart Images

  • Figure CN118733769A_ABST
    Figure CN118733769A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of text classification, and provides a multi-label text classification method and device, a chip and a terminal. The method comprises the following steps: vectorizing an original text and resetting word vector dimensions of a first label vector set to obtain a text vector set and a second label vector set; performing independent coding on the text vector set through multi-head attention calculation to obtain first text information; performing joint coding on the first text information through cross attention calculation in combination with the second label vector set to obtain second text information; extracting a label-related attention weight of each second label vector on the basis of the text vector set, and representing the second label vector set as label information according to the label-related attention weight of each second label vector; obtaining fusion information based on the second text information and the label information; and performing text classification on the original text according to the fusion information. According to the invention, the accuracy of the multi-label classification task can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of text classification, and in particular to a multi-label text classification method, device, chip and terminal. Background Art

[0002] In the field of deep learning, multi-label text classification methods improve the generalization ability and adaptability of models in different fields or tasks and improve classification accuracy by optimizing the classification performance of deep learning models, optimizing mechanisms to capture the correlation information between labels, improving loss functions and evaluation indicators, and utilizing technologies such as transfer learning and adaptive learning.

[0003] However, the above methods do not fully utilize the content of the original text and are difficult to significantly improve the classification accuracy. Summary of the invention

[0004] In view of the deficiencies in the prior art, the present invention provides a multi-label text classification method, device, chip and terminal, which solves the problem that the multi-label text classification method in the prior art does not fully utilize the content of the original text and is difficult to significantly improve the classification accuracy.

[0005] According to an embodiment of the present invention, a first aspect provides a multi-label text classification method, comprising:

[0006] Vectorize the original text and reset the word vector dimension of the first label vector set to obtain a text vector set and a second label vector set;

[0007] The first label vector set is generated based on the original text, and the second label vector is the first label vector with the word vector dimension reset;

[0008] The text vector set is separately encoded by multi-head attention calculation to obtain first text information; the first text information is jointly encoded by the second label vector set by cross attention calculation to obtain second text information;

[0009] Extracting the tag-related attention weight of each second tag vector based on the text vector set, and representing the second tag vector set as tag information according to the tag-related attention weight of each second tag vector;

[0010] Obtaining fusion information based on the second text information and the label information;

[0011] The original text is classified according to the fusion information.

[0012] Optionally, before the text vector set is individually encoded by multi-head attention calculation to obtain the first text information, the method includes:

[0013] The deformation dimension is calculated by the word vector dimension of the text vector set and the number of attention heads used in the multi-head attention calculation; the deformation dimension is the dimension of the output matrix of the multi-head attention calculation.

[0014] Optionally, combining the second label vector set and jointly encoding the first text information through cross attention calculation to obtain the second text information includes:

[0015] Using the second label vector set as the input of the cross-attention first matrix calculation, using the first text information as the input of the cross-attention second matrix calculation and the input of the cross-attention third matrix calculation, to obtain the output of the cross-attention first matrix, the output of the cross-attention second matrix and the output of the cross-attention third matrix;

[0016] The second text information is calculated based on the output of the cross-attention first matrix, the output of the cross-attention second matrix and the output of the cross-attention third matrix.

[0017] Optionally, after extracting the tag-related attention weight of each second tag vector based on the text vector set, representing the second tag vector as tag information according to the tag-related attention weight includes:

[0018] The relative spatial information between continuous text vectors in the text vector set is captured by the local matrix of the label-related attention weights, and the connection between each text vector in the text vector set and all second vector labels in the second label vector set is obtained to represent the label information.

[0019] Optionally, the tag information includes:

[0020] The connection between each text vector in the text vector set and all second vector labels in the second label vector set is normalized and enhanced through the label-related attention weights, and a weight matrix is ​​output to represent the label information.

[0021] Optionally, obtaining fusion information based on the second text information and the label information includes:

[0022] The second text information and the label information are respectively subjected to maximum sampling, and the maximum sampling results are concatenated to obtain the fusion information.

[0023] Optionally, performing text classification on the original text according to the fusion information includes:

[0024] The fusion information is mapped to each first label vector of the first label vector set through a fully connected layer, and a sigmoid activation function is used to calculate the probability of each first label vector.

[0025] A second aspect provides a multi-label text classification device, comprising:

[0026] A word embedding module, used for vectorizing the original text and resetting the word vector dimension of the first label vector set to obtain a text vector set and a second label vector set; wherein the first label vector set is generated based on the original text, and the second label vector is the first label vector with the word vector dimension reset;

[0027] An encoding module, used to encode the text vector set separately through multi-head attention calculation to obtain first text information; and also used to jointly encode the first text information through cross attention calculation with the second label vector set to obtain second text information;

[0028] A label embedding module, configured to extract a label-related attention weight of each second label vector based on the text vector set, and represent the second label vector set as label information according to the label-related attention weight of each second label vector;

[0029] A fusion module, used for obtaining fusion information based on the second text information and the label information;

[0030] The text classification module is used to perform text classification on the original text according to the fusion information.

[0031] In a third aspect, a chip is provided, comprising a first processor, configured to call and run a computer program from a first memory, so that a device equipped with the chip executes each step of the multi-label text classification method described above.

[0032] In a fourth aspect, a terminal is provided, comprising a second memory, a second processor, and a computer program stored in the second memory and executable on the second processor, wherein the second processor implements the various steps of the multi-label text classification method described above when executing the computer program.

[0033] The multi-label text classification method provided by the embodiment of the present invention obtains a text representation with label semantics, that is, the second text information, through multi-head attention calculation and cross-attention calculation; obtains a text embedded with the label and the text through the label-related attention weight combination text and label, that is, the label information, and the two are fused to obtain the fused information for the classification task, which makes full use of the semantic information of the original text. The label is no longer only used for the classifier to interpret the text information, but through the effective intermediate representation of the semantic overlap in the original text based on the second text information and the label information, that is, the above-mentioned fused information, so that the connection between the text and the label can be more directly involved in the text classification task, thereby comprehensively improving the accuracy of multi-label text classification. BRIEF DESCRIPTION OF THE DRAWINGS

[0034] Figure 1 This is a flowchart of the implementation of the multi-label text classification method according to an embodiment of the present invention;

[0035] Figure 2 Schematic diagram of experimental data of the multi-label text classification method according to an embodiment of the present invention;

[0036] Figure 3 A schematic diagram of the structure of a multi-label text classification device according to an embodiment of the present invention;

[0037] Figure 4 A schematic diagram of a calculation flow of a multi-label text classification method according to an embodiment of the present invention;

[0038] Figure 5 The following is a basic structural block diagram of a terminal according to an embodiment of the present invention. DETAILED DESCRIPTION

[0039] The technical solution of the present invention is further described below in conjunction with the accompanying drawings and embodiments.

[0040] Embodiment 1

[0041] In the actual application of the multi-label text classification method, the original text can be assigned to multiple category labels, and the embodiment of the present invention performs multi-label text classification based on the original text and the second label vector set. Figure 1 As shown, a multi-label text classification method proposed in an embodiment of the present invention includes:

[0042] S1. Vectorize the original text and reset the word vector dimension of the first label vector set to obtain a text vector set and a second label vector set.

[0043] It can be understood that the first label vector set represents multiple first label vectors, the second label vector set represents multiple second label vectors, and the text vector set includes multiple text vectors. It should be noted that the first label vector set is generated based on the original text, and the second label vector is the first label vector with the word vector dimension reset.

[0044] In one embodiment, an implementation method of vectorizing the original text in the above step S1 includes: using a word vector embedding model obtained by pre-training with 300-dimensional GloVe (Global Vectors, global vector word embedding) to vectorize the original text, and the obtained multiple text vectors, that is, the text vector model, have good representation meaning and can preliminarily represent the semantics of the original text.

[0045] In the above step S1, the word vector dimension of the first label vector set is reset to make the word vector dimension of the text vector set consistent with the word vector dimension of the second label vector for ease of calculation.

[0046] In a better solution, the word vector embedding model is used to vectorize the original text and reset the word vector dimension of the second label vector. In addition, the word vector embedding model also uses position encoding to save the relative position or absolute position of each text vector in the text vector set.

[0047] Exemplarily, the formula is introduced to explain the implementation of the above steps in detail:

[0048] The text vector set is represented as W = {w1,w2,…,w n}, the second label vector set can be expressed as L = {l1,l2,…,l l}, W={w1,w2,…,w n}L={l1,l2,…,l l}where n represents the text length of the original text, l represents the number of second label vectors in the second label vector set, and w i represents any text vector in the text vector set, l i represents any second label vector in the set of second label vectors.

[0049] The input of the word vector embedding model of the embodiment of the present invention refers to the input of Transofomer. Therefore, when the word vector embedding model also uses position encoding to save the relative position or absolute position of each text vector in the text vector set, this position encoding is represented by PE. The text vector set can be expressed as: H = {w1+PE1,w2+PE2…w n +PE n}.

[0050] S2. Separately encode the text vector set through multi-head attention calculation to obtain first text information; and jointly encode the first text information through cross-attention calculation in combination with the second label vector set to obtain second text information.

[0051] In the above step S2, a separate encoding calculated by multi-head attention is used to obtain the first text information integrating the global information and the local context. Then, the first text information is more accurate in representing the semantics of the original text than the text vector set.

[0052] In addition, before the text vector set is individually encoded by multi-head attention calculation, the embodiment of the present invention also makes adaptive adjustments to the multi-head attention calculation, with the purpose of making the output pay more attention to semantic information. Therefore, before executing the above step S2, the following steps are also included:

[0053] The deformation dimension is calculated by the word vector dimension of the text vector set and the number of attention heads used in the multi-head attention calculation; the deformation dimension is the dimension of the output matrix of the multi-head attention calculation.

[0054] Exemplarily, the formula is introduced to explain the implementation of the above steps in detail:

[0055] The calculation formula of deformation dimension is: Among them, C is the deformation dimension, d is the word vector dimension of the text vector set, and h is the number of attention heads used in the multi-head attention calculation.

[0056] Based on the deformed multi-head attention calculation matrix Q, K, V, the dimension of the output matrix of the multi-head attention calculation is C. In the multi-head attention calculation, the attention score of each attention head is calculated, and the formula is:

[0057] head i =Attention(Q i ,K i ,V i )

[0058] Multihead(H)=Concat(head1,head2,…,head h )W o

[0059] At the same time, the multi-head attention calculation uses the FeedFoward structure. The process of encoding the text vector set separately through multi-head attention calculation can be expressed as:

[0060] =layerNorm(H+Multihead(H))

[0061] Hf=max(0,HW1+b1)W2+b2

[0062] H = layerNorm (H + Hf)

[0063] In a traditional convolutional network, the receptive field usually expands gradually with the number of layers of the network. After introducing the attention mechanism, the embodiment of the present invention adjusts the size and step size of the convolution kernel according to the attention information, changes the size of the receptive field, and fully integrates the global information and the first text information output by the local context. Therefore, the output first text information can be expressed as:

[0064]

[0065] Where H = {h1,h2,…,h n} is the first text information, that is, the multi-head self-attention calculation is performed on the text vector set H = {w1+PE1,w2+P2…w n +PE n} is the output obtained by encoding separately, c j Represents the output of the jth layer of the attention convolution.

[0066] In the above step S2, the cross-attention calculation and the joint encoding of the second tag vector set are combined to output the second text information with tag semantics. Compared with the first text information, the second text information not only represents the semantics of the original text, but also includes the semantics from the tag. In one embodiment, one implementation of the joint encoding is:

[0067] Using the second label vector set as the input of the cross-attention first matrix calculation, using the first text information as the input of the cross-attention second matrix calculation and the input of the cross-attention third matrix calculation, to obtain the output of the cross-attention first matrix, the output of the cross-attention second matrix and the output of the cross-attention third matrix;

[0068] The second text information is calculated based on the output of the cross-attention first matrix, the output of the cross-attention second matrix and the output of the cross-attention third matrix.

[0069] Exemplarily, the formula is introduced to explain the implementation of the above steps in detail:

[0070] Q′=LW1;K′=M w W2; V′=M w W3;

[0071] Among them, W1, W2 and W3 are all parameter matrices, Q′ represents the first cross-attention matrix, K′ represents the second cross-attention matrix, V′ represents the third cross-attention matrix, L is the second label vector set, M w The first text message.

[0072] Based on the calculated output of the first cross-attention matrix, the output of the second cross-attention matrix, and the output of the third cross-attention matrix, the second text information is continued to be calculated, which is achieved by the following formula:

[0073]

[0074] Among them, Y represents the second text information, and d is the word vector dimension of the text vector set. The above formula indicates that the final output is obtained by calculating the similarity between the label and the text, and multiplying the output obtained after the similarity is normalized by softmax with the matrix V, that is, the text representation with label semantics, that is, the second text information.

[0075] S3. Extract the label-related attention weight of each second label vector based on the text vector set, and represent the second label vector set as label information according to the label-related attention weight of each second label vector.

[0076] In the above step S3, the label-related attention weight represents the influence of each text vector in the text vector set on each second label vector of the second label vector set, such as obtaining the influence of text vectors B1 to B3 on the second label vector A for the second label vector A. The second label vector set is represented as label information according to the label-related attention weight of each second label vector, so that the label information includes not only the second label vector, but also the information embedded in the second label vector combined with the text vector, that is, the label information is the text embedded in the label combined with the text, which includes the semantic content from the text vector.

[0077] Exemplarily, the formula is introduced to explain the implementation of the above steps in detail:

[0078] G s =LH T

[0079] G s is the label-related attention weight, L represents the second label set, H = {h1,h2,…,h n}, is the first text information, that is, the multi-head self-attention calculation is performed on the text vector set H = {w1+PE1,w2+PE2…w n +PE n}The output obtained by encoding separately.

[0080] Since the text vector set comes from the original text, and each word in the original text is continuous, the embodiment of the present invention considers the continuity of each text vector in the text vector set when representing the label information, so that the label information can reflect the higher level of spatial information between each word in the original text, thereby expanding the connection between each text vector in the text vector set and all second vector labels in the second label vector set. Then in the above step S3, after extracting the label-related attention weight of each second label vector based on the text vector set, the second label vector is represented as label information according to the label-related attention weight, including:

[0081] The relative spatial information between continuous text vectors in the text vector set is captured by the local matrix of the label-related attention weights, and the connection between each text vector in the text vector set and all second vector labels in the second label vector set is obtained to represent the label information.

[0082] In specific applications, using a local matrix of label-related attention weights is an efficient way to introduce the continuity of each text vector. For example, the formula is introduced to explain the implementation of the above steps in detail:

[0083] The relative spatial information between consecutive text vectors in the text vector set is captured by the local matrix of the label-related attention weights, and the formula is:

[0084] M S =Relu(G s-r,s+r W+b);

[0085] In the above formula, the relative spatial length is defined as r, and sr,s+r is a length module with a length of 2r+1 centered on s.

[0086] Assuming that the label-related attention weight is for the second label vector A, the influence of text vector B1 to text vector B3 on the second label vector A is obtained. The above formula can capture the connection between text vector B1, text vector B2 and text vector B3 when text vector B1 to text vector B3 are continuous text vectors.

[0087] In one embodiment, the tag information is represented as follows:

[0088] The connection between each word in the text vector set and all the labels in the second label vector is normalized, and enhanced by the label-related attention weights, and the output weight matrix represents the label information.

[0089] Exemplarily, the formula is introduced to explain the implementation of the above steps in detail:

[0090] Ml =softmax(M s );

[0091] M w =M l H T ;

[0092] Among them, Ms is the relative spatial information between consecutive text vectors in the text vector set, M l is the normalized M s , M w The enhanced M l , H is the text vector set.

[0093] The label information is finally M w express.

[0094] S4. Obtain fusion information based on the second text information and the label information.

[0095] One implementation of step S4 is as follows:

[0096] The second text information and the label information are respectively subjected to maximum sampling, and the maximum sampling results are concatenated to obtain the fusion information.

[0097] The above steps are described by formula:

[0098] M k =mapool(M w );

[0099] Y k =maxpool(Y);

[0100] M o =Concat(M k ,Y k );

[0101] The fusion of the second text information and the label information is the fusion of the text representation with label semantics and the text embedded in the label joint text, so that the fused information is the information representation associated with the global label.

[0102] S5. Classify the original text according to the fusion information.

[0103] One implementation of step S5 is as follows:

[0104] The fusion information is mapped to each first label vector of the first label vector set through a fully connected layer, and a sigmoid activation function is used to calculate the probability of each first label vector.

[0105] The above steps are described by formula:

[0106] y=sigmoid(WM O +b)

[0107] In the above steps S1 to S5, a text representation with label semantics is obtained through multi-head attention calculation and cross-attention calculation, i.e., the second text information; the text embedded with the label and the text is obtained by combining the text and the label through the label-related attention weight, i.e., the label information. After the two are fused, the fused information is obtained and then the classification task is performed, which makes full use of the semantic information of the original text. The label is no longer only used for the classifier to interpret the text information, but through the effective intermediate representation of the semantic overlap existing in the original text based on the second text information and the label information, i.e., the above-mentioned fused information, so that the connection between the text and the label can be more directly involved in the text classification task, and the accuracy of multi-label text classification is comprehensively improved. In addition, the embodiment of the present invention also uses a local matrix to expand the connection between each text vector in the text vector set and all second vector labels in the second label vector set to model the correlation between text and words.

[0108] Embodiment 2

[0109] The embodiment of the present invention also provides experimental data of applying the multi-label text classification task performed according to the above steps S1 to S5 on different data sets. Figure 2 As shown in the figure, the experimental results of the comparison with other benchmark models on the RCV1-V2 dataset are shown, among which the four indicators of Hamming loss (HL), micro F1 value (Micro-F1), micro precision (Micro-Precision) and micro recall (Micro-Recall) are 0.0073, 0.880, 0.906 and 0.856 respectively, which can prove that the multi-label text classification method provided by the embodiment of the present invention has a comprehensive improvement in classification performance and has achieved better classification effect.

[0110] Embodiment 3

[0111] To solve the above technical problems, the present invention also provides a multi-label text classification device. Figure 3 , Figure 3 The basic structural diagram of the multi-label text classification device 30 for this embodiment includes:

[0112] A word embedding module 31, used for vectorizing the original text and resetting the word vector dimension of the first label vector set to obtain a text vector set and a second label vector set; wherein the first label vector set is generated based on the original text, and the second label vector is the first label vector with the word vector dimension reset;

[0113] The encoding module 32 is used to encode the text vector set separately through multi-head attention calculation to obtain the first text information; and is also used to jointly encode the first text information through cross attention calculation with the second label vector set to obtain the second text information;

[0114] A tag embedding module 33 is used to extract a tag-related attention weight of each second tag vector based on the text vector set, and represent the second tag vector set as tag information according to the tag-related attention weight of each second tag vector;

[0115] A fusion module 34, configured to obtain fusion information based on the second text information and the label information;

[0116] The text classification module 35 is used to classify the original text according to the fusion information.

[0117] like Figure 4 As shown, the embodiment of the present invention provides a schematic diagram of a calculation flow chart to illustrate the above-mentioned multi-label text classification method and multi-label text classification device. Figure 4 In the above step S101 and the word embedding module are implemented as follows: Figure 4 The implementation of the above step S102 and the encoding module is as follows: Figure 4 D2, the above step S103 and the tag embedding module are implemented as follows: Figure 4 D3, the above step S104 and the fusion module are implemented as follows: Figure 4 D2 and D3 in the figure point to the process of D4 obtaining fusion information. For example, Figure 4 D1 in the figure can represent a 300-dimensional Glove pre-trained word vector embedding module, D2 can represent an encoding module and a cross attention module based on a multi-head attention mechanism, and D3 can represent a label attention model for extracting text attention from labels. As for D4 and the network model used in the text classification task based on D4, the embodiment of the present invention does not limit them.

[0118] Embodiment 4

[0119] To solve the above technical problems, an embodiment of the present invention further provides a chip, which can be a general-purpose processor or a dedicated processor. The chip includes a processor, which is used to support the terminal to execute the above related steps, such as calling and running a computer program from a memory, so that the device equipped with the chip executes to implement the multi-label text classification method in each of the above embodiments.

[0120] Optionally, in some examples, the chip further includes a transceiver, which is used to accept control of the processor and to support the terminal in executing the above-mentioned related steps to implement the multi-label text classification method in the above-mentioned embodiments.

[0121] Optionally, the chip may also include a storage medium.

[0122] It should be noted that the chip can be implemented using the following circuits or devices: one or more field programmable gate arrays (FPGA), programmable logic devices (PLD), controllers, state machines, gate logic, discrete hardware components, any other suitable circuits, or any combination of circuits that can perform the various functions described throughout this application.

[0123] Embodiment 5

[0124] The present invention also provides a terminal, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the steps of the multi-label text classification method of each of the above embodiments are implemented.

[0125] Please refer to Figure 5 , Figure 5 The basic structural block diagram of a terminal shown in FIG. 1 includes a processor, a non-volatile storage medium, a memory, and a network interface connected via a system bus. The non-volatile storage medium of the terminal stores an operating system, a database, and a computer-readable instruction. The database may store a control information sequence. When the computer-readable instruction is executed by the processor, the processor may implement a multi-label text classification method. The processor of the terminal is used to provide computing and control capabilities to support the operation of the entire terminal. The memory of the terminal may store computer-readable instructions. When the computer-readable instruction is executed by the processor, the processor may execute a multi-label text classification method. The network interface of the terminal is used to connect and communicate with the terminal. It can be understood by those skilled in the art that the structure shown in the figure is only a block diagram of a partial structure related to the scheme of the present application, and does not constitute a limitation on the terminal to which the scheme of the present application is applied. The specific terminal may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0126] It will be understood by those skilled in the art that the "terminal" and "terminal device" used herein include both devices with wireless signal receivers, which are devices with only wireless signal receivers without transmission capabilities, and devices with receiving and transmitting hardware, which are electronic devices with receiving and transmitting hardware capable of performing two-way communications on a two-way communication link. Such electronic devices may include: cellular or other communication devices, which have a single-line display or a multi-line display or a cellular or other communication device without a multi-line display; PCS (Personal Communications Service), which may combine voice, data processing, fax and / or data communication capabilities; PDA (Personal Digital Assistant), which may include a radio frequency receiver, a pager, Internet / intranet access, a web browser, a notepad, a calendar and / or a GPS (Global Positioning System) receiver; conventional laptop and / or palmtop computers or other devices, which have and / or include a conventional laptop and / or palmtop computer or other device with a radio frequency receiver. The "terminal" and "terminal device" used herein may be portable, transportable, installed in a vehicle (air, sea and / or land), or adapted and / or configured to operate locally, and / or in a distributed form, at any other location on the earth and / or in space. The "terminal" and "terminal device" used herein may also be a communication terminal, an Internet terminal, a music / video playing terminal, such as a PDA, a MID (Mobile Internet Device) and / or a mobile phone with a music / video playing function, or a smart TV, a set-top box and other devices.

[0127] The present invention also provides a storage medium storing computer-readable instructions, and when the computer-readable instructions are executed by one or more processors, the one or more processors execute the steps of the multi-label text classification method described in the above embodiments.

[0128] This embodiment also provides a computer program that can be distributed on a computer-readable medium and executed by a computing device to implement at least one step of the multi-label text classification method described in the above embodiments; and in some cases, at least one of the steps shown or described can be executed in an order different from that described in the above embodiments.

[0129] This embodiment further provides a computer program product, including a computer readable device, on which the computer program as shown above is stored. In this embodiment, the computer readable device may include the computer readable storage medium as shown above.

[0130] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program, and the computer program can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, the aforementioned storage medium can be a non-volatile storage medium such as a disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM).

[0131] It should be understood that, although the steps in the flowchart of the accompanying drawings are displayed in sequence as indicated by the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least a part of the steps in the flowchart of the accompanying drawings may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be executed in turn or alternately with other steps or at least a part of the sub-steps or stages of other steps.

[0132] The technical features of the above-described embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above-described embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0133] The above-mentioned embodiments only express several implementation methods of the present invention, and the description thereof is relatively specific and detailed, but it cannot be understood as limiting the scope of the patent of the present invention. It should be pointed out that, for ordinary technicians in this field, several variations and improvements can be made without departing from the concept of the present invention, which all belong to the protection scope of the present invention. Therefore, the protection scope of the patent of the present invention shall be subject to the attached claims.

Claims

1. A multi-label text classification method, characterized in that: include: Vectorize the original text and reset the word vector dimension of the first label vector set to obtain a text vector set and a second label vector set; The first label vector set is generated based on the original text, and the second label vector is the first label vector with the word vector dimension reset; The text vector set is separately encoded by multi-head attention calculation to obtain first text information; the first text information is jointly encoded by the second label vector set by cross attention calculation to obtain second text information; Extracting the tag-related attention weight of each second tag vector based on the text vector set, and representing the second tag vector set as tag information according to the tag-related attention weight of each second tag vector; Obtaining fusion information based on the second text information and the label information; The original text is classified according to the fusion information.

2. The multi-label text classification method according to claim 1, characterized in that: The text vector set is separately encoded by multi-head attention calculation, before obtaining the first text information, including: The deformation dimension is calculated by the word vector dimension of the text vector set and the number of attention heads used in the multi-head attention calculation; the deformation dimension is the dimension of the output matrix of the multi-head attention calculation.

3. The multi-label text classification method according to claim 1, characterized in that: Combining the second label vector set, and jointly encoding the first text information through cross attention calculation to obtain second text information, including: Using the second label vector set as the input of the cross-attention first matrix calculation, using the first text information as the input of the cross-attention second matrix calculation and the input of the cross-attention third matrix calculation, to obtain the output of the cross-attention first matrix, the output of the cross-attention second matrix and the output of the cross-attention third matrix; The second text information is calculated based on the output of the cross-attention first matrix, the output of the cross-attention second matrix and the output of the cross-attention third matrix.

4. The multi-label text classification method according to claim 1, characterized in that: After extracting the tag-related attention weight of each second tag vector based on the text vector set, representing the second tag vector as tag information according to the tag-related attention weight, including: The relative spatial information between continuous text vectors in the text vector set is captured by the local matrix of the label-related attention weights, and the connection between each text vector in the text vector set and all second vector labels in the second label vector set is obtained to represent the label information.

5. The multi-label text classification method according to claim 4, characterized in that: Indicates the tag information, including: The connection between each text vector in the text vector set and all second vector labels in the second label vector set is normalized and enhanced through the label-related attention weights, and a weight matrix is ​​output to represent the label information.

6. The multi-label text classification method according to claim 1, characterized in that: Obtaining fusion information based on the second text information and the label information includes: The second text information and the label information are respectively subjected to maximum sampling, and the maximum sampling results are concatenated to obtain the fusion information.

7. The multi-label text classification method according to claim 1, characterized in that: Performing text classification on the original text according to the fusion information includes: The fusion information is mapped to each first label vector of the first label vector set through a fully connected layer, and a sigmoid activation function is used to calculate the probability of each first label vector.

8. A multi-label text classification device, used to implement the multi-label text classification method according to any one of claims 1 to 7, characterized in that: include: A word embedding module, used for vectorizing the original text and resetting the word vector dimension of the first label vector set to obtain a text vector set and a second label vector set; wherein the first label vector set is generated based on the original text, and the second label vector is the first label vector with the word vector dimension reset; An encoding module, configured to encode the text vector set individually through multi-head attention calculation to obtain first text information; and to jointly encode the first text information through cross-attention calculation in combination with the second label vector set to obtain second text information; A label embedding module, configured to extract a label-related attention weight of each second label vector based on the text vector set, and represent the second label vector set as label information according to the label-related attention weight of each second label vector; A fusion module, used for obtaining fusion information based on the second text information and the label information; The text classification module is used to perform text classification on the original text according to the fusion information.

9. A chip, characterized in that: include: The first processor is used to call and run a computer program from the first memory, so that the device equipped with the chip performs the steps of the multi-label text classification method according to any one of claims 1 to 7.

10. A terminal, characterized in that: The method comprises a second memory, a second processor, and a computer program stored in the second memory and executable on the second processor, wherein the second processor implements the steps of the multi-label text classification method as described in any one of claims 1 to 7 when executing the computer program.

Citation Information

Patent Citations

  • BILSTM multi-label text classification method based on attention mechanism

    CN114398488A

  • Multi-label text classification method based on deep learning

    CN116821340A

Cited By

  • Multi-mode irony detection method based on joint attention and graph learning enhancement

    CN118916683A