Training, recognition methods, devices, equipment, and storage media for sub-character recognition models
By acquiring and clustering Chinese character vectors to form a sub-character corpus, and training an n-gram language model, the problems of slow speed and low accuracy in polyphonic character recognition are solved, achieving fast and accurate polyphonic character recognition.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-08
- Publication Date
- 2026-04-03
AI Technical Summary
Existing polyphonic character disambiguation techniques are insufficient in terms of speed and accuracy. In particular, DNN models have high computational requirements and slow recognition speed, making them unable to effectively solve the problem of polyphonic character recognition.
By acquiring corpora with and without sub-character labels, Chinese character vectors are extracted and clustered to form a sub-character corpus. An n-gram language model is then used to train a sub-character recognition model to identify the meaning and pronunciation of Chinese characters in sentences.
It achieves rapid and accurate recognition of polyphonic characters, and can determine the unique meaning and pronunciation of each Chinese character in a sentence, thus meeting the disambiguation requirements for polyphonic characters.
Smart Images

Figure CN115691469B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of speech synthesis technology, and in particular to a method, apparatus, device, and storage medium for training and recognizing a sub-character recognition model. Background Technology
[0002] Text-to-Speech (TTS) technology refers to the technology of converting arbitrary text into speech using computers. The accuracy of polyphonic character conversion significantly impacts the user's understanding of the synthesized speech; incorrect conversion will negatively affect the user experience. Therefore, polyphonic character disambiguation is a crucial task in speech synthesis systems.
[0003] Polyphonic character disambiguation technology specifically refers to recognizing the specific pronunciations of polyphonic characters in Chinese speech or text, and is an essential front-end processing step in speech synthesis technology. Among current polyphonic character disambiguation technologies, Pypinyin is a Chinese polyphonic character disambiguation scheme based on a lexicon and word segmentation. This scheme does not address the issue of separating polyphonic characters into single characters and polyphonic words, resulting in a relatively high error rate. While DNN (Deep Neural Networks) models achieve higher accuracy than Pypinyin's scheme due to limited corpora and other factors, there is still significant room for improvement. Combining DNN models with pre-trained models such as BERT achieves higher accuracy in polyphonic character disambiguation, but this requires significant computation and results in slow recognition speed.
[0004] Therefore, it is necessary to develop a training method for a sub-character recognition model to solve the problems of slow speed and low error rate of existing technologies for disambiguating polyphonic characters. Summary of the Invention
[0005] This application provides a training method, apparatus, device, and storage medium for a character recognition model, which can achieve rapid recognition of polyphonic characters and improve the accuracy of recognition.
[0006] To solve the above problems, this application adopts the following technical solution:
[0007] In a first aspect, embodiments of this application provide a method for training a sub-character recognition model, the method comprising:
[0008] Obtain a first corpus and a second corpus; the first corpus includes sentences carrying sub-character tags, and the second corpus includes sentences without sub-character tags. The sub-character tags are used to characterize the position and category of sub-characters in the sentences. Each Chinese character includes at least one sub-character, and each sub-character is used to characterize a meaning of the corresponding Chinese character.
[0009] Obtain the statement vectors corresponding to each statement in the first corpus and the second corpus; the statement vectors of different statements are composed of the Chinese character vectors in the statement;
[0010] From the Chinese character vectors, extract the target Chinese character vectors carrying the sub-character tags;
[0011] Using the target Chinese character vector as the cluster center, each Chinese character vector is clustered to determine the corresponding target sub-character for each Chinese character in the sentence, thus obtaining a sub-character corpus composed of target sub-characters.
[0012] The sub-character corpus is used as a training sample to train the language model, resulting in a sub-character recognition model. This sub-character recognition model is used to identify the meaning of Chinese characters in a sentence.
[0013] In one embodiment of this application, obtaining a first corpus includes:
[0014] The Chinese dictionary is analyzed to obtain sentences containing the Chinese characters to be annotated;
[0015] Based on the position and category of the Chinese character to be annotated in the corresponding sentence, a sub-character tag is added to the Chinese character to be annotated to obtain the sentence carrying the sub-character tag;
[0016] The first corpus is obtained based on the statements carrying the sub-character tags.
[0017] In one embodiment of this application, the target Chinese character vector is used as the cluster center, and each Chinese character vector is clustered to determine the corresponding target sub-character for each Chinese character in the sentence, thereby obtaining a sub-character corpus composed of target sub-characters, including:
[0018] Using the target Chinese character vector as the cluster center, each Chinese character vector is clustered to obtain a preset number of clusters; different clusters are used to represent target sub-characters with different meanings;
[0019] The Chinese characters corresponding to the vectors of Chinese characters belonging to the same cluster are determined as the target sub-characters corresponding to the cluster.
[0020] The Chinese characters in each of the sentences are mapped to their corresponding target sub-characters, resulting in a sub-character corpus composed of the target sub-characters.
[0021] In one embodiment of this application, the target Chinese character vector is used as the cluster center, and each Chinese character vector is clustered to obtain a preset number of clusters, including:
[0022] The target Chinese character vectors are used as cluster centers. Each Chinese character vector is clustered, and the Euclidean distance between each Chinese character vector and the cluster center is determined. Different cluster centers correspond to different clusters.
[0023] If the Euclidean distance between any Chinese character vector and the cluster center is less than a distance threshold, the Chinese character vector is determined to belong to the cluster corresponding to the cluster center.
[0024] In one embodiment of this application, the sub-character corpus is used as training samples to train a language model to obtain a sub-character recognition model, including:
[0025] The sub-character corpus is used as a training sample to train an n-gram language model, resulting in a sub-character recognition model. The sub-character recognition model learns the word sequence preceding the sub-character in each sentence containing the same sub-character.
[0026] Secondly, based on the same inventive concept, embodiments of this application provide a sub-character recognition method, the method comprising:
[0027] The sentence to be identified is input into the sub-character recognition model to obtain the target sub-characters corresponding to each Chinese character in the sentence to be identified; wherein, the sub-character recognition model is trained based on the training method of the sub-character recognition model proposed in the first aspect of the present application; the meaning of the target sub-character is the meaning of the corresponding Chinese character with the highest probability in the sentence to be identified.
[0028] In one embodiment of this application, after inputting the sentence to be recognized into the sub-character recognition model to obtain the target sub-characters corresponding to the Chinese characters in the sentence to be recognized, the method further includes:
[0029] Based on the meaning of the target sub-character, determine the pronunciation of the corresponding Chinese character in the sentence to be identified.
[0030] Thirdly, based on the same inventive concept, embodiments of this application provide a training device for a sub-character recognition model, the device comprising:
[0031] The acquisition module is used to acquire a first corpus and a second corpus; the first corpus includes sentences carrying sub-character tags, and the second corpus includes sentences without sub-character tags. The sub-character tags are used to characterize the position and category of sub-characters in the sentences. Each Chinese character includes at least one sub-character, and each sub-character is used to characterize a meaning of the corresponding Chinese character.
[0032] The vector module is used to obtain the statement vectors corresponding to each statement in the first corpus and the second corpus; the statement vectors of different statements are composed of the Chinese character vectors in the statement;
[0033] The extraction module is used to extract the target Chinese character vector carrying the sub-character tag from the Chinese character vector;
[0034] The clustering module is used to use the target Chinese character vector as the cluster center to cluster each Chinese character vector, so as to determine the target sub-characters corresponding to the Chinese characters in each sentence, and obtain a sub-character corpus composed of target sub-characters.
[0035] The training module is used to train the language model using the sub-character corpus as training samples to obtain the sub-character recognition model, which is used to recognize the meaning of Chinese characters in a sentence.
[0036] In one embodiment of this application, the acquisition module includes:
[0037] The analysis submodule is used to analyze the Chinese dictionary to obtain sentences containing the Chinese characters to be annotated;
[0038] Add a submodule to add sub-character tags to the Chinese characters to be annotated based on their position and category in the corresponding sentences, and obtain sentences carrying sub-character tags;
[0039] The acquisition submodule is used to obtain the first corpus based on the statements carrying sub-character tags.
[0040] In one embodiment of this application, the clustering module includes:
[0041] The clustering submodule is used to use the target Chinese character vector as the cluster center to cluster each Chinese character vector to obtain a preset number of clusters; different clusters are used to represent target sub-characters with different meanings;
[0042] The determination submodule is used to determine the target sub-character corresponding to the cluster for Chinese characters whose vectors belong to the same cluster;
[0043] The mapping submodule is used to map the Chinese characters in each statement to their corresponding target sub-characters, thereby obtaining a sub-character corpus composed of the target sub-characters.
[0044] In one embodiment of this application, the clustering submodule includes:
[0045] The Euclidean distance determination unit is used to cluster each Chinese character vector as a cluster center, and to determine the Euclidean distance between each Chinese character vector and the cluster center; different cluster centers correspond to different clusters;
[0046] The cluster determination unit is used to determine that a Chinese character vector belongs to the cluster corresponding to the cluster center when the Euclidean distance between any Chinese character vector and the cluster center is less than a distance threshold.
[0047] In one embodiment of this application, the training module is specifically used to train the n-gram language model using the sub-character corpus as training samples to obtain a sub-character recognition model. The sub-character recognition model learns the word sequence preceding the sub-character in each sentence containing the same sub-character.
[0048] Fourthly, based on the same inventive concept, embodiments of this application provide a sub-character recognition device, the device comprising:
[0049] The sub-character recognition module is used to input the sentence to be recognized into the sub-character recognition model to obtain the target sub-characters corresponding to the Chinese characters in the sentence to be recognized; wherein, the sub-character recognition model is trained based on the training method of the sub-character recognition model proposed in the first aspect of the embodiments of this application; the meaning of the target sub-character is the meaning of the corresponding Chinese character with the highest probability in the sentence to be recognized.
[0050] In one embodiment of this application, the apparatus further includes:
[0051] The pronunciation determination module is used to determine the pronunciation of the Chinese character corresponding to the target sub-character in the sentence to be recognized based on the meaning of the target sub-character.
[0052] Fifthly, embodiments of this application provide an electronic device, including a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement the training method for the sub-character recognition model proposed in the first aspect of embodiments of this application or the sub-character recognition method proposed in the second aspect of embodiments of this application.
[0053] Sixthly, embodiments of this application provide a computer-readable storage medium storing a computer program / instructions thereon, which, when executed by a processor, implements the training method for the sub-character recognition model proposed in the first aspect of embodiments of this application or the sub-character recognition method proposed in the second aspect of embodiments of this application.
[0054] Compared with the prior art, this application has the following advantages:
[0055] This application provides a method for training a sub-character recognition model. The method involves acquiring sentence vectors corresponding to each sentence in a first and second corpus. The sentence vectors of different sentences are composed of the character vectors of the Chinese characters within those sentences. Then, target character vectors carrying sub-character labels are extracted from these character vectors. These target character vectors are then used as cluster centers to cluster each character vector, thus determining the corresponding target sub-character for each character in each sentence, resulting in a sub-character corpus composed of target sub-characters. Finally, this sub-character corpus is used as training samples to train a language model, thereby obtaining the sub-character recognition model. This application utilizes the trained sub-character recognition model to quickly and accurately identify the target sub-character corresponding to each Chinese character in the sentence to be recognized, thereby determining the unique meaning and pronunciation of each Chinese character in the sentence and effectively meeting the disambiguation requirements for polyphonic characters. Attached Figure Description
[0056] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0057] Figure 1 This is a flowchart illustrating the steps of a training method for a sub-character recognition model provided in an embodiment of this application.
[0058] Figure 2 This is a schematic diagram illustrating the generation of sub-character corpus for a specific Chinese character, as provided in an embodiment of this application.
[0059] Figure 3 This is a flowchart of the steps of a sub-character recognition method provided in an embodiment of this application.
[0060] Figure 4 This is a schematic diagram of the functional modules of a training device for a sub-character recognition model provided in an embodiment of this application.
[0061] Figure 5 This is a schematic diagram of the functional modules of a sub-character recognition device provided in an embodiment of this application.
[0062] Figure 6 This is a schematic diagram of an electronic device provided in an embodiment of this application. Detailed Implementation
[0063] Next, the technical solutions in this embodiment will be clearly and completely described in conjunction with the accompanying drawings in this embodiment. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention.
[0064] It should be noted that in modern Chinese, a Chinese character often has multiple meanings. Especially in different contexts, a Chinese character will show one of its specific meanings. For example, in the sentence "The economic operation environment determines that its equilibrium duration is relatively long", the character "long" is an adjective pronounced as "cháng", indicating a long time; in the sentence "The more it is protected, the less it grows up", the character "long" is a verb pronounced as "zháng", indicating growth.
[0065] Similarly, there are also many words with multiple meanings. For example, in the sentence "Consider how to respect children, rather than just teaching knowledge", the word "teach" is a verb pronounced as "jiāo shòu", meaning to instruct and impart; in the sentence "Keynes never served as a professor throughout his life", the word "professor" is a noun pronounced as "jiào shòu", which is the highest level of the university teacher position.
[0066] Therefore, based on the fact that the meanings represented by the same Chinese character or the same word in different sentences may be different or the same, the concepts of sub-characters and sub-words are introduced in the embodiments of this application. That is, for a certain Chinese character, a specific meaning corresponding to it is called a sub-character of this Chinese character, and all the sub-characters of this Chinese character can be called a sub-character set of this Chinese character. Similarly, for a certain word, a specific meaning corresponding to it is called a sub-word of this word, and all the sub-words of this word can be called a sub-word set of this word.
[0067] Specifically, for a certain Chinese character (word), the sub-character set (sub-word set) corresponding to this Chinese character (word) can be expressed as:
[0068] W = {w1,..., w Figure 1 ,
[0070] , } (1);
[0069] where W represents the sub-character set (sub-word set) corresponding to a certain Chinese character (word); n represents the number of sub-characters (sub-words) included in this Chinese character (word), and n is a positive integer greater than or equal to 1; w1,..., w n represent the n sub-characters of this Chinese character (word), and different sub-characters (sub-words) represent different meanings of this Chinese character (word).
[0070] Based on the above definitions of sub-characters and sub-words, referring to <00002, showing the step flowchart of a method for training a sub - character recognition model of the present application. The method may specifically include the following steps:
[0071] S101: Obtain a first corpus and a second corpus; the first corpus includes sentences carrying sub - character labels, and the second corpus includes sentences without sub - character labels. The sub - character label is used to represent the position and category of sub - characters in a sentence. Each Chinese character includes at least one sub - character, and each sub - character is used to represent a meaning of the corresponding Chinese character.
[0072] It should be noted in this embodiment that each Chinese character can be converted into a corresponding sub - character form according to its specific meaning. Exemplarily, referring to formula (1), for the sub - character set of a certain Chinese character, when n = 2, it means that there are only two different meanings of the Chinese character in different sentences, and when n = 1, it means that the Chinese character has only one meaning. Exemplarily, assume that the Chinese character "长" (long) has two different meanings, then the sub - character set corresponding to "长" can be expressed as {长 - 1, 长 - 2}, where 长 - 1 represents the meaning of "length" and is pronounced as "cháng"; 长 - 2 represents the meaning of "grow" and is pronounced as "zhǎng". It should be noted that the Chinese character "长" actually has more meanings in different sentences. The above is only an example, that is, the number of sub - characters included in "长" can be more, but the pronunciation corresponding to each specific meaning is unique. For example, the Chinese character "长" means "length" in the sentence "The total length of the railway bridge is 6772 meters" and means "strength" in the phrase "a special skill", and both are pronounced as "cháng".
[0073] In this embodiment, the first corpus represents a set of sentences carrying sub - character labels, and the first corpus can be obtained by analyzing a Chinese dictionary. Specifically, the Chinese dictionary can be analyzed to obtain sentences containing the Chinese characters to be labeled, and then based on the position and category of the Chinese characters to be labeled in the corresponding sentences, sub - character labels are added to the Chinese characters to be labeled to obtain sentences carrying sub - character labels; finally, all the sentences carrying sub - character labels are integrated to obtain the first corpus. In a specific implementation, according to actual needs, some or all Chinese characters in the Chinese dictionary can be One - hot encoded so that some or all Chinese characters correspond to specific label sub - character labels, and finally, all the sentences where the Chinese characters carrying label sub - character labels are located are integrated to obtain the first corpus.
[0074] It should be noted that in a Chinese dictionary, for all Chinese characters in the dictionary, there will be corresponding annotations, and corresponding application contexts will be given for these annotations of Chinese characters. Sentences with Chinese characters carrying these label sub-character tags in these different contexts are thus obtained, resulting in sentences carrying sub-character tags. For example, for the Chinese character "好" (hao), in the Chinese dictionary, there are annotations with different meanings, such as: "美好" (beautiful), "爱好" (hobby), "喜好" (liking), "好多" (many), etc. Among them, "爱好" and "喜好" have the same meaning, so the same sub-character tags can be encoded, while "美好" and "好多" have different meanings respectively, so different sub-character tags are encoded respectively. If a certain "好" character in a sentence is marked with the corresponding sub-character tag, then this sentence is a sentence carrying the sub-character tag of the "好" character.
[0075] In this embodiment, after integrating a large number of Chinese characters carrying sub-character tags in the Chinese dictionary, a sub-character dictionary containing all sub-characters corresponding to all Chinese characters is obtained. This sub-character dictionary can be represented as a database containing all sub-characters of Chinese characters. The sub-character dictionary in this embodiment is represented by the following formula:
[0076] WM = {(W1, w 11 , w 12 ,...), (W2, w 21 , w 22 ,...),..., (W n , w n1 , w n2 ,...)} (2);
[0077] Among them, WM is the sub-character dictionary; W n represents the nth Chinese character in the sub-character dictionary; w n1 and w n2 respectively represent each sub-character corresponding to the nth Chinese character.
[0078] In this embodiment, the first corpus can be represented by the following formula:
[0079] D1 = {(x1,y1),(x2,y2),...(x i ,y i )} (3);;
[0080] x i = (W i1 ,W i2 ,...) (4);
[0081] y i = (I i ,w i ) (5);
[0082] Among them, D1 represents the first corpus, and x i represents the i-th sentence carrying sub-character tags in the first corpus, and y i represents the sub-character corresponding to a Chinese character at a certain position in the i-th sentence carrying sub-character tags in the first corpus. W i1 , W i2 represents all the Chinese characters that make up x i , and w i represents a specific sub-character in y i , and I i represents the specific position of a specific sub-character in y i .
[0083] In this embodiment, the second corpus represents a set of unannotated sentences without sub-character tags. The text corpus in the second corpus can be obtained from the network through crawler technology and / or from any text database containing a large amount of text or sentences. Specifically, since the obtained original text corpus may contain non-text corpora such as pictures, emojis, invalid punctuation marks, etc., or text corpora with some long sentences, it is necessary to perform operations such as cleaning and sentence splitting on the original text corpus so that the second corpus only contains pure text and is composed of short sentences.
[0084] In this embodiment, the second corpus can be represented by the following formula::
[0085] D u ={x u1 ,x u2 ,...} (6);
[0086] Among them, D u represents the second corpus, and x u1 , x u2 represents the sentences without sub-character tags in the second corpus.
[0087] S102: Obtain the sentence vectors corresponding to each sentence in the first corpus and the second corpus; the sentence vectors of different sentences are composed of the Chinese character vectors of the Chinese characters in the sentence.
[0088] In this embodiment, by inputting the first corpus and the second corpus into a pre-trained model, a vector set E can be obtained. The vector set E includes the sentence vectors corresponding to each sentence in the first corpus and the second corpus, and can be specifically represented by the following formula:
[0089] E={e1,e2,...} (7);
[0090] Where E represents the set of statement vectors corresponding to each statement in the first corpus and the second corpus; e1 and e2 represent specific statement vectors in E.
[0091] It should be noted that the number of elements in the vector set E is the sum of the number of sentences in the first corpus and the second corpus. In other words, the vector set E can be understood as the vector representation of the union of the first corpus and the second corpus. Each sentence vector is specifically composed of the Chinese character vectors of the corresponding Chinese characters in the sentence.
[0092] S103: Extract the target Chinese character vector carrying the sub-character label from the Chinese character vector.
[0093] In this embodiment, after obtaining the vector set E, the Chinese character vectors in the sentence vectors are compared with the sub-character dictionary WM obtained in the previous steps. Then, based on the sub-character dictionary WM, the Chinese characters that have been labeled with sub-character tags are found in each sentence, and the target Chinese character vector of the Chinese character is extracted.
[0094] S104: Using the target Chinese character vector as the cluster center, cluster each Chinese character vector to determine the corresponding target sub-character for each Chinese character in each sentence, and obtain a sub-character corpus composed of target sub-characters.
[0095] It should be noted that the target Chinese character vector corresponding to each Chinese character carrying a sub-character label can represent a specific meaning of the Chinese character. Therefore, by using the target Chinese character vector as the cluster center to cluster all Chinese characters, the same Chinese character with the same or similar meaning in different sentences can be grouped into the same category, thereby realizing the classification of all Chinese characters in each sentence. Chinese characters in the same category correspond to a target sub-character.
[0096] In this embodiment, by mapping the Chinese characters in each sentence to their corresponding target sub-characters, the sub-character corpus corresponding to each sentence can be obtained. Then, by integrating the various sub-character corpora, the sub-character corpus set H can be obtained, which can be specifically expressed by the following formula:
[0097] H = {h1,h2,...} (8);
[0098] Where H represents the sub-character corpus; h1 and h2 represent the sub-character corpus in H.
[0099] It should be noted that, referring to formulas (7) and (8), the sub-character corpus h1 corresponds to the sentence vector e1, which is equivalent to the sub-character representation of the sentence vector e1; the sub-character corpus h2 corresponds to the sentence vector e2, which is equivalent to the sub-character representation of the sentence vector e2.
[0100] S105: Using the sub-character corpus as training samples, the language model is trained to obtain the sub-character recognition model, which is used to identify the meaning of Chinese characters in sentences.
[0101] In this embodiment, by using the target Chinese character vector as the cluster center, the sub-character corpus H obtained by the clustering algorithm is not only sufficiently large in quantity but also highly accurate, with each sub-character in the corpus having an accurate and unique meaning. Therefore, by using the sub-character corpus as training samples, the resulting sub-character recognition model can quickly and accurately identify the target sub-character corresponding to each Chinese character in a sentence. Based on the target sub-character corresponding to each Chinese character, the unique meaning and pronunciation of each Chinese character in the sentence to be recognized can be determined, effectively meeting the disambiguation requirements for polyphonic characters.
[0102] In one feasible implementation, S104 may specifically include the following sub-steps:
[0103] S104-1: Using the target Chinese character vector as the cluster center, cluster each Chinese character vector to obtain a preset number of clusters; different clusters are used to represent target sub-characters with different meanings.
[0104] In this embodiment, the K-means clustering algorithm can be used to cluster each Chinese character vector in the sentence vector. Here, K represents the preset number, meaning the value of K can be set according to actual needs, i.e., the number of sub-character categories to be classified. After determining the value of K, compared to the traditional K-means clustering algorithm randomly selecting K data points as cluster centers, this embodiment uses the extracted target Chinese character vectors carrying sub-character labels as cluster centers. This allows for accurate classification of the Chinese character vectors, ensuring that Chinese character vectors that are the same as or similar to the target Chinese character vectors are grouped into the same cluster, thereby improving the accuracy of clustering.
[0105] In practical implementation, the target Chinese character vector can be used as the cluster center. Each Chinese character vector is clustered, and the Euclidean distance between each vector and the cluster center is calculated. If the Euclidean distance between any Chinese character vector and the cluster center is less than a distance threshold, then the Chinese character vector belongs to the cluster corresponding to that cluster center. It should be noted that different cluster centers correspond to different clusters, and the different clusters obtained based on different cluster centers are used to represent different target sub-characters corresponding to a given Chinese character.
[0106] S104-2: Determine the target sub-character corresponding to the cluster for Chinese characters whose vectors belong to the same cluster.
[0107] In this embodiment, since the Chinese characters corresponding to the Chinese character vectors belonging to the same clustering cluster have the same or similar meanings, a mapping relationship between the Chinese characters corresponding to the Chinese character vectors belonging to the same clustering cluster and the target sub-characters corresponding to the clustering cluster can be obtained.
[0108] S104-3: Map the Chinese characters in each sentence to their respective corresponding target sub-characters to obtain a sub-character corpus set composed of the target sub-characters.
[0109] In this embodiment, by clustering all Chinese characters, the sub-character expressions corresponding to each Chinese character in different sentences can be determined, that is, the mapping relationship between each Chinese character and the target sub-character in different sentences can be determined. Furthermore, based on this mapping relationship, the Chinese characters in each sentence can be mapped to their respective corresponding target sub-characters to obtain a set of sub-character corpora composed of the target sub-characters, that is, the sub-character corpus set H.
[0110] Exemplarily, referring to Figure 2 , a schematic diagram of generating a sub-character corpus for a certain Chinese character provided by an embodiment of the present application is shown. It can be seen that for the Chinese character "长 (cháng)", there are many sentences containing this character in actual applications. For example: "时间长 (a long time)", "长不大 (not grow up)", "长期 (long term)", etc. For these sentences containing "长 (cháng)", the character "长 (cháng)" has similar meanings in "时间长 (a long time)" and "长期 (long term)", while it has a different meaning in the sentence "长不大 (not grow up)". These sentences are pre-trained. Among them, the pre-training model can adopt the pre-mode l pre-training model to obtain different Chinese character vectors corresponding to the character "长 (cháng)" in these sentences.
[0111] Furthermore, among the Chinese character vectors corresponding to all the characters "长 (cháng)", the Chinese character vector of the character "长 (cháng)" carrying the sub-character label is extracted as the target Chinese character vector of the character "长 (cháng)", and this target Chinese character vector is used as the initial value of the clustering center to cluster all the characters "长 (cháng)". Here, the K-means clustering algorithm is used to cluster the sub-characters of the character "长 (cháng)" with the same or similar meanings into the same clustering cluster. For example, the sub-characters of the character "长 (cháng)" in "时间长 (a long time)" and "长期 (long term)" have the same meaning, so the sub-characters of the character "长 (cháng)" in "时间长 (a long time)" and "长期 (long term)" are clustered into clustering cluster A, and the target sub-character corresponding to clustering cluster A is denoted as "长-1 (cháng-1)". The character "长 (cháng)" in "长不大 (not grow up)" represents a different meaning, so it is clustered into another clustering cluster B, and the target sub-character corresponding to clustering cluster B is denoted as "长-2 (cháng-ii)".
[0112] Using the same method, all Chinese characters in "long time", "not grow up", "long term", etc. are pre-trained to obtain Chinese character vectors corresponding to all Chinese characters, and all Chinese characters are clustered, and the Chinese character vectors with the same meaning are grouped into the same clustering cluster. Taking "long time" as an example, input "long time" into the pre-trained model to obtain the Chinese character vectors of all Chinese characters in this sentence. That is, the Chinese character vector corresponding to the character "时" can be obtained, the Chinese character vector corresponding to the character "间" can be obtained, and the Chinese character vector corresponding to the character "长" can be obtained, and these Chinese character vectors are clustered to determine the target sub-characters corresponding to the characters "时", "间", and "长" respectively, namely "时-1", "间-1", and "长-1". Thus, the corresponding sub-character corpus of the sentence "long time" can be obtained as "时-1间-1长-1". After mapping all the Chinese characters of these sentences to the corresponding target sub-characters, a sub-character corpus set can be obtained.
[0113] In a feasible implementation manner, S105 may specifically include the following sub-steps:
[0114] S105-1: Use the sub-character corpus set as a training sample to train the n-gram language model to obtain a sub-character recognition model. The sub-character recognition model learns the word sequences before the sub-character in each sentence containing the same sub-character.
[0115] In this implementation manner, the n-gram language model can be used to train the sub-character corpus set to learn the word sequences before the sub-character in each sentence containing the same sub-character, and the probability that a certain sub-character appears after a certain word sequence in a sub-character sequence can be obtained. Specifically, it can be expressed by the following formula:
[0116]
[0117] where, w [[ID=**16**]] i represents a certain sub-character, represents the word sequence before the sub-character, represents w [[ID=**22**]] i following the size of the conditional probability, n is a preset parameter, and i represents the position of the sub-character in the sentence where it is located.
[0118] The above can obtain the recognition model for sub-characters. For a sentence composed of sub-characters, the recognition model for a certain sub-character sentence can be obtained through the following formula:
[0119] This probability can be used to identify the sub-character corresponding to each Chinese character in a specific sentence.
[0120] In this embodiment, the sub-character corpus is used as a training sample. Based on formula (9), the n-gram language model can be trained to obtain a recognition model for recognizing sub-characters. Based on formula (10), the n-gram language model can be trained to obtain a recognition model for recognizing sub-character sentences.
[0121] Secondly, based on the same inventive concept, and referring to... Figure 3 This application provides a sub-character recognition method, the method comprising:
[0122] S301: Input the sentence to be recognized into the sub-character recognition model to obtain the target sub-characters corresponding to each Chinese character in the sentence to be recognized; wherein, the sub-character recognition model is trained based on the training method of the sub-character recognition model proposed in the first aspect of the present application; the meaning of the target sub-character is the meaning of the corresponding Chinese character with the highest probability in the sentence to be recognized.
[0123] In this embodiment, for a statement to be identified, which consists of multiple Chinese characters, the specific meaning of each Chinese character in the statement is uncertain. That is, each Chinese character in the statement corresponds to one or more sub-characters. By traversing and combining them, all possible combinations of sub-characters in the statement to be identified are obtained.
[0124] In this embodiment, the sub-character recognition model can be used to input the sentence to be recognized to obtain the probability of all sub-character combinations. Since the meaning of the sub-character in the sub-character combination is unique, the probability of a certain sub-character combination is the probability of a certain Chinese character having one of its meanings in the sentence to be recognized.
[0125] In this embodiment, an estimation algorithm can be applied to all sub-character combinations, such as using the maximum likelihood estimation algorithm to find the sub-character combination with the highest probability of occurrence among all sub-character combinations, and take it as the target sub-character combination corresponding to the sentence to be identified. Then, based on the target sub-character combination, the target sub-character corresponding to each Chinese character in the sentence to be identified can be determined.
[0126] In one feasible implementation, after S201, the sub-character recognition method may further include the following steps:
[0127] S302: Based on the meaning of the target sub-character, determine the pronunciation of the corresponding Chinese character in the sentence to be recognized.
[0128] In this embodiment, the target sub-character in the target sub-character combination is the most accurate meaning of the corresponding Chinese character in the sentence to be recognized. Since each target sub-character corresponds to a unique pronunciation, the pronunciation of the Chinese character corresponding to the target sub-character in the sentence to be recognized can be determined based on the meaning of each target sub-character in the target sub-character combination.
[0129] In one example, there is a sentence S to be recognized, and the sentence S to be recognized consists of m Chinese characters. Specifically, it is shown in the following formula:
[0130] S = (W1, W2,..., W m ) (11);
[0131] where S is the sentence to be recognized, and Wl, W2, W m are all the Chinese characters that make up the sentence to be recognized.
[0132] Traverse all the Chinese characters in the above sentence S to be recognized to obtain all possible sub - character combinations of the sentence S to be recognized. Specifically, it is shown in the following formula:
[0133] {(w 11 , w 21 ,...)...(w 1i , w 2j ,...,)...} (12);;
[0134] where w 11 , w 21 , w 1i , w 2j are the sub - characters corresponding to the Chinese characters in the sentence S to be recognized.
[0135] Substitute each sub - character combination in formula (12) into formula (10), and the probability of each sub - character combination can be calculated. The calculation process can be expressed by the following formula:
[0136]
[0137] Solve formula (13) to obtain the target sub - character combination with the highest occurrence probability among all the sub - character combinations of the sentence S to be recognized. The target sub - character combination with the highest occurrence probability is the final recognition result S * , specifically shown in the following formula:
[0138]
[0139] where respectively represent the target sub - characters corresponding to the Chinese characters in the sentence to be recognized.
[0140] It should be noted that comparing formula (11) and formula (14), the recognition result of the sentence S to be recognized is S * ; the target sub - character corresponding to the Chinese character W1 is the target sub - character corresponding to the Chinese character W2 is the target sub - character corresponding to the Chinese character W m is In other words, all the Chinese characters to be recognized in the sentence S are converted into their corresponding target sub-characters.
[0141] In this embodiment, since the target sub-character has a unique meaning and pronunciation, based on the recognition result S * This allows us to obtain the correct pronunciation of each Chinese character in the sentence to be recognized. In a specific implementation, this can be achieved by... Inputting the character into the dictionary will yield the correct pronunciation for each character.
[0142] For example, taking “long time” as an example, there are many combinations of all the sub-characters of “time”, “space” and “long” in this sentence, such as “time-1space-1long-1”, “time-1space-1long-2”, “time-2space-1long-2”, etc. The probability of all sub-character combinations is calculated by formula (13), and the target sub-character combination with the highest probability is “time-1space-1long-1”. This sub-character combination is the final recognition result. Finally, the target sub-characters in these recognized target sub-character combinations are input into the sub-character dictionary to obtain the corresponding pronunciation of “time-1space-1long-1”.
[0143] Thirdly, based on the same inventive concept, and referring to... Figure 4 This application provides a training device 400 for a sub-character recognition model, which includes:
[0144] The acquisition module 401 is used to acquire a first corpus and a second corpus. The first corpus includes sentences carrying sub-character tags, and the second corpus includes sentences without sub-character tags. Sub-character tags are used to characterize the position and category of sub-characters in sentences. Sub-characters are Chinese characters with at least one meaning, and the meaning of sub-characters in a sentence is: one meaning of a Chinese character with multiple meanings.
[0145] Vector module 402 is used to input the first corpus and the second corpus into the pre-trained model to obtain the sentence vectors corresponding to each sentence; the sentence vectors of different sentences are composed of the Chinese character vectors in the sentence;
[0146] Extraction module 403 is used to extract the target Chinese character vector carrying the sub-character label from the Chinese character vector;
[0147] Clustering module 404 is used to cluster each Chinese character vector as a cluster center, thereby determining the corresponding target sub-characters for each Chinese character in each sentence and obtaining a sub-character corpus composed of target sub-characters.
[0148] A training module 405, configured to use the sub - character corpus as a training sample to train a language model, so as to obtain a sub - character recognition model, where the sub - character recognition model is used to recognize the meanings of Chinese characters in a sentence.
[0149] In an embodiment of the present application, the acquisition module 401 includes:
[0150] An analysis sub - module, configured to analyze a Chinese dictionary to obtain sentences containing sub - characters;
[0151] An adding sub - module, configured to add a sub - character label to a sub - character based on the position and category of the sub - character in the corresponding sentence, so as to obtain a sentence carrying the sub - character label;
[0152] An acquisition sub - module, configured to obtain a first corpus based on the sentence carrying the sub - character label.
[0153] In an embodiment of the present application, the clustering module 404 includes:
[0154] A clustering sub - module, configured to use the target Chinese character vector as a clustering center to cluster each Chinese character vector, so as to obtain a preset number of clustering clusters; different clustering clusters are used to represent target sub - characters with different meanings;
[0155] A determination sub - module, configured to determine the Chinese characters corresponding to the Chinese character vectors belonging to the same clustering cluster as the target sub - character corresponding to the clustering cluster;
[0156] A mapping sub - module, configured to map the Chinese characters in each sentence to their corresponding target sub - characters, so as to obtain a sub - character corpus composed of target sub - characters.
[0157] In an embodiment of the present application, the clustering sub - module includes:
[0158] An Euclidean distance determination unit, configured to use the target Chinese character vector as a clustering center to cluster each Chinese character vector, and determine the Euclidean distance between each Chinese character vector and the clustering center; different clustering centers correspond to different clustering clusters;
[0159] A clustering cluster determination unit, configured to determine that a Chinese character vector belongs to the clustering cluster corresponding to the clustering center when the Euclidean distance between any Chinese character vector and the clustering center is less than a distance threshold.
[0160] In an embodiment of the present application, the training module 405 is specifically configured to use the sub - character corpus as a training sample to train an n - gram language model, so as to obtain a sub - character recognition model, and the sub - character recognition model learns the word sequences before the sub - character in each sentence containing the same sub - character.
[0161] It should be noted that the specific implementation of the training device 400 for the sub-character recognition model in this application embodiment refers to the specific implementation of the training method for the sub-character recognition model proposed in the first aspect of the aforementioned application embodiment, and will not be repeated here.
[0162] Fourthly, based on the same inventive concept, referring to Figure 5 This application provides a sub-character recognition device 500, which includes:
[0163] The sub-character recognition module 501 is used to input the sentence to be recognized into the sub-character recognition model to obtain the target sub-characters corresponding to the Chinese characters in the sentence to be recognized; wherein, the sub-character recognition model is trained based on the training method of the sub-character recognition model proposed in the first aspect of the embodiments of this application; the meaning of the target sub-character is the meaning of the corresponding Chinese character with the highest probability in the sentence to be recognized.
[0164] In one embodiment of this application, the sub-character recognition device 500 further includes:
[0165] The pronunciation determination module 502 is used to determine the pronunciation of the Chinese character corresponding to the target sub-character in the sentence to be recognized based on the meaning of the target sub-character.
[0166] It should be noted that the specific implementation of the sub-character recognition device 500 in this application embodiment refers to the specific implementation of the sub-character recognition method proposed in the second aspect of the aforementioned application embodiment, and will not be repeated here.
[0167] Fifthly, refer to Figure 6 This application provides an electronic device 600, including a memory 601, a processor 602, and a computer program stored in the memory 602. The processor 601 executes the computer program to implement the training method of the sub-character recognition model proposed in the first aspect of this application or the sub-character recognition method proposed in the second aspect of this application.
[0168] It should be noted that the specific implementation of the electronic device 600 in this application embodiment refers to the specific implementation of the training method of the sub-character recognition model proposed in the first aspect of the present application embodiment or the sub-character recognition method proposed in the second aspect of the present application embodiment, and will not be repeated here.
[0169] In a sixth aspect, embodiments of this application provide a computer-readable storage medium storing a computer program / instructions thereon, which, when executed by a processor, implements the training method for the sub-character recognition model proposed in the first aspect of embodiments of this application or the sub-character recognition method proposed in the second aspect of embodiments of this application.
[0170] It should be noted that the specific implementation of the computer-readable storage medium in the embodiments of this application refers to the specific implementation of the training method of the sub-character recognition model proposed in the first aspect of the embodiments of this application or the specific implementation of the sub-character recognition method proposed in the second aspect of the embodiments of this application, and will not be repeated here.
[0171] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, apparatus, or computer program products. Therefore, embodiments of the present invention can take the form of entirely hardware embodiments, entirely software embodiments, or embodiments combining software and hardware aspects. Furthermore, embodiments of the present invention can take the form of computer program products implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0172] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, terminal devices (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing terminal device to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing terminal device, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0173] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing terminal device to operate in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0174] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal equipment, causing a series of operational steps to be performed on the computer or other programmable terminal equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable terminal equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0175] Although preferred embodiments of the present invention have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of the embodiments of the present invention.
[0176] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or terminal device that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or terminal device. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or terminal device that includes the element.
[0177] The training, recognition method, apparatus, device, and storage medium of the sub-character recognition model provided by the present invention have been described in detail above. Specific examples have been used to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only for the purpose of helping to understand the method and core ideas of the present invention. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of the present invention. Therefore, the content of this specification should not be construed as a limitation of the present invention.
Claims
1. A training method for a sub-character recognition model, characterized in that, The method includes: Obtain a first corpus and a second corpus; the first corpus includes sentences carrying sub-character tags, and the second corpus includes sentences without sub-character tags. The sub-character tags are used to characterize the position and category of sub-characters in the sentences. Each Chinese character includes at least one sub-character, and each sub-character is used to characterize a meaning of the corresponding Chinese character. Obtain the statement vectors corresponding to each statement in the first corpus and the second corpus; the statement vectors of different statements are composed of the Chinese character vectors in the statement; From the Chinese character vectors, extract the target Chinese character vectors carrying the sub-character tags; Using the target Chinese character vectors as cluster centers, each Chinese character vector is clustered to determine the corresponding target sub-characters for each Chinese character in the sentences, resulting in a sub-character corpus composed of target sub-characters, including: Using the target Chinese character vector as the cluster center, each Chinese character vector is clustered to obtain a preset number of clusters; different clusters are used to represent target sub-characters with different meanings; For Chinese characters whose vectors belong to the same cluster, determine the target sub-character corresponding to the cluster. Map the Chinese characters in each of the sentences to their corresponding target sub-characters to obtain a sub-character corpus composed of target sub-characters; The sub-character corpus is used as training samples to train the language model and obtain the sub-character recognition model. The sub-character recognition model learns the word sequence before the sub-character in each sentence containing the same sub-character to obtain the probability that a certain sub-character appears after a certain word sequence in a sub-character sequence, which is used to identify the meaning of Chinese characters in the sentence.
2. The training method for the sub-character recognition model according to claim 1, characterized in that, Obtain the first corpus, including: The Chinese dictionary is analyzed to obtain sentences containing the Chinese characters to be annotated; Based on the position and category of the Chinese character to be annotated in the corresponding sentence, a sub-character tag is added to the Chinese character to be annotated to obtain the sentence carrying the sub-character tag; The first corpus is obtained based on the statements carrying the sub-character tags.
3. The training method for the sub-character recognition model according to claim 1, characterized in that, Using the target Chinese character vector as the cluster center, each Chinese character vector is clustered to obtain a preset number of clusters, including: The target Chinese character vectors are used as cluster centers. Each Chinese character vector is clustered, and the Euclidean distance between each Chinese character vector and the cluster center is determined. Different cluster centers correspond to different clusters. If the Euclidean distance between any Chinese character vector and the cluster center is less than a distance threshold, the Chinese character vector is determined to belong to the cluster corresponding to the cluster center.
4. A sub-character recognition method, characterized in that, The method includes: The sentence to be recognized is input into the sub-character recognition model to obtain the target sub-characters corresponding to each Chinese character in the sentence to be recognized; wherein, the sub-character recognition model is trained based on the training method of the sub-character recognition model according to any one of claims 1-3; the meaning of the target sub-character is the meaning of the corresponding Chinese character with the highest probability in the sentence to be recognized.
5. The sub-character recognition method according to claim 4, characterized in that, After inputting the sentence to be recognized into the sub-character recognition model to obtain the target sub-characters corresponding to each Chinese character in the sentence to be recognized, the method further includes: Based on the meaning of the target sub-character, determine the pronunciation of the corresponding Chinese character in the sentence to be identified.
6. A training device for a sub-character recognition model, characterized in that, The device includes: The acquisition module is used to acquire a first corpus and a second corpus; the first corpus includes sentences carrying sub-character tags, and the second corpus includes sentences without sub-character tags. The sub-character tags are used to characterize the position and category of sub-characters in the sentences. Each Chinese character includes at least one sub-character, and each sub-character is used to characterize a meaning of the corresponding Chinese character. The vector module obtains the statement vectors corresponding to each statement in the first corpus and the second corpus; the statement vectors of different statements are composed of the Chinese character vectors in the statement. The extraction module is used to extract the target Chinese character vector carrying the sub-character tag from the Chinese character vector; The clustering module is used to cluster each Chinese character vector as a cluster center to determine the corresponding target sub-characters for each Chinese character in each sentence, thereby obtaining a sub-character corpus composed of target sub-characters. This includes: using the target Chinese character vector as a cluster center to cluster each Chinese character vector to obtain a preset number of clusters; different clusters are used to represent target sub-characters with different meanings; determining the target sub-characters corresponding to the clusters for Chinese character vectors belonging to the same cluster; and mapping the Chinese characters in each sentence to their corresponding target sub-characters to obtain a sub-character corpus composed of target sub-characters. The training module is used to train the language model using the sub-character corpus as training samples to obtain the sub-character recognition model. The sub-character recognition model learns the word sequence before the sub-character in each sentence containing the same sub-character to obtain the probability that a certain sub-character appears after a certain word sequence in a sub-character sequence, which is used to identify the meaning of Chinese characters in the sentence.
7. A sub-character recognition device, characterized in that, The device includes: The sub-character recognition module is used to input the sentence to be recognized into the sub-character recognition model to obtain the target sub-characters corresponding to each Chinese character in the sentence to be recognized; wherein, the sub-character recognition model is trained based on the training method of the sub-character recognition model according to any one of claims 1-3; the meaning of the target sub-character is the meaning of the corresponding Chinese character with the highest probability in the sentence to be recognized.
8. An electronic device, characterized in that, It includes a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement the training method of the sub-character recognition model as described in any one of claims 1-3 or the sub-character recognition method as described in claim 4 or 5.
9. A computer-readable storage medium, characterized in that, It stores a computer program / instruction, which, when executed by a processor, implements the training method of the sub-character recognition model as described in any one of claims 1-3 or the sub-character recognition method as described in claim 4 or 5.
Citation Information
Patent Citations
Polyphone pronunciation labeling method and device, equipment and storage medium
CN113268974A