Artificial intelligence-based text classification method, device, computer equipment and medium
By obtaining the attributes and content entries of table text and using semantic models and association discrimination models to determine associated entries, the problem of low accuracy in table text classification is solved and higher text classification accuracy is achieved.
Patent Information
- Application Number
- CN202211422861.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-14
- Publication Date
- 2025-10-03
- Estimated Expiration
- 2042-11-14
AI Technical Summary
In financial and electronic transaction scenarios, conventional text classification models find it difficult to accurately extract semantic features from tabular text due to its discrete distribution of entries and incoherent word order, resulting in low accuracy in tabular text classification.
By obtaining the attribute terms and content terms in the table text, the word embedding vector is extracted using the trained semantic model, the related terms are determined by combining the position distance and association discrimination model, the feature information is fused by encoding, and input into the classification model for text classification.
The classification accuracy of tabular text is improved, related terms are determined through spatial domain and semantic association, feature interaction of unrelated terms is avoided, and the semantic information of tabular text is fully represented.
Smart Images

Figure CN115905531B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and in particular to an artificial intelligence-based text classification method, device, computer equipment and medium. Background Art
[0002] With the rapid development of artificial intelligence technology, text classification has also been widely used in various scenarios such as text recognition, text semantic perception, and text intelligent interaction. The objects of text classification processing usually use texts with coherent word order to ensure that the text classification model can accurately learn the semantic features of the text and then perform text classification based on semantic extraction.
[0003] However, in financial scenarios, such as insurance and electronic transactions, collected text often takes the form of tables. In tabular text, the terms are distributed discretely, and the word order between terms is inconsistent. Conventional text classification models often struggle to accurately extract the semantic features of tabular text, resulting in low text classification accuracy. Therefore, improving the accuracy of text classification for tabular text has become a pressing issue. Summary of the Invention
[0004] In view of this, embodiments of the present invention provide an artificial intelligence-based text classification method, apparatus, computer device, and medium to solve the problem of low text classification accuracy of tabular text.
[0005] In a first aspect, an embodiment of the present invention provides a text classification method based on artificial intelligence, the text classification method comprising:
[0006] Obtaining attribute terms and content terms in the table text, for any content term, inputting the content term into a trained semantic model for semantic extraction, obtaining a character embedding vector corresponding to each character in the content term, calculating the mean of all character embedding vectors, and determining the calculated result as the content embedding vector of the content term;
[0007] Obtaining the positions of the content term and each attribute term in the table text, and determining a distance evaluation value of the corresponding attribute term based on the distance between the position of the content term and the position of each attribute term;
[0008] The content term is concatenated with each attribute term, and each concatenation result is input into a trained association discrimination model, and the output discrimination probability value is determined as the semantic evaluation value of the corresponding attribute term. The weighted mean of the distance evaluation value and the semantic evaluation value of each attribute term is calculated, and the attribute term corresponding to the minimum weighted mean is determined as the associated term of the content term.
[0009] Encoding the associated terms using a preset encoding method to obtain an associated embedding vector, adding the content embedding vector to the associated embedding vector to determine a target embedding vector corresponding to the content terms, and obtaining target embedding vectors corresponding to all content terms;
[0010] The target embedding vectors corresponding to all content entries are concatenated and input into the trained classification model for text classification to obtain the classification result of the table text.
[0011] In a second aspect, an embodiment of the present invention provides an artificial intelligence-based text classification device, the text classification device comprising:
[0012] A content embedding module is configured to obtain attribute terms and content terms in a table text, input any content term into a trained semantic model for semantic extraction, obtain a character embedding vector corresponding to each character in the content term, calculate the mean of all character embedding vectors, and determine the calculated result as the content embedding vector of the content term;
[0013] a distance evaluation module, configured to obtain the positions of the content term and each attribute term in the table text, and determine a distance evaluation value of the corresponding attribute term based on the distance between the position of the content term and the position of each attribute term;
[0014] A term association module is used to splice the content term with each attribute term, input each splicing result into a trained association discrimination model, determine the output discrimination probability value as the semantic evaluation value of the corresponding attribute term, calculate the weighted mean of the distance evaluation value and the semantic evaluation value of each attribute term, and determine the attribute term corresponding to the minimum weighted mean as the associated term of the content term;
[0015] an association embedding module, configured to encode the associated terms using a preset encoding method to obtain an associated embedding vector, add the content embedding vector to the associated embedding vector, determine a target embedding vector corresponding to the content terms, and obtain target embedding vectors corresponding to all content terms;
[0016] The text classification module is used to concatenate the target embedding vectors corresponding to all content entries and input them into the trained classification model to perform text classification, thereby obtaining the classification result of the table text.
[0017] In a third aspect, an embodiment of the present invention provides a computer device, comprising a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the text classification method as described in the first aspect is implemented.
[0018] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the text classification method as described in the first aspect is implemented.
[0019] Compared with the prior art, the embodiments of the present invention have the following beneficial effects:
[0020] Obtain attribute terms and content terms in the table text. For any content term, input the content term into the trained semantic model for semantic extraction, obtain the character embedding vector corresponding to each character in the content term, calculate the mean of all character embedding vectors, and determine the calculation result as the content embedding vector of the content term. Obtain the position of the content term and each attribute term in the table text, determine the distance evaluation value of the corresponding attribute term based on the distance between the position of the content term and the position of each attribute term, splice the content term with each attribute term respectively, input each splicing result into the trained association discrimination model respectively, determine the output discrimination probability value as the semantic evaluation value of the corresponding attribute term, calculate the weighted mean of the distance evaluation value and the semantic evaluation value of each attribute term, and determine the attribute term corresponding to the minimum weighted mean. For the associated terms of content terms, a preset encoding method is used to encode the associated terms to obtain an associated embedding vector, the content embedding vector is added to the associated embedding vector, the target embedding vector corresponding to the content term is determined, and the target embedding vectors corresponding to all content terms are obtained. The target embedding vectors corresponding to all content terms are spliced and input into the trained classification model for text classification to obtain the classification result of the table text. The associated terms of the content terms are determined based on the spatial domain association and semantic association of the content terms and the attribute terms, avoiding feature interaction between unrelated content terms and attribute terms in the table text, and only performing feature fusion on the content terms and their associated terms, so that the target embedding vectors of all content terms can fully represent the semantic information of the table text after splicing, thereby effectively improving the classification accuracy of the table text. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0022] Figure 1 This is a schematic diagram of an application environment of an artificial intelligence-based text classification method provided in the first embodiment of the present invention;
[0023] Figure 2This is a flowchart of an artificial intelligence-based text classification method provided in Example 1 of the present invention;
[0024] Figure 3 This is a flowchart of an artificial intelligence-based text classification method provided in the second embodiment of the present invention;
[0025] Figure 4 This is a schematic diagram of the structure of an artificial intelligence-based text classification device provided in Example 3 of the present invention;
[0026] Figure 5 This is a structural diagram of a computer device provided in Example 4 of the present invention. DETAILED DESCRIPTION
[0027] In the following description, specific details such as particular system structures and techniques are provided for purposes of illustration, not limitation, to facilitate a thorough understanding of the embodiments of the present invention. However, it will be apparent to those skilled in the art that the present invention may be practiced in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted so as not to obscure the description of the present invention with unnecessary detail.
[0028] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, integers, steps, operations, elements and / or components, but does not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or groups thereof.
[0029] It will also be understood that the term "and / or" used in the present description and appended claims refers to and includes any and all possible combinations of one or more of the associated listed items.
[0030] As used in the present specification and the appended claims, the term "if" may be interpreted as "when" or "upon" or "in response to determining" or "in response to detecting," depending on the context. Similarly, the phrase "if it is determined" or "if [described condition or event] is detected" may be interpreted as meaning "upon determination" or "in response to determining" or "upon detection of [described condition or event]" or "in response to detecting [described condition or event]," depending on the context.
[0031] In addition, in the description of the present specification and the appended claims, the terms "first", "second", "third", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance.
[0032] References to "one embodiment" or "some embodiments" in the present specification mean that a particular feature, structure, or characteristic described in conjunction with that embodiment is included in one or more embodiments of the present invention. Thus, phrases such as "in one embodiment," "in some embodiments," "in other embodiments," and "in yet other embodiments" appearing in various places in this specification do not necessarily refer to the same embodiment, but rather mean "one or more, but not all, embodiments," unless otherwise specifically emphasized. The terms "including," "comprising," "having," and variations thereof mean "including but not limited to," unless otherwise specifically emphasized.
[0033] Embodiments of the present invention can acquire and process relevant data based on artificial intelligence technology. Artificial Intelligence (AI) refers to the theories, methods, technologies, and application systems that use digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, perceive the environment, acquire knowledge, and use that knowledge to achieve optimal results.
[0034] Fundamental AI technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing, operating / interaction systems, and mechatronics. AI software technologies primarily encompass computer vision, robotics, biometrics, speech processing, natural language processing, and machine learning / deep learning.
[0035] It should be understood that the order of execution of the steps in the following embodiments does not necessarily mean the order in which they are executed. The order in which each process is executed should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.
[0036] In order to illustrate the technical solution of the present invention, specific embodiments are provided below.
[0037] The text classification method based on artificial intelligence provided by the first embodiment of the present invention can be applied in the following aspects: Figure 1The application environment in which the client communicates with the server. The client includes but is not limited to computer devices such as PDAs, desktop computers, laptops, ultra-mobile personal computers (UMPCs), netbooks, cloud terminal devices, and personal digital assistants (PDAs). The server can be an independent server or 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, content delivery networks (CDNs), and big data and artificial intelligence platforms.
[0038] See also Figure 2 , is a flowchart of a text classification method based on artificial intelligence provided by the first embodiment of the present invention. The above text classification method can be applied to Figure 1 The client in the client, the computer device corresponding to the client connects to the server to obtain the attribute terms and content terms in the table text. The computer device corresponding to the client is deployed with a trained semantic model, a trained association discrimination model and a trained classification model. The trained semantic model can be used to extract the semantic features of the terms, the trained association discrimination model can be used to determine whether there is a semantic association between the attribute terms and the content terms, and the trained classification model can be used to determine whether the target embedding vector splicing result corresponding to the table text belongs to the preset category. Figure 2 As shown, the text classification method may include the following steps:
[0039] Step S201: Obtain attribute terms and content terms in the table text. For any content term, input the content term into the trained semantic model for semantic extraction to obtain the character embedding vector corresponding to each character in the content term. Calculate the mean of all character embedding vectors, and determine the calculation result as the content embedding vector of the content term.
[0040] The term "table text" may refer to text comprising attribute cells and content cells, an attribute term may refer to a text term within an attribute cell, and a content term may refer to a text term within a content cell. The trained semantic model may employ a trained word embedding model, a trained BERT model, or the like. A content term may consist of multiple characters, a character embedding vector may be used to represent feature information corresponding to a character within the content term, and a content embedding vector may be used to represent feature information of the content term.
[0041] Specifically, the application scenarios of this embodiment can be financial scenarios, insurance scenarios, etc., and tabular texts are often used frequently in such scenarios. For example, in the insurance scenario, tabular text can refer to the policy text. At this time, the attribute terms can include "disease name", "chief complaint", "department code", "customer application reason" and other attribute terms. Correspondingly, for the policy text, usually one attribute term corresponds to one content term, and the content terms can include "fracture", "left calf injury while playing basketball three days ago", "seven", and "accident".
[0042] Optionally, the content terms are input into a trained semantic model for semantic extraction, and the word embedding vector corresponding to each word in the content terms is obtained, including:
[0043] The content entry is processed into words to obtain N words;
[0044] N words are input into the trained semantic model for semantic extraction, and the word embedding vector corresponding to each word in the content entry is obtained.
[0045] Wherein, N is an integer greater than zero, and the word segmentation process may adopt a word segmentation model, such as an N-gram model, a Jieba model, and a dictionary model.
[0046] Specifically, in this embodiment, the trained semantic model can adopt the trained word vector embedding model, and each word in the content entry is uniquely encoded through a preset dictionary to obtain the encoding vector of each word, and the selection number is set. In this embodiment, the selection number can be 2. For each word, the two words before the word and the two words after the word are determined as the context information of the word according to the selection number and the word order in the content entry. The encoding vector of each word in the context information is superimposed with the encoding vector of the word, and the superposition result is input into the trained word vector embedding model to obtain the word embedding vector of the word. The word embedding vector can be used to represent the probability sequence of the word obtained according to the context information that belongs to each preset word in the preset dictionary.
[0047] It should be noted that when determining the context information, it may be impossible to select words that meet the selection quantity as context information for the words at the starting and ending positions of the content entry. At this time, a zero vector is used as a supplement, or the selected words are directly used as the context information.
[0048] In this embodiment, the word embedding vector of a word is determined in combination with the context information of the word, which improves the characterization ability of the word embedding vector for the semantic association information between words, thereby improving the characterization ability of the word embedding vector and further improving the text classification accuracy of the tabular text.
[0049] Optionally, computing the mean of all word embedding vectors involves:
[0050] Calculate the sum of the word embedding vectors corresponding to all words to obtain the accumulated vector;
[0051] The number of words in the content entries is counted, and the ratio of each element in the cumulative vector to the number is calculated, and the vector composed of the ratios corresponding to all elements is determined as the mean.
[0052] The accumulated vector may refer to the sum of word embedding vectors, the quantity may refer to the number of words in the content entry, and the mean may be used as the content embedding vector.
[0053] Specifically, the mean calculation method can be expressed as: Among them, s can represent the sth content term, μ s It can refer to the mean value corresponding to the sth content entry, lrn s It can refer to the number of words in the sth content entry, e i It can refer to the word embedding vector corresponding to the i-th word, It can refer to the accumulated vector corresponding to the s-th content term.
[0054] In this embodiment, the fusion of embedded vectors is performed through mean calculation, which prevents the element values of the vector elements from being too large, reduces the calculation load, and improves the calculation efficiency.
[0055] The above steps of obtaining attribute terms and content terms in the table text, for any content term, inputting the content term into the trained semantic model for semantic extraction, obtaining the character embedding vector corresponding to each character in the content term, calculating the mean of all character embedding vectors, and determining the calculation result as the content embedding vector of the content term, embedding the content term by character and then taking the mean as the content embedding vector, can enable the content embedding vector to fully represent the characteristics of the content term, thereby improving the text classification accuracy of the table text.
[0056] Step S202 : obtaining the position of the content term and each attribute term in the table text, and determining the distance evaluation value of the corresponding attribute term based on the distance between the position of the content term and the position of each attribute term.
[0057] Among them, the position can refer to the coordinate position in the two-dimensional image corresponding to the table text. The two-dimensional image corresponding to the table text can be obtained by scanning the table text. The distance can be calculated by distance calculation methods such as Euclidean distance and Manhattan distance. The distance evaluation value can be used to represent the spatial correlation degree between the attribute term and the content term.
[0058] Optionally, determining the distance evaluation value of the corresponding attribute term based on the distance between the position of the content term and the position of each attribute term includes:
[0059] Calculate the Euclidean distance between the position of the content term and the position of each attribute term to obtain the Euclidean distance corresponding to each attribute term;
[0060] Determine the maximum value of the Euclidean distances corresponding to all attribute terms. For any attribute term, calculate the ratio of the Euclidean distance corresponding to the attribute term to the maximum value. Determine the calculation result as the distance evaluation value of the attribute term, and obtain the distance evaluation values of all corresponding attribute terms.
[0061] Among them, the Euclidean distance can refer to the two-dimensional straight-line distance between the attribute entry position and the content entry position. The maximum value of the Euclidean distances corresponding to all attribute entries can be used as a reference value for normalization. The ratio calculation can refer to comparing the Euclidean distance with the reference value. The value range of the calculation result is [0, 1], that is, the ratio calculation can be used to obtain the normalized processing result.
[0062] Specifically, for any content term, its position can be expressed as (x′, y′), and the position of the kth attribute term can be expressed as (x k ,y k ), then the Euclidean distance d between the position of the kth attribute term and the position of the content term k The calculation method is Assume that there are K attribute terms, and calculate the Euclidean distance corresponding to all K attribute terms. The reference value α can be expressed as α=max k∈[1,2,…,K] (d k ), then the distance evaluation value β of the k-th attribute term can be expressed as
[0063] In this embodiment, the calculated distances between content terms and attribute terms are normalized to prevent the calculated distance from being too large and affecting the accuracy of subsequent determination of associated terms. At the same time, the value ranges of the distance evaluation value and the subsequently obtained semantic evaluation value are unified to prevent the distance evaluation value from having too much influence on the associated term determination process, resulting in inaccurate determination of associated terms, thereby improving the accuracy of associated term determination.
[0064] The above steps of obtaining the position of the content term and each attribute term in the table text, and determining the distance evaluation value of the corresponding attribute term based on the distance between the position of the content term and the position of each attribute term, characterize the spatial domain correlation of the content term and the attribute term through image position to determine the correspondence between the content term and the attribute term, and improve the feature richness of the content term through the associated attribute terms, thereby improving the classification accuracy of the table text.
[0065] In step S203, the content terms are spliced with each attribute term respectively, and each splicing result is input into the trained association discrimination model respectively, and the output discrimination probability value is determined to be the semantic evaluation value of the corresponding attribute term, and the weighted mean of the distance evaluation value and the semantic evaluation value of each attribute term is calculated, and the attribute term corresponding to the minimum weighted mean is determined to be the associated term of the content term.
[0066] Among them, the splicing method can be connection. In this embodiment, the connection is performed with the attribute terms in front and the content terms in the back. The trained association discrimination model can use the trained discriminator. The discrimination probability value can refer to the probability value of the input splicing result being judged as belonging to a preset category. The semantic evaluation value can be used to characterize the degree of semantic association between the content terms and the attribute terms. The associated terms can refer to the attribute terms corresponding to the content terms.
[0067] Specifically, in this embodiment, the trained association discrimination model adopts a trained discriminator for binary classification, and the binary classification categories are semantic association categories and semantic non-association categories. The discrimination probability value can refer to the probability value that the input splicing result is judged to belong to the preset semantic association category, and the probability value range is [0, 1].
[0068] In this embodiment, the distance weight of the distance evaluation value is set to 0.6, and the semantic weight of the semantic evaluation value is set to 0.4. The implementer can adjust the values of the above distance weight and semantic weight according to actual conditions.
[0069] The above steps include splicing the content terms with each attribute term respectively, inputting each splicing result into the trained association discrimination model respectively, determining the output discrimination probability value as the semantic evaluation value of the corresponding attribute term, calculating the weighted mean of the distance evaluation value and the semantic evaluation value of each attribute term, and determining the attribute term corresponding to the minimum weighted mean as the associated term of the content term. The associated terms are determined jointly by spatial domain association and semantic association to avoid incorrect correspondence between attribute terms and content terms due to misplacement of terms in the table text, which in turn leads to a decrease in the accuracy of the features extracted subsequently, thereby improving the classification accuracy of the table text.
[0070] In step S204, the associated terms are encoded using a preset encoding method to obtain an associated embedding vector, the content embedding vector is added to the associated embedding vector, and a target embedding vector corresponding to the content terms is determined to obtain target embedding vectors corresponding to all content terms.
[0071] Among them, the encoding method can adopt encoding methods such as one-hot encoding and bag-of-words model encoding, the associated embedding vector can be used to represent the feature information of the associated terms, and the target embedding vector can be used to represent the feature information of the content terms.
[0072] Specifically, in this embodiment, the associated terms are encoded using one-hot encoding. The processing speed of one-hot encoding is fast, but it cannot represent the semantic association information between words. The associated terms are essentially attribute terms, and the attribute terms themselves have the characteristics of semantic discreteness. Therefore, the use of one-hot encoding can improve the encoding efficiency without reducing the representation ability.
[0073] It should be noted that in order to enable the content embedding vector to be added to the associated embedding vector, when the associated terms are one-hot encoded, the dictionary dimension used should be consistent with the dimension of the content embedding vector. If the dictionary dimension used is smaller than the dimension of the content embedding vector, the dimension can be expanded by padding with zeros. If the dictionary dimension used is larger than the dimension of the content embedding vector, the dimension can be reduced by masking some preset words.
[0074] The above steps of encoding the associated terms using a preset encoding method to obtain an associated embedding vector, adding the content embedding vector to the associated embedding vector, determining the target embedding vector corresponding to the content term, and obtaining the target embedding vector corresponding to all content terms, while ensuring the accuracy of the word embedding vector of the associated terms, improve the encoding efficiency, thereby improving the efficiency of text classification.
[0075] Step S205: The target embedding vectors corresponding to all content terms are concatenated and input into the trained classification model for text classification to obtain the classification result of the table text.
[0076] Among them, splicing can refer to connection, that is, splicing multiple target embedding vectors in the order of content terms. The splicing result is a high-dimensional vector. One dimension of information corresponds to the target embedding vector of a content term. The trained classification model can be implemented using a fully connected layer, decision tree, etc. The classification result can refer to a binary classification result or a multi-classification result.
[0077] Optionally, the trained classification model includes a trained encoder and a trained classifier;
[0078] The target embedding vectors corresponding to all content entries are concatenated and input into the trained classification model for text classification. The classification results of the table text include:
[0079] Multiply the concatenation result with the first interaction matrix, the second interaction matrix, and the third interaction matrix in the trained encoder respectively to obtain the value vector, the key-value vector, and the query vector;
[0080] Multiply the query vector by the transpose of the key-value vector, normalize the multiplication result using a normalized exponential function, and multiply the normalized result by the value vector to obtain the interaction vector;
[0081] The interaction vector is input into the trained classifier to obtain the classification result of the table text.
[0082] Among them, the first interaction matrix, the second interaction matrix and the third interaction matrix can refer to the parameter matrices in the trained encoder, and the interaction vector can refer to the feature vector with stronger representation ability obtained through the attention mechanism.
[0083] Specifically, the normalization processing result can be used to represent attention information, and multiplying the normalization processing result with the value vector can effectively extract important features of the splicing vector after the target embedding vectors corresponding to all content entries are spliced together.
[0084] This embodiment uses the attention mechanism to further extract features from the spliced vector obtained by splicing the target embedding vectors corresponding to all content entries, isolate irrelevant feature information, improve the effective feature representation ability of the obtained interaction vector, and thus improve the classification accuracy of the table text.
[0085] Optionally, the interaction vector is input into a trained classifier to obtain the classification results of the table text, including:
[0086] The interaction vector is input into the trained classifier for feature mapping to obtain the category vector;
[0087] The category vector is subjected to probability normalization processing to obtain a category probability distribution, and the preset category corresponding to the maximum value in the category probability distribution is determined to be a classification result of the tabular text.
[0088] Each element in the category vector may refer to a predicted value of whether the table text corresponding to the interaction vector belongs to the preset category corresponding to the position of the element. After normalization, the predicted value is normalized into a probability value.
[0089] Specifically, in this embodiment, the classification result is a binary classification result, and the binary classification result may be whether the insurance policy case corresponding to the table text is a disease case.
[0090] In one embodiment, the classification result is a multi-classification result, that is, the probability of whether the insurance policy case corresponding to the table text is directly claimed. At this time, the multi-classification result is a plurality of preset probabilities, for example, the preset probabilities are 0.2, 0.4, 0.6, 0.8, and 1.0, which are five preset categories.
[0091] In one embodiment, the above-mentioned binary classification results and multi-classification results can be performed simultaneously, and two trained classification models can be used for classification respectively. The simultaneous multi-classification tasks can enable the model to better extract features during the training process, improve the feature representation ability, and thus improve the classification accuracy of the table text.
[0092] This embodiment provides flexible downstream classification tasks, thereby improving the generalization ability of the text classification method, and also enables the model to extract features more accurately during training, thereby improving the classification accuracy of tabular text.
[0093] The above step of concatenating the target embedding vectors corresponding to all content entries and inputting them into the trained classification model for text classification to obtain the classification result of the table text fully represents the semantic information of the table text, thereby effectively improving the classification accuracy of the table text.
[0094] This embodiment determines the associated terms of content terms based on the spatial association and semantic association of content terms and attribute terms, avoids feature interaction between unrelated content terms and attribute terms in the table text, and only performs feature fusion on the content terms and their associated terms. This allows the target embedding vectors of all content terms to fully represent the semantic information of the table text after splicing, thereby effectively improving the classification accuracy of the table text.
[0095] See also Figure 3 , is a flow chart of an artificial intelligence-based text classification method provided in the second embodiment of the present invention. In this text classification method, when extracting the semantic features of content terms, each word in the content terms can be directly input into the trained semantic extraction model to obtain the word embedding vectors of all words. However, for tabular text, there may be a situation where the content terms belong to discrete information, that is, the content terms include continuous terms and discrete terms. When extracting the semantic features of the content terms, different feature extraction methods are used for continuous terms and discrete terms to perform semantic extraction.
[0096] When each word in the content entry is directly input into the trained semantic extraction model to obtain the word embedding vectors of all words, the semantic extraction process is as described in Example 1 and will not be repeated here.
[0097] When extracting semantic features of content terms, the process of semantic extraction using different feature extraction methods for continuous terms and discrete terms includes the following steps:
[0098] Step S301: input the continuous terms into the trained semantic model for semantic extraction to obtain the word embedding vector corresponding to each word in the continuous terms;
[0099] Step S302: Encode each character in the discrete entry according to the encoding method to obtain a character embedding vector corresponding to each character in the discrete entry;
[0100] Step S303 : Determine the word embedding vector corresponding to each word in the continuous word entry and the word embedding vector corresponding to each word in the discrete word entry as the word embedding vector corresponding to each word in the content word entry.
[0101] Among them, continuous terms may refer to content terms with continuous word order, and discrete terms may refer to content terms with discontinuous word order.
[0102] Specifically, both continuous entries and discrete entries need to be segmented. The application scenario of this embodiment can be an insurance scenario, that is, the table text can be the policy text in the insurance scenario. In order to adapt to both Chinese and English table texts, the word segmentation processing can use dictionary-based forward matching algorithms, backward matching algorithms, two-way matching algorithms, N-gram algorithms, and Jieba word segmentation algorithms.
[0103] A continuous entry may refer to an entry with a continuous word order. For example, the content entry is "I injured my left calf while playing basketball three days ago". The word order of this content entry is coherent, and a trained semantic model can be used for semantic extraction. A discrete entry may refer to an entry with a discontinuous word order. For example, the content entry is "seven", and its semantic information is independent.
[0104] In this embodiment, discrete terms are encoded using a one-hot encoding method, that is, K preset characters need to be preset. In the character embedding vector obtained after encoding a single character in the discrete term, the element value at the preset character position corresponding to the character is 1, and the element values of other elements are 0. Obviously, for different application scenarios, the semantic meanings corresponding to discrete terms are different. Therefore, the preset characters used in encoding discrete terms should be determined based on the application scenario. In this embodiment, the preset characters include the numbers "one" to "ten", and the attribute term corresponding to the numbers is the department code, that is, the semantic information of "seven" in the above example can actually be "Department No. 7".
[0105] The trained semantic model can adopt the trained word vector conversion model. Specifically, each word in the continuous word entry is uniquely encoded to obtain the encoding vector of each word, and the selection number is set. In this embodiment, the selection number can be 2. For each word, the two words before the word and the two words after the word are determined as the context information of the word according to the selection number and the word order in the continuous word entry. The encoding vector of each word in the context information is superimposed with the encoding vector of the word, and the superposition result is input into the trained word vector conversion model to obtain the word embedding vector of the word. The word embedding vector can be used to represent the probability sequence of the word belonging to each preset word obtained according to the context information.
[0106] It should be noted that the preset words used for one-hot encoding of continuous terms should be different from the preset words used for one-hot encoding of discrete terms, that is, the preset words used for one-hot encoding of continuous terms can be determined by a dictionary with stronger generalization, and the preset words used for one-hot encoding of discrete terms can be determined by a dictionary adapted to the application scenario. However, in order to ensure the uniformity of the size of the word embedding vector and to facilitate the subsequent calculation of the mean of the word embedding vector, the union of the dictionary with stronger generalization and the dictionary adapted to the application scenario will be taken as the preset word dictionary for one-hot encoding in this embodiment.
[0107] This embodiment adopts different semantic feature extraction methods for continuous terms and discrete terms in content terms, respectively. While ensuring the accuracy of word embedding vectors, it effectively reduces the model inference time, improves the efficiency of feature extraction, and thus improves the accuracy and efficiency of text classification.
[0108] Corresponding to the text classification method based on artificial intelligence in the above embodiment, Figure 4 A structural block diagram of an artificial intelligence-based text classification device provided in Example 3 of the present invention is shown. The above-mentioned text classification device is applied to the client, and the computer device corresponding to the client is connected to the server to obtain attribute terms and content terms in the table text. The computer device corresponding to the client is deployed with a trained semantic model, a trained association discrimination model and a trained classification model. The trained semantic model can be used to extract the semantic features of the terms, the trained association discrimination model can be used to determine whether there is a semantic association between the attribute terms and the content terms, and the trained classification model can be used to determine whether the target embedding vector splicing result corresponding to the table text belongs to a preset category. For the sake of convenience, only the part related to the embodiment of the present invention is shown.
[0109] See also Figure 4 , the text classification device includes:
[0110] The content embedding module 41 is configured to obtain attribute terms and content terms from the table text, input the content term into the trained semantic model for semantic extraction, obtain a character embedding vector corresponding to each character in the content term, calculate the mean of all character embedding vectors, and determine the calculated result as the content embedding vector of the content term;
[0111] A distance evaluation module 42 is used to obtain the position of the content term and each attribute term in the table text, and determine the distance evaluation value of the corresponding attribute term based on the distance between the position of the content term and the position of each attribute term;
[0112] The term association module 43 is used to concatenate the content term with each attribute term, input each concatenation result into the trained association discrimination model, determine the output discrimination probability value as the semantic evaluation value of the corresponding attribute term, calculate the weighted mean of the distance evaluation value and the semantic evaluation value of each attribute term, and determine the attribute term corresponding to the minimum weighted mean as the associated term of the content term;
[0113] The association embedding module 44 is configured to encode the associated terms using a preset encoding method to obtain an associated embedding vector, add the content embedding vector to the associated embedding vector, determine the target embedding vector corresponding to the content terms, and obtain the target embedding vectors corresponding to all content terms;
[0114] The text classification module 45 is used to concatenate the target embedding vectors corresponding to all content entries and input them into the trained classification model to perform text classification and obtain the classification results of the table text.
[0115] Optionally, the content terms include continuous terms and discrete terms;
[0116] The content embedding module 41 includes:
[0117] The semantic extraction unit is used to input the continuous word entries into the trained semantic model for semantic extraction, and obtain the word embedding vector corresponding to each word in the continuous text;
[0118] The term encoding unit is used to encode each word in the discrete term according to the encoding method to obtain the word embedding vector corresponding to each word in the discrete text;
[0119] The vector determination unit is used to determine the word embedding vector corresponding to each word in the continuous word entry and the word embedding vector corresponding to each word in the discrete word entry as the word embedding vector corresponding to each word in the content word entry.
[0120] Optionally, the content embedding module 41 includes:
[0121] The word segmentation unit is used to segment the content word into N words, where N is an integer greater than zero;
[0122] The character feature extraction unit is used to input N characters into the trained semantic model for semantic extraction, and obtain the character embedding vector corresponding to each character in the content entry.
[0123] Optionally, the content embedding module 41 includes:
[0124] A vector accumulation unit is used to calculate the sum of the word embedding vectors corresponding to all words to obtain an accumulated vector;
[0125] The mean calculation unit is used to count the number of words in the content entry, calculate the ratio of each element in the accumulated vector to the number, and determine the vector composed of the ratios corresponding to all elements as the mean.
[0126] Optionally, the distance evaluation module 42 includes:
[0127] a distance calculation unit, configured to calculate the Euclidean distance between the position of the content term and the position of each attribute term, and obtain the Euclidean distance corresponding to each attribute term;
[0128] The normalization unit is used to determine the maximum value of the Euclidean distances corresponding to all attribute terms. For any attribute term, the Euclidean distance corresponding to the attribute term is calculated with the maximum value, and the calculation result is determined as the distance evaluation value of the attribute term, thereby obtaining the distance evaluation values of all corresponding attribute terms.
[0129] Optionally, the trained classification model includes a trained encoder and a trained classifier;
[0130] The text classification module 45 includes:
[0131] A matrix calculation unit, configured to multiply the concatenation result by the first interaction matrix, the second interaction matrix, and the third interaction matrix in the trained encoder respectively to obtain a value vector, a key-value vector, and a query vector;
[0132] A vector interaction unit, configured to multiply the query vector by the transpose of the key-value vector, normalize the multiplication result using a normalized exponential function, and multiply the normalized result by the value vector to obtain an interaction vector;
[0133] The vector classification unit is used to input the interaction vector into the trained classifier to obtain the classification result of the table text.
[0134] Optionally, the vector classification unit includes:
[0135] The feature mapping subunit is used to input the interaction vector into the trained classifier for feature mapping to obtain the category vector;
[0136] The category determination subunit is used to perform probability normalization processing on the category vector to obtain a category probability distribution, and determine that the preset category corresponding to the maximum value in the category probability distribution is a classification result of the tabular text.
[0137] It should be noted that the information interaction, execution process, etc. between the above-mentioned modules, units, and sub-units are based on the same concept as the embodiment of the method of the present invention. Their specific functions and technical effects can be found in the method embodiment part and will not be repeated here.
[0138] Figure 5This is a schematic diagram of the structure of a computer device provided by the fourth embodiment of the present invention. Figure 5 As shown, the computer device of this embodiment includes: at least one processor ( Figure 5 Only one is shown in the figure), a memory, and a computer program stored in the memory and executable on at least one processor. When the processor executes the computer program, the steps of any of the above-mentioned text classification method embodiments are implemented.
[0139] The computer device may include, but is not limited to, a processor and a memory. It will be understood by those skilled in the art that Figure 5 The above is merely an example of a computer device and does not constitute a limitation on the computer device. The computer device may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, it may also include a network interface, a display screen, and an input device.
[0140] The processor may be a CPU, or other general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic device, a discrete gate or transistor logic device, or a discrete hardware component. A general-purpose processor may be a microprocessor, or any conventional processor.
[0141] The memory includes a readable storage medium, an internal memory, etc., wherein the internal memory can be the memory of a computer device, and the internal memory provides an environment for the operation of the operating system and computer-readable instructions in the readable storage medium. The readable storage medium can be the hard disk of the computer device, and in other embodiments, it can also be an external storage device of the computer device, for example, a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped on the computer device. Furthermore, the memory can also include both the internal storage unit of the computer device and the external storage device. The memory is used to store the operating system, application programs, boot loaders (BootLoader), data, and other programs, such as the program code of the computer program. The memory can also be used to temporarily store data that has been output or is about to be output.
[0142] Those skilled in the art can clearly understand that, for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In actual applications, the above-mentioned functions can be distributed and completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated into a processing unit, or each unit can exist physically alone, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of a software functional unit. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other and are not used to limit the scope of protection of the present invention. The specific working process of the units and modules in the above-mentioned device can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here. If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present invention implements all or part of the processes in the above-mentioned embodiment method, which can be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium. When the computer program is executed by the processor, it can implement the steps of the above-mentioned method embodiment. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include at least: any entity or device capable of carrying computer program code, recording medium, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium. For example, a USB flash drive, a mobile hard disk, a magnetic disk or an optical disk. In some jurisdictions, according to legislation and patent practice, computer-readable media cannot be electric carrier signals and telecommunication signals.
[0143] The present invention may implement all or part of the processes in the above-mentioned method embodiments, and may also be completed through a computer program product. When the computer program product runs on a computer device, the computer device can implement the steps in the above-mentioned method embodiments when executing the computer program product.
[0144] In the above embodiments, the description of each embodiment has its own focus. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant description of other embodiments.
[0145] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the present invention.
[0146] In the embodiments provided by the present invention, it should be understood that the disclosed apparatus / computer equipment and methods can be implemented in other ways. For example, the apparatus / computer equipment embodiments described above are merely illustrative. For example, the division of modules or units is merely a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0147] Units described as separate components may or may not be physically separate, and components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment according to actual needs.
[0148] The above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present invention, and should all be included in the scope of protection of the present invention.
Claims
1. A text classification method based on artificial intelligence, characterized in that: The text classification method comprises: Obtaining attribute terms and content terms in the table text, for any content term, inputting the content term into a trained semantic model for semantic extraction, obtaining a character embedding vector corresponding to each character in the content term, calculating the mean of all character embedding vectors, and determining the calculated result as the content embedding vector of the content term; Obtaining the positions of the content term and each attribute term in the table text, and determining a distance evaluation value of the corresponding attribute term based on the distance between the position of the content term and the position of each attribute term; The content term is concatenated with each attribute term, and each concatenation result is input into a trained association discrimination model, and the output discrimination probability value is determined as the semantic evaluation value of the corresponding attribute term. The weighted mean of the distance evaluation value and the semantic evaluation value of each attribute term is calculated, and the attribute term corresponding to the minimum weighted mean is determined as the associated term of the content term. Encoding the associated terms using a preset encoding method to obtain an associated embedding vector, adding the content embedding vector to the associated embedding vector to determine a target embedding vector corresponding to the content terms, and obtaining target embedding vectors corresponding to all content terms; The target embedding vectors corresponding to all content entries are concatenated and input into the trained classification model for text classification to obtain the classification result of the table text.
2. The text classification method according to claim 1, characterized in that The content terms include continuous terms and discrete terms; Inputting the content terms into a trained semantic model for semantic extraction to obtain a word embedding vector corresponding to each word in the content terms includes: Inputting the continuous terms into the trained semantic model for semantic extraction to obtain a word embedding vector corresponding to each word in the continuous terms; Encode each word in the discrete word entry according to the encoding method to obtain a word embedding vector corresponding to each word in the discrete word entry; The word embedding vector corresponding to each word in the continuous word and the word embedding vector corresponding to each word in the discrete word are determined as the word embedding vector corresponding to each word in the content word.
3. The text classification method according to claim 1, characterized in that Inputting the content terms into a trained semantic model for semantic extraction to obtain a word embedding vector corresponding to each word in the content terms includes: Performing word segmentation processing on the content entry to obtain N words, where N is an integer greater than zero; The N words are respectively input into the trained semantic model for semantic extraction to obtain a word embedding vector corresponding to each word in the content entry.
4. The text classification method according to claim 1, characterized in that The calculation of the mean of all word embedding vectors includes: Calculate the sum of the word embedding vectors corresponding to all words to obtain the accumulated vector; The number of characters in the content entry is counted, a ratio of each element in the accumulated vector to the number is calculated, and a vector consisting of the ratios corresponding to all elements is determined as the mean.
5. The text classification method according to claim 1, characterized in that Determining the distance evaluation value of the corresponding attribute term based on the distance between the position of the content term and the position of each attribute term includes: Calculating the Euclidean distance between the position of the content term and the position of each attribute term to obtain the Euclidean distance corresponding to each attribute term; Determine the maximum value of the Euclidean distances corresponding to all attribute terms. For any attribute term, calculate the ratio of the Euclidean distance corresponding to the attribute term to the maximum value. Determine the calculation result as the distance evaluation value of the attribute term, and obtain the distance evaluation values of all corresponding attribute terms.
6. The text classification method according to any one of claims 1 to 5, characterized in that: The trained classification model includes a trained encoder and a trained classifier; The target embedding vectors corresponding to all content entries are concatenated and input into the trained classification model for text classification. The classification results of the table text are obtained as follows: Multiplying the concatenation result with the first interaction matrix, the second interaction matrix, and the third interaction matrix in the trained encoder respectively to obtain a value vector, a key-value vector, and a query vector; Multiplying the query vector by the transpose of the key-value vector, normalizing the multiplication result using a normalized exponential function, and multiplying the normalized result by the value vector to obtain an interaction vector; The interaction vector is input into the trained classifier to obtain a classification result of the table text.
7. The text classification method according to claim 6, characterized in that Inputting the interaction vector into the trained classifier to obtain a classification result of the table text includes: Inputting the interaction vector into the trained classifier for feature mapping to obtain a category vector; Probability normalization processing is performed on the category vector to obtain a category probability distribution, and a preset category corresponding to a maximum value in the category probability distribution is determined to be a classification result of the table text.
8. A text classification device based on artificial intelligence, characterized in that: The text classification device comprises: A content embedding module is configured to obtain attribute terms and content terms in a table text, input any content term into a trained semantic model for semantic extraction, obtain a character embedding vector corresponding to each character in the content term, calculate the mean of all character embedding vectors, and determine the calculated result as the content embedding vector of the content term; a distance evaluation module, configured to obtain the positions of the content term and each attribute term in the table text, and determine a distance evaluation value of the corresponding attribute term based on the distance between the position of the content term and the position of each attribute term; A term association module is used to splice the content term with each attribute term, input each splicing result into a trained association discrimination model, determine the output discrimination probability value as the semantic evaluation value of the corresponding attribute term, calculate the weighted mean of the distance evaluation value and the semantic evaluation value of each attribute term, and determine the attribute term corresponding to the minimum weighted mean as the associated term of the content term; an association embedding module, configured to encode the associated terms using a preset encoding method to obtain an associated embedding vector, add the content embedding vector to the associated embedding vector, determine a target embedding vector corresponding to the content terms, and obtain target embedding vectors corresponding to all content terms; The text classification module is used to concatenate the target embedding vectors corresponding to all content entries and input them into the trained classification model to perform text classification, thereby obtaining the classification result of the table text.
9. A computer device, characterized in that: The computer device includes a processor, a memory, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the text classification method according to any one of claims 1 to 7 is implemented.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the text classification method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Text classification method, language model training method, devices and equipment
CN111930942A
Document information extraction method and device, equipment and medium
CN114821590A