Text classification method, electronic device, and computer-readable storage medium

By performing hash bucketing and neighbor node screening on the text graph, the computational complexity of text classification is reduced, the efficiency and accuracy of text classification are improved, and the problem of high computational complexity of graph attention network in text classification is solved.

CN116127064BActive Publication Date: 2025-09-16MASHANG CONSUMER FINANCE CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211549401.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-12-05
Publication Date
2025-09-16
Estimated Expiration
2042-12-05

AI Technical Summary

Technical Problem

The existing graph attention network has high computational complexity in text classification, resulting in poor efficiency in determining text features, which in turn affects the efficiency of text classification.

Method used

By hashing the nodes in the text graph into buckets, the target neighbor node set is determined using the hash bucket and the neighbor node set, and the neighbor node feature vectors of the same hash bucket are filtered to reduce the computational complexity and improve the accuracy of the feature vector.

Benefits of technology

The computational complexity and time consumption of text classification are reduced, and the efficiency and accuracy of text classification are improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116127064B_ABST
    Figure CN116127064B_ABST
Patent Text Reader

Abstract

The present application provides a text classification method, apparatus, and electronic device. The method comprises: obtaining an initial feature vector for each node in a text graph; performing hash bucketing on the N nodes to obtain M hash buckets based on the initial feature vectors of the N nodes in the text graph; determining a target neighbor node set for each of the N nodes based on the M hash buckets and the N neighbor node sets, wherein the nodes in the target neighbor node set of the node and the node belong to the same hash bucket; determining a target feature vector for at least one node to be classified based on the initial feature vectors of the N nodes and the initial feature vectors of the nodes in the target neighbor node set of the N nodes; and performing text classification on the at least one node to be classified based on the target feature vector of the at least one node to be classified to determine a text category. This method filters out neighbor nodes that do not belong to the same hash bucket as the node, thereby reducing computational complexity, thereby reducing the time required for text classification of the node to be classified and improving text classification efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of information processing, and in particular to a text classification method, an electronic device, and a computer-readable storage medium. Background Art

[0002] Graph neural networks have achieved significant success in processing graph data and have become an important research direction in deep learning, with applications across various fields. Graph Attention Networks (GATs) are a representative type of graph neural network that aggregate features using an attention mechanism, representing the features of a node by aggregating the features of its neighbors. For example, when applying GATs to text classification, a text graph (including multiple nodes representing text, which can be understood as including multiple texts) can be input into the GAT for text feature extraction. To determine the features of a text in the text graph, the features of each text in the corresponding neighboring text set are used. This means that the correlation between two adjacent texts in the graph must be calculated, resulting in high computational complexity and a long time-consuming feature determination process. This results in poor text feature determination efficiency. Subsequent classification using the text features can lead to low text classification efficiency. Summary of the Invention

[0003] Embodiments of the present application provide a text classification method, an electronic device, and a computer-readable storage medium to solve the problem of poor efficiency in existing text classification.

[0004] In order to solve the above technical problems, this application is implemented as follows:

[0005] In a first aspect, an embodiment of the present application provides a text classification method, the method comprising:

[0006] Obtaining an initial feature vector for each node in a text graph, wherein the text graph includes N nodes, wherein one node is used to represent one text, and the N nodes include at least one unclassified node to be classified, where N is an integer greater than 1;

[0007] Based on the initial feature vectors of the N nodes, hash bucketing is performed on the N nodes to obtain M hash buckets, where M is an integer greater than 1;

[0008] Determining a target neighbor node set for each of the N nodes according to the M hash buckets and N neighbor node sets, wherein the N neighbor node sets include a neighbor node set of each of the N nodes in the text graph, the target neighbor node set of the node belongs to the neighbor node set of the node, and the nodes in the target neighbor node set of the node belong to the same hash bucket as the node;

[0009] Determining a target feature vector for each node in the at least one node to be classified based on the initial feature vectors of the N nodes and the initial feature vectors of nodes in the target neighbor node set of the N nodes;

[0010] Text classification is performed on the at least one node to be classified according to the target feature vector of the at least one node to be classified, and a text category of the at least one node to be classified is determined.

[0011] In a second aspect, an embodiment of the present application further provides a text classification device, comprising:

[0012] A first acquisition module is configured to acquire an initial feature vector of each node in a text graph, wherein the text graph includes N nodes, wherein one node is used to represent one text, and the N nodes include at least one unclassified node to be classified, where N is an integer greater than 1;

[0013] A bucketing module, configured to perform hash bucketing on the N nodes based on the initial feature vectors of the N nodes to obtain M hash buckets, where M is an integer greater than 1;

[0014] a first determining module, configured to determine a target neighbor node set of each of the N nodes based on the M hash buckets and N neighbor node sets, wherein the N neighbor node sets include a neighbor node set of each of the N nodes in the text graph, the target neighbor node set of the node belongs to the neighbor node set of the node, and the nodes in the target neighbor node set of the node belong to the same hash bucket as the node;

[0015] A second determining module is configured to determine a target feature vector for each node in the at least one node to be classified based on the initial feature vectors of the N nodes and the initial feature vectors of nodes in the target neighbor node set of the N nodes;

[0016] The classification module is configured to perform text classification on the at least one node to be classified according to the target feature vector of the at least one node to be classified, and determine the text category of the at least one node to be classified.

[0017] In a third aspect, an embodiment of the present application further provides an electronic device comprising: a memory, a processor, and a computer program stored on the memory and executable on the processor, wherein the processor implements the steps of the method provided in the first aspect when executing the computer program.

[0018] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps in the method provided in the first aspect are implemented.

[0019] In this embodiment, based on the initial feature vectors of N nodes in the text graph, the N nodes can be hashed and bucketed to obtain M hash buckets, and the M hash buckets and the neighbor node sets of the N nodes can be used to determine the target neighbor node set of each node in the N nodes. In this embodiment, in the process of determining the target feature vector of a node, it is not necessary to use the feature vectors of all the neighbor nodes of the node in the text graph. Instead, the initial feature vector of the node in the target neighbor node set that belongs to the same hash bucket as the node is screened. The nodes in the target neighbor node set of the node belong to the same hash bucket as the node, that is, the neighbor nodes that do not belong to the same hash bucket as the node are filtered out, and the node in the text graph represents text. In this way, the target feature vector of the text is determined by using the initial feature vector of the text and the initial feature vector of the text in the target neighbor node set of the text, which can reduce the computational complexity. Subsequently, the category of at least one text to be classified can be determined based on the target feature vector of at least one uncategorized text to be classified in the N texts, thereby realizing category identification of the text to be classified, thereby reducing the time consumption of text classification and improving the efficiency of text classification. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following briefly introduces the drawings required for use in the description of the embodiments of the present application. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.

[0021] Figure 1 This is one of the flowcharts of a text classification method provided in an embodiment of the present application;

[0022] Figure 2 This is one of the principle diagrams of a text classification method provided in an embodiment of the present application;

[0023] Figure 3 This is the second principle diagram of a text classification method provided in an embodiment of the present application;

[0024] Figure 4This is the second flowchart of a text classification method provided in an embodiment of the present application;

[0025] Figure 5 This is an application scenario diagram of a text classification method provided by this implementation;

[0026] Figure 6 This is a structural diagram of a text classification device provided in an embodiment of the present application;

[0027] Figure 7 This is a structural diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0028] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.

