Text classification method, apparatus, device, and storage medium

By introducing an attention mechanism into a deep learning model, the importance of features is determined and combined with associated text to generate category detection results and explanatory information, thus solving the problem of low reliability of deep learning models and achieving more reliable text classification.

CN113722474BActive Publication Date: 2025-10-21TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202110268045.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-03-12
Publication Date
2025-10-21
Estimated Expiration
2041-03-12

AI Technical Summary

Technical Problem

Existing deep learning models lack sufficient credibility in text classification, resulting in unreliable classification results.

Method used

An attention mechanism is used to process feature information, obtain the importance weight of features, and combine it with associated text for feature extraction to generate category detection results and result interpretation information.

Benefits of technology

It improves the reliability of category detection results, enabling users to understand the classification results more intuitively through diversity and interpretability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113722474B_ABST
    Figure CN113722474B_ABST
Patent Text Reader

Abstract

The application discloses a text classification method and device, equipment and a storage medium, and belongs to the technical field of artificial intelligence. The method comprises the following steps: acquiring a to-be-detected text and associated text corresponding to the to-be-detected text; performing feature extraction processing on the to-be-detected text and the associated text to acquire feature information; processing the feature information by using an attention mechanism to acquire attention weights corresponding to each feature; and acquiring a category detection result corresponding to the to-be-detected text and result explanation information based on the feature information and the attention weights. In the application, the category detection result comprises a category distribution probability, so that the category detection result has diversity, and the single output caused by outputting only one category is avoided; the result explanation information is used for describing the influence degree of each feature on the category detection result, the credibility of the category detection result is improved, the category detection result is provided with interpretability, and users can more intuitively understand the category detection result.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of artificial intelligence technology, and in particular to a text classification method, apparatus, device, and storage medium. Background Art

[0002] At present, with the development of artificial intelligence, the use of computer equipment combined with deep learning models for text classification is becoming more and more common.

[0003] In related technologies, technicians can train models using a large number of training samples, and then use the deep learning model after training to classify each text. For example, in a disease prediction scenario in the medical field, when medical staff perform disease detection on a target object, they can input the target object's symptom description text into a deep learning model, and the deep learning model will predict the disease based on the symptom description text, and output the pathological information data corresponding to the target object for the medical staff to use as a reference. For another example, in a book classification scenario in the education field, when staff classify the subjects to which the book belongs, they can input the book's summary description text (preface, postscript, abstract, etc.) into a deep learning model, and the deep learning model will classify the book based on the summary description text, and output the subject information data corresponding to the book as the subject classification result. Of course, text classification based on deep learning models can also be applied in many other scenarios, which are not listed one by one here.

[0004] However, in the above-mentioned related technologies, the credibility of the text classification results output by the deep learning model is not high enough. Summary of the Invention

[0005] The embodiments of the present application provide a text classification method, apparatus, device, and storage medium, which improve the credibility of category detection results. The technical solution is as follows:

[0006] According to one aspect of an embodiment of the present application, a text classification method is provided, the method comprising:

[0007] Obtaining the text to be detected and the associated text corresponding to the text to be detected;

[0008] Performing feature extraction processing on the text to be detected and the associated text to obtain feature information; wherein the feature information includes at least one feature;

[0009] The feature information is processed using an attention mechanism to obtain attention weights corresponding to the features, where the attention weights are used to indicate the importance of the features to the text to be detected and the associated texts;

[0010] Based on the feature information and the attention weight, the category detection result and result explanation information corresponding to the text to be detected are obtained; wherein, the category detection result includes the category distribution probability corresponding to the text to be detected, and the result explanation information is used to describe the degree of influence of each of the features on the category detection result.

[0011] According to one aspect of an embodiment of the present application, a method for training a text classification model is provided, the method comprising:

[0012] Obtaining multiple sample texts and category information corresponding to each of the sample texts;

[0013] Extracting sample feature information from each of the sample texts;

[0014] Training the text classification model using the sample feature information and the category information;

[0015] Among them, the attention mechanism is introduced into the text classification model, and the attention mechanism is used to determine the importance of each sample feature in the sample feature information to the sample text, and the importance is used to determine the influence of each sample feature on the model output result.

[0016] According to one aspect of an embodiment of the present application, a text classification device is provided, the device comprising:

[0017] A text acquisition module, used to acquire the text to be detected and the associated text corresponding to the text to be detected;

[0018] A feature extraction module, configured to perform feature extraction processing on the text to be detected and the associated text to obtain feature information; wherein the feature information includes at least one feature;

[0019] A weight acquisition module is used to process the feature information using an attention mechanism to obtain attention weights corresponding to each feature, where the attention weights are used to indicate the importance of the feature to the text to be detected and the associated text;

[0020] A result acquisition module is used to obtain the category detection result and result explanation information corresponding to the text to be detected based on the feature information and the attention weight; wherein the category detection result includes the category distribution probability corresponding to the text to be detected, and the result explanation information is used to describe the degree of influence of each of the features on the category detection result.

[0021] According to one aspect of an embodiment of the present application, a training device for a text classification model is provided, the device comprising:

[0022] A sample acquisition module, configured to acquire a plurality of sample texts and category information corresponding to each of the sample texts;

[0023] A feature acquisition module, configured to extract sample feature information from each of the sample texts;

[0024] A model training module, configured to train the text classification model using the sample feature information and the category information;

[0025] Among them, the attention mechanism is introduced into the text classification model, and the attention mechanism is used to determine the importance of each sample feature in the sample feature information to the sample text, and the importance is used to determine the influence of each sample feature on the model output result.

[0026] According to one aspect of an embodiment of the present application, an embodiment of the present application provides a computer device, which includes a processor and a memory, wherein the memory stores at least one instruction, at least one program, a code set, or an instruction set, and the at least one instruction, the at least one program, the code set, or the instruction set is loaded and executed by the processor to implement the above-mentioned text classification method, or to implement the above-mentioned text classification model training method.

[0027] According to one aspect of an embodiment of the present application, an embodiment of the present application provides a computer-readable storage medium, which stores at least one instruction, at least one program, a code set or an instruction set. The at least one instruction, the at least one program, the code set or the instruction set is loaded and executed by a processor to implement the above-mentioned text classification method, or to implement the above-mentioned text classification model training method.

[0028] According to one aspect of an embodiment of the present application, a computer program product or computer program is provided, comprising computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the aforementioned text classification method or implement the aforementioned text classification model training method.

[0029] The technical solutions provided in the embodiments of the present application can bring the following beneficial effects:

[0030] The feature information is processed through the attention mechanism to determine the attention weight used to indicate the importance of each feature to the text, and then the category detection results and result explanation information are obtained based on the special information and attention weight. On the one hand, the category detection results include the category distribution probability, which makes the category detection results diverse and avoids the single output caused by outputting only one category; on the other hand, the result explanation information is used to describe the influence of each feature on the category detection result, provide explainability for the category detection result, and improve the credibility of the category detection result. Users can determine the basis for obtaining the category detection result based on the result explanation information, so that users can understand the category detection result more intuitively. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0032] Figure 1 This is a flowchart of a text classification method provided by an embodiment of the present application;

[0033] Figure 2 This is a flowchart of a method for training a text classification model provided by one embodiment of the present application;

[0034] Figure 3 A schematic diagram illustrating a process of a text classification method is shown;

[0035] Figure 4 A schematic diagram illustrating a detection process of a text classification model is shown as an example;

