Text knowledge supplementation method and device based on knowledge graph

By acquiring and processing multiple vectors in text classification, combining bidirectional GRU network and knowledge graph, and calculating and adjusting relationship weights for knowledge supplementation, the problems of semantic understanding difficulties and sparse features in text classification are solved, and the knowledge quality and classification accuracy are improved.

CN113919333BActive Publication Date: 2025-04-04PING AN TECH (SHENZHEN) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111235816.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-10-22
Publication Date
2025-04-04
Estimated Expiration
2041-10-22

AI Technical Summary

Technical Problem

The prior art has problems with semantic understanding and sparse features in text classification processing, especially in text knowledge supplement methods that introduce external knowledge. The quality of knowledge is low, resulting in the lack of context information in the text and poor semantic understanding effect.

Method used

By obtaining the character vector, word vector and subject vector of the text, stitching to get the word vector matrix and input it into a bidirectional GRU network to output a hidden state. Use the self-attention mechanism to process hidden states, call the knowledge graph for conceptualization, calculate the relationship weight between the concept vector and the eigenvector and the importance weight of the concept vector, adjust the relationship weight to weight to calculate the characteristics of the concept set, and supplement knowledge.

Benefits of technology

The quality of the introduced knowledge is improved, and the text is supplemented more fully and effectively, thereby improving the accuracy of text classification and solving the problems of semantic understanding difficulties and sparse features.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113919333B_ABST
    Figure CN113919333B_ABST
Patent Text Reader

Abstract

The embodiment of the present application provides a method and device for supplementing text knowledge based on a knowledge graph, the method comprising: obtaining and concatenating the character vector, word vector and topic vector of the text, and inputting them into a bidirectional GRU to obtain a hidden state; using a self-attention mechanism to process the hidden state, obtaining a feature matrix, and converting it into a feature vector through a pooling layer; calling the knowledge graph to conceptualize the text, obtaining a concept set including a concept vector; calculating the relationship weight between the concept vector and the feature vector; calculating the importance weight of the concept vector in the concept set; adjusting the corresponding relationship weight using the importance weight, and performing weighted calculation on each concept vector according to the adjusted relationship weight to obtain a concept set feature, so as to supplement the text with knowledge through the concept set feature. The present application expands the text features from the character granularity, word granularity and text granularity levels, and uses the knowledge graph to make up for the lack of text context information.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of natural language processing, and in particular to a method and device for supplementing text knowledge based on a knowledge graph. Background Art

[0002] Text classification is a widely used natural language processing technology. Text classification can quickly mine implicit information from massive amounts of text on the Internet and is widely used in information retrieval, question-answering systems, dialogue systems and other fields.

[0003] Since the texts on the Internet are short, lack context, and are not rigorously expressed, there are problems such as difficulty in semantic understanding and sparse features in text classification. The use of knowledge graphs can effectively alleviate the problem of sparse features in texts. However, in the text knowledge supplementation method that introduces external knowledge, there is still a problem of low quality of the introduced knowledge, which leads to a lack of contextual information in the text and poor semantic understanding. Summary of the invention

[0004] The present application aims to solve the problems of the prior art to at least a certain extent, and to provide a text knowledge supplement method, apparatus, computer device and computer-readable storage medium based on a knowledge graph, which can improve the quality of introduced knowledge, thereby more fully and effectively supplementing the text with knowledge.

[0005] The technical solution of the embodiment of the present application is as follows:

[0006] In a first aspect, the present application provides a text knowledge supplement method based on a knowledge graph, the method comprising:

[0007] Get the character vector, word vector and topic vector of the text;

[0008] Concatenate the character vector, the word vector and the topic vector to obtain a word vector matrix;

[0009] Inputting the word vector matrix into a bidirectional gated recurrent unit (GRU) network to output a hidden state through the bidirectional GRU network;

[0010] Processing the hidden state using a self-attention mechanism to obtain a feature matrix of the text;

[0011] Calling the knowledge graph to conceptualize the text to obtain a concept set including a concept vector;

[0012] Inputting the feature matrix into a pooling layer to output a feature vector through the pooling layer;

[0013] Using an attention mechanism to calculate the relationship weight between the concept vector and the feature vector;

[0014] Using a self-attention mechanism to calculate the importance weight of the concept vector in the concept set;

[0015] The importance weight is used to adjust the corresponding relationship weight, and each concept vector is weighted calculated according to the adjusted relationship weight to obtain a concept set feature, so as to supplement the text with knowledge through the concept set feature.

[0016] According to some embodiments of the present application, the calculation formula of the relationship weight is:

[0017]

[0018] Among them, the a i is the relationship weight between the concept vector in the i-th concept set and the feature vector q of the text, and the c i Represents the i-th concept vector in the concept set, i is an integer greater than 1, is the weight matrix, is the weight vector, the d a is a hyperparameter, and b1 is a bias.