[0029] In the process of extracting text features of nodes in the text graph, the features of each text in the text graph and the neighboring text set corresponding to the text are used. It is necessary to calculate the correlation between the text in the text graph and each adjacent node of the text. The calculation complexity is high, and it takes a lot of time to determine the features, resulting in poor efficiency in determining the features of the text. Subsequently, the text is classified using the features of the text, which easily leads to low efficiency in text classification. Based on this, an embodiment of the present application provides a text classification method, which obtains M hash buckets by hashing N texts in a text graph, and uses the M hash buckets and the neighbor node set of the N texts to determine the target neighbor node set of each text in the N texts. In the process of determining the target feature vector of the text, this embodiment does not need to use the feature vectors of all neighbor nodes of the text in the text graph, but instead uses the initial feature vector of the node in the target neighbor node set that belongs to the same hash bucket as the text obtained by screening. The nodes in the target neighbor node set of the node belong to the same hash bucket as the node, that is, the neighboring texts that do not belong to the same hash bucket as the text are filtered out. In this way, the target feature vector of the text is determined by using the initial feature vector of the text and the initial feature vector of the text in the target neighbor node set of the text, which can reduce the computational complexity. Subsequently, the category of the text to be classified can be determined according to the target feature vector of the text to be classified, and the category identification of the text to be classified can be realized, thereby reducing the time consumption of text classification and improving the efficiency of text classification.

[0030] See also Figure 1 , Figure 1 This is a flowchart of a text classification method provided by an embodiment of the present application. Figure 1As shown, the method includes the following steps:

[0031] Step 101: Obtain an initial feature vector of each node in a text graph, where the text graph includes N nodes.

[0032] One node is used to represent one text, the N nodes include at least one unclassified node to be classified, and N is an integer greater than 1.

[0033] It is understood that different nodes in a text graph represent different texts. That is, the text graph includes N texts. The text graph is a topological graph pre-created based on the N collected texts. There is an association relationship between the texts corresponding to two nodes with an edge in the text graph, such as a reference relationship. It should be noted that the N nodes in the text graph may include categorized nodes and uncategorized nodes to be classified.

[0034] The initial feature vector can be understood as a feature vector obtained by pre-extracting features from the node. The feature vector can be the attribute feature vector of the node itself, which can preliminarily represent some attribute characteristics of the node, or the initial feature vector is a feature vector obtained by feature extraction through a model (for example, a Bidirectional Encoder Representations from Transformer (BERT) model). The initial feature vector of each of the N nodes can be obtained, so that N initial feature vectors can be obtained, that is, the initial feature vectors of the N nodes. It should be noted that in the text classification scenario, the node in the text graph represents the text, and the initial feature vector corresponding to the node can be the vector representation of the text.

[0035] Step 102: Based on the initial feature vectors of the N nodes, hash buckets are performed on the N nodes to obtain M hash buckets, where M is an integer greater than 1.

[0036] After obtaining the initial feature vectors of N nodes, the initial feature vectors of N nodes can be used to hash bucket the N nodes to obtain M hash buckets, where any hash bucket includes at least one node. In one example, the locality-sensitive hashing (LSH) algorithm can be used to hash bucket the N nodes to obtain M hash buckets. It should be noted that the closer the two feature vectors are, the easier it is to obtain the same hash value. Using the LSH algorithm to group the nodes with the closest initial feature vectors into the same hash bucket can quickly identify similar nodes. The initial feature vectors of the nodes in the same hash bucket have the same hash value, which is also the number of the hash bucket. The number of each hash bucket in the M hash buckets is different.

[0037] Step 103: Determine a target neighbor node set for each of the N nodes based on the M hash buckets and the N neighbor node sets.

[0038] The N neighbor node sets include the neighbor node set of each of the N nodes in the text graph, the target neighbor node set of the node belongs to the neighbor node set of the node, and the nodes in the target neighbor node set of the node belong to the same hash bucket as the node.

[0039] In the text graph, each node has a corresponding neighbor node. The neighbor node set of a node in the text graph includes all the neighbor nodes of the node in the text graph. Each node in the text graph corresponds to a neighbor node set, that is, there are N neighbor node sets. After performing hash bucketing to obtain M hash buckets, the M hash buckets and the neighbor node sets of N nodes can be used to determine the target neighbor node sets of N nodes, thereby determining N target neighbor node sets. It should be noted that, for a node, the target neighbor node set of the node may include neighbor nodes that belong to the same hash bucket as the node, which are filtered out from the neighbor node set of the node using M hash buckets, that is, the target neighbor node set of the node is the node set after excluding the neighbor nodes that do not belong to the same hash bucket as the node in the neighbor node set of the node.

[0040] Step 104 : Determine a target feature vector for each node in at least one node to be classified based on the initial feature vectors of the N nodes and the initial feature vectors of the nodes in the target neighbor node set of the N nodes.

[0041] After determining the target neighbor node set for each node, the initial feature vectors of the N nodes and the initial feature vectors of the nodes in the target neighbor node set of the N nodes can be used to determine the target feature vector of each of the N nodes. At least one node to be classified is a node in the N nodes, so the target feature vector of each of the at least one node to be classified can be determined. It should be noted that the target feature vector of a node is determined based on the initial feature vector of the node and the initial feature vectors of the nodes in the target neighbor node set of the node.

[0042] Step 105: performing text classification on at least one node to be classified according to the target feature vector of at least one node to be classified, and determining the text category of the at least one node to be classified.

[0043] After determining the target feature vectors of the N nodes, the nodes to be classified that have no category among the N nodes can be classified, that is, the target feature vectors of the nodes to be classified can be used to classify the nodes to be classified. For example, in one example, the target feature vector of the node to be classified can be input into a preset category recognition model for category prediction to obtain the category of the node to be classified, or in another example, the distance between the target feature vector of the node to be classified and the target feature vector of the first node among the N nodes can be used, and the category of the node with the shortest distance between the target feature vector of the first node and the target feature vector of the node to be classified is used as the category of the node to be classified, where the first node is a node with a category among the N nodes.

[0044] It should be noted that the text category of a node is used to characterize the category to which the text of the node belongs. During the text classification process of a node, the target feature vector of the node can be used to determine the category of the node. The determined category of the node is a category in a preset text category list, which can include multiple text categories. Exemplarily, the preset text category list can include multiple text category sublists, each text category sublist corresponding to a text attribute, that is, multiple text category sublists corresponding to multiple text attributes, and each text category sublist includes at least two text categories, and each text category sublist includes at least two text categories under the corresponding text attribute. Exemplarily, the multiple text attributes can include but are not limited to fields, titles, subjects of study, importance levels, etc. For example, for a field attribute, the corresponding text category sublist can include at least two field categories, such as, but not limited to, the fields of medicine, education, computers, finance, academic research, etc. After performing text classification using the target feature vector of the text to be classified, the field category of the text to be classified can be determined. For example, the field category of the text to be classified can be determined to be the computer field.

[0045] In this embodiment, according to the initial feature vectors of N nodes in the text graph, the N nodes can be hashed and bucketed to obtain M hash buckets, and the M hash buckets and the neighbor node set of the N nodes are used to determine the target neighbor node set of each node in the N nodes. In this embodiment, in the process of determining the target feature vector of a node, it is not necessary to use the feature vectors of all the neighbor nodes of the node in the text graph. Instead, the initial feature vector of the node in the target neighbor node set that belongs to the same hash bucket as the node is used. The nodes in the target neighbor node set of the node belong to the same hash bucket as the node, that is, the neighbor nodes that do not belong to the same hash bucket as the node are filtered out, and the node in the text graph represents text. In this way, the target feature vector of the text is determined by using the initial feature vector of the text and the initial feature vector of the text in the target neighbor node set of the text, which can reduce the computational complexity. Subsequently, the category of at least one text to be classified can be determined according to the target feature vector of at least one text to be classified that has no category in the N texts, so as to realize the category identification of the text to be classified, thereby reducing the time consumption of text classification and improving the efficiency of text classification. At the same time, because more similar texts are more likely to be assigned to the same hash bucket, hash bucketing can be used to assign similar texts to the same hash bucket. The target feature vector of a text is determined by the text in the target neighbor node set that belongs to the same hash bucket as the text. This means that the target feature vector of a text is represented by using the neighboring texts that are similar to the text, which can improve the accuracy of the target feature vector of the text. Furthermore, text classification can be performed using the target feature vectors of texts with higher accuracy, thus improving the accuracy of text classification.

[0046] In one embodiment, before determining the target neighbor node set of each of the N nodes based on the M hash buckets and the N neighbor node sets, the method further includes:

[0047] Sort the M hash buckets according to their numbers;

[0048] For each of the sorted M hash buckets, the nodes in the hash bucket are sorted according to the structural scores of the nodes in the hash bucket to update the order of the nodes in the sorted M hash buckets. The structural scores are used to represent the importance of the nodes in the text graph.

[0049] Based on M hash buckets and N sets of neighbor nodes, before determining the target neighbor node set for each of the N nodes, the M hash buckets can be sorted. For each of the sorted N hash buckets, the nodes within the hash bucket are sorted, that is, the order of the nodes within the bucket is sorted to update the order of the nodes in the sorted M hash buckets. The updated sorted M hash buckets are then used to determine the target neighbor node set for the node. It should be noted that the structure score of a node is used to represent the importance of the node in the text graph. It can be understood that in the text graph, the more neighbor nodes a node has, the higher the structure score of the node, indicating that the node is more important in the text graph (i.e., more important). The structure score of each of the N nodes can be obtained in advance, and the structure scores of the nodes in the hash bucket can be used to sort the nodes in the hash bucket. For example, the nodes can be sorted in descending order according to the structure score, with the higher the structure score, the higher the ranking. It should also be noted that the nodes in the same hash bucket are sorted. Taking M as 2 as an example, hash bucket 1 includes node 1, node 2 and node 3, and hash bucket 2 includes node 4, node 5 and node 6. Hash bucket 1 and hash bucket 2 are sorted first, for example, hash bucket 1 is ranked before hash bucket 2, and then the order of the nodes in each hash bucket is sorted. For example, the structural scores of the nodes in hash bucket 1 are used to sort the nodes in hash bucket 1. After sorting, the nodes in hash bucket 1 are: node 2, node 1, node 3. The structural scores of the nodes in hash bucket 2 are used to sort the nodes in hash bucket 2. After sorting, the nodes in hash bucket 2 are: node 6, node 5, node 4. The nodes in the hash bucket in front are all before the nodes in the hash bucket in the back, that is, nodes 1-node 3 are sorted before nodes 4-6.

[0050] In this embodiment, the M hash buckets can be sorted first, and the nodes in the hash buckets can be sorted using the structural scores of the nodes in the hash buckets to update the sorted M hash buckets. In this way, the updated sorted M hash buckets can be used to screen the neighbor nodes of the node subsequently, so as to facilitate orderly screening of neighbor nodes in the hash bucket where the node is located.

[0051] In one embodiment, determining a target neighbor node set for each of the N nodes based on the M hash buckets and the N neighbor node sets includes:

[0052] Divide the N nodes into K node blocks according to the order of the nodes in the updated M hash buckets. Each node block includes at least one node, and K is an integer greater than 1.

[0053] For each of the N nodes, the target neighbor node set of the node is determined based on the nodes that meet the target conditions in the target node block corresponding to the node. The target node block corresponding to the node includes blocks adjacent to the node block where the node is located in the K node blocks and / or the node block where the node is located. The target conditions include the set of neighbor nodes that belong to the same hash bucket as the node and belong to the node.

[0054] M hash buckets have been sorted by number, and the nodes in each hash bucket have been sorted by structural score. In this way, the N nodes have been sorted as a whole, and the nodes can be divided according to the order of the sorted N nodes to obtain K node blocks. For a certain node, the neighbor nodes of the node can be concentrated, and the nodes in the blocks that belong to the same hash bucket as the node and the same node block as the node or are adjacent to the node block where the node is located are used as the nodes in the target neighbor node set of the node. In one example, adjacent to the block where the target node is located can be along the first direction and / or the second direction, the previous block of the block where the target node is located, the first direction (positive direction) can be along the direction from the first node to the last node of the sorted N nodes, and the second direction (reverse direction) can be along the direction from the last node to the first node of the sorted N nodes.

[0055] For example, in the process of dividing N nodes according to the order of nodes in the updated M hash buckets, the N nodes can be divided into K node blocks according to the preset number (an integer greater than 1) in the order of the nodes, where K is the value of N divided by the preset number rounded up. The number of nodes in any node block is less than or equal to the preset number. For example, if the preset number is divisible by N, the value of N divided by the preset number rounded up is the result of N divided by the preset number, and K is the result of N divided by the preset number. The number of nodes may be a preset number. If the preset number cannot be divided by N, the number of nodes in each of the first K-1 node blocks in the K node blocks is the same, and the number of nodes in each of the K-1 node blocks is the preset number. The number of nodes in the remaining node blocks other than the K-1 node blocks in the K node blocks is different from the number of nodes in each of the K-1 node blocks, and the number of nodes in the remaining node blocks is the difference between N and the total number of nodes in the K-1 node blocks.

[0056] In this embodiment, the nodes in the target neighbor node set of the node not only belong to the same hash bucket as the node and are adjacent to the node in the text graph, but also belong to the same node block or are adjacent to the node block in which they are located, and the node block is divided according to the order of the sorted N nodes, and the nodes in the hash bucket are sorted according to the structure score. The closer the structure score of the nodes in the same hash bucket is, the greater the possibility of being divided into the same block or into adjacent blocks. In this way, the neighbor nodes with a structure score close to the node (closer in importance in the text graph) can be screened out in the hash bucket of the node to improve the accuracy of the target neighbor node set of the node. In this way, the target feature vector of the node is determined using the initial feature vector of the node and the initial feature vector of the nodes in the target neighbor node set of the node, which can improve the accuracy of the target feature vector of the node. In this way, the target feature vector of the node to be classified is subsequently used to classify the node to be classified, which can improve the accuracy of the classification of the node to be classified.

[0057] In one embodiment, for each of the sorted M hash buckets, before sorting the nodes in the hash bucket according to the structural scores of the nodes in the hash bucket to update the order of the nodes in the sorted M hash buckets, the method further includes:

[0058] Get the adjacency matrix of the text graph;

[0059] Multiply the adjacency matrix with the preset column vector to obtain the structure score vector;

[0060] The structure score vector includes the structure score of each of the N nodes, the number of rows of the preset column vector is the same as the number of columns of the adjacency matrix, and the elements in the preset column vector are all preset values.

[0061] It should be noted that the preset value is a value greater than zero, for example, it can be 1. In addition, a graph can be represented by a set of edges and nodes, an edge can represent a connection (adjacency) relationship between nodes, and an adjacency matrix can represent a connection relationship between nodes in a text graph, that is, it includes data representing the relationship between nodes in a text graph, that is, the adjacency matrix of a text graph is a matrix used to represent the adjacency relationship between nodes in a text graph, one graph corresponds to one adjacency matrix, and the size of the adjacency matrix is ​​N rows and N columns. For example, if there is an edge between node 1 and node 2 in a text graph, then the elements corresponding to node 1 and node 2 in the adjacency matrix are 1. If there is no edge between the two nodes, then the elements corresponding to the two nodes in the adjacency matrix are 0.

[0062] The number of rows and columns of the preset column vector is N, and the adjacency matrix of N rows and N columns is multiplied by the preset column vector of N rows to obtain the structure score vector. The structure score vector is the column vector of N rows, that is, the number of columns is 1, which includes N structure scores, that is, the structure scores of N nodes. For example, the structure score of a node can be calculated by the following formula:

[0063] S = AE;

[0064] Among them, A is the adjacency matrix of the text graph, E∈R N×1 , is the preset column vector, R N×1 It represents a real number space with dimension of N rows and 1 column. The elements of the preset column vector can all be 1. S is the structural score vector, which counts the connectivity of the node edges. The structural score focuses on its own structural information. Since the structure of the text graph is unchanged, S is constant and only needs to be calculated once.

[0065] In this embodiment, the structural score vector can be obtained by multiplying the adjacency matrix with the preset column vector, thereby obtaining the structural score of each node in N nodes. That is, the structural score of each node can be obtained by a single matrix multiplication, and the structural scores of N nodes can be obtained by a single calculation. The amount of calculation is small, thereby improving the efficiency of obtaining the structural scores of N nodes.