[0036] Figure 5 A schematic diagram of a user interface is exemplarily shown;

[0037] Figure 6 is a block diagram of a text classification device provided by one embodiment of the present application;

[0038] Figure 7 is a block diagram of a text classification device provided by another embodiment of the present application;

[0039] Figure 8 This is a block diagram of a training device for a text classification model provided by one embodiment of the present application;

[0040] Figure 9 This is a structural block diagram of a computer device provided in one embodiment of the present application. DETAILED DESCRIPTION

[0041] In order to make the objectives, technical solutions and advantages of this application clearer, the implementation methods of this application will be further described in detail below with reference to the accompanying drawings.

[0042] Artificial Intelligence (AI) refers to the theories, methods, techniques, and application systems that use digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, to perceive the environment, acquire knowledge, and use that knowledge to achieve optimal results. In other words, AI is a comprehensive technology within computer science that seeks to understand the essence of intelligence and produce new intelligent machines that can respond in a manner similar to human intelligence. AI also studies the design principles and implementation methods of various intelligent machines, enabling them to possess the capabilities of perception, reasoning, and decision-making.

[0043] Artificial intelligence (AI) technology is a comprehensive discipline encompassing a wide range of fields, encompassing both hardware and software technologies. Foundational AI technologies generally include sensors, specialized AI chips, cloud computing, distributed storage, big data processing, operating / interaction systems, and mechatronics. AI software technologies primarily encompass computer vision, speech processing, natural language processing, and machine learning / deep learning.

[0044] Natural language processing (NLP) is a key area of ​​research in computer science and artificial intelligence. It studies the theories and methods that enable effective communication between humans and computers using natural language. Natural language processing (NLP) integrates linguistics, computer science, and mathematics. Therefore, research in this field involves natural language—the language we use in everyday life—and is closely linked to the study of linguistics. Natural language processing technologies typically include text processing, semantic understanding, machine translation, robotic question answering, and knowledge graphs.

[0045] Machine learning (ML) is a multidisciplinary field that encompasses probability theory, statistics, approximation theory, convex analysis, and algorithmic complexity theory. It specifically studies how computers can simulate or implement human learning behaviors to acquire new knowledge or skills and reorganize existing knowledge structures to continuously improve their performance. Machine learning is at the core of artificial intelligence and the fundamental way to make computers intelligent. Its applications span all areas of AI. Machine learning and deep learning typically include techniques such as artificial neural networks, belief networks, reinforcement learning, transfer learning, inductive learning, and learning through demonstration.

[0046] With the research and advancement of artificial intelligence technology, artificial intelligence technology has been studied and applied in many fields, such as common smart homes, smart wearable devices, virtual assistants, smart speakers, smart marketing, unmanned driving, autonomous driving, drones, robots, smart medical care, smart customer service, etc. It is believed that with the development of technology, artificial intelligence technology will be applied in more fields and play an increasingly important role.

[0047] The solution provided by the embodiments of this application involves artificial intelligence (AI) machine learning and other technologies. A text classification model is trained using sample feature information extracted from multiple sample texts, as well as category information corresponding to the sample texts. Optionally, a single sample text includes a first text and a second text, with the second text being a related text of the first text. For example, if the first text is a user's current medical history, the second text is the user's historical medical history; if the first text is a user's currently submitted article, the second text is the user's previously submitted text; and if the first text is a user's currently browsed webpage, the second text is a limited number of the user's recently browsed webpages. When acquiring sample feature information, feature extraction is performed on the first and second texts to obtain sample feature information corresponding to the first text. After the text classification model is trained, when a text to be tested is acquired, feature information corresponding to the text to be tested is extracted based on the text to be tested and its related texts. The text classification model processes this feature information to output a category detection result and result explanation information corresponding to the text to be tested. The category detection result includes the category distribution probability corresponding to the text to be tested, and the result description information describes the degree of influence of each feature in the feature information on the category detection result. In addition, in the embodiments of the present application, the above text classification model introduces a spatial attention mechanism and a sparse access level attention mechanism. The spatial attention mechanism is used to determine the importance of a single feature, and the sparse access level attention mechanism is used to determine the importance of the feature set in which the feature is located. The feature set includes features from the same text.

[0048] It should be noted that the text classification model provided in this application can be widely applied in various fields. The details are as follows:

[0049] (1) In the disease prediction scenario in the medical field, medical staff determine the current symptom description text based on the symptoms observed from the target object, and input the target object's identification information and symptom description text into the computer device. Furthermore, after obtaining the symptom description text, the computer device obtains the target object's historical medical record text based on the target object's identification information, and performs feature extraction processing on the current symptom description text and the historical medical record text to determine the target object's feature information, which includes at least one feature (such as the name of the symptom, the medication used for the symptom, etc.). Afterwards, a text classification model is used to process the target object's feature information to obtain the disease distribution probability and result interpretation information corresponding to the target object output by the text classification model. Among them, the disease distribution probability is used to indicate the diseases that the target object may have, as well as the probability value of each disease; the result interpretation information is used to describe the basis for obtaining the disease distribution probability. For example, the result interpretation information includes the degree of influence of each feature in the process of determining the disease distribution probability. Furthermore, based on the disease distribution probability corresponding to the target object and the result interpretation information, medical staff can quickly determine the user's corresponding disease and take corresponding measures based on the disease, thereby reducing the manual burden of medical staff.

[0050] (2) In the book classification scenario in the field of education, the staff uses the summary description text (preface, postscript, abstract, etc.) of the book to be classified as the text to be detected, and inputs the identification information of the book to be classified (the author of the book to be classified) and the text to be detected into the computer device. Furthermore, the computer device obtains related books (books with the same author as the book to be classified) based on the identification information of the data to be detected, and extracts features from the summary description text of the book to be classified and the summary description text of the related books to determine the feature information of the book to be detected, which includes at least one feature (keyword). Afterwards, the text classification model is used to process the feature information of the book to be classified to obtain the type distribution probability and result interpretation information of the book to be classified. Among them, the type distribution probability is used to indicate the subject to which the book to be classified may belong, as well as the probability value of belonging to each subject; the result interpretation information is used to describe the basis for obtaining the type distribution probability. For example, the result interpretation information includes the degree of influence of each feature in the process of determining the type distribution probability. Furthermore, based on the type distribution probability and result interpretation information of the books to be classified, the subject to which the book belongs can be quickly determined, and the book can be placed in a suitable location to facilitate subsequent students' search and learning. The rapid classification of books indirectly ensures the integrity of the information sought by students.

[0051] (3) In the user intention determination scenario in the field of artificial intelligence, after detecting the user to be served, the intelligent robot talks with the user to be served, obtains the user's words to generate the text to be detected, and determines whether the user to be served is an old user based on the user identity information of the user to be served. Optionally, the robot can start the identity recognition system to determine the user identity to obtain the user identity information, or the user to be served can actively provide the user identity. Furthermore, if the user to be served is an old user, the historical service information of the user to be served is obtained based on the user identity information to generate the associated text, and the feature extraction of the to-be-detected text and the associated text is performed to determine the feature information of the user to be served, which includes at least one feature (keyword). Afterwards, the feature information of the user to be served is processed using a text classification model to determine the intention distribution probability and the result interpretation information of the user to be served. Among them, the intention distribution probability is used to indicate the possible intention of the user to be served and the probability value corresponding to the intention; the result interpretation information is used to describe the basis for obtaining the intention distribution probability. For example, the result interpretation information includes the degree of influence of each feature in the determination process of the intention distribution probability. Furthermore, the intelligent robot determines the user needs of the user to be served based on the intention distribution probability and guides the user to the appropriate location.