[0019] According to some embodiments of the present application, the calculation formula of the importance weight is:

[0020]

[0021] Among them, the β i is the importance weight of the concept vector in the i-th concept set in the concept set, and the c i Represents the i-th concept vector in the concept set, is the weight matrix, is the weight vector, the d b is a hyperparameter, and b2 is a bias.

[0022] According to some embodiments of the present application, the calculation formula for adjusting the corresponding relationship weight using the importance weight is:

[0023] α i =softmax(γα i +(1-γ)β i )

[0024] Wherein, the γ is an adaptive coefficient based on a neural network, γ∈(0,1).

[0025] According to some embodiments of the present application, the method for obtaining the character vector of the text is as follows:

[0026] A convolutional neural network (CNN) model with character granularity as input unit is established, and character features of each word in the word sequence in the text are extracted through the CNN model to obtain a character vector.

[0027] According to some embodiments of the present application, the method for obtaining the word vector of the text is as follows:

[0028] Map the words in the text into word vectors.

[0029] According to some embodiments of the present application, a method for obtaining a topic vector of the text is as follows:

[0030] Inputting the text into a word to vector (word2vec) model to obtain multiple word vectors corresponding to the text;

[0031] For each word vector, input it into a pre-trained Latent Dirichlet Allocation (LDA) model, so that the LDA model outputs multiple topics corresponding to the word vector and probability distribution values ​​corresponding to the topics;

[0032] Select a topic with the largest probability distribution value from the topics as a target topic, and obtain a keyword file corresponding to the target topic, wherein the keyword file includes multiple keywords and probability values ​​corresponding to the keywords;

[0033] Sort the multiple subject words from large to small according to the probability values, and select the first K subject words as target subject words;

[0034] According to the probability value of each target keyword, the weight of each target keyword is obtained;

[0035] According to the weight of each target topic word, a weighted operation is performed on the K target topic words to obtain a topic feature corresponding to the word vector;

[0036] According to the topic features corresponding to each word vector, the topic vector corresponding to the text is obtained.

[0037] In a second aspect, the present application provides a text knowledge supplement device based on a knowledge graph, comprising:

[0038] Vector acquisition module, used to obtain character vectors, word vectors and topic vectors of text;

[0039] A vector concatenation module, used for concatenating the character vector, the word vector and the topic vector to obtain a word vector matrix;

[0040] A hidden state acquisition module, used for inputting the word vector matrix into a bidirectional GRU network to output a hidden state through the bidirectional GRU network;

[0041] A hidden state processing module, used to process the hidden state using a self-attention mechanism to obtain a feature matrix of the text;

[0042] A text knowledge acquisition module, used to call the knowledge graph to conceptualize the text and obtain a concept set including a concept vector;

[0043] A feature matrix processing module, used for inputting the feature matrix into a pooling layer to output a feature vector through the pooling layer;

[0044] A first weight acquisition module, used for calculating the relationship weight between the concept vector and the feature vector using an attention mechanism;

[0045] A second weight acquisition module, used for calculating the importance weight of the concept vector in the concept set by using a self-attention mechanism;

[0046] The text knowledge supplement module is used to adjust the corresponding relationship weight using the importance weight, and perform weighted calculation on each concept vector according to the adjusted relationship weight to obtain a concept set feature, so as to supplement the text knowledge through the concept set feature.

[0047] In a third aspect, the present application provides a computer device, comprising a memory and a processor, wherein the memory stores computer-readable instructions, and when the computer-readable instructions are executed by one or more of the processors, the one or more processors execute the steps of any one of the methods described in the first aspect above.

[0048] In a fourth aspect, the present application also provides a computer-readable storage medium, which can be read and written by a processor, and the storage medium stores computer instructions. When the computer-readable instructions are executed by one or more processors, the one or more processors execute the steps of any one of the methods described in the first aspect above.

[0049] The technical solution provided in the embodiments of the present application has the following beneficial effects:

[0050] The embodiment of the present application obtains the character vector, word vector and topic vector of the text, concatenates them to obtain the word vector matrix, and uses it as the input of the bidirectional GRU network to output the hidden state through the bidirectional GRU network, and then uses the self-attention mechanism to process the hidden state to obtain the feature matrix of the text, and calls the knowledge graph to conceptualize the text to obtain a concept set including the concept vector. In addition, the feature matrix is ​​input into the pooling layer to output the feature vector through the pooling layer, and the attention mechanism is used to calculate the relationship weight between the concept vector and the feature vector, and the self-attention mechanism is used to calculate the importance weight of the concept vector in the concept set, and then the importance weight is used to adjust the corresponding relationship weight, and each concept vector is weighted according to the adjusted relationship weight to obtain the concept set feature, so as to supplement the knowledge of the text through the concept set feature. The embodiment of the present application simultaneously models the text from the character granularity, word granularity and text granularity, expands the text features, and introduces the knowledge in the knowledge graph to supplement the text by associating the knowledge involved in the text with the knowledge graph. The importance weight is used to adjust the corresponding relationship weight, which more reasonably increases the weight of the key concept vector and reduces the incorrect concepts introduced due to the ambiguity of the entities in the knowledge graph or irrelevant noise. Text classification based on the text knowledge supplementation method of the embodiment of the present application can improve the quality of the introduced knowledge, more fully and effectively supplement the text with knowledge, and thus more accurately classify the text. BRIEF DESCRIPTION OF THE DRAWINGS