[0066] In one embodiment, determining a target feature vector for each node in at least one node to be classified based on the initial feature vectors of the N nodes and the initial feature vectors of the nodes in the target neighbor node set of the N nodes includes:

[0067] For each of the N nodes, the initial weight between the node and the nodes in the target neighbor node set is calculated based on the initial feature vector of the node and the initial feature vector of the nodes in the target neighbor node set, and the initial weight set of the node is obtained, where the initial weight is used to represent the similarity of the initial feature vectors between the nodes;

[0068] The target feature vector of the node is determined according to the initial weight set of the node and the initial feature vectors of the nodes in the target neighbor node set of the node.

[0069] For each node, the corresponding initial weight set includes the initial weight between the node and each node in the corresponding target neighbor node set. It can be understood that, based on the initial weights between the node and the nodes in the corresponding target neighbor node set, the initial feature vectors of the nodes in the target neighbor node set corresponding to the node are subjected to feature aggregation to obtain the first feature vector of the node, and the target feature vector of the node is determined by combining the initial feature vector of the node. For example, the target feature vector of a node can be the feature vector obtained by processing the result of the weighted sum of the first feature vector of the node and the initial feature vector of the node through an activation function.

[0070] In this embodiment, the initial weights between the nodes can be calculated using the initial feature vectors between the nodes, and then the target feature vector of the node can be determined using the initial weight set of the node and the initial feature vectors of the nodes in the target neighbor node set of the node. That is, the target feature vector of the node not only takes into account the weights between the node and the nodes in the corresponding target neighbor node set, but also takes into account the initial feature vectors of the nodes in the target neighbor node set of the node, thereby improving the accuracy of the target feature vector of the node.

[0071] In one embodiment, determining a target feature vector of the node according to an initial feature vector of the node, an initial weight set of the node, and initial feature vectors of nodes in a target neighbor node set of the node includes: determining the target feature vector of the node through L graph convolution layers according to the initial feature vector of the node, the initial weight set of the node, and the initial feature vectors of nodes in the target neighbor node set of the node, where L is an integer greater than 1;

[0072] Among them, the first graph convolution layer in the L-layer graph convolution layer performs feature extraction based on the initial feature vector of the node, the initial weight set of the node, and the initial feature vector of the node in the target neighbor node set of the node, and outputs the first-layer feature vector of the node. The r-th graph convolution layer in the L-layer graph convolution layer performs feature extraction based on the r-1-th layer feature vector of the node, the r-1-th layer weight set of the node, and the r-1-th layer feature vector of the node in the target neighbor node set of the node, and outputs the r-th layer feature vector of the node, where r is an integer and 2≤r≤L. The target feature vector of the node is the L-th layer feature vector output by the L-layer graph convolution layer, wherein the r-1-th layer weight set of the node includes the r-1-th layer weight between the node and each node in the target neighbor node set corresponding to the node, and the r-1-th layer weight is used to represent the similarity of the r-1-th layer feature vectors between nodes.

[0073] It should be noted that, in an example, the first-layer feature vector of the node output by the first-layer graph convolution layer can be the feature vector obtained by processing the result of the weighted sum of the first feature vector of the 0th layer of the node and the 0th layer feature vector of the node through the activation function. The first feature vector of the 0th layer of the node is obtained by weighted summing the 0th layer feature vectors of the nodes in the target neighbor node set of the node based on the 0th layer weight set of the node. The 0th layer feature vector is the initial feature vector, the 0th layer weight set is the initial weight set, and the 0th layer first feature vector can be understood as the feature aggregation of the initial feature vectors of the nodes in the target neighbor node set corresponding to the node. The r-th layer feature vector of the node output by the r-th layer graph convolution layer can be the feature vector obtained by processing the result of the weighted sum of the first feature vector of the r-1 layer of the node and the r-1 layer feature vector of the node through the activation function. The first feature vector of the r-1 layer of the node is obtained by weighted summing the r-1 layer feature vectors of the nodes in the target neighbor node set of the node based on the r-1 layer weight set of the node. The first feature vector of the r-1 layer can be understood as feature aggregation of the r-1 layer feature vectors of the nodes in the target neighbor node set corresponding to the node. In addition, it should be noted that the graph convolution layer in this embodiment is the graph convolution layer in the graph attention network, that is, the graph attention network may include the above-mentioned L-layer graph convolution layer.

[0074] In this embodiment, L graph convolution layers can be used for feature extraction. The latter graph convolution layer in two adjacent graph convolution layers performs graph convolution processing based on the feature vector output by the previous graph convolution layer. The last layer, that is, the Lth graph convolution layer, performs processing based on the feature vector output by the L-1th graph convolution layer to obtain the Lth layer feature vector of each node in the N nodes, that is, the target feature vector of each node. In this way, by performing feature extraction through the cascaded L-layer graph convolution layer, a feature vector that more accurately characterizes the node can be extracted, thereby improving the accuracy of the obtained target feature vector.

[0075] In one embodiment, before performing hash bucketing on the N nodes based on the initial feature vectors of the N nodes, the method further includes:

[0076] Feature mapping is performed on the initial feature vector of each of the N nodes to update the initial feature vector of each of the N nodes.

[0077] In this embodiment, the graph attention network also includes an embedding layer, which can also be called a feature mapping layer. The initial feature vector of each node in the N nodes can be feature mapped to obtain the mapping feature vector of each node in the N nodes, that is, N mapping feature vectors. This not only can achieve dimensionality reduction of the feature vector, but also can obtain the feature representation of N nodes in the same space, that is, the mapping feature vectors of N nodes. Then, the graph convolution layer uses the N mapping feature vectors obtained after feature mapping to perform subsequent processing to obtain the target feature vector of the N nodes, which can improve the accuracy of the target feature vector.

[0078] The process of the above method is described in detail below with reference to a specific embodiment.

[0079] The problem of quickly finding the nearest neighbor in a high-dimensional space can be solved by Locality Sensitive Hashing (LSH) in the embodiment of the present application. Vectors that are relatively close can be mapped to the same hash value with a high probability, while vectors that are relatively far away can be mapped to different hash values ​​with a high probability. There are many types of LSH, for example, the hash method based on random projection, the function for obtaining the hash value is Hash(x), and the embodiment of the present application does not specifically limit the specific hash method. Figure 2 As shown, the process of the text classification method based on the LSCH graph attention neural network in the embodiment of the present application is as follows:

[0080] First, the node feature map, the input of the attention neural network in this application is the initial feature matrix X, X∈R N×C , N is the number of nodes, C is the input node feature dimension, the initial feature matrix includes the initial feature vectors of N nodes in the text graph, R N×C Represents a real number space with dimensions of N rows and C columns. The following formula can be used to embed the input, i.e., feature transformation or feature mapping:

[0081] H0=XW0;

[0082] Among them, the input data X is linearly transformed, W0∈R C×F Is the parameter matrix to be trained, the dimension of W0 is C rows and F columns, R C×F Represents a real number space with dimensions C rows and F columns, H0∈R N×F is the transformed node representation, that is, the feature vector after feature mapping, that is, the feature vector after feature mapping of N nodes, R N×F Represents a real number space with dimensions N rows and F columns;

[0083] Secondly, the self-attention mechanism based on locality sensitive hashing:

[0084] (1) Hash bucketing: Since two similar vectors are more likely to obtain the same hash value than two distant inputs, the LSH algorithm is used to divide the nodes with the closest feature vectors into the same hash bucket. The purpose of this step is to quickly obtain similar nodes.

[0085] (2) Sorting: After assigning each node to the corresponding hash bucket, sort it according to the hash bucket number. At the same time, within each hash bucket, sort the nodes in the bucket according to the structure score, so that nodes with the same or similar structures are placed together.

[0086] (3) Blocking: Since bucketing has a certain degree of randomness, it is possible that a large number of node vectors will be concentrated in one hash bucket. For example, in the extreme case, if there is only one bucket, the computational complexity is still O(V 2 ). Therefore, node block processing is required to obtain K node blocks.