[0052] Of course, the text classification model in this application can also be applied to various other fields, which are not listed here one by one.

[0053] For ease of explanation, in the following method embodiments, only a computer device is used as an example to describe the execution subject of each step. The computer device can be any electronic device with computing and storage capabilities. For example, the computer device can be a server, which can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers. It can also be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms. For another example, the computer device can also be a terminal, which can be a smartphone, tablet computer, laptop computer, desktop computer, smart speaker, smart watch, etc., but is not limited to this. The terminal and the server can be directly or indirectly connected via wired or wireless communication, and this application does not limit this. It should be noted that in the embodiments of this application, the execution subject of each step can be the same computer device, or it can be executed by multiple different computer devices interacting and cooperating, and this is not limited here. It should also be noted that in the embodiment of the present application, the execution entity of the following text classification method and the execution entity of the following text classification model training method can be the same computer device or different computer devices, and the embodiment of the present application does not limit this.

[0054] Below, the technical solution of this application will be described in detail with reference to several embodiments.

[0055] Please refer to Figure 1 , which shows a flowchart of a text classification method provided by an embodiment of the present application. The method may include the following steps (101-104):

[0056] Step 101: Obtain the text to be detected and the associated text corresponding to the text to be detected.

[0057] The text to be detected is a text of unknown category. In an embodiment of the present application, before classifying the text to be detected, the computer device obtains the text to be detected and obtains the associated text corresponding to the text to be detected. Among them, the associated text refers to the text that has an associated relationship with the text to be detected. Optionally, the associated relationship includes but is not limited to at least one of the following: having the same author, targeting the same object, having the same operator, having the same attribute information, etc., which is not limited in the embodiment of the present application. Among them, the above-mentioned attribute information includes the text browsing time, the text browsing time, the number of text browsing times, etc.

[0058] For example, taking the above-mentioned association relationship as an example for the same object, after obtaining the text to be detected, the computer device determines the target object (person, animal, object, weather, etc.) described by the text to be detected, and then based on the target object, obtains other texts for the target object as associated texts of the text to be detected.

[0059] In one possible implementation, a user proactively provides the above-mentioned text to be detected to a computer device. Optionally, the user determines the information to be detected based on actual conditions and inputs the text content corresponding to the information to be detected into the computer device or an associated device of the computer device. Furthermore, the computer device obtains the text content as the text to be detected. The text content can be input by text input, voice input, image input, gesture input, etc., which is not limited in this embodiment of the application.

[0060] In another possible implementation, the computer device actively obtains the text to be detected. Optionally, the computer device can obtain the text to be detected from a network environment or a specific device at a certain time interval. The time interval can be 1 second, 1 minute, 1 hour, 1 day, or 1 month, etc., and is not limited to this embodiment of the present application.

[0061] Of course, the computer device can flexibly set and adjust the method for obtaining the text to be detected based on actual conditions. For example, if the text to be detected is a disease to be detected, the computer device can obtain the text to be detected in real time and determine the disease of the user based on the text to be detected, thereby ensuring the timeliness of the disease detection; if the text to be detected is an article to be classified, the computer device obtains the text to be detected at a certain time interval and determines the article classification based on the text to be detected, and then stores the article in an appropriate location based on the article classification. While classifying the text to be detected, the computer device is operated according to a certain time period to avoid excessive load on the computer device at a certain moment.

[0062] The text to be detected may be directly input text or indirectly input text.

[0063] In one possible implementation, the text to be detected is text directly input by a user. After obtaining the user input, the computer device directly uses the input content as the text to be detected. In this case, the user input content is text content. Optionally, the input method of the above content can be text input, voice input, image input, gesture input, etc., which is not limited in this embodiment of the present application.

[0064] In another possible embodiment, the above-mentioned text to be detected is text indirectly input by the user. After obtaining the user input content, the computer device extracts the input content and uses the extracted text as the text to be detected. In this case, the user input content is voice content, image content, text content, etc., which is not limited by the embodiment of the present application. For example, in order to simplify user operations, the user can directly input an image, and then the computer device extracts the text to be detected based on the image. In this case, the text to be detected can be text information in the image.

[0065] Step 102: Perform feature extraction on the text to be detected and the associated text to obtain feature information.

[0066] In an embodiment of the present application, after obtaining the aforementioned text to be detected and associated text, the computer device performs feature extraction processing on the text to be detected and associated text to obtain feature information. The feature information includes at least one feature, which refers to a keyword extracted based on the content of the text record. For example, if the aforementioned text to be detected is a description of a disease, the feature information includes features such as the disease name and the medication used for the disease, and the feature is directly recorded in the disease description.

[0067] Optionally, when extracting feature information, the computer device filters out noise information in the text (text to be detected and related text), such as punctuation marks, emoticons, etc., and further performs word segmentation on the noise-removed text, and extracts entities as keywords, thereby generating the above-mentioned feature information.

[0068] Step 103: Use the attention mechanism to process the feature information and obtain the attention weight corresponding to each feature.

[0069] In an embodiment of the present application, after obtaining the above-mentioned feature information, the computer device uses an attention mechanism to process the feature information and obtains the attention weights corresponding to each feature. Wherein, the attention weight is used to indicate the importance of the feature for the above-mentioned text to be detected and the above-mentioned associated text. Optionally, the computer device can determine the importance of the feature for the text to be detected and the associated text based on the frequency of occurrence of the feature in the above-mentioned text to be detected and / or the above-mentioned associated text. Of course, the computer device can also determine the importance of the feature for the text to be detected and the associated text based on the correlation between the various features. For example, if a certain feature has a correlation with multiple features, it is determined that the feature is important. If a certain feature has a correlation with fewer features, it is determined that the feature is not important.

[0070] In the embodiment of the present application, the above-mentioned attention mechanism includes a spatial attention mechanism and a sparse access level attention mechanism. Among them, the spatial attention mechanism is used to measure the importance of a single feature, and the sparse access level attention mechanism is used to measure the importance of a feature set, which includes features from the same text.

[0071] Optionally, the above step 103 includes the following steps:

[0072] 1. Use the spatial attention mechanism to process each feature in the feature information and obtain the spatial attention weight corresponding to each feature;

[0073] 2. Based on the sources of each feature, features from the same text are combined and divided to obtain multiple feature sets; different feature sets include features from different texts;

[0074] 3. Use the sparse access level attention mechanism to process multiple sets of feature sets and obtain the sparse access level attention weights corresponding to each feature set.

[0075] In an embodiment of the present application, the above-mentioned attention weights include spatial attention weights and sparse access level attention weights.

[0076] Optionally, when obtaining the spatial attention weight, the computer device uses a spatial attention mechanism to process each feature in the feature information to obtain a spatial attention weight corresponding to each feature. The spatial attention weight is used to indicate the importance of a single feature in the feature information.

[0077] Optionally, when obtaining the sparse access level attention weights, the computer device combines and divides the features from the same text based on the source of each feature to obtain multiple sets of feature combinations. Different feature sets include features from different files, and the same feature set includes features from different files. Furthermore, the computer device uses a sparse access level attention mechanism to process multiple sets of feature sets and obtain the sparse access level attention weights corresponding to each feature set. The sparse access level attention weights are used to refer to the importance of a feature set.