[0051] Figure 1 It is a flowchart of a text knowledge supplement method based on knowledge graph provided by an embodiment of the present application;

[0052] Figure 2 is a flowchart of a text knowledge supplement method based on a knowledge graph provided by another embodiment of the present application;

[0053] Figure 3 is a structural diagram of a text classification model provided by an embodiment of the present application;

[0054] Figure 4 It is a structural schematic diagram of a text knowledge supplement device based on a knowledge graph provided by an embodiment of the present application;

[0055] Figure 5 It is a schematic diagram of the structure of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0056] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0057] In the embodiments of the present application, "at least one" refers to one or more, and "more than one" 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 the existence of A alone, the existence of A and B at the same time, and the existence of B alone. Among them, A and B can be singular or plural. The text " / " generally indicates that the previous and next associated objects are in an "or" relationship. "At least one of the following" and similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one of a, b and c can represent: a, b, c, a and b, a and c, b and c, or a and b and c, where a, b, c can be single or multiple.

[0058] It should be understood that the embodiments of the present application can acquire and process relevant data based on artificial intelligence technology. Among them, artificial intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results. Basic artificial intelligence technologies generally include technologies such as sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, big data processing technology, operation / interaction systems, mechatronics, etc. Artificial intelligence software technology mainly includes computer vision technology, robotics technology, biometrics technology, speech processing technology, natural language processing technology, and machine learning / deep learning.

[0059] See also Figure 1 , Figure 1 The flowchart of a text knowledge supplement method based on knowledge graph provided by an embodiment of the present application is shown. It can be understood that the method of the embodiment of the present application can be applied to a server, the method can also be applied to a terminal, and can also be applied to a system including a terminal and a server, and is implemented through the interaction between the terminal and the server. Figure 1 As shown, the method comprises the following steps:

[0060] Step S110, obtaining the character vector, word vector and topic vector of the text.

[0061] In some embodiments, a CNN model with character granularity as input unit is established, and character features of each word in the word sequence in the text are extracted through the CNN model to obtain a character vector.

[0062] Convolutional neural networks can be used to extract morphological information from the characters of words in a text, such as extracting the prefix or suffix of a word. By using character embedding as an extension of word vectors, additional information can be provided for words that lack word vectors. By using character-level word embedding vectors and concatenating them with word vectors as the input of a text encoding model, for example, by inputting a word sequence of text {x1, x2, ..., x i , ..., x n}, x i Represents the i-th word in the text, where x i The word contains characters of length L, c j For word x i Each character in the embedding vector represents a corresponding feature, and a standard convolutional neural network is used to process each word x. i The character sequence in can be trained to obtain the character vector of the word

[0063]

[0064] Among them, W CNN With b CNN is a training parameter, ke represents the convolution kernel size, and max represents the maximum pooling operation.

[0065] In some embodiments, the method for obtaining the word vector of the text is as follows: mapping the words in the text into word vectors.

[0066] By transforming the word sequence {x1, x2, ..., x i , ..., x n The words in} are mapped to word vectors one by one: It is understandable that the word2vec model can be used to map each word in a word sequence to a word vector.

[0067] In some embodiments, see Figure 2 , Figure 2 A flow chart of a text knowledge supplement method based on a knowledge graph provided in an embodiment of the present application is shown, and a method for obtaining a topic vector of the text is as follows:

[0068] Step S210, input the text into the word2vec model to obtain multiple word vectors corresponding to the text.

[0069] Use the word2vec model to map each word in the text to a vector and get the word vector corresponding to each word in the text.

[0070] Step S220: For each word vector, each word vector is input into a pre-trained LDA model, so that the LDA model outputs multiple topics corresponding to the word vector and probability distribution values ​​corresponding to the topics.

[0071] It can be understood that by using the LDA model to train the topic model on the text training set, a topic word file including X topics and Y topic words corresponding to the topics and probability values ​​is obtained, where X and Y are integers greater than 1. By inputting the word vectors of the text words into the trained LDA model, multiple topics corresponding to the input word vectors and the probability distribution corresponding to the topics are obtained.