[0087] (4) Attention score calculation: After block division, attention score calculation (i.e. weight calculation) is performed in the local block, and only the similarity between each node and the node of the current block or the previous block is calculated, such as Figure 3 As shown. The two nodes must belong to the same hash bucket, and at the same time, the two nodes must be adjacent nodes in the text graph (that is, they have an adjacency relationship in the text graph, that is, they have an edge). Then, the attention score calculation process between node i and node j can be expressed as:

[0088] e ij =q i ·q j ,j∈P(i)∩N(i);

[0089] Where, e ij represents the degree of association between node i and node j (also called attention score or similarity), q i is the feature vector of node i, q j is the feature vector of node j. The more similar the node features are, the better the ij The larger the value, the greater the weight α between node i and node j. ij It is e ijNormalized form. N(i) represents the set of neighbor nodes of node i, and the link information between its nodes comes from the adjacency matrix A. P(i) represents the set of nodes belonging to the same hash bucket in the target node block corresponding to node i. For example, the target node block corresponding to node i may include the previous block of the node block where node i is located and the node block where node i is located. Here, the "previous block" is determined by the retrieval order, and the retrieval direction includes both positive and negative directions. The previous block of the node block where node i is located may be a block adjacent to the node block where node i is located along the retrieval direction. Node j must belong to both N(i) and P(i). P(i)∩N(i) represents the intersection of P(i) and N(i), which can be represented by Q(i), which is the target neighbor node set of node i. After obtaining the attention score between the two nodes, a normalization function (for example, Softmax) is used for normalization to obtain a normalized attention score (i.e., weight), for example, as shown below:

[0090]

[0091] Among them, α ij represents the normalized weight between the i-th node and the j-th node, e ik represents the degree of association between node i and node k, e ij It represents the degree of association between node i and node j, and exp is an exponential function with the natural constant e as the base.

[0092] This embodiment of the application finds the most similar nodes for each node, only calculates the dot product with them, and then takes the softmax to obtain the attention score. Because the LSH method is fast enough to find similar nodes, the number of similar nodes found is less than N, and only the feature vector similarity between adjacent nodes is calculated, this embodiment of the application can effectively control the computational complexity of the attention score to below O(Vlog(N)).

[0093] Then, the graph convolution is calculated to obtain the target feature vector of the node:

[0094] Get the node attention score α ij After that, graph convolution is performed, that is, feature aggregation is performed on neighboring nodes and the representation of the central node is updated:

[0095]

[0096] Among them, N(i) represents the set of neighbor nodes of node i, It is the feature vector of node j input to the l-th graph convolution layer in the L-layer graph convolution layer. It can also be understood as the l-1-th layer feature vector of node j output by the l-1-th graph convolution layer in the L-layer graph convolution layer. is the l-th layer feature vector of node i outputted by the l-th layer graph convolutional layer, which can also be understood as the feature vector of node i inputted to the l+1-th layer graph convolutional layer. is the l-1th layer feature vector of node i output by the l-1th layer graph convolutional layer, is the l-1th layer weight between node i and node j, β is the weighting coefficient, which can be set in advance according to actual needs and is any number between 0-1, for example, it can be 0.5, etc. σ is the activation function, and the ReLU function can be used. In the above formula, the node features of all neighbor nodes of node i are weighted summed. It should be noted that the embodiment of the present application considers the similarity between the node and the nodes in the target neighbor node set of the node, and does not consider the similarity between the node and other nodes in the neighbor node set of the node except the target neighbor node set of the node, that is, the weights between the node and other nodes in the neighbor node set of the node except the target neighbor node set of the node can be set to zero, then the features of all neighbor nodes of node i (that is, the nodes in the neighbor node set N(i)) in the above formula are weighted summed. It can be understood that the features of the nodes in the target neighbor node set of node i are weighted summed, that is, the l-th layer feature vector of node i can be calculated by the following formula:

[0097]

[0098] The L-th layer feature vector of node i output by the L-th layer of the graph convolution layer in the L-layer graph convolution layer can be used as the target feature vector of node i. In this way, the target feature vector of each node in the N nodes can be obtained.

[0099] Furthermore, node property prediction:

[0100] Subsequently, the properties of the node to be classified can be predicted based on the target feature vector of the node to be classified, for example, the category of the node can be predicted.

[0101] The embodiment of the present application mainly uses the idea of ​​local sensitive hashing (LSH) to optimize the calculation of attention scores in GAT (Graph Attention Networks), quickly realizes the search of nodes with similar representations, and only calculates attention scores between these similar nodes, reducing the computational complexity of solving the attention score from O(N 2 ) is reduced to O(Vlog(N)), which reduces the calculation time and memory usage of the attention score.

[0102] The method of this embodiment is applied to a text classification scenario as an example for explanation. Figure 4 As shown, the method of this embodiment includes:

[0103] Step 401: Constructing a text graph: Collect texts and create a topological graph of the collected N texts, i.e., obtaining a text graph. The text graph includes N nodes. The nodes in the text graph represent texts, and the edges represent the reference relationships between texts.

[0104] Step 402: Obtaining an initial feature vector for each text in the text graph: For example, for a certain text, feature vectors of characters or words in the text may be extracted, and the initial feature vector of the text may be a combination of feature vectors of characters or words in the text;

[0105] Step 403: Based on the initial feature vectors of the N texts, perform hash bucketing on the N texts to obtain M hash buckets;

[0106] Step 404: Determine the target neighbor text set for each of the N texts based on the M hash buckets and the N neighbor text sets:

[0107] Step 405: Determine a target feature vector for each of the N texts based on the initial feature vectors of the N texts and the initial feature vectors of the texts in the target neighbor text set of the N texts;

[0108] Step 406: performing text classification on the text to be classified according to the target feature vector of the text to be classified, and determining the text category of the text to be classified.

[0109] The text graph is processed using the solution of the embodiment of the present application, the target feature vector of the text in the text graph is extracted, the properties of the text to be classified are predicted, and the classification of the text to be classified is achieved.

[0110] like Figure 5 As shown, D1, D2 and D3 represent three texts respectively. D2 and D3 are from the training set. Both D2 and D3 have corresponding title categories, such as Figure 5The figure shows examples of keywords contained in a text, with the text categories in parentheses. Keywords in text D2 can include triples, entity recognition, entity extraction, and relationship extraction. The title category of text D2 is knowledge graph. Keywords in text D3 can include activation functions, fully connected networks, CNNs, and multilayer networks. The title category of text D3 is neural networks. D1 is from the test set. Keywords in text D1 can include entity recognition, CNNs, multilayer networks, and activation functions. CNNs, or convolutional neural networks, are convolutional neural networks. D1 is a text in the untitled category. Let D1 be the central node (i.e., the central text node) with an unknown category. D1's neighbor nodes are D2 and D3. The feature extraction process aggregates the features of D2 and D3 onto D1 to better represent D1. D1 and D3 share more common words, such as "CNN," "multilayer network," and "activation function," indicating a high degree of similarity in their node features. Therefore, D3 can be given a higher weight than D2, indicating that D1 is more relevant to D2. After feature aggregation, D1 has features closer to D3 and is more likely to be assigned the label of D3 during training.

[0111] There is a certain connection between the target (center) text node and its adjacent text nodes. The embodiment of the present application performs weighted aggregation on the feature vectors of the neighboring text nodes based on the similarity between the target text node and the neighboring text nodes, and prioritizes the aggregation of text node features with high similarity to achieve more accurate feature extraction and improve the accuracy of the target feature vector of the text. The target feature vector of the text is subsequently used to predict the nature of the text to obtain the text category.

[0112] The embodiment of the present application proposes a graph neural network based on local sensitive hashing, which uses the idea of ​​local sensitive hashing (LSH) to optimize the attention score calculation process. The LSH method is used to quickly find all nodes with similar node features. The model only calculates the attention scores of two nodes with similar features, similar structures, and neighbors, thereby achieving the sparsification of the attention score matrix. The attention score calculation is no longer performed between nodes with dissimilar node feature vectors, thereby reducing its computational complexity. The computational complexity of solving the attention score can be reduced from O(N^2) to below O(Nlog(N)).

