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

By constructing semantic graphs and utilizing contextual information, the problem of not considering entity relationships in existing text classification is solved, thus improving the accuracy of text classification.

CN113761195BActive Publication Date: 2026-02-13TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202110567630.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-05-24
Publication Date
2026-02-13
Estimated Expiration
2041-10-14

AI Technical Summary

Technical Problem

Existing text classification methods fail to effectively consider the relationships between entities in the text, resulting in low classification accuracy.

Method used

By constructing a semantic graph, the relationships between entities and semantic concepts in the target text are obtained, and the classification information of the target text is determined by combining contextual information.

Benefits of technology

It improves the accuracy of text classification by comprehensively considering entity relationships and contextual information.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113761195B_ABST
    Figure CN113761195B_ABST
Patent Text Reader

Abstract

The application discloses a text classification method and device, computer equipment and a computer readable storage medium, and belongs to the technical field of artificial intelligence. The application fully obtains the relationship information of entities and concepts in the target text by representing the association relationship between the entities and the concepts corresponding to the target text by applying a semantic graph, determines first classification information based on the semantic graph, directly determines second classification information based on the context information of the target text, and determines the category to which the target text belongs in combination with the first classification information and the second classification information, that is, in the text classification process, the information of the relationship between the entities in the target text and the context of the target text is comprehensively considered, the category to which the target text belongs is determined based on more comprehensive text information, and therefore the accuracy of the text classification result is effectively improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of artificial intelligence technology, and in particular to a text classification method, apparatus, computer device, and computer-readable storage medium. Background Technology

[0002] Natural Language Processing (NLP) is an important field within computer science and artificial intelligence. Text classification, as a crucial component of NLP, is widely used in various scenarios such as question-answering matching and content detection.

[0003] Currently, text classification typically involves vectorizing the text using dictionaries or bag-of-words models, then extracting features and classifying the text based on this vectorized representation to determine its category. However, this text classification process does not consider the relationships between the entities within the text, resulting in low accuracy. Summary of the Invention

[0004] This application provides a text classification method, apparatus, computer device, and computer-readable storage medium, which can improve the accuracy of text classification results. The technical solution is as follows:

[0005] On the one hand, a text classification method is provided, which includes:

[0006] Obtain the semantic graph corresponding to the target text. The nodes in the semantic graph correspond to entities in the target text or semantic concepts corresponding to those entities. The edges in the semantic graph are used to indicate the relationship between any two nodes.

[0007] Based on this semantic map, the first classification information of the target text is determined;

[0008] Based on the contextual information of the target text, determine the second classification information of the target text;

[0009] Based on the first classification information and the second classification information, the classification information of the target text is obtained.

[0010] On the one hand, a text classification device is provided, the device comprising:

[0011] The acquisition module is used to acquire the semantic graph corresponding to the target text. The nodes in the semantic graph correspond to entities in the target text or semantic concepts corresponding to the entities. The edges in the semantic graph are used to indicate the relationship between any two nodes.

[0012] The first determining module is used to determine the first classification information of the target text based on the semantic graph;

[0013] The second determining module is used to determine the second classification information of the target text based on the context information of the target text;

[0014] The third determining module is used to obtain the classification information of the target text based on the first classification information and the second classification information.

[0015] In one possible implementation, the first determining module includes:

[0016] The feature extraction submodule is used to extract graph features of the semantic graph based on the node in the semantic graph and the relationship between any two nodes through at least one graph processing layer in the first text classification model.

[0017] The classification submodule is used to classify based on the graph features through the classification layer in the first text classification model to obtain the first classification information.

[0018] In one possible implementation, the feature extraction submodule is used for:

[0019] The at least one graph processing layer is an L-layer graph processing layer, where L is a positive integer greater than 1.

[0020] For the first graph processing layer in the first text classification model, the first graph processing layer performs soft clustering on the relationship between the node and any two nodes in the semantic graph to obtain an intermediate graph.

[0021] For the (l+1)th graph processing layer in the first text classification model, soft clustering is performed on the nodes in the target intermediate graph and the relationship between any two nodes through the (l+1)th graph processing layer to obtain a new intermediate graph. The target intermediate graph is the intermediate graph output by the lth graph processing layer, where l is a positive integer greater than or equal to 1 and less than L.

[0022] Based on the intermediate graph output by the last graph processing layer in the first text classification model, the graph features are determined.

[0023] In one possible implementation, the feature extraction submodule includes:

[0024] The feature update unit is used to update the first node features of each node and the first relation features of each association at least once through at least one sub-layer in the graph processing layer to obtain the second node features of each node and the second relation features of each association. The first node features are feature representations of the entity or semantic concept indicated by the node, and the first relation features are feature representations of the association.

[0025] The first clustering unit is used to perform soft clustering on each node based on the second node features of each node in the semantic graph to obtain at least one node in the intermediate graph.

[0026] The second clustering unit is used to perform clustering processing on each association based on the second relationship features of each association in the semantic graph, so as to obtain the association between at least one node in the intermediate graph.

[0027] In one possible implementation, the feature update unit includes:

[0028] The first subunit is used to determine the intermediate node features corresponding to any node in any sublayer of the graph processing layer based on the first node features of any node, the first node features of the connected nodes of any node, and the first relationship features of at least one candidate association relationship, wherein the candidate association relationship is the association relationship between any node and any connected node.

[0029] The second subunit is used to perform linear processing on the first relation feature of any association through any sub-layer to obtain the intermediate relation feature of any association.

[0030] The third sub-unit is used to input the intermediate node features of each node and the intermediate relationship features of each association as new first node features and first relationship features into the next sub-layer, so as to obtain the new intermediate node features and new intermediate relationship features output by the next sub-layer.

[0031] The fourth sub-unit is used to take the intermediate node features of each node and the intermediate relationship features of each association from the output of the last sub-layer in the graph processing layer as the second node feature and the second relationship feature, respectively.

[0032] In one possible implementation, the first subunit is used for:

[0033] The first node feature of any node is combined with the first relation feature of at least one candidate association relationship to obtain at least one first intermediate feature corresponding to any node;

[0034] The weighted sum of at least one first intermediate feature is used to obtain the second intermediate feature;

[0035] Based on the second intermediate feature and the first node feature corresponding to any node, the intermediate node feature corresponding to any node is determined.

[0036] In one possible implementation, the first subunit is used for:

[0037] The third intermediate feature is obtained by weighted summing of the second intermediate feature and the first node feature of any given node.

[0038] The third intermediate feature is linearly processed to obtain the intermediate node feature corresponding to any given node.

[0039] In one possible implementation, the device further includes:

[0040] The matrix determination module is used to determine the clustering assignment matrix corresponding to any graph processing layer based on the node features of the nodes in the graph input by the graph processing layer and the relationship features of the association between the nodes in the graph. The clustering assignment matrix is ​​used to perform soft clustering processing in this layer.

[0041] In one possible implementation, the first clustering unit is used for:

[0042] Multiply the second node feature of each node with the clustering assignment matrix corresponding to this layer to obtain the node feature matrix. One column of the node feature matrix represents the node feature of a node in the intermediate graph.

[0043] In one possible implementation, the second clustering unit is used for:

[0044] For any two nodes in the intermediate graph, determine the candidate elements corresponding to those two nodes from the elements included in the clustering assignment matrix corresponding to this layer;

[0045] Based on the candidate element, the first relation features of each association in the semantic graph are weighted and summed to obtain the relation features of the association between any two nodes in the intermediate graph.

[0046] On one hand, a computer device is provided, the computer device including one or more processors and one or more memories, the one or more memories storing at least one computer program, the at least one computer program being loaded and executed by the one or more processors to implement the operations performed by the text classification method.

[0047] On the one hand, a computer-readable storage medium is provided, which stores at least one computer program that is loaded and executed by a processor to implement the operations performed by the text classification method.

[0048] On one hand, a computer program product is provided, comprising at least one computer program stored in a computer-readable storage medium. A processor of a computer device reads the at least one computer program from the computer-readable storage medium and executes the at least one computer program, causing the computer device to perform the operations performed by the text classification method described above.

[0049] The technical solution provided in this application uses semantic graphs to represent the relationships between entities and concepts corresponding to the target text, thereby fully obtaining the relationship information between entities and concepts in the target text. Based on the semantic graph, a first classification information is determined, and then a second classification information is determined directly based on the context information of the target text. Combining the first and second classification information, the category to which the target text belongs is determined. That is, in the text classification process, the relationship between entities in the target text and the context information of the target text are integrated to determine the category to which the target text belongs based on more comprehensive text information, thereby effectively improving the accuracy of the text classification results. Attached Figure Description

[0050] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0051] Figure 1 This is a structural block diagram of a text classification system provided in an embodiment of this application;