[0072] Exemplarily, 500 news items are selected as the text training set. First, the file training set is cleaned, stop words, non-Chinese special characters, etc. are removed, and then word segmentation is performed, and each news item is digitized, and finally used as input to train the LDA model. LDA is an unsupervised learning method. It only needs to specify the number of topics during training. For example, the number of topics is specified as 4. After the training of the LDA model is completed, a topic word file including 4 topics and several topic words and probabilities under these 4 topics is obtained, such as: (0, '0.08*"Fund" + 0.014*"Market" + 0.013*"Company" + 0.012*"Investment" + 0.011*"Stock" + 0.010*"Dividend" + ... ') and other information, wherein 0 represents the first topic; taking '0.08*"Fund" as an example, 0.08 represents the probability distribution value of the topic word "Fund" under the first topic. After that, the word vector of the text word is input into the trained LDA model to obtain the topic distribution result, such as: [(0, 0.07), (1, 0.46), (2, 0.24), (3, 0.23)]. Taking (1, 0.46) as an example, 1 represents the second topic, and 0.46 represents the probability value that the input word vector belongs to this topic.

[0073] Step S230, selecting a topic with the largest probability distribution value from the topics as a target topic, and obtaining a topic word file corresponding to the target topic, wherein the topic word file includes a plurality of topic words and probability values ​​corresponding to the topic words.

[0074] Exemplarily, when the topic probability distribution is [(0, 0.07), (1, 0.46), (2, 0.24), (3, 0.23)], it can be seen that the topic with the largest probability distribution value is the second topic. The second topic is taken as the target topic, and a topic word file including the target topic and Y topic words corresponding to the target topic and probability values ​​as described above is obtained.

[0075] Step S240 , sorting the multiple subject words from large to small according to the probability values, and selecting the first K subject words as target subject words.

[0076] After obtaining a subject word file including a target subject, subject words corresponding to the subject, and probability values, the subject words are sorted from large to small according to the probability values, and the first K subject words are selected as target subject words, where K is an integer greater than 1.

[0077] Exemplarily, a keyword file including a target topic and keywords corresponding to the target topic and probability values ​​is obtained, and the keywords are sorted from large to small according to the probability values, for example: (0, '0.08*"fund"+0.014*"market"+0.013*"company"+0.012*"investment"+0.011*"stock"+0.010*"dividend"+…'), and the first 5 keywords are selected as target keywords, that is, fund, market, investment, stock and dividend are selected as target keywords.

[0078] Step S250, obtaining the weight of each target keyword according to the probability value of each target keyword.