[0113] See also Figure 6 , Figure 6 This is a structural diagram of the text classification device provided in the embodiment of the present application, which can implement the details of the text classification method in the above embodiment and achieve the same effect. Figure 6 As shown, the text classification method and apparatus 600 includes:

[0114] A first acquisition module 601 is configured to acquire an initial feature vector for each node in a text graph, wherein the text graph includes N nodes, wherein one node represents one text, and the N nodes include at least one unclassified node to be classified, where N is an integer greater than 1.

[0115] Bucketing module 602, configured to perform hash bucketing on N nodes based on the initial feature vectors of the N nodes to obtain M hash buckets, where M is an integer greater than 1;

[0116] A first determining module 603 is configured to determine a target neighbor node set for each of the N nodes based on the M hash buckets and the N neighbor node sets, wherein the N neighbor node sets include a neighbor node set of each of the N nodes in the text graph, the target neighbor node set of the node belongs to the neighbor node set of the node, and the nodes in the target neighbor node set of the node and the node belong to the same hash bucket;

[0117] A second determining module 604 is configured to determine a target feature vector for each node in at least one node to be classified based on the initial feature vectors of the N nodes and the initial feature vectors of the nodes in the target neighbor node set of the N nodes;

[0118] The third determination module 605 is configured to perform text classification on at least one node to be classified according to a target feature vector of the at least one node to be classified, and determine a text category of the at least one node to be classified.

[0119] In one embodiment, the apparatus 600 further includes:

[0120] A first sorting module is used to sort the M hash buckets according to their numbers;

[0121] The second sorting module sorts the nodes in each of the sorted M hash buckets according to the structural scores of the nodes in the hash bucket to update the order of the nodes in the sorted M hash buckets. The structural scores are used to represent the importance of the nodes in the text graph.

[0122] In one embodiment, the first determining module 603 includes:

[0123] A partitioning module is used to partition the N nodes according to the order of the nodes in the updated M hash buckets to obtain K node blocks, where any node block includes at least one node, and K is an integer greater than 1;

[0124] A neighbor node determination module is used to determine, for each of N nodes, a target neighbor node set of the node based on the nodes that meet the target conditions in the target node block corresponding to the node, where the target node block corresponding to the node includes blocks adjacent to the node block where the node is located in the K node blocks and / or the node block where the node is located, and the target conditions include a set of neighbor nodes that belong to the same hash bucket as the node and belong to the node.

[0125] In one embodiment, the apparatus 600 further includes:

[0126] The second acquisition module is used to obtain the adjacency matrix of the text graph;

[0127] A score vector acquisition module is used to multiply the adjacency matrix with a preset column vector to obtain a structural score vector;

[0128] The structure score vector includes the structure score of each of the N nodes, the number of rows of the preset column vector is the same as the number of columns of the adjacency matrix, and the elements in the preset column vector are all preset values.

[0129] In one embodiment, the second determining module 604 includes:

[0130] a weight calculation module, configured to calculate, for each node in at least one to-be-classified node, an initial weight between the node and the nodes in the target neighbor node set based on the initial feature vector of the node and the initial feature vectors of the nodes in the target neighbor node set of the node, thereby obtaining an initial weight set of the nodes, wherein the initial weight is used to represent the similarity of the initial feature vectors between the nodes;

[0131] The target feature vector determination module is used to determine the target feature vector of the node according to the initial feature vector of the node, the initial weight set of the node and the initial feature vectors of the nodes in the target neighbor node set of the node.

[0132] In one embodiment, determining a target feature vector of a node according to an initial feature vector of the node, an initial weight set of the node, and initial feature vectors of nodes in a target neighbor node set of the node includes: determining a first feature vector of each of N nodes through an L-layer graph convolution layer according to the initial feature vector of the node, the initial weight set of the node, and the initial feature vectors of nodes in the target neighbor node set of the node, where L is an integer greater than 1;

[0133] Among them, the first graph convolution layer in the L-layer graph convolution layer performs feature extraction based on the initial feature vector of the node, the initial weight set of the node, and the initial feature vector of the node in the target neighbor node set of the node, and outputs the first-layer feature vector of the node. The r-th graph convolution layer in the L-layer graph convolution layer performs feature extraction based on the r-1-th layer feature vector of the node, the r-1-th layer weight set of the node, and the r-1-th layer feature vector of the node in the target neighbor node set of the node, and outputs the r-th layer feature vector of the node, where r is an integer and 2≤r≤L. The target feature vector of the node is the L-th layer feature vector output by the L-layer graph convolution layer, wherein the r-1-th layer weight set of the node includes the r-1-th layer weight between the node and each node in the target neighbor node set corresponding to the node, and the r-1-th layer weight is used to represent the similarity of the r-1-th layer feature vectors between nodes.

[0134] In one embodiment, the apparatus 600 further includes:

[0135] The mapping module is used to perform feature mapping on the initial feature vector of each node in the N nodes to update the initial feature vector of each node in the N nodes.

[0136] Figure 7 A schematic diagram of the hardware structure of an electronic device for implementing various embodiments of the present application.

[0137] The electronic device 700 includes but is not limited to: a radio frequency unit 701, a network module 702, an audio output unit 703, an input unit 704, a sensor 705, a display unit 706, a user input unit 707, an interface unit 708, a memory 709, a processor 710, and a power supply 711. It will be understood by those skilled in the art that Figure 7 The electronic device structure shown in the figure does not constitute a limitation on the electronic device. The electronic device may include more or fewer components than shown, or combine certain components, or arrange the components differently. In the embodiments of this application, the electronic device includes but is not limited to mobile phones, tablet computers, laptop computers, PDAs, vehicle-mounted terminals, servers, wearable devices, and pedometers.

[0138] The processor 710 is configured to:

[0139] Obtaining an initial feature vector for each node in a text graph, where the text graph includes N nodes, wherein one node is used to represent one text, and the N nodes include at least one unclassified node to be classified, where N is an integer greater than 1;

[0140] Based on the initial feature vectors of N nodes, hash bucket the N nodes to obtain M hash buckets, where M is an integer greater than 1;

[0141] Determine a target neighbor node set for each of the N nodes based on the M hash buckets and the N neighbor node sets, wherein the N neighbor node sets include the neighbor node set of each of the N nodes in the text graph, the target neighbor node set of the node belongs to the neighbor node set of the node, and the nodes in the target neighbor node set of the node and the node belong to the same hash bucket;

[0142] Determine a target feature vector for each node in at least one node to be classified based on the initial feature vectors of the N nodes and the initial feature vectors of the nodes in the target neighbor node set of the N nodes;

[0143] Text classification is performed on at least one node to be classified according to a target feature vector of at least one node to be classified, and a text category of the at least one node to be classified is determined.

[0144] In one embodiment, the processor 710 is further configured to:

[0145] Sort the M hash buckets according to their numbers;

[0146] For each of the sorted M hash buckets, the nodes in the hash bucket are sorted according to the structural scores of the nodes in the hash bucket to update the order of the nodes in the sorted M hash buckets. The structural scores are used to represent the importance of the nodes in the text graph.

[0147] In one embodiment, the processor 710 is specifically configured to:

[0148] Divide the N nodes into K node blocks according to the order of the nodes in the updated M hash buckets. Each node block includes at least one node, and K is an integer greater than 1.

[0149] For each of the N nodes, the target neighbor node set of the node is determined based on the nodes that meet the target conditions in the target node block corresponding to the node. The target node block corresponding to the node includes blocks adjacent to the node block where the node is located in the K node blocks and / or the node block where the node is located. The target conditions include the set of neighbor nodes that belong to the same hash bucket as the node and belong to the node.

[0150] In one embodiment, the processor 710 is further configured to:

[0151] Get the adjacency matrix of the text graph;

[0152] Multiply the adjacency matrix with the preset column vector to obtain the structure score vector;

[0153] The structure score vector includes the structure score of each of the N nodes, the number of rows of the preset column vector is the same as the number of columns of the adjacency matrix, and the elements in the preset column vector are all preset values.

[0154] In one embodiment, the processor 710 is specifically configured to:

[0155] For each node in at least one node to be classified, calculating an initial weight between the node and the nodes in the target neighbor node set according to the initial feature vector of the node and the initial feature vectors of the nodes in the target neighbor node set of the node, to obtain an initial weight set of the node, wherein the initial weight is used to represent the similarity of the initial feature vectors between the nodes;

[0156] The target feature vector of the node is determined according to the initial feature vector of the node, the initial weight set of the node, and the initial feature vectors of the nodes in the target neighbor node set of the node.

[0157] In one embodiment, determining a target feature vector of the node according to an initial feature vector of the node, an initial weight set of the node, and initial feature vectors of nodes in a target neighbor node set of the node includes: determining the target feature vector of the node through L graph convolution layers according to the initial feature vector of the node, the initial weight set of the node, and the initial feature vectors of nodes in the target neighbor node set of the node, where L is an integer greater than 1;

[0158] Among them, the first graph convolution layer in the L-layer graph convolution layer performs feature extraction based on the initial feature vector of the node, the initial weight set of the node, and the initial feature vector of the node in the target neighbor node set of the node, and outputs the first-layer feature vector of the node. The r-th graph convolution layer in the L-layer graph convolution layer performs feature extraction based on the r-1-th layer feature vector of the node, the r-1-th layer weight set of the node, and the r-1-th layer feature vector of the node in the target neighbor node set of the node, and outputs the r-th layer feature vector of the node, where r is an integer and 2≤r≤L. The target feature vector of the node is the L-th layer feature vector output by the L-layer graph convolution layer, wherein the r-1-th layer weight set of the node includes the r-1-th layer weight between the node and each node in the target neighbor node set corresponding to the node, and the r-1-th layer weight is used to represent the similarity of the r-1-th layer feature vectors between nodes.

[0159] In one embodiment, the processor 710 is further configured to:

[0160] Feature mapping is performed on the initial feature vector of each of the N nodes to update the initial feature vector of each of the N nodes.

[0161] The embodiment of the present application also has the same beneficial technical effects as the above-mentioned text classification method embodiment, and the details will not be repeated here.

[0162] It should be understood that in the embodiments of the present application, the RF unit 701 may be used to receive and transmit signals during information transmission or calls. Specifically, it receives downlink data from the base station and transmits it to the processor 710 for processing; in addition, it transmits uplink data to the base station. Typically, the RF unit 701 includes, but is not limited to, an antenna, at least one amplifier, a transceiver, a coupler, a low-noise amplifier, a duplexer, and the like. Furthermore, the RF unit 701 may communicate with the network and other devices via a wireless communication system.

[0163] The electronic device provides users with wireless broadband Internet access through the network module 702, such as helping users to send and receive emails, browse web pages, and access streaming media.

[0164] The audio output unit 703 can convert audio data received by the RF unit 701 or the network module 702 or stored in the memory 709 into an audio signal and output it as sound. In addition, the audio output unit 703 can also provide audio output related to a specific function performed by the electronic device 700 (for example, a call signal reception sound, a message reception sound, etc.). The audio output unit 703 includes a speaker, a buzzer, a receiver, etc.

[0165] The input unit 704 is used to receive audio or video signals. The input unit 704 may include a graphics processing unit (GPU) 7041 and a microphone 7042. The graphics processor 7041 processes image data of a still picture or video obtained by an image capture device (such as a camera) in a video capture mode or an image capture mode. The processed image frames can be displayed on the display unit 706. The image frames processed by the graphics processor 7041 can be stored in the memory 709 (or other storage medium) or transmitted via the radio frequency unit 701 or the network module 702. The microphone 7042 can receive sound and can process such sound into audio data. The processed audio data can be converted into a format that can be sent to a mobile communication base station via the radio frequency unit 701 in the case of a telephone call mode.

[0166] The electronic device 700 also includes at least one sensor 705, such as a light sensor, a motion sensor, and other sensors. Specifically, the light sensor includes an ambient light sensor and a proximity sensor, wherein the ambient light sensor can adjust the brightness of the display panel 7061 according to the brightness of the ambient light, and the proximity sensor can turn off the display panel 7061 and / or the backlight when the electronic device 700 is moved to the ear. As a type of motion sensor, the accelerometer sensor can detect the magnitude of acceleration in all directions (generally three axes), and can detect the magnitude and direction of gravity when stationary. It can be used to identify the posture of the electronic device (such as horizontal and vertical screen switching, related games, magnetometer posture calibration), vibration recognition related functions (such as pedometer, tapping), etc.; the sensor 705 can also include a fingerprint sensor, a pressure sensor, an iris sensor, a molecular sensor, a gyroscope, a barometer, a hygrometer, a thermometer, an infrared sensor, etc., which will not be repeated here.

[0167] The display unit 706 is used to display information input by the user or information provided to the user. The display unit 706 may include a display panel 7071, which may be configured in the form of a liquid crystal display (LCD), an organic light-emitting diode (OLED), or the like.

[0168] The user input unit 707 can be used to receive input digital or character information, and to generate key signal input related to the user settings and function control of the electronic device. Specifically, the user input unit 707 includes a touch panel 7071 and other input devices 7072. The touch panel 7071, also known as a touch screen, can collect user touch operations on or near it (such as operations performed by the user using any suitable object or accessory such as a finger, stylus, etc. on or near the touch panel 7071). The touch panel 7071 may include two parts: a touch detection device and a touch controller. Among them, the touch detection device detects the user's touch direction and detects the signal caused by the touch operation, and transmits the signal to the touch controller; the touch controller receives the touch information from the touch detection device and converts it into touch point coordinates, which are then sent to the processor 710, which receives and executes the command sent by the processor 710. In addition, the touch panel 7071 can be implemented using various types such as resistive, capacitive, infrared, and surface acoustic wave. In addition to the touch panel 7071, the user input unit 707 may also include other input devices 7072. Specifically, other input devices 7072 may include but are not limited to a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, and a joystick, which will not be repeated here.

[0169] Furthermore, the touch panel 7071 may be overlaid on the display panel 7061. When the touch panel 7071 detects a touch operation on or near it, it transmits the information to the processor 710 to determine the type of touch event. Subsequently, the processor 710 provides corresponding visual output on the display panel 7061 according to the type of touch event. Figure 7 In the figure, the touch panel 7071 and the display panel 7061 are two independent components to realize the input and output functions of the electronic device. However, in some embodiments, the touch panel 7071 and the display panel 7061 can be integrated to realize the input and output functions of the electronic device, which is not limited here.

[0170] The interface unit 708 is an interface for connecting external devices to the electronic device 700. For example, the external devices may include a wired or wireless headset port, an external power supply (or battery charger) port, a wired or wireless data port, a memory card port, a port for connecting a device with an identification module, an audio input / output (I / O) port, a video I / O port, a headphone port, etc. The interface unit 708 may be used to receive input (e.g., data information, power, etc.) from the external device and transmit the received input to one or more elements within the electronic device 700, or may be used to transmit data between the electronic device 700 and the external device.

[0171] Memory 709 can be used to store software programs and various data. Memory 709 may primarily include a program storage area and a data storage area. The program storage area may store an operating system and at least one application required for a function (such as a sound playback function or an image playback function); the data storage area may store data generated based on the use of the mobile phone (such as audio data, a phone book, etc.). Furthermore, memory 709 may include high-speed random access memory and non-volatile memory, such as at least one disk storage device, flash memory device, or other volatile solid-state storage device.