[0078] Of course, in actual applications, a computer device can determine multiple sets of features when acquiring feature information. For example, after acquiring each feature, the computer device uses a feature vector to represent the feature set, with one feature vector corresponding to one feature set. Furthermore, multiple feature sets are combined into a feature matrix, and the feature information is represented by the feature matrix. In this case, the computer device can directly use a sparse access-level attention mechanism to process the feature information, without the need to combine and divide the individual features.

[0079] Step 104: Based on the feature information and the attention weight, obtain the category detection result and result explanation information corresponding to the text to be detected.

[0080] In an embodiment of the present application, after obtaining the feature information and the attention weights, the computer device obtains a category detection result and result interpretation information corresponding to the text to be detected based on the feature information and the attention weights. The category detection result includes the category distribution probability corresponding to the text to be detected, and the result interpretation information is used to describe the degree of influence of each feature on the category detection result.

[0081] The above-mentioned attention mechanism includes a spatial attention mechanism and a sparse access level attention mechanism. The spatial attention mechanism is used to indicate the importance of a single feature, and the sparse access level attention mechanism is used to indicate the importance of a feature set, where the feature set includes features from the same text. Optionally, the above-mentioned step 104 includes the following steps:

[0082] 1. Obtain the spatial attention weight and sparse access level attention weight corresponding to the feature;

[0083] 2. Determine the final attention weight corresponding to the feature based on the spatial attention weight and the sparse access level attention weight;

[0084] 3. Based on the final attention weight and the embedding vector corresponding to the feature, determine the contribution coefficient corresponding to the feature.

[0085] In the embodiment of the present application, when obtaining the above-mentioned result explanation information, the computer device traverses each feature in the feature information, obtains the contribution coefficient corresponding to each feature, and then generates the result explanation information. The result explanation information includes the contribution coefficient corresponding to each feature.

[0086] Taking a single feature as an example, when obtaining the contribution coefficient corresponding to the feature, the computer device obtains the spatial attention weight and sparse access level attention weight corresponding to the feature. The spatial attention weight is used to indicate the importance of a single feature, and the sparse access level attention weight is used to indicate the importance of the feature set in which the feature is located. Furthermore, based on the spatial attention weight and the sparse access level attention weight, the final attention weight corresponding to the feature is determined. Based on the final attention weight and the embedding vector corresponding to the feature, the contribution coefficient corresponding to the feature is determined.

[0087] Optionally, after obtaining the category detection results and result explanation information, the computer device can display the category detection results and result explanation information to the user. Furthermore, the user can determine the possible categories of the text to be detected based on the category detection results, as well as the probability values ​​corresponding to each category of the text to be detected. Moreover, the user can determine the basis for obtaining the category detection results based on the result explanation information.

[0088] To sum up, in the technical solution provided by the embodiment of the present application, feature information is processed through the attention mechanism to determine the attention weight used to indicate the importance of each feature to the text, and then the category detection result and result explanation information are obtained based on the special information and the attention weight. On the one hand, the category detection result includes the category distribution probability, so that the category detection result has diversity, avoiding the single output caused by outputting only one category; on the other hand, the result explanation information is used to describe the degree of influence of each feature on the category detection result, provide explainability for the category detection result, and improve the credibility of the category detection result. The user can determine the basis for obtaining the category detection result based on the result explanation information, so that the user can understand the category detection result more intuitively.

[0089] In addition, when classifying the text to be detected, the related text is combined to ensure the accuracy of the category detection results; moreover, for a single feature, the spatial attention mechanism is used to measure the importance of the single feature, and the sparse access level attention mechanism is used to measure the importance of the feature set, and the feature set includes features from the same text. Subsequently, the spatial attention weight and sparse access level attention weight are used to determine the contribution coefficient of the feature, ensuring the accuracy of the contribution evaluation of the feature, making the result interpretation information for the category detection results more reliable.

[0090] Optionally, in an embodiment of the present application, the above method can also be implemented by a text classification model, that is, the above category detection result and the above result explanation information are obtained by the text classification model through the above feature information. Wherein, the text classification model uses different model parameters to process the feature information multiple times. Optionally, the above category detection result includes n groups of category detection sub-results, and the above result explanation information includes n result explanation sub-information corresponding to the n groups of category detection sub-results, where n is a positive integer. It should be noted that the above category detection sub-results and the above result explanation sub-information have a one-to-one correspondence, that is, after the text classification model uses a certain set of model parameters to process the feature information, it can obtain the category detection sub-results and result explanation sub-information processed this time.

[0091] In an embodiment of the present application, after obtaining the above-mentioned category detection result and result explanation information, the computer device averages the category detection sub-results in the category detection result and averages the result explanation sub-information in the result explanation information.

[0092] Optionally, the processing steps for the category detection results are as follows:

[0093] 1. Obtain the probability value corresponding to the target category from each of the n groups of category detection sub-results;

[0094] 2. Average the probability values ​​of the target category to obtain the final probability value corresponding to the target category;

[0095] 3. Generate the final category detection result corresponding to the text to be detected. The final category detection result includes the final probability value corresponding to each category.

[0096] The category detection sub-result includes the category distribution probability corresponding to the text to be detected. Different category detection results are obtained by processing the text to be detected using different model parameters in a text classification model. In other words, the category distribution probabilities included in different category detection results vary. In this embodiment of the present application, after obtaining the aforementioned n groups of category detection sub-results, the computer device averages the category probability distributions in these n groups of category detection sub-results.

[0097] Optionally, after obtaining the n groups of category detection sub-results, the computer device obtains probability values ​​corresponding to the target category from each of the n groups of category detection sub-results. The target category can be any category in any detection result for the text to be detected. Furthermore, the computer device averages the probability values ​​of the target category to obtain a final probability value corresponding to the target category, thereby generating a final category detection result corresponding to the text to be detected. The final category detection result includes the final probability values ​​corresponding to each category.

[0098] Optionally, the processing steps for the result interpretation information are as follows:

[0099] 1. Obtain the contribution coefficient corresponding to the target feature from each of the n result explanation sub-information;

[0100] 2. Average the contribution coefficients corresponding to the target features to obtain the final contribution coefficients corresponding to the target features;

[0101] 3. Generate final result explanation information corresponding to the text to be detected, where the final result explanation information includes the final contribution coefficient corresponding to each of the features.

[0102] The result explanation sub-information includes the contribution coefficient corresponding to each feature. Different result explanation sub-information is obtained after the text classification model uses different model parameters to process the text to be tested. In other words, the contribution coefficients corresponding to the features contained in different result explanation sub-information vary. In this embodiment of the present application, after obtaining the aforementioned n sets of result explanation sub-information, the computer device averages the contribution coefficients in these n sets of result explanation sub-information.

[0103] Optionally, after obtaining the n result explanation sub-information, the computer device obtains contribution coefficients corresponding to target features from each of the n result explanation sub-information. The target feature can be any feature. Furthermore, the computer device averages the contribution coefficients of the target feature to obtain a final contribution coefficient corresponding to the target feature, and then generates final result explanation information corresponding to the text to be detected. The final result explanation information includes the final contribution coefficients corresponding to each feature.

[0104] Optionally, in an embodiment of the present application, after the computer device obtains the above-mentioned final category detection result, it can determine the confidence level of the text classification model for the text to be detected based on the final category detection result. The specific steps are as follows:

[0105] 1. Based on the final probability values ​​corresponding to each category, obtain the measurement parameters of the final category detection results; wherein the measurement parameters are used to measure the degree of confusion of the final category detection results;

[0106] 2. Determine the confidence level of the text classification model for the text to be detected based on the measurement parameters;

[0107] 3. In response to the confidence level satisfying the condition, determining that the final category detection result is an accurate detection result;

[0108] 4. In response to the confidence level not meeting the conditions, generating manual prompt information, the manual prompt information is used to remind the to-be-detected text to be manually detected.

[0109] The above-mentioned measurement parameter can be the variance or entropy of the category distribution probability in the final category detection result. The measurement parameter is positively correlated with the degree of confusion, that is, the larger the measurement parameter, the more chaotic the final category detection result. In an embodiment of the present application, after obtaining the above-mentioned final category detection result, the computer device obtains the measurement parameter of the final detection result based on the final probability values ​​corresponding to each category in the final category detection result, and determines the confidence of the text classification model for the text to be detected based on the measurement parameter. Among them, the confidence is proportional to the reliability of the text classification model for the text to be detected, that is, the higher the confidence, the more reliable the text classification model is for the classification of the text to be detected.

[0110] The above conditions refer to judgment conditions for confidence. For example, the condition is that the confidence is greater than a threshold value. In an embodiment of the present application, after obtaining the above confidence, the computer device detects the confidence. If the confidence meets the conditions, it is determined that the reliability of the text classification model for the text to be detected meets the requirements, and the above final category detection result is determined to be an accurate detection result; if the confidence does not meet the conditions, it is determined that the reliability of the text classification model for the text to be detected does not meet the requirements, and then an artificial prompt message is generated to remind the staff to perform manual detection on the text to be detected. Of course, in actual application, the staff can adjust the above conditions. For example, when the uncertainty is determined based on the measurement parameters, the condition is set to be less than the target value.

[0111] Optionally, the above-mentioned different model parameters are obtained based on multiple random samplings. For example, when processing the model to be detected, before each processing of the text to be detected, Monte Carlo sampling is used to obtain a set of model parameters, and then the text to be detected is processed based on the model parameters. Of course, in actual application, the methods for obtaining multiple sets of different model parameters can be flexibly configured and adjusted according to actual conditions, and this embodiment of the present application is not limited to this.

[0112] Next, the training method of the text classification model in this application is introduced.

[0113] Please refer to Figure 2 , which shows a flow chart of a method for training a text classification model provided by an embodiment of the present application. The method may include the following steps (201-203):

[0114] Step 201: Acquire multiple sample texts and category information corresponding to each sample text.

[0115] Sample text refers to text of known categories. In an embodiment of the present application, before training the text classification model, the computer device obtains multiple sample texts and obtains the category information corresponding to each sample text. Among them, a single sample text includes a first text and a second text, and the second text is an associated text of the first text. For example, if the first text is the user's current disease text, the second text is the user's historical medical history text; if the first text is the user's current submitted article, the second text is the user's historical submitted text; if the first text is the user's current browsing web page, the second text is a limited number of historical browsing web pages that the user has recently browsed.

[0116] Step 202: Extract sample feature information from each sample text.

[0117] In an embodiment of the present application, after obtaining the sample texts, the computer device extracts sample feature information from each sample text. The sample feature information includes at least one sample feature, which refers to keywords extracted from the text record content. Optionally, when extracting the sample feature information, the computer device filters and removes noise information, such as punctuation marks and emoticons, from the sample texts. Furthermore, the computer device performs word segmentation on the noise-removed sample texts and extracts entities as keywords, thereby generating the sample feature information.

[0118] Step 203: Use the sample feature information and category information to train the text classification model.

[0119] In an embodiment of the present application, after obtaining the sample feature information, the computer device uses the sample feature information and the category information to train a text classification model. Optionally, based on the correspondence between the sample text and the sample feature information, the computer device uses the category information as label information for the sample feature information, generates training samples, and uses the training samples to train the text classification model.

[0120] Optionally, during the training of the text classification model, the computer device uses multiple sets of model parameters, processes the sample feature information multiple times, obtains multiple sets of model output results, and determines a loss function value for the text classification model based on the multiple sets of model output results and the category information. The loss function is used to indicate the accuracy of the output results of the text classification model. The computer device then adjusts the parameters of the text classification model based on the loss function value until the loss function converges.

[0121] For example, the loss function of the text classification model is Lesm:

[0122]

[0123] Among them, Tmc refers to the number of times the text classification model processes the sample feature information, and each time different model parameters are used to process the sample feature information, N refers to the number of sample feature information, C refers to the sample feature information, and c refers to the features in the sample feature information. Refers to the category information corresponding to the feature information of the i-th sample, refers to the jth output result of the text classification model, l refers to the number of categories output by the text classification model, λ refers to the balance parameter of the text classification model, L refers to the number of network layers of the text classification model, W k 、b k Refers to the model parameters corresponding to the k-th layer network.

[0124] Optionally, in the implementation of this application, an attention mechanism is introduced into the above-mentioned text classification model, and the attention mechanism is used to determine the importance of each sample feature in the sample feature information for the sample text, and the importance is used to determine the degree of influence of each sample feature on the model output result. Optionally, the above-mentioned attention mechanism includes a spatial attention mechanism and a sparse access level attention mechanism. In actual application, the spatial attention mechanism is used to measure the importance of a single feature, and the sparse access level attention mechanism is used to measure the importance of a feature set, which includes features from the same text.

[0125] To sum up, in the technical solution provided in the embodiment of the present application, a text classification model is obtained by training sample feature information and category information, and an attention mechanism is introduced into the text classification model. During the application of the model, the attention mechanism is used to process the feature information and determine the attention weight used to indicate the importance of each feature to the text. When the model outputs the result, it can also output the basis for obtaining the result, so that users can understand the results output by the model more intuitively.

[0126] Below, combined with reference Figure 3 , taking the medical field as an example, the text classification method in this application is introduced. In the medical field, the above text classification model can be used for disease prediction.

[0127] Step 301: Obtain the current symptom description text of the target object and the historical medical record text of the target object.

[0128] The target subject is any user who is performing disease prediction. The current symptom description text is used to indicate the symptom currently present in the target subject. Optionally, the current symptom description text is text information determined by medical personnel based on the actual condition of the target subject and input into the computer device.

[0129] In an embodiment of the present application, before performing a disease prediction on a target subject, a text describing the target subject's current condition and the target subject's historical medical records are obtained. Optionally, after determining to perform a disease prediction on the target subject, the computer device retrieves the target subject's historical medical records from a medical record repository based on the target subject's identification information. The identification information uniquely identifies the target subject and, for example, may be an ID number, a unique number assigned by a hospital, or a mobile phone number.

[0130] Of course, in actual application, the above-mentioned historical medical record text can also be obtained by medical staff based on paper document summaries and input into computer equipment.

[0131] Step 302: Perform feature extraction processing on the current medical record description text and the historical medical record description text to obtain medical record feature information.

[0132] In the embodiment of the present application, after obtaining the current medical record description text and the historical medical record description text, the computer device performs feature extraction processing on the current medical record description text and the historical medical record description text to obtain medical record feature information. The medical record feature information includes medical record features, which are keywords extracted from the recorded content of the current medical record description text or the historical medical record description text, such as the name of the disease, the medication used for the disease, etc.