[0052] Figure 2 This is a flowchart of a text classification method provided in an embodiment of this application;

[0053] Figure 3 This is a flowchart of a text classification method provided in an embodiment of this application;

[0054] Figure 4 This is a schematic diagram of a method for obtaining graph features of a semantic graph provided in an embodiment of this application;

[0055] Figure 5 This is a schematic diagram of a text classification process provided in an embodiment of this application;

[0056] Figure 6 This is a flowchart of a training method for a text classification model provided in an embodiment of this application;

[0057] Figure 7 This is a schematic diagram of the structure of a text classification device provided in an embodiment of this application;

[0058] Figure 8 This is a schematic diagram of the structure of a terminal provided in an embodiment of this application;

[0059] Figure 9 This is a schematic diagram of the structure of a server provided in an embodiment of this application. Detailed Implementation

[0060] To make the objectives, technical solutions, and advantages of this application clearer, the embodiments of this application will be described in further detail below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0061] In this application, the terms "first," "second," etc., are used to distinguish identical or similar items with essentially the same function. It should be understood that there is no logical or temporal dependency between "first," "second," and "nth," nor are there any restrictions on quantity or execution order.

[0062] The technical solutions provided in this application relate to Artificial Intelligence (AI) technology. AI utilizes digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, perceiving the environment, acquiring knowledge, and using that knowledge to obtain optimal results. In other words, AI is a comprehensive technology within computer science that attempts to understand the essence of intelligence and produce new intelligent machines that can react in a way similar to human intelligence. AI studies the design principles and implementation methods of various intelligent machines, enabling them to possess perception, reasoning, and decision-making capabilities. AI technology is a comprehensive discipline involving a wide range of fields, encompassing both hardware and software technologies. Fundamental AI technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing technology, operating / interactive systems, and mechatronics. AI software technologies mainly include computer vision, speech processing, natural language processing, and machine learning / deep learning. This application's embodiments relate to natural language processing technology within AI.

[0063] Natural Language Processing (NLP) is an important field within computer science and artificial intelligence. It studies the theories and methods for enabling effective communication between humans and computers using natural language. NLP is a science that integrates linguistics, computer science, and mathematics. Therefore, research in this field involves natural language, that is, the language people use in daily life, and thus it has a close relationship with linguistic research. NLP technologies typically include text processing, semantic understanding, machine translation, question answering, and knowledge graphs. In this embodiment, text content is classified based on NLP technology.

[0064] To facilitate understanding of the embodiments of this application, some terms involved in the embodiments of this application are explained below:

[0065] Soft clustering, also known as fuzzy clustering, refers to classifying data into different clusters with varying probabilities, allowing each data point to belong to multiple clusters simultaneously with different probabilities. In this embodiment, soft clustering of nodes means assigning a node to at least one cluster according to a certain probability.

[0066] Figure 1 This is a structural block diagram of a text classification system provided in an embodiment of this application. The text classification system 100 includes: a terminal 110 and a text classification platform 140.

[0067] The terminal 110 has a target application that supports text classification installed and running. Optionally, the terminal 110 can be a smartphone, tablet, laptop, desktop computer, smart speaker, smartwatch, etc., and this embodiment does not limit the device type of the terminal 110. For example, the terminal 110 is a terminal used by a user, and the application running on the terminal 110 has a user account logged in. The terminal 110 generally refers to one of multiple terminals, and this embodiment only uses the terminal 110 as an example.

[0068] In one possible implementation, the text classification platform 140 is at least one of a server, multiple servers, a cloud computing platform, and a virtualization center. The text classification platform 140 provides background services for the aforementioned target application. Optionally, the text classification platform 140 undertakes the primary text data processing work, and the terminal 110 undertakes the secondary text data processing work; or, the text classification platform 140 undertakes the secondary text data processing work, and the terminal 110 undertakes the primary text data processing work; or, the text classification platform 140 or the terminal 110 each undertakes text data processing work independently. Optionally, the server 140 includes: an access server, a text classification server, and a database. The access server provides access services to the terminal 110. The text classification server provides background services for the text classification function in the target application. Exemplarily, there is one or more text classification servers. When there are multiple text classification servers, at least two text classification servers provide different services, and / or at least two text classification servers provide the same service, such as providing the same service in a load-balanced manner; this embodiment of the application does not limit this. In this embodiment, a text classification model is configured in the text classification server. For example, the server may be an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms. This embodiment does not limit the number of servers or the type of equipment.

[0069] Figure 2 This is a flowchart of a text classification method provided in an embodiment of this application. The method is applied to the aforementioned terminal or text classification platform, and both the terminal and the server can be considered as a computer device. In this embodiment, a computer device is used as the execution subject to describe the text classification method. See [link to relevant documentation]. Figure 2 In one possible implementation, this embodiment includes the following steps:

[0070] 201. The computer device obtains the semantic graph corresponding to the target text. The nodes in the semantic graph correspond to entities in the target text or semantic concepts corresponding to the entities. The edges in the semantic graph are used to indicate the relationship between any two nodes.

[0071] In this context, an entity refers to a distinguishable and independently existing thing, such as a person, a role, an animal, or an event. Semantic concepts are used to interpret the meaning of an entity; one semantic concept corresponds to at least one entity. For example, the semantic concepts corresponding to the entity "Xiaomi" include "food" and "company." The semantic graph includes multiple nodes and multiple edges. In this embodiment, the semantic graph can indicate the relationships between various entities in the target text. These relationships include at least one of syntactic and semantic relationships. It should be noted that the semantic graph can be represented as a graph structure or a tree structure; this embodiment does not limit its representation.

[0072] 202. Based on the semantic graph, the computer device determines the first classification information of the target text.

[0073] In one possible implementation, the computer device further extracts features from the semantic graph using a text classification model to obtain the first classification information. For example, the text classification model is built on a convolutional neural network, and the computer device maps the semantic graph to the first classification information through at least one computational layer in the classification model. Optionally, the first classification information is represented as a vector, where one element indicates the probability that the target text belongs to a category.

[0074] 203. The computer device determines the second classification information of the target text based on the context information of the target text.

[0075] Contextual information refers to the association information between an object in the text and the objects preceding and following it; that is, the association information between an object and its surrounding text. The object is a character or phrase in the text. Contextual information of the target text refers to the association information between each object in the target text and its surrounding text. In one possible implementation, the computer device directly extracts features from the target text using a convolutional neural network to obtain text features. These text features contain the contextual information of the target text. Based on these text features, the convolutional neural network outputs a second classification information for the target text.

[0076] It should be noted that in the embodiments of this application, the steps of obtaining the first classification information are performed first, followed by the steps of obtaining the second classification information. In some embodiments, the steps of obtaining the second classification information may be performed first, followed by the steps of obtaining the first classification information, or the two steps may be performed simultaneously. The embodiments of this application do not limit this.

[0077] 204. The computer device obtains the classification information of the target text based on the first classification information and the second classification information.

[0078] In one possible implementation, the computer device performs a weighted summation of the first classification information and the second classification information to obtain the classification information of the target text. That is, in this embodiment of the application, the classification information of the target text is obtained based on data from both semantic graph and contextual information, and then the category to which the target text belongs is determined by combining the data.

[0079] The technical solution provided in this application uses semantic graphs to represent the relationships between entities and concepts corresponding to the target text, thereby fully obtaining the relationship information between entities and concepts in the target text. Based on the semantic graph, a first classification information is determined, and then a second classification information is determined directly based on the context information of the target text. Combining the first and second classification information, the category to which the target text belongs is determined. That is, in the text classification process, the relationship between entities in the target text and the context information of the target text are integrated to determine the category to which the target text belongs based on more comprehensive text information, thereby effectively improving the accuracy of the text classification results.

[0080] The above embodiments are a brief introduction to one of the implementation methods of this application. Figure 3 This is a flowchart of a text classification method provided in an embodiment of this application. The following is in conjunction with... Figure 3 The text classification method is described below. In one possible implementation, this embodiment includes the following steps:

[0081] 301. Computer equipment acquires the target text to be classified.

[0082] In one possible implementation, the computer device, in response to a text classification instruction, acquires the target text to be classified. For example, the target text may be a piece of text stored in the computer device, text entered by the user in real time, or text obtained from any type of application or webpage; this application embodiment does not limit this.

[0083] In one possible implementation, the computer device preprocesses the acquired target text and performs subsequent text classification steps based on the preprocessed target text. For example, the target text acquired by the computer device includes a title and body text, and the preprocessing of the target text by the computer device involves concatenating the title and body text. For example, the preprocessing process also includes removing HTML (HyperText Markup Language) tags, English letters, special characters, etc., from the target text. The method for preprocessing the target text in this application embodiment is not limited.