[0172] The processor 710 is the control center of the electronic device. It connects the various components of the electronic device using various interfaces and circuits. By running or executing software programs and / or modules stored in the memory 709 and accessing data stored in the memory 709, it performs various functions of the electronic device and processes data, thereby monitoring the electronic device as a whole. The processor 710 may include one or more processing units; preferably, the processor 710 may integrate an application processor and a modem processor, wherein the application processor primarily processes the operating system, user interface, and application programs, while the modem processor primarily handles wireless communications. It is understood that the modem processor may not be integrated into the processor 710.

[0173] The electronic device 700 may also include a power supply 711 (such as a battery) to supply power to each component. Preferably, the power supply 711 may be logically connected to the processor 710 through a power management system, thereby managing functions such as charging, discharging, and power consumption through the power management system.

[0174] In addition, the electronic device 700 includes some functional modules not shown, which will not be described here.

[0175] Preferably, an embodiment of the present application also provides an electronic device, including a processor 710, a memory 709, and a computer program stored in the memory 709 and executable on the processor 710. When the computer program is executed by the processor 710, the various processes of the above-mentioned text classification method embodiment or the various processes of the above-mentioned network training method embodiment are implemented, and the same technical effect can be achieved. To avoid repetition, it will not be described here.

[0176] The present application also provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the computer program implements the various processes of the above-mentioned text classification method embodiment or the various processes of the above-mentioned network training method embodiment, and can achieve the same technical effect. To avoid repetition, it is not described here. The computer-readable storage medium is, for example, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.

[0177] It should be noted that, in this document, the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, article, or apparatus comprising a series of elements includes not only those elements but also other elements not explicitly listed, or elements inherent to such process, method, article, or apparatus. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article, or apparatus comprising the element.

[0178] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus the necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for enabling a terminal (which can be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in each embodiment of the present application.

[0179] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of this application, ordinary technicians in this field can also make many forms without departing from the purpose of this application and the scope of protection of the claims, all of which are within the protection of this application.

Claims

1. A text classification method, characterized in that: The method comprises: Obtaining an initial feature vector for each node in a text graph, wherein the text graph includes N nodes, wherein one node is used to represent one text, and the N nodes include at least one unclassified node to be classified, where N is an integer greater than 1; Based on the initial feature vectors of the N nodes, hash bucketing is performed on the N nodes to obtain M hash buckets, where M is an integer greater than 1; Determining a target neighbor node set for each of the N nodes according to the M hash buckets and N neighbor node sets, wherein the N neighbor node sets include a neighbor node set of each of the N nodes in the text graph, the target neighbor node set of the node belongs to the neighbor node set of the node, and the nodes in the target neighbor node set of the node belong to the same hash bucket as the node; Determining a target feature vector for each node in the at least one node to be classified based on the initial feature vectors of the N nodes and the initial feature vectors of nodes in the target neighbor node set of the N nodes; Perform text classification on the at least one node to be classified according to the target feature vector of the at least one node to be classified, and determine the text category of the at least one node to be classified.

2. The method according to claim 1, characterized in that Before determining the target neighbor node set of each of the N nodes according to the M hash buckets and the N neighbor node sets, the method further includes: Sort the M hash buckets according to their numbers; For each of the sorted M hash buckets, the nodes in the hash bucket are sorted according to the structural scores of the nodes in the hash bucket to update the order of the nodes in the sorted M hash buckets, where the structural scores are used to represent the importance of the nodes in the text graph.

3. The method according to claim 2, characterized in that Determining a target neighbor node set for each of the N nodes based on the M hash buckets and the N neighbor node sets includes: Divide the N nodes according to the order of the nodes in the updated M hash buckets to obtain K node blocks, where any node block includes at least one node, and K is an integer greater than 1; For each of the N nodes, a target neighbor node set of the node is determined based on the nodes that meet the target condition in the target node block corresponding to the node, the target node block corresponding to the node includes blocks in the K node blocks adjacent to the node block where the node is located and / or the node block where the node is located, and the target condition includes a set of neighbor nodes that belong to the same hash bucket as the node and belong to the node.

4. The method according to claim 2, characterized in that Before sorting the nodes in each of the sorted M hash buckets according to the structural scores of the nodes in the hash bucket to update the order of the nodes in the sorted M hash buckets, the method further includes: Obtaining an adjacency matrix of the text graph; Multiplying the adjacency matrix by a preset column vector to obtain a structure score vector; The structure score vector includes the structure score of each of the N nodes, the number of rows of the preset column vector is the same as the number of columns of the adjacency matrix, and the elements in the preset column vector are all preset values.

5. The method according to claim 1, wherein The determining, based on the initial feature vectors of the N nodes and the initial feature vectors of nodes in the target neighbor node set of the N nodes, a target feature vector of each node in the at least one node to be classified includes: For each node in the at least one node to be classified, calculating an initial weight between the node and the nodes in the target neighbor node set of the node based on the initial feature vector of the node and the initial feature vectors of the nodes in the target neighbor node set of the node, to obtain an initial weight set of the node, wherein the initial weight is used to represent the similarity of the initial feature vectors between the nodes; A target feature vector of the node is determined according to the initial feature vector of the node, the initial weight set of the node, and the initial feature vectors of nodes in the target neighbor node set of the node.

6. The method according to claim 5, characterized in that Determining the target feature vector of the node according to the initial feature vector of the node, the initial weight set of the node, and the initial feature vectors of nodes in the target neighbor node set of the node includes: determining the target feature vector of the node through L-layer graph convolution layers according to the initial feature vector of the node, the initial weight set of the node, and the initial feature vectors of nodes in the target neighbor node set of the node, where L is an integer greater than 1; Among them, the first graph convolution layer in the L-layer graph convolution layer performs feature extraction based on the initial feature vector of the node, the initial weight set of the node, and the initial feature vector of the nodes in the target neighbor node set of the node, and outputs the first-layer feature vector of the node. The r-th graph convolution layer in the L-layer graph convolution layer performs feature extraction based on the r-1-th layer feature vector of the node, the r-1-th layer weight set of the node, and the r-1-th layer feature vector of the nodes in the target neighbor node set of the node, and outputs the r-th layer feature vector of the node, where r is an integer and 2≤r≤L. The target feature vector of the node is the L-th layer feature vector output by the L-layer graph convolution layer, wherein the r-1-th layer weight set of the node includes the r-1-th layer weight between the node and each node in the target neighbor node set corresponding to the node, and the r-1-th layer weight is used to represent the similarity of the r-1-th layer feature vectors between nodes.

7. The method according to claim 1, characterized in that Before performing hash bucketing on the N nodes based on the initial feature vectors of the N nodes, the method further includes: Feature mapping is performed on the initial feature vector of each of the N nodes to update the initial feature vector of each of the N nodes.

8. A text classification device, characterized in that: The device comprises: A first acquisition module is configured to acquire an initial feature vector of each node in a text graph, wherein the text graph includes N nodes, wherein one node is used to represent one text, and the N nodes include at least one unclassified node to be classified, where N is an integer greater than 1; A bucketing module, configured to perform hash bucketing on the N nodes based on the initial feature vectors of the N nodes to obtain M hash buckets, where M is an integer greater than 1; a first determining module, configured to determine a target neighbor node set of each of the N nodes based on the M hash buckets and N neighbor node sets, wherein the N neighbor node sets include a neighbor node set of each of the N nodes in the text graph, the target neighbor node set of the node belongs to the neighbor node set of the node, and the nodes in the target neighbor node set of the node belong to the same hash bucket as the node; A second determining module is configured to determine a target feature vector for each node in the at least one node to be classified based on the initial feature vectors of the N nodes and the initial feature vectors of nodes in the target neighbor node set of the N nodes; The classification module is configured to perform text classification on the at least one node to be classified according to the target feature vector of the at least one node to be classified, and determine the text category of the at least one node to be classified.

9. An electronic device, characterized in that: include: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the text classification method according to any one of claims 1 to 7 when executing the computer program.

10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps of the text classification method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Address similarity relation generation method and device thereof

    CN112699676A

  • Text duplicate removal method and device, electronic equipment and storage medium

    CN114282511A