Unsupervised Chinese word disambiguation method, device, terminal device and storage medium
By obtaining multi-layer features in the unsupervised Chinese word disambiguation method and combining semantic map updates, multi-hop reasoning and contrast learning mechanisms are adopted to solve the lag problem of semantic disambiguation in dynamically changing semantic scenarios, and the accuracy and efficiency of disambiguation results are improved.
Patent Information
- Application Number
- CN202510022895.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-07
- Publication Date
- 2025-08-19
- Estimated Expiration
- 2045-01-07
AI Technical Summary
In dynamically changing semantic scenarios, unsupervised semantic disambiguation methods based on knowledge graphs have lag, resulting in large errors in semantic disambiguation and low efficiency.
By obtaining multi-layer features of text data, including vocabulary layer, semantic layer and pragmatic layer features, combining word vector spatial model and sentiment analysis, the semantic map is updated, and the word vector spatial model is trained using multi-hop reasoning and contrast learning mechanisms to dynamically update the semantic representation.
It improves the accuracy and efficiency of semantic disambiguation results, reduces dependence on labeled data, updates the semantic map in a timely manner, and adapts to the dynamically changing semantic environment.
Smart Images

Figure CN119962540B_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 labeled data, which needs to be manually labeled, which is time-consuming, labor-intensive, and costly. Although unsupervised semantic disambiguation methods do not need to rely on a large amount of labeled 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 the local context, 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, existing technologies usually collect a large amount of corpus data in advance, establish a complete knowledge graph, and update the knowledge graph regularly 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 lead to 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 graphs in dynamically changing semantic scenarios has a high lag, resulting in large semantic disambiguation errors and low semantic disambiguation efficiency.
[0006] In order to solve the above technical problems, in a first aspect, the embodiments of the present application provide an unsupervised Chinese word disambiguation method, comprising:
[0007] 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;
[0008] Iteratively updating the first semantic layer features of each of the words, updating a preset semantic graph according to the multi-layer features of each of the words during each iterative update process, performing multi-hop reasoning on the semantic graph, and updating the first fusion features of the nodes corresponding to each of the words; inputting 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 updating 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 for 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 based on the currently obtained second semantic layer features.
[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 is guaranteed to be updated in time. Moreover, since the features extracted from the unannotated text data are usually partially distorted or noisy when the initial features are extracted, the features of each word in the text data are repeatedly iterated and optimized during the disambiguation process, without the 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, the efficiency of disambiguation is improved.
[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 by using 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 using 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 to existing technologies, the above embodiment has the following beneficial effects: by clarifying the part of speech of a word, more important basic information is embedded in the subsequently acquired fusion features; through the word vector space model, semantic feature sharing is achieved and semantic relationships in the context are captured, providing more relevant semantic information for the subsequently acquired fusion features; finally, considering the sentiment tendency of the sentence in which the word is located, the subsequently acquired fusion features not only include static lexical semantics but also semantic expressions in different contexts. By combining features from three different dimensions: lexical layer, semantic layer, and 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 features, 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 based on the words and the first adjacent nodes of the words; and constructing negative sample pairs based on the non-adjacent words;
[0019] A contrastive learning mechanism is adopted to train the word vector space model based on the positive sample pairs and the negative sample pairs.
[0020] Compared with the existing technology, 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, based on the latest data in the semantic graph, positive and negative sample pairs are constructed, and a contrastive learning mechanism is used to continuously train the word vector space model. The word vector space model is used as a feature sharing layer to achieve backpropagation of the disambiguation results, so that the word vector space model can be dynamically updated in the subsequent feature extraction process, ensuring that the word vector space model can adapt to the dynamically changing semantic environment and improve the accuracy of the semantic disambiguation results.
[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 based on 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 by 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 existing technology, 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, provide 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 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 existing technology, 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 and updating the first fusion feature of each node corresponding to the word includes:
[0032] Obtaining first adjacent nodes adjacent to the node corresponding to the word, and calculating third cosine similarities between the node corresponding to the word and each corresponding first adjacent node based on first fusion features of the node corresponding to the word and the first adjacent nodes;
[0033] Obtaining second adjacent nodes adjacent to each of the first adjacent nodes, and calculating, based on first fusion features of the first adjacent nodes and the second adjacent nodes, a fourth cosine similarity between each of the first adjacent nodes and the corresponding second adjacent nodes;
[0034] Determining, based on 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 existing technology, 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 weights of the word corresponding to the first adjacent node and the second adjacent node based on 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 first adjacent node of the i-th word; is the weight of the jth second adjacent node of the i-th first adjacent node of the word; S i S is the third cosine similarity between the node corresponding to the word and the i-th first adjacent node; 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 existing technology, 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 for noise words, and can effectively deal with the fusion feature acquisition of unlabeled data.
[0042] In a second aspect, an 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 sequentially extract multi-layer features of each of the words; the multi-layer features include: first semantic layer features;
[0044] The feature updating module is configured to iteratively update the first semantic layer features of each of the words. During each iterative updating process, a preset semantic graph is updated based on the multi-layer features of each of the words, and multi-hop reasoning is performed on the semantic graph to update the first fused features of the nodes corresponding to each of the words; the first fused 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 based on the second semantic layer features;
[0045] The semantic acquisition module is configured to terminate the iterative update of the second semantic layer features corresponding to each currently acquired word and the second semantic layer features acquired last time when the first cosine similarity between the first semantic layer features corresponding to each currently acquired word and the second semantic layer features acquired last time is less than a preset value, and to acquire the semantic representation of the corresponding word based on the currently acquired second semantic layer features.
[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 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 structural diagram of an unsupervised Chinese word disambiguation device provided in some embodiments of the present application. DETAILED DESCRIPTION
[0052] Traditional unsupervised semantic disambiguation methods rely solely on the semantic features of local context, ignoring the long-range dependencies between words in complex language structures. Unsupervised semantic disambiguation methods based on knowledge graphs often suffer from high lags in knowledge graph updates when faced with dynamically changing semantic environments, which affects disambiguation efficiency and 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 of the present application, all other embodiments obtained by ordinary technicians in this field without making creative efforts shall fall within the scope of protection of this application.
[0054] Example 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 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.
[0057] Preferably, in some embodiments of the present application, text segmentation can be performed on text data by the following preferred implementations:
[0058] S11: Using regular expressions, remove meaningless characters from text data, such as HTML (HyperTextMarkup Language) tags and specified punctuation marks;
[0059] S12: Using the Jieba word segmentation tool (the THULAC (Tsinghua University Chinese Lexical Analysis System) word segmentation tool may also be used), the text data preprocessed in S11 is segmented to obtain a number of words.
[0060] Furthermore, in some embodiments of the present application, sequentially extracting multi-layer features of each of the words includes:
[0061] Determine the part of speech of the word by using 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 using 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 a word, more important foundational information is embedded in the subsequently acquired fusion features. Using the word vector space model, semantic features are shared and contextual semantic relationships are captured, providing more relevant semantic information for the subsequently acquired fusion features. Finally, the sentiment of the sentence in which the word appears is considered, ensuring that the subsequently acquired fusion features not only include static lexical semantics but also semantic expressions in different contexts. By combining features from three different dimensions: lexical, semantic, and pragmatic, 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 word segmentation using the Jieba word segmentation tool, each segmented word is labeled with its part of speech in the context. For example, in the text "Natural language processing is very interesting", "natural language" is labeled as a "noun", "processing" is labeled as a "verb", "very" is labeled as an "adverb", and "interesting" is labeled as an "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 to extract a high-dimensional vector as the first semantic layer feature of the corresponding word; alternatively, using a semantic role labeling technique, the semantic role of the word in the context is identified, the semantic role is used as a label, and the context words are input into the word vector space model to extract a high-dimensional vector 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 the 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 sarcasm. Therefore, through sentiment analysis, different labels are added to "smart" in different contexts. For example, in the first text, the sentiment analysis result is "{'neg': 0.0, 'neu': 0.412, 'pos': 0.888}", indicating 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. During each iterative update process, update the 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 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 a timely manner 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, 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, thereby improving 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 delay-free Bluetooth communication." After the text is segmented, the words obtained include: "Apple," "phone," "Huawei," "computer," "Bluetooth," "delay-free," and so on.
[0077] S22: First, search for words that already exist in the words segmented by 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; this application does not limit the fusion method. The preferred implementation method can use dimensionality conversion and then splice the features of each layer to obtain the fusion features; this application does not limit the update method of the node here. Specifically, it can adopt: simple feature replacement, feature fusion update using weighted method, or feature merging, etc.
[0078] S23: After completing the feature update, filter out the segmented words obtained from S21 that do not exist in Figure 2 The words in a are generated and the corresponding nodes are embedded into the fusion features of the words, 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 b, 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 lead to large errors in subsequent semantic disambiguation. Therefore, by deleting the association between two nodes whose correlation has decreased 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] Obtaining first adjacent nodes adjacent to the node corresponding to the word, and calculating third cosine similarities between the node corresponding to the word and each corresponding first adjacent node based on first fusion features of the node corresponding to the word and the first adjacent nodes;
[0082] Obtaining second adjacent nodes adjacent to each of the first adjacent nodes, and calculating, based on first fusion features of the first adjacent nodes and the second adjacent nodes, a fourth cosine similarity between each of the first adjacent nodes and the corresponding second adjacent nodes;
[0083] Determining, based on 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 For example, in some embodiments of the present application, a multi-hop reasoning method is used 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". In this case, it is necessary to deduplicate the second adjacent nodes and remove the node "apple" in the second adjacent node as well as the "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 sequence;
[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 a 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” to determine a second weight; the first weight and the second weight are added together to obtain the weight of “Bluetooth”;
[0091] S29: Through weighted fusion, the fusion features of "banana", "mobile phone", "Huawei", "computer", and "bluetooth" are fused into the fusion feature of "apple" in turn.
[0092] Preferably, in some embodiments of the present application, determining the weights of the word corresponding to the first adjacent node and the second adjacent node based on 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 first adjacent node of the i-th word; is the weight of the jth second adjacent node of the i-th first adjacent node of the word; S i S is the third cosine similarity between the node corresponding to the word and the i-th first adjacent node; 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, where the number of first adjacent nodes and 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 correlation degree is not high, but the features that still contain 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 this method has strong anti-interference ability for noise words, and can effectively deal with the fusion feature acquisition 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 the 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 based on the words and the first adjacent nodes of the words; and constructing negative sample pairs based on the non-adjacent words;
[0102] A contrastive learning mechanism is adopted to train the word vector space model based on the positive sample pairs and the negative sample pairs.
[0103] When the first semantic layer stops iterating, the latest semantic information updated by the disambiguation model can be obtained, so that the semantic graph also contains the latest updated semantic information. At this time, based on the latest data in the semantic graph, positive and negative sample pairs are constructed, and a contrastive learning mechanism is used to continuously train the word vector space model. The word vector space model is used as a feature sharing layer to achieve backpropagation of disambiguation results. This allows the word vector space model to be dynamically updated in the subsequent feature extraction process, ensuring 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 based on 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 by 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, provide 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: Each word is sequentially passed through a word vector space model, a part-of-speech tagging tool, and a sentiment analysis tool to extract multi-layer features;
[0112] S33: Fusing multiple layers of features to obtain a second fused feature. Based on the second fused feature, updating the first fused feature of each node in the semantic graph and the connection edges between each node, and performing multi-hop reasoning on the semantic graph.
[0113] S34: Input 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 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 based on the second semantic layer features, and output the correct semantic representation corresponding to the second semantic layer features.
[0116] In summary, the unsupervised Chinese word disambiguation method provided by the 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 the semantic graph is guaranteed to 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 iteratively optimized during the disambiguation process, without the 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, the efficiency of disambiguation is improved.
[0117] Example 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 several 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 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 embodiment corresponds to the method embodiment of the present invention. The unsupervised Chinese word disambiguation device provided by the embodiment of the present invention can implement any method embodiment of the present invention, that is, the unsupervised Chinese word disambiguation method provided in Example 1.
[0121] In summary, the unsupervised Chinese word disambiguation device provided by the 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 the semantic graph is guaranteed to 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 iteratively optimized during the disambiguation process, without the 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, the efficiency of disambiguation is improved.
[0122] Example 3
[0123] Based on the above-mentioned embodiment 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] For example, 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 implement the present application. The one or more modules may be a series of computer program instruction segments capable of performing specific functions, and the instruction segments 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 computer, 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 can be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), off-the-shelf programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or any conventional processor. The processor is the control center of the unsupervised Chinese word disambiguation device, connecting the various parts of the entire unsupervised Chinese word disambiguation device using various interfaces and lines. The memory can be used to store the computer programs and / or modules. The processor implements the various functions of the unsupervised Chinese word disambiguation device by running or executing the computer programs and / or modules stored in the memory and calling the data stored in the memory. The memory can mainly include a program storage area and a data storage area. The program storage area can store the operating system, at least one application required for a function, etc.; the data storage area can store data created based on the use of the mobile phone, etc. In addition, the memory may include high-speed random access memory and non-volatile memory, such as a hard disk, 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 device.
[0127] Example 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. 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. 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 illustrate the objectives, technical solutions, and beneficial effects of this application. It should be understood that the above descriptions are merely specific embodiments of this application and are not intended to limit the scope of protection of this application. In particular, it should be noted that any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of this application by those skilled in the art should be included within the scope of protection of this 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 updating the first semantic layer features of each of the words, updating a preset semantic graph according to the multi-layer features of each of the words during each iterative update process, performing multi-hop reasoning on the semantic graph, and updating the first fusion features of the nodes corresponding to each of the words; inputting 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 updating 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 currently obtained second semantic layer features.
2. The unsupervised Chinese word disambiguation method according to claim 1, wherein: The step of sequentially extracting multi-layer features of each of the words includes: Determine the part of speech of the word by using 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 using 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, wherein: After terminating the iterative update of the first semantic layer features, 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 based on the words and the first adjacent nodes of the words; and constructing negative sample pairs based on the non-adjacent words; A contrastive learning mechanism is adopted to train the word vector space model based on the positive sample pairs and the negative sample pairs.
4. The unsupervised Chinese word disambiguation method according to claim 3, wherein: The contrastive learning mechanism is used to train the word vector space model based on the positive sample pairs and the negative sample pairs, including: The Euclidean distance between the positive sample pairs is minimized and the Euclidean distance between the negative sample pairs is maximized by 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, wherein: The updating of the preset semantic graph according to the multi-layer features of each of the words includes: Fusing 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, wherein: The performing multi-hop reasoning on the semantic graph to update the first fusion feature of each node corresponding to the word includes: Obtaining first adjacent nodes adjacent to the node corresponding to the word, and calculating third cosine similarities between the node corresponding to the word and each corresponding first adjacent node based on first fusion features of the node corresponding to the word and the first adjacent nodes; Obtaining second adjacent nodes adjacent to each of the first adjacent nodes, and calculating, based on first fusion features of the first adjacent nodes and the second adjacent nodes, a fourth cosine similarity between each of the first adjacent nodes and the corresponding second adjacent nodes; Determining, based on 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, based on 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 first adjacent node of the i-th word; is the weight of the jth second adjacent node of the i-th first adjacent node of the word; S i S is the third cosine similarity between the node corresponding to the word and the i-th first adjacent node; 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 sequentially extract multi-layer features of each of the words; the multi-layer features include: first semantic layer features; The feature updating module is configured to iteratively update the first semantic layer features of each of the words. During each iterative updating process, a preset semantic graph is updated based on the multi-layer features of each of the words, and multi-hop reasoning is performed on the semantic graph to update the first fused features of the nodes corresponding to each of the words; the first fused 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 based on the second semantic layer features; The semantic acquisition module is configured to terminate the iterative update of the second semantic layer features corresponding to each currently acquired word and the second semantic layer features acquired last time when the first cosine similarity between the first semantic layer features corresponding to each currently acquired word and the second semantic layer features acquired last time is less than a preset value, and to acquire the semantic representation of the corresponding word based on the currently acquired second semantic layer features.
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, the method implements an unsupervised Chinese word disambiguation method as described in any one of claims 1 to 7.
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 running, the device where the computer-readable storage medium is located is controlled to execute the unsupervised Chinese word disambiguation method according to 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