[0084] 302. The computer device obtains a semantic graph corresponding to the target text, where the nodes in the semantic graph correspond to the entities in the target text or the concepts corresponding to the entities, and the edges in the semantic graph are used to indicate the association relationship between any two nodes.

[0085] In a possible implementation manner, the process by which the computer device obtains the semantic graph includes the following steps:

[0086] Step 1. The computer device obtains the entities in the target text and the semantic concepts corresponding to each entity.

[0087] In a possible implementation manner, the computer device determines at least one entity included in the target text based on an entity linking algorithm, and then obtains at least one semantic concept corresponding to the at least one entity from a concept knowledge base.

[0088] Exemplarily, first, the computer device performs word segmentation on the target text to obtain at least one phrase included in the target text. Then, the computer device obtains the entity corresponding to each phrase from an entity knowledge base, where the entity knowledge base is used to store the corresponding relationship between the phrase and the entity. Exemplarily, an entity is a standardized expression of a thing, and some phrases in the target text are non-standardized expressions of things, such as nicknames and aliases. Exemplarily, the target text includes the phrase "Mountain City", and the entity corresponding to this phrase is "Chongqing". In the embodiments of the present application, determining the entity corresponding to the phrase based on the entity knowledge base facilitates the subsequent construction of the semantic graph. Finally, the computer device retrieves at least one semantic concept corresponding to each entity from the concept knowledge base based on the obtained entities, where the concept knowledge base is used to store the corresponding relationship between the entity and the concept. For example, the concept knowledge base is MCG (Microsoft ConceptGraph).

[0089] In one possible implementation, when acquiring the semantic concepts corresponding to an entity, the computer device filters the semantic concepts corresponding to the entity to acquire the semantic concepts that are most relevant to the entity in the context of the target text. For example, for any entity, the computer device acquires at least one candidate semantic concept corresponding to that entity from a concept knowledge base. If the number of acquired candidate semantic concepts is less than or equal to a first number, the computer device determines the at least one candidate semantic concept as the semantic concept corresponding to that entity. If the number of acquired candidate semantic concepts is greater than the first number, the computer device determines the weight of each candidate semantic concept based on the overlap between each candidate semantic concept and the semantic concepts of other entities in the target text, and acquires the first number of candidate semantic concepts with the highest weights as the semantic concepts corresponding to that entity. The greater the overlap between a candidate semantic concept and the semantic concepts of other entities in the target text, the greater the relevance between the candidate semantic concept and the entity in the current context of the target text. For example, the candidate semantic concepts corresponding to the entity "apple" include "fruit" and "company." If other entities such as "banana" and "grape" appear in the target text, and these other entities all correspond to the semantic concept "fruit," then the computer device determines that the candidate semantic concept "fruit" corresponding to the entity "apple" has a greater overlap with the semantic concepts of other entities. In the current context, the candidate semantic concept "fruit" is more relevant to the entity "apple," and the computer device assigns a larger weight to the candidate semantic concept "fruit" and a smaller weight to the candidate semantic concept "company." It should be noted that the above description of the method for determining the weights of candidate semantic concepts is merely an exemplary description of one possible implementation. This application does not limit which method is used to determine the weights of candidate semantic concepts. In this embodiment of the application, when the computer device retrieves the semantic concept corresponding to each entity in the concept knowledge base, it will obtain multiple semantic concepts. For example, in the MCG concept knowledge base, there are more than 15,000 semantic concepts related to the entity "water". In this case, by assigning weights to each semantic concept and filtering the semantic concepts based on the weights, the number of semantic concepts corresponding to each entity can be effectively limited, avoiding the acquisition of too many semantic concepts and the construction of an overly complex semantic graph structure.

[0090] Step 2: The computer device determines the nodes in the semantic graph based on the entity and corresponding semantic concept in the target text.

[0091] In this embodiment of the application, the computer device determines the entities in the target text and the semantic concepts corresponding to each entity as nodes in the semantic graph.

[0092] Step 3: The computer device adds edges between nodes that are related in the semantic graph.

[0093] In this embodiment, if any two nodes indicate entities or semantic concepts that have an association relationship, then the two nodes have an association relationship. In one possible implementation, if any two first nodes correspond to entities that have a syntactic relationship, then an edge is added between the two first nodes. Here, a first node refers to the node corresponding to an entity in the target text. For example, a computer device performs syntactic analysis on the target text to determine the shortest syntactic dependency path between each entity in the target text, and determines the syntactic relationship between entities based on the shortest dependency path between entities. Here, the shortest dependency path refers to the shortest path that establishes a relationship between two entities. For example, for the text "There are flowers on the grass behind the artificial hill in Central Park", the shortest dependency path between "Central Park" and "flowers" is "Central Park" - "have" - ​​"flowers", and this shortest dependency path is used to determine the syntactic relationship between entities. In one possible implementation, if any first node has a corresponding second node, then an edge is added between the first node and the second node, wherein the second node corresponds to the semantic concept of the entity indicated by the first node. That is, if any entity has a semantic concept, then an edge is added between the node of any entity and the node of the corresponding semantic concept.

[0094] 303. The computer device extracts graph features of the semantic graph based on the node in the semantic graph and the relationship between any two nodes through at least one graph processing layer in the first text classification model.

[0095] In one possible implementation, the first text classification model includes at least one graph processing layer and a classification layer. The at least one graph processing layer is used to extract graph features of the semantic graph based on the node in the semantic graph and the association between any two nodes. The classification layer is used to classify the target text based on the graph features.

[0096] In one possible implementation, the at least one graph processing layer is an L-layer graph processing layer. When L is a positive integer greater than 1, for the first graph processing layer in the first text classification model, the computer device performs soft clustering on the nodes and relationships between any two nodes in the semantic graph through the first graph processing layer to obtain an intermediate graph. For the (l+1)th graph processing layer in the first text classification model, the computer device performs soft clustering on the nodes and relationships between any two nodes in the target intermediate graph through the (l+1)th graph processing layer to obtain a new intermediate graph, where the target intermediate graph is the intermediate graph output by the l-th graph processing layer, and l is a positive integer greater than or equal to 1 and less than L. The computer device determines the graph features based on the intermediate graph output by the last graph processing layer in the first text classification model. In another possible implementation, if the first text classification model includes a graph processing layer, the computer device performs soft clustering on the nodes and relationships between any two nodes in the semantic graph through this graph processing layer to obtain an intermediate graph, and determines the graph features based on the intermediate graph output by this graph processing layer. It should be noted that the number of graph processing layers included in the first text model is not limited in this embodiment. In this embodiment, the example of the first text model including multiple graph processing layers is used for explanation. In this embodiment, the number of nodes included in the intermediate graph output by the (l+1)th graph processing layer is less than the number of nodes included in the graph input to the (l+1)th graph processing layer, and the intermediate graph output by the last graph processing layer includes one node. Taking the intermediate graph output by the lth graph processing layer as intermediate graph l as an example, the (l+1)th graph processing layer divides the multiple nodes in intermediate graph l into multiple clusters through soft clustering, and takes one cluster as a new node to obtain one node in intermediate graph l+1.

[0097] In this embodiment, the process of any graph processing layer processing the input graph includes updating the feature representations of nodes and relationships, and performing soft clustering based on the updated nodes and relationships. In one possible implementation, the graph processing layer includes a Flat Graph Neural Network (Flat GNN) and a soft clustering network. The Flat GNN includes at least one cascaded sublayer, meaning the output of one sublayer is the input of the next sublayer. This at least one sublayer is used to update the feature representations of nodes and relationships. The soft clustering network obtains the updated feature representations from the output of the last sublayer and performs soft clustering processing on the nodes and relationships based on the updated feature representations. Figure 4 This is a schematic diagram of a method for obtaining graph features of a semantic graph provided in an embodiment of this application, such as... Figure 4As shown, any graph processing layer updates the feature representations of nodes and relationships in the input semantic graph or intermediate graph through at least one sublayer of Flat GNN, and then performs soft clustering on the nodes and relationships to generate a new intermediate graph. In this embodiment, the number of nodes included in the intermediate graph output by any graph processing layer is less than the number of nodes included in the input intermediate graph or semantic graph. The following uses the first graph processing layer in the first text classification model as an example to illustrate the above feature representation update process and soft clustering process:

[0098] (1) The process of updating the feature representation of nodes and relationships.

[0099] In this embodiment, the feature representation of the entity or semantic concept indicated by any node in the semantic graph is called the first node feature. Optionally, the first node feature is represented in vector form. For example, the entity knowledge base and the concept knowledge base store vectors corresponding to each entity and semantic concept, respectively. The feature representation of any association in the semantic graph is called the first relationship feature. Optionally, the first relationship feature is a directed vector. For example, the first relationship feature of any association is determined based on the two nodes connected by the association. In one possible implementation, the feature representations of two nodes are concatenated according to the direction indicated by the association to obtain the feature representation of the association. For example, if entity A corresponds to node 1 and the semantic concept of entity A corresponds to node 2, then the association indicates that node 1 points to node 2. Concatenating node 1 and node 2 according to the direction indicated by the association means concatenating the feature representation of node 2 after the feature representation of node 1 to obtain the feature representation of the association. It should be noted that this embodiment does not limit the method for determining the feature representations of nodes and associations.