[0079] Each target keyword {r1, r2, ..., r k The probability values ​​of {p1, p2, ..., p k}Normalized as the weight of the target keyword.

[0080] For example, when the probability values ​​corresponding to K=5 target keywords are selected as (0.08, 0.014, 0.013, 0.012, 0.011), the following formula can be used to calculate the normalized probability values:

[0081]

[0082] Among them, q i Represents the probability value p i The normalized value is the weight corresponding to the target keyword.

[0083] Step S260, performing a weighted operation on the K target topic words according to the weight of each target topic word, to obtain a topic feature corresponding to the word vector.

[0084] It can be understood that the weight of the target topic word is multiplied by the word vector corresponding to the target topic word to obtain the topic feature of each topic word.

[0085] Step S270, obtaining the topic vector corresponding to the text according to the topic features corresponding to each word vector.

[0086] For example, the topic vector The calculation formula is:

[0087]

[0088] Among them, K is the number of target keywords, q m is the weight of the target keyword, C(r m ) is the word vector of the target topic word, q m ×C(r m ) is the topic feature of the target keyword.

[0089] By summing up the topic vectors of each target topic word, the topic features of the text are obtained.

[0090] Step S120, concatenating the character vector, the word vector and the topic vector to obtain a word vector matrix.

[0091] Exemplary, concatenating character vectors, word vectors, and topic vectors in Represent the corresponding character vector, word vector and topic vector in the text respectively, so as to obtain the word vector matrix E = (E1, E2, ..., E n ).

[0092] Step S130, inputting the word vector matrix into the bidirectional GRU network to output the hidden state through the bidirectional GRU network.

[0093] It can be understood that the word vector matrix E = (E1, E2, ..., E n ) as the input of the bidirectional GRU network. The forward GRU network in the bidirectional GRU network reads the input sequence (E1, E2, ..., E n ), the reverse GRU network reads the input sequence in reverse order (E n , E n-1 ,…,E1), the input vector E at each time t i After the calculation of the gated recurrent unit, the forward hidden state at each moment is obtained and the reverse hidden state The forward hidden state at each moment The reverse hidden state at the corresponding moment Connect to get the hidden state at that moment:

[0094] Step S140, using a self-attention mechanism to process the hidden state to obtain a feature matrix of the text.

[0095] The self-attention mechanism is used to process the hidden state at each moment, and the words input at each time step are weighted according to the attention calculation, so that important words have higher weights and the feature matrix of the text is obtained.

[0096] Step S150, calling the knowledge graph to conceptualize the text to obtain a concept set including concept vectors.

[0097] Map the keywords in the text to the entities in the knowledge graph, map the text keywords to the target entities through entity linking technology, obtain the concept set of the text and vectorize it to obtain a concept set including concept vectors.

[0098] For example, the keywords in the text are mapped to entities in the encyclopedia general knowledge graph CN-DBpedia or Microsoft's ConceptGraph knowledge graph, and the text keywords are mapped to the target entities through the entity linking technology to obtain a text concept set C including concept vectors = (c1, c2, ..., c i , ..., c m ), where c i Represents the concept vector in the i-th concept set.

[0099] Step S160: input the feature matrix into a pooling layer to output a feature vector through the pooling layer.

[0100] The feature matrix of the text is converted into a feature vector through the maximum pooling layer. It can be understood that the feature matrix of the text can be compressed into a feature vector by using the maximum pooling layer.

[0101] For example, the text matrix h′∈R n×2n After the maximum pooling layer, it is converted into a feature vector q∈R 2n .

[0102] Step S170: Use the attention mechanism to calculate the relationship weight between the concept vector and the feature vector.

[0103] In some embodiments, the relationship weight is calculated as follows:

[0104]

[0105] Among them, the a i is the relationship weight between the concept vector in the i-th concept set and the feature vector q of the text, and the c i Represents the i-th concept vector in the concept set, i is an integer greater than 1, is the weight matrix, is the weight vector, the d a is a hyperparameter, and b1 is a bias.

[0106] Step S180, using a self-attention mechanism to calculate the importance weight of the concept vector in the concept set.

[0107] The self-attention mechanism is introduced into the concept set and attention calculation is performed to obtain the importance weight of each concept vector in the entire concept set. It should be noted that the attention mechanism gives a larger weight to important concepts and a very small weight to unimportant concepts to highlight the important concepts in the concept set.

[0108] In some embodiments, the calculation formula of the importance weight is:

[0109]

[0110] Among them, the β i is the importance weight of the concept vector in the i-th concept set in the concept set, and the c i Represents the i-th concept vector in the concept set, is the weight matrix, is the weight vector, the d b is a hyperparameter, and b2 is a bias.

[0111] Step S190, using the importance weight to adjust the corresponding relationship weight, and performing weighted calculation on each concept vector according to the adjusted relationship weight to obtain a concept set feature, so as to supplement the text with knowledge through the concept set feature.

[0112] In some embodiments, the calculation formula for adjusting the corresponding relationship weight using the importance weight is:

[0113] α i =softmax(γα i +(1-γ)β i )

[0114] Wherein, the γ is an adaptive coefficient based on a neural network, γ∈(0,1).

[0115] The importance weights are used to adjust the relationship weights, so as to better calculate the semantic relevance between the text and the corresponding concept set, increase the weights of the key concept vectors more reasonably, and reduce the incorrect concepts introduced due to entity ambiguity or irrelevant noise.

[0116] According to the adjusted relationship weights, the weighted sum of the concept vectors is calculated to obtain the semantic vector representing the concept That is, the concept feature set, where m is the total number of concept vectors in the concept set, c i is the i-th concept vector in the concept set, a i is the corresponding concept vector c i The adjusted relationship weights.

[0117] For example, refer to Figure 3 , Figure 3 A structural schematic diagram of a text classification model provided in an embodiment of the present application is shown, and a text knowledge supplement method based on a knowledge graph provided in an embodiment of the present application is described based on this text classification model.

[0118] This text classification model combines knowledge graph, attention mechanism and bidirectional GRU network. The model mainly consists of two parts:

[0119] Part 1, text encoding: After obtaining the character vector, word vector and topic vector of the text, the character vector, word vector and topic vector are concatenated to obtain the word vector matrix, and then the word vector matrix is ​​input into the bidirectional GRU network to output the hidden state through the bidirectional GRU network. Finally, the self-attention layer is used to process the hidden state using the self-attention mechanism to obtain the feature matrix of the text.

[0120] The second part is knowledge conceptualization encoding: calling the knowledge graph to conceptualize the text and obtain a concept set including concept vectors. In addition, the feature matrix is ​​input into the pooling layer to output the feature vector through the pooling layer. Then, the attention mechanism is used to calculate the relationship weight between the concept vector and the feature vector and the self-attention mechanism is used to calculate the importance weight of the concept vector in the concept set. The importance weight is used to adjust the corresponding relationship weight to increase the weight of the concept vector that is closely related to the text in the concept set and reduce the introduction of some incorrect concepts due to entity ambiguity or irrelevant noise. According to the adjusted relationship weight, each concept vector is weighted and calculated to obtain the concept set feature.

[0121] It is further understood that, although the operations are described in a specific order in the accompanying drawings in the embodiments of the present invention, it should not be understood as requiring the operations to be performed in the specific order or serial order shown, or requiring the execution of all the operations shown to obtain the desired results. In certain environments, multitasking and parallel processing may be advantageous.

[0122] The embodiment of the present application obtains the character vector, word vector and topic vector of the text, concatenates them to obtain the word vector matrix, and uses it as the input of the bidirectional GRU network to output the hidden state through the bidirectional GRU network, and then uses the self-attention mechanism to process the hidden state to obtain the feature matrix of the text, and calls the knowledge graph to conceptualize the text to obtain a concept set including the concept vector. In addition, the feature matrix is ​​input into the pooling layer to output the feature vector through the pooling layer, and the attention mechanism is used to calculate the relationship weight between the concept vector and the feature vector, and the self-attention mechanism is used to calculate the importance weight of the concept vector in the concept set, and then the importance weight is used to adjust the corresponding relationship weight, and each concept vector is weighted according to the adjusted relationship weight to obtain the concept set feature, so as to supplement the knowledge of the text through the concept set feature. The embodiment of the present application simultaneously models the text from the character granularity, word granularity and text granularity, expands the text features, and introduces the knowledge in the knowledge graph to supplement the text by associating the knowledge involved in the text with the knowledge graph. The importance weight is used to adjust the corresponding relationship weight, which more reasonably increases the weight of the key concept vector and reduces the incorrect concepts introduced due to the ambiguity of the entities in the knowledge graph or irrelevant noise. Text classification based on the text knowledge supplementation method of the embodiment of the present application can improve the quality of the introduced knowledge, more fully and effectively supplement the text with knowledge, and thus more accurately classify the text.

[0123] Reference Figure 4 , a text knowledge supplement device 200 based on a knowledge graph is provided in an embodiment of the present application, comprising:

[0124] A vector acquisition module 210, used to acquire character vectors, word vectors and topic vectors of a text;

[0125] A vector concatenation module 220, configured to concatenate the character vector, the word vector and the topic vector to obtain a word vector matrix;

[0126] A hidden state acquisition module 230, used for inputting the word vector matrix into a bidirectional GRU network to output a hidden state through the bidirectional GRU network;

[0127] A hidden state processing module 240 is used to process the hidden state using a self-attention mechanism to obtain a feature matrix of the text;

[0128] A text knowledge acquisition module 250 is used to call the knowledge graph to perform conceptual processing on the text to obtain a concept set including a concept vector;

[0129] A feature matrix processing module 260, used for inputting the feature matrix into a pooling layer to output a feature vector through the pooling layer;

[0130] A first weight acquisition module 270, configured to calculate the relationship weight between the concept vector and the feature vector using an attention mechanism;

[0131] A second weight acquisition module 280, configured to calculate the importance weight of the concept vector in the concept set using a self-attention mechanism;

[0132] The text knowledge supplement module 290 is used to adjust the corresponding relationship weight using the importance weight, and perform weighted calculation on each concept vector according to the adjusted relationship weight to obtain a concept set feature, so as to supplement the text knowledge through the concept set feature.

[0133] In some embodiments, the vector acquisition module specifically includes:

[0134] A character vector acquisition unit, used to acquire the character vector of the text;

[0135] A word vector acquisition unit, used to acquire the word vector of the text;

[0136] The topic vector acquisition unit is used to acquire the topic vector of the text.

[0137] In some embodiments, the text knowledge supplement module specifically includes:

[0138] A weight adjustment unit, used to adjust the corresponding relationship weight using the importance weight;

[0139] The weighted calculation unit is used to perform weighted calculation on each concept vector according to the adjusted relationship weight to obtain the concept set feature.

[0140] The knowledge supplement unit is used to supplement the text with knowledge through the concept set features.

[0141] The embodiment of the present application obtains the character vector, word vector and topic vector of the text through the vector acquisition module, the vector concatenation module concatenates the above vectors to obtain the word vector matrix, the hidden state acquisition module uses it as the input of the bidirectional GRU network to output the hidden state through the bidirectional GRU network, and then the hidden state processing module uses the self-attention mechanism to process the hidden state to obtain the feature matrix of the text, and the text knowledge acquisition module calls the knowledge graph to conceptualize the text to obtain a concept set including the concept vector. In addition, the feature matrix processing module inputs the feature matrix into the pooling layer to output the feature vector through the pooling layer, the first weight acquisition module uses the attention mechanism to calculate the relationship weight between the concept vector and the feature vector, and the second weight acquisition module uses the self-attention mechanism to calculate the importance weight of the concept vector in the concept set. Finally, the text knowledge supplement module uses the importance weight to adjust the corresponding relationship weight, and performs weighted calculation on each concept vector according to the adjusted relationship weight to obtain the concept set feature, so as to supplement the text with knowledge through the concept set feature. The embodiment of the present application simultaneously models the text from the character granularity, word granularity and text granularity, expands the text features, and introduces the knowledge in the knowledge graph to supplement the text by associating the knowledge involved in the text with the knowledge graph. The importance weight is used to adjust the corresponding relationship weight, which more reasonably increases the weight of the key concept vector and reduces the incorrect concepts introduced due to the ambiguity of the entities in the knowledge graph or irrelevant noise. Text classification based on the text knowledge supplementation method of the embodiment of the present application can improve the quality of the introduced knowledge, more fully and effectively supplement the text with knowledge, and thus more accurately classify the text.

[0142] It should be noted that the information interaction, execution process, etc. between the above-mentioned modules / units are based on the same concept as the method embodiment of the present application. Their specific functions and technical effects can be found in the method embodiment part and will not be repeated here.

[0143] Figure 5 The computer device 300 provided in the embodiment of the present application is shown. The computer device 300 may be a server or a terminal, and the internal structure of the computer device 300 includes but is not limited to:

[0144] A memory 310, used for storing programs;

[0145] The processor 320 is used to execute the program stored in the memory 310. When the processor 320 executes the program stored in the memory 310, the processor 320 is used to execute the above-mentioned text knowledge supplement method based on the knowledge graph.

[0146] The processor 320 and the memory 310 may be connected via a bus or in other ways.

[0147] The memory 310 is a non-transitory computer-readable storage medium that can be used to store non-transitory software programs and non-transitory computer executable programs, such as the text knowledge supplement method based on the knowledge graph described in any embodiment of the present invention. The processor 320 implements the above-mentioned text knowledge supplement method based on the knowledge graph by running the non-transitory software program and instructions stored in the memory 310.

[0148] The memory 310 may include a program storage area and a data storage area, wherein the program storage area may store an operating system and application programs required for at least one function; the data storage area may store and execute the above-mentioned text knowledge supplement method based on the knowledge graph. In addition, the memory 310 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage devices. In some embodiments, the memory 310 may optionally include a memory remotely arranged relative to the processor 320, and these remote memories may be connected to the processor 320 via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0149] The non-transient software programs and instructions required to implement the above-mentioned knowledge graph-based text knowledge supplement method are stored in the memory 310. When executed by one or more processors 320, the knowledge graph-based text knowledge supplement method provided by any embodiment of the present invention is executed.

