Unsupervised Chinese word disambiguation method and device, terminal equipment and storage medium
By combining iterative update and multi-hop reasoning mechanisms in the semantic disambiguation process, the semantic map and disambiguation model are dynamically updated, and the lag problem of semantic disambiguation based on knowledge graphs in dynamic scenarios is solved, and the accuracy and efficiency of disambiguation are improved.
Patent Information
- Application Number
- CN202510022895.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-07
- Publication Date
- 2025-05-09
- Estimated Expiration
- 2045-01-07
AI Technical Summary
In dynamically changing semantic scenarios, the semantic disambiguation method based on knowledge graphs has lag, resulting in large errors and low efficiency.
By obtaining the text data input by the user, multi-layer features, including the first semantic layer features, and update the semantic map through iterative update and multi-hop inference mechanisms, obtain the second semantic layer features in combination with the disambiguation model, and dynamically update the semantic representation.
It improves the accuracy and efficiency of semantic disambiguation results, ensures that the semantic map can be updated in a timely manner and adapts to the dynamically changing semantic environment.
Smart Images

Figure CN119962540A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of natural language processing, and in particular to an unsupervised Chinese word disambiguation method, apparatus, terminal device and storage medium. Background Art
[0002] In the field of natural language processing, word disambiguation is an important research direction, which aims to solve the problem that words may have different meanings in different contexts. Existing word disambiguation methods usually achieve semantic disambiguation through supervised and unsupervised methods.
[0003] Among them, supervised methods rely on a large amount of annotated data, which needs to be manually annotated, which is time-consuming, labor-intensive, and costly. Although unsupervised semantic disambiguation methods do not need to rely on a large amount of annotated data, they still have a lot of limitations. The main reason is that traditional unsupervised semantic disambiguation methods only rely on the semantic features of local contexts, ignoring the long-distance dependencies between words in complex language structures, which leads to low accuracy of semantic disambiguation in complex semantic environments. Although unsupervised semantic disambiguation based on knowledge graphs can capture long-distance semantic dependencies between words, the existing technology usually collects a large amount of corpus data in advance, establishes a complete knowledge graph, and regularly updates the knowledge graph to ensure the correctness of the semantic information in the knowledge graph, thereby further ensuring the accuracy of subsequent semantic disambiguation. However, this method has a certain lag. When faced with dynamically changing semantic scenarios, this method will cause errors in the subsequent semantic disambiguation results obtained based on the knowledge graph.
[0004] Therefore, how to improve the accuracy of semantic relationships expressed in knowledge graphs in dynamically changing semantic scenarios while ensuring the efficiency and accuracy of semantic disambiguation is a technical problem that needs to be solved at present. Summary of the invention
[0005] The present application provides an unsupervised Chinese word disambiguation method, apparatus, terminal device and storage medium to solve the technical problem that semantic disambiguation based on knowledge graph has high lag in dynamically changing semantic scenarios, resulting in large semantic disambiguation errors and low semantic disambiguation efficiency.
[0006] In order to solve the above technical problems, in a first aspect, an embodiment of the present application provides an unsupervised Chinese word disambiguation method, comprising:
[0007] Acquire text data input by a user, perform text segmentation on the text data, acquire a number of words, and sequentially extract multi-layer features of each of the words; the multi-layer features include: first semantic layer features;
[0008] Iteratively update the first semantic layer features of each of the words. In each iterative update process, update a preset semantic graph according to the multi-layer features of each of the words, perform multi-hop reasoning on the semantic graph, and update the first fusion features of the nodes corresponding to each of the words; input the first fusion features of the nodes corresponding to each of the words into a pre-trained disambiguation model to obtain second semantic layer features, and update the first semantic layer features of the corresponding nodes according to the second semantic layer features;
[0009] When the first cosine similarity between the second semantic layer features obtained twice before and after each word and the second semantic layer features obtained last time is less than a preset value, the iterative update of the first semantic layer features is terminated, and the semantic representation of the corresponding word is obtained according to the second semantic layer features currently obtained.
[0010] Compared with the prior art, the embodiments of the present application have the following beneficial effects: by combining the disambiguation results and the semantic graph update in the process of semantic disambiguation, the semantic data in the semantic graph is updated in time through the semantic disambiguation results, and the updated semantic graph is used to improve the accuracy of subsequent semantic disambiguation results. After multiple feedback adjustments, the accuracy of the semantic disambiguation results and the semantic graph are automatically improved in the semantic disambiguation process, and the semantic graph can be updated in time. Moreover, since the features extracted from the unannotated text data are usually partially distorted or noisy when preliminary features are extracted, the features of each word in the text data are repeatedly iterated and optimized during the disambiguation process, and there is no need to collect additional corpus information in advance and perform a large number of annotation operations on the corpus data or perform additional unsupervised clustering on the corpus data, thereby improving the efficiency of disambiguation.
[0011] In some embodiments of the first aspect of the present application, sequentially extracting multi-layer features of each of the words includes:
[0012] Determine the part of speech of the word through a part-of-speech tagging tool, and obtain the lexical layer features of the word;
[0013] Converting the context of the word into a high-dimensional vector through a word vector space model to obtain the first semantic layer feature of the word;
[0014] By using sentiment analysis technology and combining the context of the word, the pragmatic features of the word are obtained.
[0015] Compared with the prior art, the above embodiment has the following beneficial effects: by clarifying the part of speech of a word, more important basic information is embedded for the fusion features obtained later; by using the word vector space model, semantic feature sharing is achieved, and the semantic relationship in the context is captured, providing more relevant semantic information for the fusion features obtained later; finally, considering the emotional tendency of the sentence in which the word is located, the fusion features obtained later not only include static lexical semantics, but also semantic expressions in different scenarios. By combining the features of three different dimensions, namely the lexical layer, the semantic layer and the pragmatic layer, more accurate and comprehensive fusion features are provided.
[0016] In some embodiments of the first aspect of the present application, after terminating the iterative update of the first semantic layer feature, the method further includes:
[0017] Obtaining, from the semantic graph, the first adjacent node of the node corresponding to each of the words;
[0018] constructing positive sample pairs according to each of the words and the first adjacent nodes of each of the words; constructing negative sample pairs according to the words that are not adjacent to each other;
[0019] A contrastive learning mechanism is adopted to train the word vector space model according to the positive sample pairs and the negative sample pairs.
[0020] Compared with the prior art, the above embodiment has the following beneficial effects: when the first semantic layer feature stops iterating, the latest updated semantic information of the disambiguation model can be obtained, so that the semantic graph also contains the latest updated semantic information. At this time, according to the latest data in the semantic graph, positive and negative sample pairs are constructed, and the contrast learning mechanism is used to continuously train the word vector space model, and the word vector space model is used as a feature sharing layer to realize the back propagation of the disambiguation result, so that in the subsequent feature extraction process, the word vector space model is dynamically updated to ensure that the word vector space model can adapt to the dynamically changing semantic environment and improve the accuracy of the semantic disambiguation result.
[0021] In some embodiments of the first aspect of the present application, the adopting a contrastive learning mechanism to train the word vector space model according to the positive sample pairs and the negative sample pairs includes:
[0022] The Euclidean distance between the positive sample pairs is minimized and the Euclidean distance between the negative sample pairs is maximized through the following loss function:
[0023]
[0024] Among them, L is the loss value; N is the number of sample pairs; D(W i ) is the Euclidean distance between sample pairs; y iis the label of the sample pair, 1 is a positive sample pair, and 0 is a negative sample pair; m represents the boundary threshold of the Euclidean distance.
[0025] Compared with the prior art, the above embodiment has the following beneficial effects: by minimizing the Euclidean distance between positive sample pairs, the word vector space model can cluster the semantic representations of similar words in similar positions in the high-dimensional vector space; by maximizing the Euclidean distance of negative sample pairs, the model can keep words with different semantics away, so that the word vector space model can effectively handle the semantic differences of polysemous words in different contexts, give accurate first semantic layer features, and improve the accuracy of disambiguation.
[0026] In some embodiments of the first aspect of the present application, updating a preset semantic graph according to the multi-layer features of each of the words includes:
[0027] Fusing the multiple layers of features to obtain a second fused feature corresponding to the word;
[0028] Determine whether there is a node corresponding to the word in the semantic graph; if not, generate a node corresponding to the word according to the second fusion feature; otherwise, update the node corresponding to the word according to the second fusion feature;
[0029] The second cosine similarity between the first semantic layer features of words corresponding to any two nodes in the semantic graph is calculated in sequence, and the edge between the corresponding two nodes is updated according to the second cosine similarity.
[0030] Compared with the prior art, the above embodiment has the following beneficial effects: the nodes in the semantic graph are updated in time through the fusion features after multi-layer feature fusion. If the corresponding node does not exist in the semantic graph, the corresponding node is added to the semantic graph, and the fusion feature is added to the corresponding node. Otherwise, the fusion feature in the corresponding node is updated according to the new fusion feature, thereby ensuring the real-time nature of the semantic information in the semantic graph under a dynamically changing semantic environment. In addition, through the first semantic layer feature that includes the contextual semantic relationship, the degree of association between two words can be accurately judged, so that the edges between nodes in the semantic graph can be effectively updated, thereby improving the accuracy of the semantic graph.
[0031] In some embodiments of the first aspect of the present application, performing multi-hop reasoning on the semantic graph to update the first fusion feature of each node corresponding to the word includes:
[0032] Acquire a first adjacent node adjacent to the node corresponding to the word, and calculate a third cosine similarity between the node corresponding to the word and each of the first adjacent nodes according to a first fusion feature of the node corresponding to the word and the first adjacent node;
[0033] Acquire second adjacent nodes adjacent to each of the first adjacent nodes, and calculate fourth cosine similarities between each of the first adjacent nodes and corresponding second adjacent nodes according to first fusion features of the first adjacent nodes and the second adjacent nodes;
[0034] Determining, according to the third cosine similarity and the fourth cosine similarity, a weight of the word corresponding to the first adjacent node and the second adjacent node;
[0035] The first fusion feature of the node corresponding to the word is determined according to the weight and the first fusion feature corresponding to the first adjacent node or the second adjacent node.
[0036] Compared with the prior art, the above embodiment has the following beneficial effects: through the multi-hop reasoning mechanism, word nodes can capture semantic relationships at a longer distance by calculating the similarity with adjacent nodes, thereby effectively solving the long-distance dependency problem and improving the accuracy of semantic disambiguation in long texts and complex semantic scenarios.
[0037] In some embodiments of the first aspect of the present application, determining the weight of the word corresponding to the first adjacent node and the second adjacent node according to the third cosine similarity and the fourth cosine similarity includes:
[0038] The weight of the first adjacent node or the second adjacent node is obtained by the following formula:
[0039]
[0040] in, is the weight of the i-th first adjacent node of the word; is the weight of the jth second adjacent node of the i-th first adjacent node of the word; S i is the third cosine similarity between the node corresponding to the word and the i-th first adjacent node; S i,j is the fourth cosine similarity between the i-th first adjacent node and the j-th second adjacent node; O and T are the number of first adjacent nodes and second adjacent nodes respectively.
[0041] Compared with the prior art, the above embodiment has the following beneficial effects: according to the similarity between the two nodes, the influence of the distant node on the current node is adaptively adjusted, wherein the closer the node is, the greater the probability that it may appear in the context of the corresponding word, and therefore the closer the node is, the greater the influence of the current node should be; at the same time, in order to ensure that the features with low correlation but still containing some valid information are fused to the current node, by considering the similarity between the current nearest neighbor node and the current node, more appropriate weights are adaptively assigned to nodes at a farther distance, thereby effectively improving the accuracy of the fusion features of polysemous words in the knowledge graph, and the method has strong anti-interference ability against noise words, and can effectively obtain fusion features of unlabeled data.
[0042] In a second aspect, the embodiment of the present application further provides an unsupervised Chinese word disambiguation device, comprising: a feature extraction module, a feature update module and a semantic acquisition module;
[0043] The feature extraction module is used to obtain text data input by the user, perform text segmentation on the text data, obtain a number of words, and extract multi-layer features of each of the words in sequence; the multi-layer features include: first semantic layer features;
[0044] The feature updating module is used to iteratively update the first semantic layer features of each of the words. In each iterative updating process, a preset semantic graph is updated according to the multi-layer features of each of the words, and multi-hop reasoning is performed on the semantic graph to update the first fusion features of the nodes corresponding to each of the words; the first fusion features of the nodes corresponding to each of the words are input into a pre-trained disambiguation model to obtain second semantic layer features, and the first semantic layer features of the corresponding nodes are updated according to the second semantic layer features;
[0045] The semantic acquisition module is used to terminate the iterative update of the second semantic layer features corresponding to each word currently acquired and the second semantic layer features acquired last time when the first cosine similarity between the first semantic layer features corresponding to each word currently acquired and the second semantic layer features acquired last time is less than a preset value, and acquire the semantic representation of the corresponding word based on the second semantic layer features currently acquired.
[0046] In a third aspect, the present application also provides a terminal device, comprising a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein the processor implements the above-mentioned unsupervised Chinese word disambiguation method when executing the computer program.
[0047] In a fourth aspect, the present application also provides a computer-readable storage medium, which includes a stored computer program, wherein when the computer program is running, the device where the computer-readable storage medium is located is controlled to execute the above-mentioned unsupervised Chinese word disambiguation method. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] Figure 1 A flowchart of an unsupervised Chinese word disambiguation method provided in some embodiments of the present application;
[0049] Figure 2 A schematic diagram of a semantic graph obtained by an unsupervised Chinese word disambiguation method provided in some embodiments of the present application before and after updating;
[0050] Figure 3 Another flowchart of an unsupervised Chinese word disambiguation method provided in some embodiments of the present application;
[0051] Figure 4 This is a schematic diagram of the structure of an unsupervised Chinese word disambiguation device provided in some embodiments of the present application. DETAILED DESCRIPTION
[0052] Traditional unsupervised semantic disambiguation methods rely only on the semantic features of local contexts, ignoring the long-distance dependencies between words in complex language structures. Unsupervised semantic disambiguation methods based on knowledge graphs often have a high lag in updating knowledge graphs when facing dynamically changing semantic environments, which affects disambiguation efficiency and disambiguation results.
[0053] In order to solve the above technical problems, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0054] Embodiment 1
[0055] Please refer to Figure 1 , an unsupervised Chinese word disambiguation method provided in an embodiment of the present application, including S10 to S30, specifically:
[0056] S10: Obtain text data input by a user, perform text segmentation on the text data, obtain a number of words, and extract multi-layer features of each of the words in sequence; the multi-layer features include: first semantic layer features.
[0057] Preferably, in some embodiments of the present application, text data can be segmented by the following preferred implementations:
[0058] S11: Remove meaningless characters in the text data, such as HTML (HyperTextMarkup Language) tags, specified punctuation marks, etc., through regular expressions;
[0059] S12: Use Jieba word segmentation tool (you can also use THULAC (Tsinghua University Chinese Lexical Analysis System) word segmentation tool) to segment the text data preprocessed in S11 to obtain several words.
[0060] Furthermore, in some embodiments of the present application, sequentially extracting the multi-layer features of each of the words includes:
[0061] Determine the part of speech of the word through a part-of-speech tagging tool, and obtain the lexical layer features of the word;
[0062] Converting the context of the word into a high-dimensional vector through a word vector space model to obtain the first semantic layer feature of the word;
[0063] By using sentiment analysis technology and combining the context of the word, the pragmatic features of the word are obtained.
[0064] By clarifying the part of speech of words, more important basic information is embedded for the fusion features obtained later; through the word vector space model, semantic feature sharing is achieved, and the semantic relationship in the context is captured, providing more relevant semantic information for the fusion features obtained later; finally, considering the sentiment tendency of the sentence in which the word is located, the fusion features obtained later not only include static lexical semantics, but also semantic expressions in different scenarios. By combining the features of three different dimensions of lexical layer, semantic layer and pragmatic layer, more accurate and comprehensive fusion features are provided.
[0065] Preferably, in some embodiments of the present application, multi-layer features of each word can be extracted through the preferred implementation:
[0066] S13: When performing the word segmentation operation through the Jieba word segmentation tool, the part of speech of each word in the context is marked for each segmented word. For example, in the text "Natural language processing is very interesting", "natural language" is marked as "noun", "processing" is marked as "verb", "very" is marked as "adverb", and "interesting" is marked as "adjective";
[0067] S14: Using a word vector space model, such as a Word2Vec (Word to Vector) model, the context words are input into the Word2Vec model together, and a high-dimensional vector is extracted as the first semantic layer feature of the corresponding word; or, using a semantic role labeling technology, after identifying the semantic role of the word in the context, the semantic role is used as a label and input into the word vector space model together with the context words, and a high-dimensional vector is extracted as the first semantic layer feature of the corresponding word;
[0068] S15: Input the context of the corresponding word into a sentiment analysis tool, such as TextBlob (TextBlob: Simplified Text Processing) tool, to obtain the sentiment tendency of the context of the word. For example, in the text "This phone is really smart" and the text "This phone is too smart", the sentiment tendency of "smart" in the two texts is opposite, the first is praise, and the second is irony. Therefore, through sentiment analysis, different labels will be marked for "smart" in different contexts. For example, in the first text, the sentiment analysis result is "{'neg':0.0,'neu':0.412,'pos':0.888}", which means that the probability of negative sentiment is 0, the probability of neutral sentiment is 0.412, and the probability of positive sentiment is 0.888.
[0069] S20: Iteratively update the first semantic layer features of each of the words. In each iterative update process, update a preset semantic graph based on the multi-layer features of each of the words, perform multi-hop reasoning on the semantic graph, and update the first fusion features of the nodes corresponding to each of the words; input the first fusion features of the nodes corresponding to each of the words into a pre-trained disambiguation model to obtain the second semantic layer features, and update the first semantic layer features of the corresponding nodes based on the second semantic layer features.
[0070] Furthermore, in some embodiments of the present application, updating a preset semantic graph according to the multi-layer features of each of the words includes:
[0071] Fusing the multiple layers of features to obtain a second fused feature corresponding to the word;
[0072] Determine whether there is a node corresponding to the word in the semantic graph; if not, generate a node corresponding to the word according to the second fusion feature; otherwise, update the node corresponding to the word according to the second fusion feature;
[0073] The second cosine similarity between the first semantic layer features of words corresponding to any two nodes in the semantic graph is calculated in sequence, and the edge between the corresponding two nodes is updated according to the second cosine similarity.
[0074] The nodes in the semantic graph are updated in time through the fused features after multi-layer feature fusion. If the corresponding node does not exist in the semantic graph, the corresponding node is added to the semantic graph and the fused feature is added to the corresponding node. Otherwise, the fused feature in the corresponding node is updated according to the new fused feature, thereby ensuring the real-time nature of the semantic information in the semantic graph under the dynamically changing semantic environment. In addition, the first semantic layer feature that includes the contextual semantic relationship can accurately determine the degree of association between two words, so that the edges between nodes in the semantic graph can be effectively updated to improve the accuracy of the semantic graph.
[0075] Preferably, reference Figure 2 , which is a schematic diagram of the semantic graphs before and after the update obtained by the unsupervised Chinese word disambiguation method described in some embodiments of the present application, and then combined with Figure 2 Explain the update process of the semantic graph:
[0076] S21: Assume that the text currently input by the user is “Now Apple phones and Huawei computers can achieve Bluetooth communication without delay”, and the words obtained after the text is segmented include: “Apple”, “mobile phone”, “Huawei”, “computer”, “Bluetooth”, “no delay” and other words;
[0077] S22: First, search for words that already exist in the words segmented from S21. Figure 2 The word in a is fused according to the multi-layer features of the word to update the fusion features of each node; the present application does not limit the fusion method, and the preferred implementation method can adopt the dimension conversion to splice the features of each layer to obtain the fusion features; the present application does not limit the update method of the node here, and specifically can adopt: simple feature replacement, feature fusion update using weighted method or feature merging, etc.
[0078] S23: After the feature update is completed, the segmented words obtained in S21 are filtered out. Figure 2 The words in a are generated, and the corresponding nodes are embedded into the fusion features of the words into the corresponding nodes, such as Figure 2 As shown in b, the node “no delay” is first established, and then the multi-layer features of “no delay” are embedded into the corresponding node;
[0079] S24: Calculate the similarity between each updated node and other nodes in turn, and update the connection relationship, such as Figure 2As shown in Figure 2, if the feature update is achieved by a simple replacement method, the updated semantic graph connects "Apple" with "Huawei", "mobile phone", and "computer", and connects "no delay" with "Bluetooth". It should be noted that when calculating the similarity between each node in S21 and other nodes in the existing semantic graph, if the similarity between the fusion features corresponding to the two nodes is less than the preset value, the association between the two nodes should be deleted. The main reason is that in an environment with dynamic semantic changes, it is very likely that some semantic associations are no longer commonly used. At this time, after the features corresponding to each node in the semantic graph are continuously and dynamically updated, the semantic associations that are no longer commonly used will cause large errors in subsequent semantic disambiguation. Therefore, by deleting the association between two nodes whose correlation becomes smaller during the update process, the accuracy of semantic disambiguation in an environment with dynamic semantic changes can be effectively improved.
[0080] Furthermore, in some embodiments of the present application, performing multi-hop reasoning on the semantic graph to update the first fusion feature of each node corresponding to the word includes:
[0081] Acquire a first adjacent node adjacent to the node corresponding to the word, and calculate a third cosine similarity between the node corresponding to the word and each of the first adjacent nodes according to a first fusion feature of the node corresponding to the word and the first adjacent node;
[0082] Acquire second adjacent nodes adjacent to each of the first adjacent nodes, and calculate fourth cosine similarities between each of the first adjacent nodes and corresponding second adjacent nodes according to first fusion features of the first adjacent nodes and the second adjacent nodes;
[0083] Determining, according to the third cosine similarity and the fourth cosine similarity, a weight of the word corresponding to the first adjacent node and the second adjacent node;
[0084] The first fusion feature of the node corresponding to the word is determined according to the weight and the first fusion feature corresponding to the first adjacent node or the second adjacent node.
[0085] Through the multi-hop reasoning mechanism, word nodes can capture semantic relationships at a longer distance by calculating the similarity with adjacent nodes, thereby effectively solving the long-distance dependency problem and improving the accuracy of semantic disambiguation in long texts and complex semantic scenarios.
[0086] Preferably, Figure 2 b as an example, in some embodiments of the present application, a multi-hop reasoning method is adopted to update the fusion features of each node, which can be performed by the following preferred embodiments:
[0087] S25: Taking the node "apple" as an example, Figure 2In b, the first adjacent nodes of "apple" include "banana", "mobile phone", "Huawei", and "computer"; the second adjacent nodes of "apple" include "Huawei", "computer", "mobile phone", "Bluetooth", and "apple". At this time, it is necessary to deduplicate the second adjacent nodes, remove the node "apple" in the second adjacent node, and remove "Huawei", "computer", and "mobile phone" that appear repeatedly in the first adjacent node;
[0088] S26: Calculate the third cosine similarity between “apple” and the first adjacent node “Huawei”, “computer”, and “mobile phone” in sequence;
[0089] S27: Calculate the fourth cosine similarity between “mobile phone”, “computer” and “bluetooth” in turn;
[0090] S28: The weight of “Bluetooth” is determined by the third cosine similarity between “Apple” and “mobile phone” and the fourth cosine similarity between “mobile phone” and “Bluetooth” to determine the first weight; then the second weight is determined by the third cosine similarity between “Apple” and “computer” and the fourth cosine similarity between “computer” and “Bluetooth”, and the first weight and the second weight are added to obtain the weight of “Bluetooth”;
[0091] S29: Through the weighted fusion method, the fusion features of "banana", "mobile phone", "Huawei", "computer", and "Bluetooth" are fused into the fusion features of "apple" in turn.
[0092] Preferably, in some embodiments of the present application, determining the weight of the word corresponding to the first adjacent node and the second adjacent node according to the third cosine similarity and the fourth cosine similarity includes:
[0093] The weight of the first adjacent node or the second adjacent node is obtained by the following formula:
[0094]
[0095] in, is the weight of the i-th first adjacent node of the word; is the weight of the jth second adjacent node of the i-th first adjacent node of the word; S i is the third cosine similarity between the node corresponding to the word and the i-th first adjacent node; S i,j is the fourth cosine similarity between the ith first adjacent node and the jth second adjacent node; O and T are the number of first adjacent nodes and the number of second adjacent nodes respectively, where the number of first adjacent nodes and the number of second adjacent nodes is preferably the number after deduplication through the above S25.
[0096] It can be seen from the above preferred embodiments that the present application adaptively adjusts the influence of distant nodes on the current node according to the similarity between the two nodes, wherein the closer the node is, the greater the probability that it may appear in the context of the corresponding word, and therefore the closer the node is, the greater the influence of the current node should be; at the same time, in order to ensure that the features with low correlation but still containing some valid information are fused to the current node, by considering the similarity between the current nearest neighbor node and the current node, more appropriate weights are adaptively assigned to nodes at a longer distance, thereby effectively improving the accuracy of the fusion features of polysemous words in the knowledge graph, and the method has strong anti-interference ability for noise words, and can effectively obtain fusion features of unlabeled data.
[0097] S30: When the first cosine similarity between the second semantic layer features corresponding to each word currently obtained and the second semantic layer features obtained last time is less than a preset value, terminating the iterative update of the first semantic layer features, and obtaining the semantic representation of the corresponding word based on the second semantic layer features currently obtained.
[0098] Preferably, in some embodiments of the present application, the semantic representation corresponding to the second semantic layer feature can be obtained through the following preferred embodiments: using the BERT model as a disambiguation model, when performing an iterative optimization process of the first semantic layer feature, the BERT model outputs a feature vector, and when it is determined to terminate the iteration, the semantic representation corresponding to the second semantic layer feature is output through the BERT model.
[0099] Furthermore, in some embodiments of the present application, after terminating the iterative update of the first semantic layer features, the method further includes:
[0100] Obtaining, from the semantic graph, the first adjacent node of the node corresponding to each of the words;
[0101] constructing positive sample pairs according to each of the words and the first adjacent nodes of each of the words; constructing negative sample pairs according to the words that are not adjacent to each other;
[0102] A contrastive learning mechanism is adopted to train the word vector space model according to the positive sample pairs and the negative sample pairs.
[0103] When the first semantic layer feature stops iterating, the latest updated semantic information of the disambiguation model can be obtained, so that the semantic map also contains the latest updated semantic information. At this time, according to the latest data in the semantic map, construct positive and negative sample pairs, and use the contrastive learning mechanism to continuously train the word vector space model, and use the word vector space model as a feature sharing layer to achieve back propagation of the disambiguation results, so that in the subsequent feature extraction process, the word vector space model can be dynamically updated to ensure that the word vector space model can adapt to the dynamically changing semantic environment and improve the accuracy of the semantic disambiguation results.
[0104] Preferably, in some embodiments of the present application, the contrastive learning mechanism is used to train the word vector space model according to the positive sample pairs and the negative sample pairs, including:
[0105] The Euclidean distance between the positive sample pairs is minimized and the Euclidean distance between the negative sample pairs is maximized through the following loss function:
[0106]
[0107] Among them, L is the loss value; N is the number of sample pairs; D(W i ) is the Euclidean distance between sample pairs; y i is the label of the sample pair, 1 is a positive sample pair, and 0 is a negative sample pair; m represents the boundary threshold of the Euclidean distance.
[0108] By minimizing the Euclidean distance between positive sample pairs, the word vector space model can cluster the semantic representations of similar words in similar positions in the high-dimensional vector space. By maximizing the Euclidean distance of negative sample pairs, the model can keep words with different semantics away from each other, so that the word vector space model can effectively handle the semantic differences of polysemous words in different contexts, give accurate first semantic layer features, and improve the accuracy of disambiguation.
[0109] Preferably, reference Figure 3 , is another flow chart of the unsupervised Chinese word disambiguation method described in some embodiments of the present application, which illustrates the role of the word vector space model in the unsupervised Chinese word disambiguation method described in some embodiments of the present application, Figure 3 The specific process shown is:
[0110] S31: Segment the text data to obtain a number of words;
[0111] S32: Extract multi-layer features from each word through a word vector space model, a part-of-speech tagging tool, and a sentiment analysis tool in turn;
[0112] S33: Fusing the multi-layer features to obtain a second fused feature, updating the first fused feature of each node in the semantic graph and the connection edges between each node according to the second fused feature, and performing multi-hop reasoning on the semantic graph;
[0113] S34: inputting the first fusion feature after multi-hop reasoning into the disambiguation model to obtain the second semantic layer feature;
[0114] S35: Determine whether the similarity between the second semantic layer features obtained twice before and after is less than a preset value; if so, jump to S36; otherwise, update the second semantic layer features with the multi-layer features extracted in S32, and jump to S33;
[0115] S36: Retrain the word vector space model according to the second semantic layer features, and output the correct semantic representation corresponding to the second semantic layer features.
[0116] In summary, an unsupervised Chinese word disambiguation method provided in an embodiment of the present application has the following beneficial effects: by combining the disambiguation results and the semantic graph update in the process of semantic disambiguation, the semantic data in the semantic graph is updated in time through the semantic disambiguation results, and the updated semantic graph is used to improve the accuracy of subsequent semantic disambiguation results. After multiple feedback adjustments, the accuracy of the semantic disambiguation results and the semantic graph are automatically improved in the semantic disambiguation process, and it is ensured that the semantic graph can be updated in time; and, since the features extracted from the unannotated text data are usually partially distorted or noisy when preliminary feature extraction is performed, the features of each word in the text data are repeatedly iterated and optimized during the disambiguation process, and there is no need to collect additional corpus information in advance and perform a large number of annotation operations on the corpus data or perform additional unsupervised clustering processing on the corpus data, thereby improving the efficiency of disambiguation.
[0117] Embodiment 2
[0118] refer to Figure 4 , an unsupervised Chinese word disambiguation device provided in an embodiment of the present application, includes: a feature extraction module 11, a feature update module 12 and a semantic acquisition module 13.
[0119] Furthermore, in some embodiments of the present application, the feature extraction module 11 is used to obtain text data input by the user, perform text segmentation on the text data, obtain a number of words, and extract multi-layer features of each of the words in turn; the multi-layer features include: first semantic layer features; the feature update module 12 is used to iteratively update the first semantic layer features of each of the words, and in each iterative update process, update the preset semantic graph according to the multi-layer features of each of the words, and perform multi-hop reasoning on the semantic graph to update the first fusion features of the nodes corresponding to each of the words; input the first fusion features of the nodes corresponding to each of the words into the pre-trained disambiguation model to obtain the second semantic layer features, and update the first semantic layer features of the corresponding nodes according to the second semantic layer features; the semantic acquisition module 13 is used to terminate the iterative update of the first semantic layer features when the first cosine similarity between the second semantic layer features corresponding to each of the words currently obtained and the second semantic layer features obtained last time is less than a preset value, and obtain the semantic representation of the corresponding word according to the second semantic layer features currently obtained.
[0120] It can be understood that the above-mentioned device item embodiment corresponds to the method item embodiment of the present invention. The unsupervised Chinese word disambiguation device provided by the embodiment of the present invention can implement any method item embodiment of the present invention, that is, the unsupervised Chinese word disambiguation method provided in Example 1.
[0121] In summary, an unsupervised Chinese word disambiguation device provided in an embodiment of the present application has the following beneficial effects: by combining the disambiguation results and the semantic graph update in the process of semantic disambiguation, the semantic data in the semantic graph is updated in time through the semantic disambiguation results, and the updated semantic graph is used to improve the accuracy of subsequent semantic disambiguation results. After multiple feedback adjustments, the accuracy of the semantic disambiguation results and the semantic graph are automatically improved in the semantic disambiguation process, and it is ensured that the semantic graph can be updated in time; and, since the features extracted from the unannotated text data are usually partially distorted or noisy when preliminary feature extraction is performed, the features of each word in the text data are repeatedly iterated and optimized during the disambiguation process, there is no need to collect additional corpus information in advance and perform a large number of annotation operations on the corpus data or perform additional unsupervised clustering processing on the corpus data, thereby improving the efficiency of disambiguation.
[0122] Embodiment 3
[0123] Based on the above-mentioned embodiments of the unsupervised Chinese word disambiguation method, another embodiment of the present application provides an unsupervised Chinese word disambiguation terminal device, which includes a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor. When the processor executes the computer program, the unsupervised Chinese word disambiguation method of any embodiment of the present application is implemented.
[0124] Exemplarily, in this embodiment, the computer program may be divided into one or more modules, which are stored in the memory and executed by the processor to complete the present application. The one or more modules may be a series of computer program instruction segments capable of completing specific functions, which are used to describe the execution process of the computer program in the unsupervised Chinese word disambiguation device.
[0125] The unsupervised Chinese word disambiguation device may be a computing device such as a desktop computer, a notebook, a PDA, a cloud server, etc. The unsupervised Chinese word disambiguation terminal device may include, but is not limited to, a processor and a memory.
[0126] The processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor, etc. The processor is the control center of the unsupervised Chinese word disambiguation device, and uses various interfaces and lines to connect the various parts of the entire unsupervised Chinese word disambiguation device. The memory may be used to store the computer program and / or module, and the processor implements various functions of the unsupervised Chinese word disambiguation device by running or executing the computer program and / or module stored in the memory, and calling the data stored in the memory. The memory may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, at least one application required for a function, etc.; the data storage area may store data created according to the use of the mobile phone, etc. In addition, the memory may include high-speed random access memory and may also include non-volatile memory, such as a hard disk, an internal memory, a plug-in hard disk, a smart memory card (SmartMediaCard, SMC), a secure digital (SecureDigital, SD) card, a flash card (FlashCard), at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.
[0127] Embodiment 4
[0128] Based on the above-mentioned embodiment of the unsupervised Chinese word disambiguation method, another embodiment of the present application provides a storage medium, which includes a stored computer program, wherein when the computer program is running, the device where the storage medium is located is controlled to execute the unsupervised Chinese word disambiguation method of any embodiment of the present application.
[0129] In this embodiment, the storage medium is a computer-readable storage medium, and the computer program includes computer program code, which may be in source code form, object code form, executable file or some intermediate form, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium, etc. It should be noted that the content contained in the computer-readable medium may be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electric carrier signals and telecommunication signals.
[0130] The specific embodiments described above further describe the purpose, technical solutions and beneficial effects of the present application in detail. It should be understood that the above description is only a specific embodiment of the present application and is not intended to limit the scope of protection of the present application. It is particularly pointed out that for those skilled in the art, any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of protection of the present application.
Claims
1. An unsupervised Chinese word disambiguation method, characterized in that: include: Obtaining text data input by a user, performing text segmentation on the text data, obtaining a number of words, and sequentially extracting multi-layer features of each of the words; The multi-layer features include: first semantic layer features; Iteratively update the first semantic layer features of each of the words. In each iterative update process, update a preset semantic graph according to the multi-layer features of each of the words, perform multi-hop reasoning on the semantic graph, and update the first fusion features of the nodes corresponding to each of the words; input the first fusion features of the nodes corresponding to each of the words into a pre-trained disambiguation model to obtain second semantic layer features, and update the first semantic layer features of the corresponding nodes according to the second semantic layer features; When the first cosine similarity between the second semantic layer features corresponding to each word currently obtained and the second semantic layer features obtained last time is less than a preset value, the iterative update of the first semantic layer features is terminated, and the semantic representation of the corresponding word is obtained based on the second semantic layer features currently obtained.
2. The unsupervised Chinese word disambiguation method according to claim 1, characterized in that: The step of sequentially extracting the multi-layer features of each of the words includes: Determine the part of speech of the word through a part-of-speech tagging tool, and obtain the lexical layer features of the word; Converting the context of the word into a high-dimensional vector through a word vector space model to obtain the first semantic layer feature of the word; By using sentiment analysis technology and combining the context of the word, the pragmatic features of the word are obtained.
3. The unsupervised Chinese word disambiguation method according to claim 2, characterized in that: After terminating the iterative update of the first semantic layer feature, the method further includes: Obtaining, from the semantic graph, the first adjacent node of the node corresponding to each of the words; constructing positive sample pairs according to each of the words and the first adjacent nodes of each of the words; constructing negative sample pairs according to the words that are not adjacent to each other; A contrastive learning mechanism is adopted to train the word vector space model according to the positive sample pairs and the negative sample pairs.
4. The unsupervised Chinese word disambiguation method according to claim 3, characterized in that: The adopting contrastive learning mechanism to train the word vector space model according to the positive sample pairs and the negative sample pairs includes: The Euclidean distance between the positive sample pairs is minimized and the Euclidean distance between the negative sample pairs is maximized through the following loss function: Among them, L is the loss value; N is the number of sample pairs; D(W i ) is the Euclidean distance between sample pairs; y i is the label of the sample pair, 1 is a positive sample pair, and 0 is a negative sample pair; m represents the boundary threshold of the Euclidean distance.
5. The unsupervised Chinese word disambiguation method according to claim 1, characterized in that: The updating of the preset semantic graph according to the multi-layer features of each of the words includes: Fusing the multiple layers of features to obtain a second fused feature corresponding to the word; Determine whether there is a node corresponding to the word in the semantic graph; if not, generate a node corresponding to the word according to the second fusion feature; otherwise, update the node corresponding to the word according to the second fusion feature; The second cosine similarity between the first semantic layer features of words corresponding to any two nodes in the semantic graph is calculated in sequence, and the edge between the corresponding two nodes is updated according to the second cosine similarity.
6. The unsupervised Chinese word disambiguation method according to claim 1, characterized in that: The performing multi-hop reasoning on the semantic graph to update the first fusion feature of each node corresponding to the word includes: Acquire a first adjacent node adjacent to the node corresponding to the word, and calculate a third cosine similarity between the node corresponding to the word and each corresponding first adjacent node according to a first fusion feature of the node corresponding to the word and the first adjacent node; Acquire second adjacent nodes adjacent to each of the first adjacent nodes, and calculate fourth cosine similarities between each of the first adjacent nodes and corresponding second adjacent nodes according to first fusion features of the first adjacent nodes and the second adjacent nodes; Determining, according to the third cosine similarity and the fourth cosine similarity, a weight of the word corresponding to the first adjacent node and the second adjacent node; The first fusion feature of the node corresponding to the word is determined according to the weight and the first fusion feature corresponding to the first adjacent node or the second adjacent node.
7. The unsupervised Chinese word disambiguation method according to claim 6, characterized in that: The determining, according to the third cosine similarity and the fourth cosine similarity, the weight of the word corresponding to the first adjacent node and the second adjacent node includes: The weight of the first adjacent node or the second adjacent node is obtained by the following formula: in, is the weight of the i-th first adjacent node of the word; is the weight of the jth second adjacent node of the i-th first adjacent node of the word; S i is the third cosine similarity between the node corresponding to the word and the i-th first adjacent node; S i,j is the fourth cosine similarity between the i-th first adjacent node and the j-th second adjacent node; O and T are the number of first adjacent nodes and second adjacent nodes respectively.
8. An unsupervised Chinese word disambiguation device, characterized in that: include: Feature extraction module, feature update module and semantic acquisition module; The feature extraction module is used to obtain text data input by the user, perform text segmentation on the text data, obtain a number of words, and extract multi-layer features of each of the words in sequence; the multi-layer features include: first semantic layer features; The feature updating module is used to iteratively update the first semantic layer features of each of the words. In each iterative updating process, a preset semantic graph is updated according to the multi-layer features of each of the words, and multi-hop reasoning is performed on the semantic graph to update the first fusion features of the nodes corresponding to each of the words; the first fusion features of the nodes corresponding to each of the words are input into a pre-trained disambiguation model to obtain second semantic layer features, and the first semantic layer features of the corresponding nodes are updated according to the second semantic layer features; The semantic acquisition module is used to terminate the iterative update of the second semantic layer features corresponding to each word currently acquired and the second semantic layer features acquired last time when the first cosine similarity between the first semantic layer features corresponding to each word currently acquired and the second semantic layer features acquired last time is less than a preset value, and acquire the semantic representation of the corresponding word based on the second semantic layer features currently acquired.
9. A terminal device, characterized in that: The method comprises a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein when the processor executes the computer program, an unsupervised Chinese word disambiguation method as described in any one of claims 1 to 7 is implemented.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored computer program, wherein when the computer program is executed, the device where the computer-readable storage medium is located is controlled to execute the unsupervised Chinese word disambiguation method as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Weak supervision knowledge graph question answering method based on multi-view reasoning
CN113590799A
Semantic understanding method and system based on agricultural field text
CN113869066A
Paper author disambiguation method based on comparative learning tuning under recommendation architecture
CN114519108A
Entity data processing method and device, entity linking method and device and computer equipment
CN115438674A
Adaptive evaluation of meta-relationships in semantic graphs
US20180373699A1