[0100] In this embodiment, the computer device updates the first node features of each node and the first relationship features of each association at least once through at least one sublayer in the graph processing layer to obtain the second node features of each node and the second relationship features of each association. Taking the graph processing layer as an example where the computer device updates the first node features and first relationship features through any sublayer in the graph processing layer, in one possible implementation, the process includes the following steps:

[0101] Step 1: The computer device determines the intermediate node features corresponding to any node by using any sub-layer based on the first node features of any node, the first node features of the connected nodes of any node, and the first relationship features of at least one candidate association relationship, wherein the candidate association relationship is the association relationship between any node and any connected node.

[0102] In one possible implementation, firstly, the computer device combines the first node feature of any node with the first relation feature of at least one candidate association relationship to obtain at least one first intermediate feature corresponding to any node. The combination of a first node feature and a first relation feature is achieved using a combination function (cancat function). Then, the computer device performs a weighted summation on the at least one first intermediate feature to obtain a second intermediate feature. Finally, based on the second intermediate feature and the first node feature corresponding to any node, the computer device determines the intermediate node feature corresponding to any node. For example, the computer device performs a weighted summation on the second intermediate feature and the first node feature of any node to obtain a third intermediate feature, and then performs linear processing on the third intermediate feature to obtain the intermediate node feature corresponding to any node. In one possible implementation, this step can be expressed as the following formulas (1) to (3):

[0103]

[0104]

[0105]

[0106] Where k represents the k-th sub-layer in the graph processing layer, and k is greater than or equal to 1; Let e' be the set of connected nodes of any given node (connected nodes can also be called neighboring nodes). i Connected nodes, It is the feature representation of node e' in the k-th sub-layer; e i Represents a node. Represents node e i The feature representation in the k-th sub-layer is the same as the feature of the first node mentioned above. Represents node e i The feature representation in the (k+1)th sub-layer is, that is, the aforementioned intermediate node features.

[0107] Step 2: The computer device performs linear processing on the first relation feature of any association through any sub-layer to obtain the intermediate relation feature of any association.

[0108] In one possible implementation, step two can be expressed as the following formula (4):

[0109]

[0110] in, and These are the parameters of the k-th sub-layer, determined during the training of the first text classification model.

[0111] Step 3: The computer device inputs the intermediate node features of each node and the intermediate relationship features of each association as the new first node features and first relationship features into the next sub-layer, and obtains the new intermediate node features and new intermediate relationship features output by the next sub-layer.

[0112] In this embodiment, the method by which the next sub-layer processes the data of the first node features of each node and the first relationship features of each association is the same as the steps described above, and will not be repeated here.

[0113] Step 4: The computer device obtains the intermediate node features of each node and the intermediate relationship features of each association from the output of the last sub-layer in the graph processing layer, and uses them as the second node features and the second relationship features, respectively.

[0114] It should be noted that if the graph processing layer includes a sub-layer, the computer device will update the first node feature of the node and the first relation feature of the association relationship once through the sub-layer, and then obtain the second node feature of the node and the second relation feature of the association relationship.

[0115] (2) The process of clustering nodes and relationships.

[0116] In one possible implementation, for any graph processing layer, the computer device determines the clustering assignment matrix corresponding to the graph processing layer based on the node features of the nodes in the graph input to the graph processing layer and the relationship features of the associations between the nodes in the graph. This clustering assignment matrix is ​​used for soft clustering processing in this layer. In one possible implementation, the process of determining the clustering assignment matrix is ​​expressed as the following formulas (5) to (6):

[0117]

[0118]

[0119] Among them, S (l) This represents the clustering assignment matrix corresponding to the l-th graph processing layer; This represents the second node features of each node output by the planar graph neural network in the l-th graph processing layer, which is also the second node features of each node obtained in step four above. Represents node e i and node e j The second relational feature that establishes the connection between them; The value of A is determined during the training of the first text classification model; (l) based on Confirmed, A (l) One of the elements is It is a weight matrix. It is the adjacency weight between node i and node j, based on The weighted inner product is obtained in this case, A (l) This can be interpreted as graph G. l In the generalized adjacency matrix of the l-th layer, since the adjacency matrix is ​​an important indicator for characterizing the graph structure, A is used as the basis for this. (l) Assigning the input clustering matrix S (l) It will be able to capture global information about the graph very well.

[0120] In one possible implementation, the computer device performs soft clustering on each node in the semantic graph based on the second node features of each node, to obtain at least one node in the intermediate graph. Each node in the intermediate graph corresponds to at least one node in the semantic graph. During the soft clustering process, each node in the semantic graph is mapped to one or more clusters, and a cluster can form a new node as a node in the intermediate graph. In this embodiment, the number of nodes included in the intermediate graph is less than the number of nodes included in the semantic graph. For example, the computer device multiplies the second node features of each node with the clustering assignment matrix corresponding to the current layer to obtain a node feature matrix. One column of the node feature matrix represents the node features of a node in the intermediate graph. This process can be expressed as the following formula (7):

[0121] E (l+1) =Z l S (l) (7)

[0122] in, It is the second node feature output by the planar graph neural network in the l-th graph processing layer; E (1+1) The j-th column is graph G 1+1 Middle node Feature representation, This is equivalent to a weighted average of the second node features output by the planar graph neural network in the l-th graph processing layer, where the weights are determined by the clustering assignment matrix S. (l) Sure.

[0123] In one possible implementation, based on the second relation features of each association in the semantic graph, clustering is performed on each association to obtain the association between at least one node in the intermediate graph. For example, for any two nodes in the intermediate graph, the computer device determines candidate elements corresponding to the two nodes from the elements included in the clustering assignment matrix corresponding to this layer; based on the candidate elements, the first relation features of each association in the semantic graph are weighted and summed to obtain the relation features of the association between any two nodes in the intermediate graph. In one possible implementation, the above process can be expressed as the following formula (8):

[0124]

[0125] in, and It is S (l) The elements in.

[0126] It should be noted that the above description of the data processing process of the graph processing layer is merely an exemplary illustration of one possible implementation. This application embodiment does not limit the method used by the graph processing layer to process the input graph data. In this application embodiment, only the data processing process of the first graph processing layer is described as an example; the data processing processes of other graph processing layers are the same as steps one to four above, and will not be repeated here.

[0127] In this embodiment, the computer device determines the graph features based on the intermediate graph output by the last graph processing layer in the first text classification model. In one possible implementation, this process can be expressed as the following formula (9):