[0150] An embodiment of the present application also provides a computer-readable storage medium storing computer-executable instructions, which are used to execute the above-mentioned text knowledge supplementation method based on knowledge graph.

[0151] In one embodiment, the storage medium stores computer executable instructions, which are executed by one or more control processors, for example, by one or more processors 320 in the above-mentioned computer device 300, so that the above-mentioned one or more processors 320 can execute the text knowledge supplement method based on the knowledge graph provided in any embodiment of the present invention.

[0152] The above described embodiments are merely illustrative, and the units described as separate components may or may not be physically separated, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the present embodiment.

[0153] It will be appreciated by those skilled in the art that all or some of the steps and systems in the disclosed method above may be implemented as software, firmware, hardware and appropriate combinations thereof. Some physical components or all physical components may be implemented as software executed by a processor, such as a central processing unit, a digital signal processor or a microprocessor, or may be implemented as hardware, or may be implemented as an integrated circuit, such as an application specific integrated circuit. Such software may be distributed on a computer-readable medium, which may include a computer storage medium (or a non-transitory medium) and a communication medium (or a temporary medium). As known to those skilled in the art, the term computer storage medium includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information (such as computer-readable instructions, data structures, program modules or other data). Computer storage media include, but are not limited to, RAM, ROM, EEPROM, flash memory or other memory technologies, CD-ROM, digital versatile disks (DVD) or other optical disk storage, magnetic cassettes, magnetic tapes, disk storage or other magnetic storage devices, or any other medium that may be used to store desired information and may be accessed by a computer. Furthermore, it is well known to those skilled in the art that communication media generally include computer readable instructions, data structures, program modules, or other data in a modulated data signal such as a carrier wave or other transport mechanism, and may include any information delivery media.