[0133] Optionally, in the embodiment of the present application, when the computer device extracts features from each medical record text, the medical record features extracted from the same medical record text are used as a medical record feature set, and then the medical record feature information is obtained by combining multiple medical record feature sets. For example, Figure 4 As shown, the medical record feature information 41 is represented in the form of a matrix. The medical record features in each column are a medical record feature set. The medical record feature sets are sorted according to the generation time of each medical record text. The medical record feature set corresponding to the earliest generated medical record text is arranged in the first column, and the medical record feature set corresponding to the latest generated medical record text is arranged in the last column.

[0134] Step 303: Input the medical record feature information into the text classification model to obtain the disease prediction results and result explanation information output by the text classification model.

[0135] The text classification model is a deep learning model obtained through training. In the embodiment of the present application, after obtaining the above-mentioned medical record feature information, the computer device inputs the medical record feature information into the text classification model, and then obtains the disease prediction results and result interpretation information output by the text classification model. The disease prediction results include the disease prediction probability distribution for the target subject, and the result interpretation information is used to describe the degree of influence of each symptom feature on the disease prediction result.

[0136] Optionally, a spatial attention mechanism and a sparse access level attention mechanism are introduced into the text classification model. For example, Figure 4As shown, after the medical record feature information 41 is input into the text classification model, the embedded vector of the disease feature set corresponding to each medical record text is obtained through the fully connected layer 42, and then the feature encoder 43 captures the complex correlation between the input disease features, and maps the embedded matrix of the disease feature information of the target object to the hidden state. Then, according to the spatial attention mechanism 44, a spatial attention weight for measuring the importance of a single disease feature is generated, and according to the sparse access level attention mechanism 45, a sparse access level attention weight for measuring the importance of the disease feature set is generated. Then, the embedded matrix, spatial attention weight, and sparse access level attention weight of the disease feature information are input into the patient representation module 46 to obtain the representation information of the target object, and then the representation information is mapped to a logical value through the linear layer 47. Finally, according to the classifier 48, the logical value is converted into a probability value, and then the disease prediction result is generated. In addition, in the process of the text classification model processing the disease feature information 41, the spatial attention weight, sparse access level attention mechanism, and embedded vector of the disease feature are used to determine the contribution coefficient corresponding to the disease feature.

[0137] For example, assuming that the feature matrix of the disease feature information is X, the embedding vector E obtained by the fully connected layer is:

[0138] E=W e X;

[0139] Among them, W e is a learnable parameter matrix;

[0140] After the embedding matrix of the disease feature information is mapped to the hidden state, H is:

[0141] H = f(E);

[0142] Where f() is any suitable neural network-based feature encoder, such as recurrent neural network, convolutional neural network, etc.

[0143] The spatial attention weight β is:

[0144] β=tanh(W β H+b β );

[0145] Among them, W β 、b β are model parameters;

[0146] The sparse access level attention mechanism α is:

[0147] α=(softmax(δ)+sparsemax(δ)) / 2;

[0148] Where δ = W β H+b δ, W δ 、b δ are model parameters;

[0149] The patient representation E obtained by the patient representation module r for:

[0150] E r =α(β⊙E) T ;

[0151] Er is the logical value obtained by linear layer mapping for:

[0152]

[0153] Among them, W c 、b c are model parameters;

[0154] Logical value The probability value y obtained by classifier conversion * for:

[0155]

[0156] The contribution coefficient CM[t, m] obtained for the mth disease feature in the tth detection is:

[0157] CM[t, m] = W c T (α[t]β[:,t]⊙W e [:,m]);

[0158] Among them, α[t] refers to the sparse access level attention weight of the mth disease feature obtained for the tth detection of disease feature information, and β[:,t] refers to the spatial attention weight of the mth disease feature obtained for the tth detection of disease feature information. e [:,m] refers to the embedding vector of the mth disease feature.

[0159] It should be noted that the above content is an introduction to a single test of the text classification model. In actual application, the text classification model uses different model parameters to perform multiple tests on the same disease characteristic information, and then averages the results obtained from multiple tests to obtain the final disease prediction result and the final result explanation information.

[0160] Step 304: Display the disease prediction results and result explanation information in the user interface.

[0161] In an embodiment of the present application, after a computer device obtains disease prediction results and result explanation information through a text classification model, it displays the disease prediction results and result explanation information in a user interface. The result explanation information may be displayed on the same interface as the disease prediction results or on a different interface, which is not limited in this embodiment of the present application.

[0162] For example, Figure 5 As shown, the user interface 50 includes a description text 51 of the current condition of the target object and a disease prediction result 52 obtained by the text classification model. Optionally, after the user clicks a control 53, the result explanation information is displayed in the user interface.

[0163] The following are device embodiments of the present application, which can be used to implement the method embodiments of the present application. For details not disclosed in the device embodiments of the present application, please refer to the method embodiments of the present application.

[0164] Please refer to Figure 6 , which shows a block diagram of a text classification device provided by one embodiment of the present application. This device has the functionality to implement the aforementioned text classification method. This functionality can be implemented by hardware or by hardware executing corresponding software. This device can be a computer device or can be incorporated into a computer device. This device 600 may include: a text acquisition module 610, a feature extraction module 620, a weight acquisition module 630, and a result acquisition module 640.

[0165] The text acquisition module 610 is used to acquire the text to be detected and the associated text corresponding to the text to be detected.

[0166] The feature extraction module 620 is configured to perform feature extraction processing on the text to be detected and the associated text to obtain feature information; wherein the feature information includes at least one feature.

[0167] The weight acquisition module 630 is used to process the feature information using an attention mechanism to obtain the attention weight corresponding to each feature, where the attention weight is used to indicate the importance of the feature to the text to be detected and the associated text.

[0168] The result acquisition module 640 is used to obtain the category detection result and result explanation information corresponding to the text to be detected based on the feature information and the attention weight; wherein, the category detection result includes the category distribution probability corresponding to the text to be detected, and the result explanation information is used to describe the degree of influence of each of the features on the category detection result.

[0169] In an exemplary embodiment, the result acquisition module 640 is used to obtain the spatial attention weight and sparse access level attention weight corresponding to the feature; wherein the spatial attention weight is used to indicate the importance of a single feature, and the sparse access level attention weight is used to indicate the importance of the feature set in which the feature is located, and the feature set includes features from the same text; based on the spatial attention weight and the sparse access level attention weight, the final attention weight corresponding to the feature is determined; based on the final attention weight and the embedding vector corresponding to the feature, the contribution coefficient corresponding to the feature is determined; wherein the result interpretation information includes the contribution coefficient corresponding to each feature.

[0170] In an exemplary embodiment, the weight acquisition module 630 is used to adopt a spatial attention mechanism to process each of the features in the feature information and obtain the spatial attention weights corresponding to each of the features; based on the sources of each of the features, the features from the same text are combined and divided to obtain multiple groups of feature sets; wherein different feature sets include features from different texts; and a sparse access level attention mechanism is adopted to process the multiple groups of feature sets and obtain the sparse access level attention weights corresponding to each of the feature sets.

[0171] In an exemplary embodiment, the category detection result is obtained by a text classification model through the feature information; wherein, the text classification model uses different model parameters to process the feature information multiple times, the category detection result includes n groups of category detection sub-results, and the result explanation information includes n result explanation sub-information corresponding to the n groups of category detection sub-results, the category detection sub-results and the result explanation sub-information have a one-to-one correspondence, and n is a positive integer.