[0128] g=σ(W (L) Concat(e (L) ,r (L) )+b L (9)

[0129] Where g represents the graph feature of the semantic graph, e (L) Let r represent the node features output by the Lth graph processing layer, i.e., the last graph processing layer. (L) This represents the relational features output by the Lth graph processing layer; and The value is determined during the training of the first text classification model.

[0130] In this embodiment, the semantic graph is processed multiple times through multiple graph processing layers, which can fully learn the local and all information of the semantic graph. The local and global information of the semantic graph are then integrated into the finally extracted graph features, which facilitates more accurate text classification in the future.

[0131] 304. The computer device classifies the text based on the graph features through the classification layer in the first text classification model to obtain the first classification information.

[0132] In this first text classification model, the classification layer can be implemented as a convolutional neural network to process the input graph features and obtain the first classification information. Optionally, the first classification information is represented in the form of a vector, and one element of the first classification information is used to indicate the probability that the target text belongs to a category.

[0133] It should be noted that steps 303 to 304 above are steps for determining the first classification information of the target text based on the semantic graph. In this embodiment, by acquiring the semantic graph, the relationship information between the entities and concepts corresponding to the target text is fully obtained. By learning the features of the semantic graph, the local and global information of the semantic graph is fully extracted. The local and global information of the semantic graph are fused into the finally extracted graph features, so that a more accurate classification result can be obtained when performing text classification based on graph features in the subsequent process.

[0134] 305. The computer device determines the second classification information of the target text based on the context information of the target text.

[0135] In one possible implementation, the computer device is equipped with a second text classification model. For example, the second text classification model is a FastText model, a Char-CNN (Character-level Convolutional Networks) model, a BERT (Bidirectional Encoder Representations from Transformers) model, etc., and this application embodiment does not limit it to this.

[0136] In this embodiment, the computer device determines the second classification information of the target text based on the context information of the target text using the second text classification model. Taking the BERT model as an example, the computer device first preprocesses the target text using the BERT model, segmenting the target text into a character sequence composed of multiple characters, and then mapping each character to a vector to obtain the vector sequence corresponding to the target text. Then, the computer device performs encoding and decoding operations on the vector sequence using multiple transformation layers in the BERT model to extract the text features of the target text, which include the context information of the target text. Finally, the computer device predicts the category to which the target text belongs based on the extracted text features using the BERT model and outputs the second classification information. Optionally, the second classification information is represented in the form of a vector, where one element of the second classification information indicates the probability that the target text belongs to a category.

[0137] It should be noted that the above description of computer devices classifying text information using a second text classification model is merely an exemplary description of one possible implementation method. This application embodiment does not limit which method is used to obtain the second classification information.

[0138] 306. The computer device obtains the classification information of the target text based on the first classification information and the second classification information.

[0139] In one possible implementation, the computer device can perform a weighted summation of the first and second classification information to obtain the classification information of the target text, that is, determine the category to which the target text belongs. For example, this process can be expressed as the following formula (10):

[0140] Score(y)=(1-λ)P1(y|g)+λP2(y|s) (10)

[0141] Wherein, Score(y) represents the classification information of the target text; p1(y|g) represents the first classification information, p2(y|s) represents the second classification information; g represents the semantic graph of the target text, s represents the target text; λ represents the prior weight, the value of which is set by the developers.

[0142] Figure 5 This is a schematic diagram of a text classification process provided in an embodiment of this application. The following is in conjunction with... Figure 5 The above text classification process will be explained. In one possible implementation, for the input target text, the computer device performs a text classification process using a first text classification model 501 and a second text classification model 502, as follows: Figure 5As shown, the computer device extracts the entities, concepts, and relationships corresponding to the target text through the first text classification model 501, and then constructs a semantic graph, which is the process of performing the above step 202. The computer device extracts graph features based on the semantic graph, and classifies the target text based on the graph features through the classifier in the first text classification model to obtain the first classification information. The computer device extracts the context information of the target text through the second text classification model 502, classifies the target text to obtain the second text classification information, and fuses the second classification information and the second classification information to obtain the classification information corresponding to the target text.

[0143] The technical solution provided in this application uses semantic graphs to represent the relationships between entities and concepts corresponding to the target text, thereby fully obtaining the relationship information between entities and concepts in the target text. Based on the semantic graph, a first classification information is determined, and then a second classification information is determined directly based on the context information of the target text. Combining the first and second classification information, the category to which the target text belongs is determined. That is, in the text classification process, the relationship between entities in the target text and the context information of the target text are integrated to determine the category to which the target text belongs based on more comprehensive text information, thereby effectively improving the accuracy of the text classification results.

[0144] The first text classification model and the second text classification model in the above embodiments are pre-trained models stored in the computer device. These two text classification models are models trained by the computer device or models trained by other devices. Figure 6 This is a flowchart of a training method for a text classification model provided in an embodiment of this application. See also... Figure 6 In one possible implementation, the method includes the following steps:

[0145] 601. The computer device acquires the first text classification model and the second text classification model to be trained.

[0146] In one possible implementation, the first text classification model is considered a hierarchical graph learning-based text classifier, capable of learning the graph features of the semantic graph corresponding to the text data, and then classifying the text based on the graph features. The second text classification model is considered a model that classifies text based on the contextual information of the text data. For example, the second text classification model is the FastText model, Char-CNN, BERT, etc., and this application embodiment does not limit it.

[0147] 602. Computer equipment acquires training data.

[0148] In one possible implementation, the AG's News public dataset is used as the training dataset. AG's News includes a large number of news articles, i.e., training data. In this embodiment, 120,000 data points are used as training data and 7,600 data points are used as test data. The training data in AG's News is divided into four categories, with the same number of training and test data points in each category: 30,000 training data points and 1,900 test data points, respectively. The original text in AG's News contains news titles and article descriptions. In this embodiment, the news titles and article descriptions are concatenated and used as input for subsequent model training.

[0149] 603. The computer equipment inputs the training data into the first text classification model and the second text classification model respectively to obtain the classification information corresponding to the training data.

[0150] In this embodiment of the application, the process by which the computer device classifies the training data using the first text classification model and the second text classification model to obtain the classification information corresponding to the training data is the same as the process of steps 202 to 206 described above, and will not be repeated here.

[0151] 604. Based on the error between the classification information corresponding to the training data and the correct classification information, the computer device adjusts the model parameters of the first text classification model and the second text classification model respectively.

[0152] In one possible implementation, the computer device determines the error between the classification information corresponding to the training data and the correct classification information based on the cross-entropy loss function, backpropagates this error to the first text classification model and the second text classification model, and adjusts the model parameters in the first and second text classification models based on the gradient descent algorithm. It should be noted that this application does not limit the method used to adjust the model parameters of the two text classification models.

[0153] 605. The computer device, in response to the first text classification model and the second text classification model satisfying the reference conditions, acquires the trained first text classification model and the second text classification model.

[0154] The reference conditions are set by the developers, and this application embodiment does not limit them. For example, the reference conditions include a threshold for the number of training epochs of the model. If the number of training epochs reaches the threshold, a first text classification model and a second text classification model are obtained after training. If the number of training epochs does not reach the threshold, the next batch of training data is obtained to train the first and second text classification models. For example, the reference conditions include an error threshold. If the number of times the error corresponding to the classification information output by the model is less than the error threshold reaches a target number, the first and second text classification models are determined to meet the reference conditions, and a first and second text classification model are obtained after training. Otherwise, the next batch of training data is obtained for model training.

[0155] In one possible implementation, the hyperparameters of the model are set as follows during the training process:

[0156] In the first text classification model, the hyperparameters were set as follows: learning rate 10. -4 The batch size is 8, and the dimension d is 100. The first text classification model's planar graph neural network includes 5 graph processing layers, and the number of nodes in the graph output by each graph processing layer is 100, 64, 32, 8, and 1, respectively. Each graph processing layer includes 2 sub-layers.

[0157] If the second text classification model is a Char-CNN model, the hyperparameters of the Char-CNN model are set as follows: learning rate 10. -4 The training rounds were 400, the batch size was 32, the optimizer was Adam, and the dropout rate p was 0.5.

[0158] If the second text classification model is the FastText model, the hyperparameters of the FastText model are set as follows: learning rate of 0.21, number of training epochs of 11, batch size of 32, optimizer of Adam, and dropout rate p of 0.5.

[0159] If the second text classification model is a BERT model, this embodiment uses the "BERT-Base-Uncased" version of the open-source model, with the hyperparameters set as follows: learning rate 5*10^6. -5 The maximum sequence length is 200, the number of training rounds is 2, and the batch size is 8.

[0160] During model training, the prior weights λ in Equation 10 above are set to 0.51, 0.68 and 0.55 for Char-CNN, FastText and BERT, respectively.

[0161] Table 1 shows the accuracy of different models in text classification of data in the AG's News dataset.

[0162] Table 1

[0163] Char-CNN FastText BERT standalone model 87.54% 91.20% 94.15% Combined with the first text classification model 89.28% 91.76% 94.29% improve +1.74% +0.56% +0.14%

[0164] As shown in Table 1, when Char-CNN, FastText, and BERT are combined with the first text classification model, the accuracy of the output classification results is improved compared to the accuracy of the classification results output directly by the three models. Char-CNN achieves an accuracy of 87.54% on the AG's News dataset. By using hierarchical graph learning and result-level fusion (i.e., combining with the first text classification model), the final accuracy reaches 89.28%, an improvement of 1.74%. FastText's original accuracy is 91.20%, and the accuracy after fusing with the output of the first text classification model is 91.76%, an improvement of 0.56%. BERT achieves an accuracy of 94.15% on AG's News. By combining with the output of the first text classification model, the final accuracy is 94.29%, an improvement of 0.15%. Based on the above data, it can be seen that the text classification method provided in the embodiments of this application can effectively improve the performance of text classification tasks. For example, although BERT has achieved a very high accuracy on AG's News and is one of the best models on the AG's News dataset, combining it with the text classification method proposed in this application can still improve the accuracy by 0.14%.

[0165] The accuracy of different second-class text classification models on different categories of data, and the increase in accuracy of different second-class text classification models on different categories of data after combining them with the first-class text classification model, are shown in Table 2 below:

[0166] Table 2

[0167]

[0168] The data in parentheses in Table 2 represent the increase in accuracy of the output results after combining the second text classification model with the first text classification model. The second text classification model has the highest classification accuracy in the "Sports" category, i.e., category 2 above. The accuracy of the Char-CNN and FastText output results after combining with the first text classification model improved by 2.26% and 0.42%, respectively. Based on the data in Table 2, it can be seen that the text classification method proposed in this scheme can bring greater performance improvement to models with poor classification performance. For example, in different categories, the improvement of Char-CNN is more significant than that of BERT. That is, when the second text classification model cannot fully capture text features, the text classification method proposed in this scheme can effectively improve classification performance.

[0169] All of the above-mentioned optional technical solutions can be combined in any way to form the optional embodiments of this application, and will not be described in detail here.

[0170] Figure 7 This is a schematic diagram of the structure of a text classification device provided in an embodiment of this application. See also... Figure 7 The device includes:

[0171] The acquisition module 701 is used to acquire the semantic graph corresponding to the target text. The nodes in the semantic graph correspond to entities in the target text or semantic concepts corresponding to the entities. The edges in the semantic graph are used to indicate the relationship between any two nodes.

[0172] The first determining module 702 is used to determine the first classification information of the target text based on the semantic graph;

[0173] The second determining module 703 is used to determine the second classification information of the target text based on the context information of the target text;

[0174] The third determining module 704 is used to obtain the classification information of the target text based on the first classification information and the second classification information.

[0175] In one possible implementation, the association includes at least one of semantic and syntactic relations;

[0176] The acquisition module 701 is used for:

[0177] Based on the entity and its corresponding semantic concept in the target text, determine the nodes in the semantic graph;

[0178] If any two entities corresponding to the first nodes have a syntactic relationship, then add an edge between those two first nodes;

[0179] If any first node has a corresponding second node, then an edge is added between the first node and the second node, wherein the second node corresponds to the semantic concept of the entity indicated by the first node.

[0180] In one possible implementation, the first determining module 702 includes:

[0181] The feature extraction submodule is used to extract graph features of the semantic graph based on the node in the semantic graph and the relationship between any two nodes through at least one graph processing layer in the first text classification model.

[0182] The classification submodule is used to classify based on the graph features through the classification layer in the first text classification model to obtain the first classification information.

[0183] In one possible implementation, the feature extraction submodule is used for:

[0184] The at least one graph processing layer is an L-layer graph processing layer, where L is a positive integer greater than 1.

[0185] For the first graph processing layer in the first text classification model, the first graph processing layer performs soft clustering on the relationship between the node and any two nodes in the semantic graph to obtain an intermediate graph.

[0186] For the (l+1)th graph processing layer in the first text classification model, soft clustering is performed on the nodes in the target intermediate graph and the relationship between any two nodes through the (l+1)th graph processing layer to obtain a new intermediate graph. The target intermediate graph is the intermediate graph output by the lth graph processing layer, where l is a positive integer greater than or equal to 1 and less than L.

[0187] Based on the intermediate graph output by the last graph processing layer in the first text classification model, the graph features are determined.

[0188] In one possible implementation, the feature extraction submodule includes:

[0189] The feature update unit is used to update the first node features of each node and the first relation features of each association at least once through at least one sub-layer in the graph processing layer to obtain the second node features of each node and the second relation features of each association. The first node features are feature representations of the entity or semantic concept indicated by the node, and the first relation features are feature representations of the association.

[0190] The first clustering unit is used to perform soft clustering on each node based on the second node features of each node in the semantic graph to obtain at least one node in the intermediate graph.

[0191] The second clustering unit is used to perform clustering processing on each association based on the second relationship features of each association in the semantic graph, so as to obtain the association between at least one node in the intermediate graph.

[0192] In one possible implementation, the feature update unit includes:

[0193] The first subunit is used to determine the intermediate node features corresponding to any node in any sublayer of the graph processing layer based on the first node features of any node, the first node features of the connected nodes of any node, and the first relationship features of at least one candidate association relationship, wherein the candidate association relationship is the association relationship between any node and any connected node.

[0194] The second subunit is used to perform linear processing on the first relation feature of any association through any sub-layer to obtain the intermediate relation feature of any association.

[0195] The third sub-unit is used to input the intermediate node features of each node and the intermediate relationship features of each association as new first node features and first relationship features into the next sub-layer, so as to obtain the new intermediate node features and new intermediate relationship features output by the next sub-layer.

[0196] The fourth sub-unit is used to take the intermediate node features of each node and the intermediate relationship features of each association from the output of the last sub-layer in the graph processing layer as the second node feature and the second relationship feature, respectively.

[0197] In one possible implementation, the first subunit is used for:

[0198] The first node feature of any node is combined with the first relation feature of at least one candidate association relationship to obtain at least one first intermediate feature corresponding to any node;

[0199] The weighted sum of at least one first intermediate feature is used to obtain the second intermediate feature;

[0200] Based on the second intermediate feature and the first node feature corresponding to any node, the intermediate node feature corresponding to any node is determined.

[0201] In one possible implementation, the first subunit is used for:

[0202] The third intermediate feature is obtained by weighted summing of the second intermediate feature and the first node feature of any given node.

[0203] The third intermediate feature is linearly processed to obtain the intermediate node feature corresponding to any given node.

[0204] In one possible implementation, the device further includes:

[0205] The matrix determination module is used to determine the clustering assignment matrix corresponding to any graph processing layer based on the node features of the nodes in the graph input by the graph processing layer and the relationship features of the association between the nodes in the graph. The clustering assignment matrix is ​​used to perform soft clustering processing in this layer.

[0206] In one possible implementation, the first clustering unit is used for:

[0207] Multiply the second node feature of each node with the clustering assignment matrix corresponding to this layer to obtain the node feature matrix. One column of the node feature matrix represents the node feature of a node in the intermediate graph.

[0208] In one possible implementation, the second clustering unit is used for:

[0209] For any two nodes in the intermediate graph, determine the candidate elements corresponding to those two nodes from the elements included in the clustering assignment matrix corresponding to this layer;

[0210] Based on the candidate element, the first relation features of each association in the semantic graph are weighted and summed to obtain the relation features of the association between any two nodes in the intermediate graph.

[0211] The apparatus provided in this application uses semantic graphs to represent the relationships between entities and concepts corresponding to target text, thereby fully acquiring the relationship information between entities and concepts in the target text. Based on the semantic graphs, a first classification information is determined, and then a second classification information is determined directly based on the context information of the target text. Combining the first and second classification information, the category to which the target text belongs is determined. That is, in the text classification process, the relationship between entities in the target text and the context information of the target text are integrated to determine the category to which the target text belongs based on more comprehensive text information, thereby effectively improving the accuracy of text classification results.

[0212] It should be noted that the text classification device provided in the above embodiments is only illustrated by the division of the above functional modules. In practical applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. In addition, the text classification device and the text classification method embodiments provided in the above embodiments belong to the same concept, and the implementation process is detailed in the method embodiments, which will not be repeated here.

[0213] The computer equipment provided by the above technical solution can be implemented as a terminal or a server, for example, Figure 8 This is a schematic diagram of the structure of a terminal provided in an embodiment of this application. For example, the terminal 800 can be: a smartphone, tablet computer, MP3 player (Moving Picture Experts Group Audio Layer III), MP4 player (Moving Picture Experts Group Audio Layer IV), laptop computer, or desktop computer. The terminal 800 may also be referred to as a user device, portable terminal, laptop terminal, desktop terminal, or other names.

[0214] Typically, terminal 800 includes one or more processors 801 and one or more memories 802.

[0215] In one possible implementation, processor 801 includes one or more processing cores, such as a quad-core processor, an octa-core processor, etc. Optionally, processor 801 is implemented using at least one hardware form selected from DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), and PLA (Programmable Logic Array). In one possible implementation, processor 801 includes a main processor and a coprocessor. The main processor, also known as a CPU (Central Processing Unit), is used to process data in the wake-up state; the coprocessor is a low-power processor used to process data in the standby state. In some embodiments, processor 801 integrates a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content to be displayed on the screen. In some embodiments, processor 801 also includes an AI (Artificial Intelligence) processor, which handles computational operations related to machine learning.