[0154] The above is a specific description of the preferred implementation of the present invention, but the present invention is not limited to the above implementation. Those skilled in the art can make various equivalent modifications or substitutions without violating the spirit of the present invention. These equivalent modifications or substitutions are all included in the scope defined by the claims of the present invention.

Claims

1. A text knowledge supplementation method based on knowledge graph, characterized in that: The method comprises: Get the character vector, word vector and topic vector of the text; Concatenate the character vector, the word vector and the topic vector to obtain a word vector matrix; Inputting the word vector matrix into a bidirectional GRU network to output a hidden state through the bidirectional GRU network; Processing the hidden state using a self-attention mechanism to obtain a feature matrix of the text; Calling the knowledge graph to conceptualize the text to obtain a concept set including a concept vector; Inputting the feature matrix into a pooling layer to output a feature vector through the pooling layer; Using an attention mechanism to calculate the relationship weight between the concept vector and the feature vector; Using a self-attention mechanism to calculate the importance weight of the concept vector in the concept set; Using the importance weight to adjust the corresponding relationship weight, and performing weighted calculation on each concept vector according to the adjusted relationship weight to obtain a concept set feature, so as to supplement the text with knowledge through the concept set feature; The calculation formula of the relationship weight is: Among them, the a i is the relationship weight between the concept vector in the i-th concept set and the feature vector q of the text, and the c i Represents the i-th concept vector in the concept set, i is an integer greater than 1, is the weight matrix, is the weight vector, the d a is a hyperparameter, and b1 is a bias; The calculation formula of the importance weight is: Among them, the β i is the importance weight of the concept vector in the i-th concept set in the concept set, and the c i Represents the i-th concept vector in the concept set, is the weight matrix, is the weight vector, the d b is a hyperparameter, and b2 is a bias.