[0172] In an exemplary embodiment, as Figure 7 As shown, the device 600 further includes: a result processing module 650.

[0173] The result processing module 650 is used to obtain the probability values ​​corresponding to the target category from the n groups of category detection sub-results; average the probability values ​​of the target category to obtain the final probability value corresponding to the target category; and generate the final category detection result corresponding to the text to be detected, wherein the final category detection result includes the final probability values ​​corresponding to each category.

[0174] In an exemplary embodiment, as Figure 7 As shown, the device 600 further includes: a confidence detection module 660.

[0175] The confidence detection module 660 is used to obtain the measurement parameters of the final category detection result based on the final probability values ​​corresponding to each of the categories; wherein the measurement parameters are used to measure the degree of confusion of the final category detection result; according to the measurement parameters, the confidence of the text classification model for the text to be detected is determined; in response to the confidence meeting the conditions, the final category detection result is determined to be an accurate detection result; in response to the confidence not meeting the conditions, an artificial prompt information is generated, and the artificial prompt information is used to remind the manual detection of the text to be detected.

[0176] In an exemplary embodiment, the different model parameters are obtained based on multiple random samplings.

[0177] To sum up, in the technical solution provided by the embodiment of the present application, feature information is processed through the attention mechanism to determine the attention weight used to indicate the importance of each feature to the text, and then the category detection result and result explanation information are obtained based on the special information and the attention weight. On the one hand, the category detection result includes the category distribution probability, so that the category detection result has diversity, avoiding the single output caused by outputting only one category; on the other hand, the result explanation information is used to describe the degree of influence of each feature on the category detection result, provide explainability for the category detection result, and improve the credibility of the category detection result. The user can determine the basis for obtaining the category detection result based on the result explanation information, so that the user can understand the category detection result more intuitively.

[0178] Please refer to Figure 8 , which shows a block diagram of a text classification model training device provided by one embodiment of the present application. This device has the function of implementing the above-mentioned text classification model training method. This function can be implemented by hardware or by hardware executing corresponding software. The device can be a computer device or can be installed in a computer device. The device 800 may include: a sample acquisition module 810, a feature acquisition module 820, and a model training module 830.

[0179] The sample acquisition module 810 is configured to acquire a plurality of sample texts and category information corresponding to each of the sample texts.

[0180] The feature acquisition module 820 is used to extract sample feature information from each of the sample texts.

[0181] The model training module 830 is used to train the text classification model using the sample feature information and the category information; wherein, the attention mechanism is introduced into the text classification model, and the attention mechanism is used to determine the importance of each sample feature in the sample feature information for the sample text, and the importance is used to determine the influence of each sample feature on the model output result.

[0182] In an exemplary embodiment, the model training module 830 is used to use multiple sets of model parameters to process the sample feature information multiple times to obtain multiple sets of model output results; based on the multiple sets of model output results and the category information, determine the loss function value of the text classification model; wherein the loss function is used to indicate the accuracy of the output results of the text classification model; based on the loss function value, adjust the parameters of the text classification model until the loss function converges.

[0183] In an exemplary embodiment, the attention mechanism includes a spatial attention mechanism and a sparse access level attention mechanism; wherein the spatial attention mechanism is used to measure the importance of a single feature, and the sparse access level attention mechanism is used to measure the importance of a feature set, wherein the feature set includes features from the same text.

[0184] To sum up, in the technical solution provided in the embodiment of the present application, a text classification model is obtained by training sample feature information and category information, and an attention mechanism is introduced into the text classification model. During the application of the model, the attention mechanism is used to process the feature information and determine the attention weight used to indicate the importance of each feature to the text. When the model outputs the result, it can also output the basis for obtaining the result, so that users can understand the results output by the model more intuitively.

[0185] It should be noted that the apparatus provided in the above embodiments, when implementing its functions, is only illustrated by the division of the above functional modules. In actual 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 apparatus and method embodiments provided in the above embodiments are based on the same concept. The specific implementation process is detailed in the method embodiment and will not be repeated here.

[0186] Please refer to Figure 9 , which shows a block diagram of a computer device provided in one embodiment of the present application. The computer device can be used to implement the functions of the above-mentioned text classification method or text classification model training method.

[0187] Specifically:

[0188] Computer device 900 includes a central processing unit (CPU) 901, a system memory 904 including a random access memory (RAM) 902 and a read-only memory (ROM) 903, and a system bus 905 connecting system memory 904 and CPU 901. Computer device 900 also includes a basic input / output (I / O) system 906 that facilitates information transfer between various components within the computer, and a mass storage device 907 for storing an operating system 913, application programs 914, and other program modules 915.

[0189] The basic input / output system 906 includes a display 908 for displaying information and an input device 909, such as a mouse and keyboard, for user input. Both the display 908 and the input device 909 are connected to the central processing unit 901 via an input / output controller 910 connected to the system bus 905. The basic input / output system 906 may also include an input / output controller 910 for receiving and processing input from a variety of other devices, such as a keyboard, mouse, or electronic stylus. Similarly, the input / output controller 910 also provides output to a display screen, printer, or other types of output devices.

[0190] The mass storage device 907 is connected to the central processing unit 901 via a mass storage controller (not shown) connected to the system bus 905. The mass storage device 907 and its associated computer-readable media provide non-volatile storage for the computer device 900. In other words, the mass storage device 907 may include a computer-readable medium (not shown) such as a hard disk or a CD-ROM (Compact Disc Read-Only Memory) drive.

[0191] Without loss of generality, computer-readable media may include computer storage media and communication media. Computer storage media include volatile and non-volatile, removable and non-removable media implemented by any method or technology for storing information such as computer-readable instructions, data structures, program modules or other data. Computer storage media include RAM, ROM, EPROM (Erasable Programmable Read Only Memory), EEPROM (Electrically Erasable Programmable Read Only Memory), flash memory or other solid-state storage technologies, CD-ROM, DVD (Digital Video Disc) or other optical storage, tape cassettes, magnetic tape, disk storage or other magnetic storage devices. Of course, those skilled in the art will appreciate that computer storage media are not limited to the above-mentioned ones. The above-mentioned system memory 904 and mass storage device 907 can be collectively referred to as memory.

[0192] According to various embodiments of the present application, the computer device 900 may also be connected to a remote computer on a network such as the Internet for operation. That is, the computer device 900 may be connected to a network 912 via a network interface unit 911 connected to the system bus 905, or the network interface unit 911 may be used to connect to other types of networks or remote computer systems (not shown).

[0193] The memory further includes a computer program, which is stored in the memory and configured to be executed by one or more processors to implement the above-mentioned text classification method or the above-mentioned text classification model training method.

[0194] In an exemplary embodiment, a computer-readable storage medium is also provided, in which at least one instruction, at least one program, a code set or an instruction set is stored. When the at least one instruction, the at least one program, the code set or the instruction set is executed by a processor, the at least one instruction, the at least one program, the code set or the instruction set is used to implement the above-mentioned text classification method, or the training method of the above-mentioned text classification model.

[0195] Optionally, the computer-readable storage medium may include: ROM (Read Only Memory), RAM (Random Access Memory), SSD (Solid State Drives), or an optical disk, etc. Among them, the random access memory may include ReRAM (Resistance Random Access Memory) and DRAM (Dynamic Random Access Memory).

[0196] In an exemplary embodiment, a computer program product or computer program is also provided. The computer program product or computer program includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the above-described text classification method or the above-described method for training a text classification model.