[0216] In one possible implementation, memory 802 includes one or more computer-readable storage media, which, exemplary, are non-transitory. Memory 802 may also include high-speed random access memory and non-volatile memory, such as one or more disk storage devices or flash memory devices. In some embodiments, the non-transitory computer-readable storage media in memory 802 is used to store at least one line of program code, which is executed by processor 801 to implement the text classification method provided in the method embodiments of this application.

[0217] In some embodiments, the terminal 800 may also optionally include a peripheral device interface 803 and at least one peripheral device. In one possible implementation, the processor 801, memory 802, and peripheral device interface 803 are connected via a bus or signal line. In another possible implementation, the peripheral devices are connected to the peripheral device interface 803 via a bus, signal line, or circuit board. Exemplarily, the peripheral device includes at least one of the following: a radio frequency circuit 804, a display screen 805, a camera assembly 806, an audio circuit 807, a positioning assembly 808, and a power supply 809.

[0218] Peripheral device interface 803 can be used to connect at least one I / O (Input / Output) related peripheral device to processor 801 and memory 802. In some embodiments, processor 801, memory 802 and peripheral device interface 803 are integrated on the same chip or circuit board; in some other embodiments, any one or two of processor 801, memory 802 and peripheral device interface 803 are implemented on separate chips or circuit boards, which is not limited in this embodiment.