2. The method according to claim 1, characterized in that The calculation formula for adjusting the corresponding relationship weight using the importance weight is: a i =softmax(ca i +(1-c)b i ) Wherein, the γ is an adaptive coefficient based on a neural network, γ∈(0,1).

3. The method according to claim 1, characterized in that The method for obtaining the character vector of the text is as follows: A CNN model with character granularity as input unit is established, and character features of each word in the word sequence in the text are extracted through the CNN model to obtain a character vector.

4. The method according to claim 1, characterized in that: The method for obtaining the word vector of the text is as follows: Map the words in the text into word vectors.

5. The method according to claim 1, characterized in that The method for obtaining the topic vector of the text is as follows: Input the text into the word2vec model to obtain multiple word vectors corresponding to the text; For each word vector, input it into a pre-trained LDA model, so that the LDA model outputs multiple topics corresponding to the word vector and probability distribution values ​​corresponding to the topics; Select a topic with the largest probability distribution value from the topics as a target topic, and obtain a keyword file corresponding to the target topic, wherein the keyword file includes multiple keywords and probability values ​​corresponding to the keywords; Sort the multiple subject words from large to small according to the probability values, and select the first K subject words as target subject words; According to the probability value of each target keyword, the weight of each target keyword is obtained; According to the weight of each target topic word, a weighted operation is performed on the K target topic words to obtain a topic feature corresponding to the word vector; According to the topic features corresponding to each word vector, the topic vector corresponding to the text is obtained.

6. A text knowledge supplement device based on knowledge graph, characterized in that: include: Vector acquisition module, used to obtain character vectors, word vectors and topic vectors of text; A vector concatenation module, used for concatenating the character vector, the word vector and the topic vector to obtain a word vector matrix; A hidden state acquisition module, used for inputting the word vector matrix into a bidirectional GRU network to output a hidden state through the bidirectional GRU network; A hidden state processing module, used to process the hidden state using a self-attention mechanism to obtain a feature matrix of the text; A text knowledge acquisition module, used to call the knowledge graph to conceptualize the text and obtain a concept set including a concept vector; A feature matrix processing module, used for inputting the feature matrix into a pooling layer to output a feature vector through the pooling layer; A first weight acquisition module, used for calculating the relationship weight between the concept vector and the feature vector using an attention mechanism; A second weight acquisition module, used for calculating the importance weight of the concept vector in the concept set by using a self-attention mechanism; A text knowledge supplementation module, used to adjust the corresponding relationship weight using the importance weight, and perform weighted calculation on each concept vector according to the adjusted relationship weight to obtain a concept set feature, so as to supplement the text with knowledge through the concept set feature; The calculation formula of the relationship weight is: Among them, the a i is the relationship weight between the concept vector in the i-th concept set and the feature vector q of the text, and the c i Represents the i-th concept vector in the concept set, i is an integer greater than 1, is the weight matrix, is the weight vector, the d a is a hyperparameter, and b1 is a bias; The calculation formula of the importance weight is: Among them, the β i is the importance weight of the concept vector in the i-th concept set in the concept set, and the c i Represents the i-th concept vector in the concept set, is the weight matrix, is the weight vector, the d b is a hyperparameter, and b2 is a bias.

7. A computer device, characterized in that: include: Memory, used to store programs; A processor, configured to execute the program stored in the memory. When the processor executes the program stored in the memory, the processor is configured to execute: the method as claimed in any one of claims 1 to 5.

8. A computer-readable storage medium, characterized in that: Computer executable instructions are stored, and the computer executable instructions are used to execute: the method according to any one of claims 1 to 5.

Citation Information

Patent Citations

  • Text sentiment analysis method based on BERT model and double-channel attention

    CN110717334A

  • Text classification method and device based on classification model, and model training method

    CN110781305A