[0197] It should be understood that the "multiple" mentioned in this article refers to two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent three situations: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the previous and subsequent associated objects are in an "or" relationship. In addition, the step numbers described in this article only illustrate a possible execution sequence between the steps. In some other embodiments, the above steps may not be executed in the order of the numbers, such as two steps with different numbers are executed at the same time, or two steps with different numbers are executed in the opposite order to the diagram. The embodiments of the present application do not limit this.

[0198] The above description is merely an exemplary embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application shall be included in the scope of protection of the present application.

Claims

1. A text classification method, characterized in that: The method comprises: Obtaining the text to be detected and the associated text corresponding to the text to be detected; Performing feature extraction processing on the text to be detected and the associated text to obtain feature information; wherein the feature information includes at least one feature; Using a spatial attention mechanism, each feature in the feature information is processed to obtain a spatial attention weight corresponding to each feature; Based on the sources of the respective features, the features from the same text are combined and divided to obtain multiple feature sets, where different feature sets include features from different texts; Using a sparse access level attention mechanism, the plurality of feature sets are processed to obtain sparse access level attention weights corresponding to the respective feature sets; Based on the feature information and attention weight, the category detection result and result explanation information corresponding to the text to be detected are obtained; wherein, the category detection result includes the category distribution probability corresponding to the text to be detected, and the result explanation information is used to describe the degree of influence of each of the features on the category detection result, and the attention weight includes the spatial attention weight and the sparse access level attention weight.

2. The method according to claim 1, characterized in that The obtaining result interpretation information corresponding to the text to be detected based on the feature information and the attention weight includes: Determining a final attention weight corresponding to the feature according to the spatial attention weight and the sparse access level attention weight; Determining a contribution coefficient corresponding to the feature based on the final attention weight and the embedding vector corresponding to the feature; The result explanation information includes the contribution coefficient corresponding to each feature.

3. The method according to claim 1 or 2, characterized in that The category detection result is obtained by the text classification model through the feature information; In which, the text classification model uses different model parameters to process the feature information multiple times, the category detection result includes n groups of category detection sub-results, and the result explanation information includes n result explanation sub-information corresponding to the n groups of category detection sub-results. The category detection sub-results and the result explanation sub-information have a one-to-one correspondence, and n is a positive integer.

4. The method according to claim 3, characterized in that After obtaining the category detection result corresponding to the text to be detected based on the feature information and the attention weight, the method further includes: Obtaining probability values ​​corresponding to the target categories from the n groups of category detection sub-results respectively; Averaging the probability values ​​of the target category to obtain a final probability value corresponding to the target category; A final category detection result corresponding to the text to be detected is generated, wherein the final category detection result includes final probability values ​​corresponding to each category.

5. The method according to claim 4, characterized in that After generating the final category detection result corresponding to the text to be detected, the method further includes: Based on the final probability values ​​corresponding to the respective categories, obtaining a measurement parameter of the final category detection result; wherein the measurement parameter is used to measure the degree of confusion of the final category detection result; Determining the confidence of the text classification model for the text to be detected based on the measurement parameter; In response to the confidence level satisfying a condition, determining that the final category detection result is an accurate detection result; In response to the confidence level not meeting a condition, manual prompt information is generated, where the manual prompt information is used to prompt manual detection of the text to be detected.

6. The method according to claim 3, characterized in that After obtaining result explanation information corresponding to the text to be detected based on the feature information and the attention weight, the method further includes: Obtaining contribution coefficients corresponding to target features from the n result explanation sub-information respectively; Averaging the contribution coefficients corresponding to the target features to obtain a final contribution coefficient corresponding to the target features; Generate final result explanation information corresponding to the text to be detected, wherein the final result explanation information includes final contribution coefficients corresponding to each of the features.

7. The method according to claim 3, characterized in that The different model parameters are obtained based on multiple random samplings.

8. A method for training a text classification model, characterized in that: The method comprises: Obtaining multiple sample texts and category information corresponding to each of the sample texts; Extracting sample feature information from each of the sample texts; Training the text classification model using the sample feature information and the category information; Among them, the text classification model introduces a spatial attention mechanism and a sparse access level attention mechanism. The spatial attention mechanism is adopted to process each feature in the sample feature information to obtain the spatial attention weights corresponding to each feature. The sparse access level attention mechanism is adopted to process multiple groups of feature sets to obtain the sparse access level attention weights corresponding to each feature set. The multiple groups of feature sets are obtained by combining and dividing the features from the same text based on the sources of each feature. Different feature sets include features from different texts.

9. The method according to claim 8, characterized in that The adopting the sample feature information and the category information to train the text classification model includes: Using multiple sets of model parameters, the sample feature information is processed multiple times to obtain multiple sets of model output results; Determining a loss function value of the text classification model based on the multiple groups of model output results and the category information; wherein the loss function is used to indicate the accuracy of the output results of the text classification model; Parameters of the text classification model are adjusted based on the loss function value until the loss function converges.

10. A text classification device, characterized in that: The device comprises: A text acquisition module, used to acquire the text to be detected and the associated text corresponding to the text to be detected; A feature extraction module, configured to perform feature extraction processing on the text to be detected and the associated text to obtain feature information; wherein the feature information includes at least one feature; A weight acquisition module is used to process each of the features in the feature information using a spatial attention mechanism to obtain the spatial attention weight corresponding to each of the features; The weight acquisition module is further configured to combine and divide the features from the same text based on the sources of the features to obtain multiple feature sets, where different feature sets include features from different texts; The weight acquisition module is further configured to process the plurality of feature sets using a sparse access level attention mechanism to obtain the sparse access level attention weights corresponding to the respective feature sets; A result acquisition module is used to obtain the category detection result and result explanation information corresponding to the text to be detected based on the feature information and attention weight; wherein, the category detection result includes the category distribution probability corresponding to the text to be detected, and the result explanation information is used to describe the degree of influence of each of the features on the category detection result, and the attention weight includes the spatial attention weight and the sparse access level attention weight.

11. A training device for a text classification model, characterized in that: The device comprises: A sample acquisition module, configured to acquire a plurality of sample texts and category information corresponding to each of the sample texts; A feature acquisition module, configured to extract sample feature information from each of the sample texts; A model training module, configured to train the text classification model using the sample feature information and the category information; Among them, the text classification model introduces a spatial attention mechanism and a sparse access level attention mechanism. The spatial attention mechanism is adopted to process each feature in the sample feature information to obtain the spatial attention weights corresponding to each feature. The sparse access level attention mechanism is adopted to process multiple groups of feature sets to obtain the sparse access level attention weights corresponding to each feature set. The multiple groups of feature sets are obtained by combining and dividing the features from the same text based on the sources of each feature. Different feature sets include features from different texts.

12. A computer device, characterized in that: The computer device includes a processor and a memory, wherein the memory stores at least one program, and the at least one program is loaded and executed by the processor to implement the text classification method according to any one of claims 1 to 7, or to implement the training method of the text classification model according to claim 8 or 9.

13. A computer-readable storage medium, characterized in that The storage medium stores at least one program, which is loaded and executed by the processor to implement the text classification method according to any one of claims 1 to 7, or the training method of the text classification model according to claim 8 or 9.

14. A computer program product, characterized in that The computer program product includes a computer program, which is executed by a processor to implement the text classification method according to any one of claims 1 to 7, or the text classification model training method according to claim 8 or 9.