[0219] The radio frequency (RF) circuit 804 is used to receive and transmit RF (Radio Frequency) signals, also known as electromagnetic signals. The RF circuit 804 communicates with communication networks and other communication devices via electromagnetic signals. The RF circuit 804 converts electrical signals into electromagnetic signals for transmission, or converts received electromagnetic signals back into electrical signals. Optionally, the RF circuit 804 includes: an antenna system, an RF transceiver, one or more amplifiers, a tuner, an oscillator, a digital signal processor, a codec chipset, a user identity module card, etc. The RF circuit 804 can communicate with other terminals via at least one wireless communication protocol. This wireless communication protocol includes, but is not limited to: metropolitan area networks (MANs), various generations of mobile communication networks (2G, 3G, 4G, and 5G), wireless local area networks (WLANs), and / or WiFi (Wireless Fidelity) networks. In some embodiments, the RF circuit 804 also includes circuitry related to NFC (Near Field Communication), which is not limited in this application.

[0220] Display screen 805 is used to display a UI (User Interface). Exemplarily, the UI includes graphics, text, icons, videos, and any combination thereof. When display screen 805 is a touch display screen, it also has the ability to collect touch signals on or above its surface. These touch signals can be input as control signals to processor 801 for processing. In this case, display screen 805 is also used to provide virtual buttons and / or a virtual keyboard, also known as soft buttons and / or a soft keyboard. In some embodiments, there is one display screen 805, which serves as the front panel of terminal 800; in other embodiments, there are at least two display screens 805, respectively disposed on different surfaces of terminal 800 or in a folded design; in some embodiments, display screen 805 is a flexible display screen, disposed on a curved surface or folded surface of terminal 800. Furthermore, display screen 805 can also be configured as a non-rectangular irregular shape, i.e., a non-rectangular screen. Display screen 805 can be made of materials such as LCD (Liquid Crystal Display) or OLED (Organic Light-Emitting Diode).

[0221] The camera assembly 806 is used to acquire images or videos. Optionally, the camera assembly 806 includes a front-facing camera and a rear-facing camera. Typically, the front-facing camera is located on the front panel of the terminal, and the rear-facing camera is located on the back of the terminal. In some embodiments, there are at least two rear-facing cameras, which are any one of a main camera, a depth-sensing camera, a wide-angle camera, and a telephoto camera, to achieve background blurring by fusion of the main camera and the depth-sensing camera, panoramic shooting by fusion of the main camera and the wide-angle camera, VR (Virtual Reality) shooting, or other fusion shooting functions. In some embodiments, the camera assembly 806 also includes a flash. Optionally, the flash is a single-color temperature flash or a dual-color temperature flash. A dual-color temperature flash refers to a combination of a warm-light flash and a cool-light flash, which can be used for light compensation at different color temperatures.

[0222] In some embodiments, the audio circuit 807 includes a microphone and a speaker. The microphone is used to collect sound waves from the user and the environment, and convert the sound waves into electrical signals that are input to the processor 801 for processing, or input to the radio frequency circuit 804 to realize voice communication. Optionally, for stereo acquisition or noise reduction purposes, multiple microphones may be used, each located at a different part of the terminal 800. Alternatively, the microphone may be an array microphone or an omnidirectional acquisition microphone. The speaker is used to convert the electrical signals from the processor 801 or the radio frequency circuit 804 into sound waves. Optionally, the speaker may be a conventional film speaker or a piezoelectric ceramic speaker. When the speaker is a piezoelectric ceramic speaker, it can convert electrical signals not only into sound waves that humans can hear, but also into sound waves that humans cannot hear for purposes such as distance measurement. In some embodiments, the audio circuit 807 also includes a headphone jack.

[0223] The positioning component 808 is used to locate the current geographical location of the terminal 800 in order to enable navigation or LBS (Location Based Service). For example, the positioning component 808 is a positioning component based on the US GPS (Global Positioning System), China's BeiDou system, Russia's Granas system, or the European Union's Galileo system.

[0224] Power supply 809 is used to supply power to the various components in terminal 800. Exemplarily, power supply 809 is alternating current, direct current, a disposable battery, or a rechargeable battery. When power supply 809 includes a rechargeable battery, the rechargeable battery can support wired or wireless charging. The rechargeable battery can also be used to support fast charging technology.

[0225] In some embodiments, the terminal 800 further includes one or more sensors 810. The one or more sensors 810 include, but are not limited to: an accelerometer 811, a gyroscope 812, a pressure sensor 813, a fingerprint sensor 814, an optical sensor 815, and a proximity sensor 816.

[0226] In some embodiments, the accelerometer 811 can detect the magnitude of acceleration on three coordinate axes of a coordinate system established with the terminal 800. For example, the accelerometer 811 is used to detect the components of gravitational acceleration on the three coordinate axes. In some embodiments, the processor 801 can control the display screen 805 to display the user interface in a landscape or portrait view based on the gravitational acceleration signal acquired by the accelerometer 811. In some embodiments, the accelerometer 811 is also used for collecting game or user motion data.

[0227] In some embodiments, the gyroscope sensor 812 can detect the orientation and rotation angle of the terminal 800. The gyroscope sensor 812 can work in conjunction with the accelerometer sensor 811 to acquire the user's 3D movements on the terminal 800. Based on the data acquired by the gyroscope sensor 812, the processor 801 can perform the following functions: motion sensing (e.g., changing the UI based on the user's tilt operation), image stabilization during shooting, game control, and inertial navigation.

[0228] In some embodiments, the pressure sensor 813 is disposed on the side bezel of the terminal 800 and / or the lower layer of the display screen 805. When the pressure sensor 813 is disposed on the side bezel of the terminal 800, it can detect the user's grip signal on the terminal 800, and the processor 801 performs left / right hand recognition or quick operation based on the grip signal collected by the pressure sensor 813. When the pressure sensor 813 is disposed on the lower layer of the display screen 805, the processor 801 controls the operable controls on the UI interface based on the user's pressure operation on the display screen 805. The operable controls include at least one of button controls, scroll bar controls, icon controls, and menu controls.

[0229] The fingerprint sensor 814 is used to collect a user's fingerprint. The processor 801 identifies the user based on the fingerprint collected by the fingerprint sensor 814, or vice versa. When the user's identity is identified as trusted, the processor 801 authorizes the user to perform relevant sensitive operations, including unlocking the screen, viewing encrypted information, downloading software, making payments, and changing settings. In some embodiments, the fingerprint sensor 814 is located on the front, back, or side of the terminal 800. When the terminal 800 has a physical button or manufacturer logo, the fingerprint sensor 814 is integrated with the physical button or manufacturer logo.

[0230] An optical sensor 815 is used to collect ambient light intensity. In some embodiments, the processor 801 can control the display brightness of the display screen 805 based on the ambient light intensity collected by the optical sensor 815. For example, when the ambient light intensity is high, the display brightness of the display screen 805 is increased; when the ambient light intensity is low, the display brightness of the display screen 805 is decreased. In another embodiment, the processor 801 can also dynamically adjust the shooting parameters of the camera assembly 806 based on the ambient light intensity collected by the optical sensor 815.

[0231] The proximity sensor 816, also known as a distance sensor, is typically located on the front panel of the terminal 800. The proximity sensor 816 is used to detect the distance between the user and the front of the terminal 800. In one embodiment, when the proximity sensor 816 detects that the distance between the user and the front of the terminal 800 is gradually decreasing, the processor 801 controls the display screen 805 to switch from a screen-on state to a screen-off state; when the proximity sensor 816 detects that the distance between the user and the front of the terminal 800 is gradually increasing, the processor 801 controls the display screen 805 to switch from a screen-off state to a screen-on state.

[0232] Those skilled in the art will understand that Figure 8 The structure shown does not constitute a limitation on terminal 800 and may include more or fewer components than shown, or combine certain components, or use different component arrangements.

[0233] Figure 9 This is a schematic diagram of a server structure provided in an embodiment of this application. The server 900 can vary considerably due to differences in configuration or performance. In some embodiments, the server 900 includes one or more Central Processing Units (CPUs) 901 and one or more memories 902. The one or more memories 902 store at least one line of program code, which is loaded and executed by the one or more processors 901 to implement the methods provided in the various method embodiments described above. Of course, the server 900 may also have wired or wireless network interfaces, a keyboard, and input / output interfaces for input and output. The server 900 may also include other components for implementing device functions, which will not be elaborated upon here.

[0234] In an exemplary embodiment, a computer-readable storage medium is also provided, such as a memory including at least one line of program code, which can be executed by a processor to perform the text classification method in the above embodiments. For example, the computer-readable storage medium may be a read-only memory (ROM), a random access memory (RAM), a compact disc read-only memory (CD-ROM), magnetic tape, floppy disk, and optical data storage device, etc.

[0235] In an exemplary embodiment, a computer program product is also provided, comprising at least one computer program stored in a computer-readable storage medium. A processor of a computer device reads the at least one computer program from the computer-readable storage medium and executes the at least one computer program, causing the computer device to perform the operations performed by the text classification method described above.

[0236] Those skilled in the art will understand that all or part of the steps of the above embodiments can be implemented by hardware or by a program instructing related hardware. The program can be stored in a computer-readable storage medium, such as a read-only memory, a disk, or an optical disk.

[0237] The above are merely optional embodiments of this application and are not intended to limit this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.

Claims

1. A method of text classification, characterized by, The method comprises: obtaining a semantic graph corresponding to a target text, nodes in the semantic graph corresponding to entities in the target text or semantic concepts corresponding to the entities, and edges in the semantic graph used to indicate an association relationship between any two nodes; at least one graph processing layer in a first text classification model is an L-layer graph processing layer, where L is a positive integer greater than 1, for a first graph processing layer in the first text classification model, the nodes in the semantic graph and the association relationship between any two nodes are soft clustered by the first graph processing layer to obtain an intermediate graph, for an (l+1)th graph processing layer in the first text classification model, the nodes in a target intermediate graph and the association relationship between any two nodes are soft clustered by the (l+1)th graph processing layer to obtain a new intermediate graph, the target intermediate graph is an intermediate graph output by an lth graph processing layer, and l is a positive integer greater than or equal to 1 and less than L; based on an intermediate graph output by a last graph processing layer in the first text classification model, a graph feature is determined; and based on the graph feature, a classification layer in the first text classification model is used for classification to obtain first classification information of the target text; based on context information of the target text, second classification information of the target text is determined; based on the first classification information and the second classification information, classification information of the target text is obtained.

2. The method of claim 1, wherein, The association relationship comprises at least one of a semantic relationship and a grammatical relationship; The method comprises: based on the entities and the corresponding semantic concepts in the target text, nodes in the semantic graph are determined; if any two first nodes correspond to entities having a grammatical relationship, an edge is added between the any two first nodes; if any first node has a corresponding second node, an edge is added between the first node and the second node, where the second node corresponds to a semantic concept of an entity indicated by the first node.

3. The method of claim 1, wherein, The method comprises: by at least one sub-layer in the graph processing layer, a first node feature of each node and a first relationship feature of each association relationship are updated at least once to obtain a second node feature of each node and a second relationship feature of each association relationship, the first node feature being a feature representation of an entity or a semantic concept indicated by a node, and the first relationship feature being a feature representation of an association relationship; based on the second node features of the nodes in the semantic graph, the nodes are soft clustered to obtain at least one node in the intermediate graph; based on the second relationship features of the association relationships in the semantic graph, the association relationships are clustered to obtain association relationships between the at least one node in the intermediate graph.

4. The method of claim 3, wherein, The first node feature of each node and the first relationship feature of each association relationship are updated at least once through at least one sublayer in the graph processing layer, to obtain the second node feature of each node and the second relationship feature of each association relationship, including: For any sublayer in the graph processing layer, the intermediate node feature corresponding to any node is determined by the any sublayer based on the first node feature of the any node, the first node feature of the connected node of the any node, and the first relationship feature of at least one candidate association relationship between the any node and any connected node; The first relationship feature of any association relationship is linearly processed by the any sublayer to obtain the intermediate relationship feature of the any association relationship; The intermediate node feature of each node and the intermediate relationship feature of each association relationship are input as new first node features and first relationship features into the next sublayer to obtain new intermediate node features and new intermediate relationship features output by the next sublayer; The intermediate node feature of each node and the intermediate relationship feature of each association relationship output by the last sublayer in the graph processing layer are respectively taken as the second node feature and the second relationship feature.

5. The method of claim 4, wherein, The intermediate node feature corresponding to any node is determined by the any sublayer based on the first node feature of the any node, the first node feature of the connected node of the any node, and the first relationship feature of at least one candidate association relationship between the any node and any connected node, including: The first node feature of the any node is combined with the first relationship feature of at least one candidate association relationship to obtain at least one first intermediate feature corresponding to the any node; The at least one first intermediate feature is weighted and summed to obtain a second intermediate feature; The intermediate node feature corresponding to the any node is determined based on the second intermediate feature and the first node feature corresponding to the any node.

6. The method of claim 5, wherein, The intermediate node feature corresponding to the any node is determined based on the second intermediate feature and the first node feature corresponding to the any node, including: The second intermediate feature and the first node feature of the any node are weighted and summed to obtain a third intermediate feature; The third intermediate feature is linearly processed to obtain the intermediate node feature corresponding to the any node.

7. The method of claim 3, wherein, Before the second node feature of each node in the semantic graph is used to perform soft clustering on the nodes to obtain at least one node in the intermediate graph, the method further includes: For any graph processing layer, a clustering distribution matrix corresponding to the graph processing layer is determined based on the node features of the nodes in the graph input by the graph processing layer and the relationship features of the association relationships between the nodes in the graph, and the clustering distribution matrix is used for soft clustering processing in the layer.

8. The method of claim 7, wherein, The second node feature of each node in the semantic graph is used to perform soft clustering on the nodes to obtain at least one node in the intermediate graph, including: Multiplying the second node features of the respective nodes with the cluster assignment matrix corresponding to the current layer to obtain a node feature matrix, wherein a list in the node feature matrix represents node features of a node in the intermediate graph.

9. The method of claim 7, wherein, The clustering processing is performed on the respective association relationships based on the second relationship features of the respective association relationships in the semantic graph to obtain the association relationships between the at least one node in the intermediate graph, including: For any two nodes in the intermediate graph, a candidate element corresponding to the any two nodes is determined from elements included in the cluster assignment matrix corresponding to the current layer; The first relationship features of the respective association relationships in the semantic graph are weighted and summed based on the candidate element to obtain a relationship feature of the association relationship between any two nodes in the intermediate graph.

10. A text classification apparatus characterized by comprising: The apparatus includes: An acquisition module configured to acquire a semantic graph corresponding to a target text, wherein a node in the semantic graph corresponds to an entity in the target text or a semantic concept corresponding to the entity, and an edge in the semantic graph is used to indicate an association relationship between any two nodes; A first determination module including a feature extraction submodule configured to, for an L-layer graph processing layer in a first text classification model, perform soft clustering on the nodes in the semantic graph and the association relationship between any two nodes by the first graph processing layer to obtain an intermediate graph, when L is a positive integer greater than 1; for an (l+1)-th graph processing layer in the first text classification model, perform soft clustering on the nodes in a target intermediate graph and the association relationship between any two nodes by the (l+1)-th graph processing layer to obtain a new intermediate graph, the target intermediate graph being an intermediate graph output by an l-th graph processing layer, and l being a positive integer greater than or equal to 1 and less than L; determine a graph feature based on an intermediate graph output by a last graph processing layer in the first text classification model; and a classification submodule configured to perform classification based on the graph feature by a classification layer in the first text classification model to obtain first classification information of the target text; A second determination module configured to determine second classification information of the target text based on context information of the target text; A third determination module configured to obtain classification information of the target text based on the first classification information and the second classification information.

11. The apparatus of claim 10, wherein, The association relationship includes at least one of a semantic relationship and a grammatical relationship; The acquisition module is configured to: Determine the nodes in the semantic graph based on the entities and corresponding semantic concepts in the target text; Add an edge between any two first nodes if the entities corresponding to the any two first nodes have a grammatical relationship; Add an edge between a first node and a second node if the first node has the second node, wherein the second node corresponds to a semantic concept of an entity indicated by the first node.

12. A computer device, comprising: The computer device comprises one or more processors and one or more memories, and at least one computer program is stored in the one or more memories, and the at least one computer program is loaded and executed by the one or more processors to implement the operations performed by the text classification method according to any one of claims 1 to 9.

13. A computer-readable storage medium, characterized in that, At least one computer program is stored in the computer readable storage medium, and the at least one computer program is loaded and executed by the processor to implement the operations performed by the text classification method according to any one of claims 1 to 9.

Citation Information

Patent Citations

  • Method, device, apparatus and medium for extracting non-classification relation for Chinese field

    CN109117477A

  • Semantic comprehension method, device and equipment and storage medium

    CN111814487A

  • Character recognition method and device

    CN111860506A