Translation model training method and text translation method and device
By extracting and using the pronunciation information and word structure information of the source language corpus in the translation model, more accurate word embedding vectors are generated, which solves the problem of low accuracy of the translation model in the prior art and significantly improves the accuracy of the translation results.
Patent Information
- Application Number
- CN202411132733.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Priority Date
- 2023-08-16
- Filing Date
- 2024-08-16
- Publication Date
- 2024-12-06
AI Technical Summary
The existing translation model training methods only use word meta information as input, resulting in inaccurate translation results and low accuracy of the translation model.
Extract pronunciation information and word structure information from the source language corpus, and input the result of word segmentation processing into the word embedding layer of the translation model to generate word feature vectors, pronunciation information feature vectors, word structure information feature vectors, and position information feature vectors. To determine the word embedding vector, the model parameters are adjusted to improve translation accuracy.
By considering the pronunciation information of words and word structure information, the training effect of the translation model is improved, making the translation results more accurate and the overall accuracy of the translation model is improved.
Smart Images

Figure CN119089914A_ABST
Abstract
Description
[0001] This application claims the priority of the Chinese patent application filed with the China Patent Office on August 16, 2023, with application number "202311036117.0" and invention name "Training method of translation model, text translation method and device", all contents of which are recorded in this application by reference. Technical Field
[0002] The present application relates to the field of machine translation technology, and in particular to a method for training a translation model. The present application also relates to a text translation method, a training device for a translation model, a text translation device, a computing device, and a computer-readable storage medium. Background Art
[0003] With the improvement of computer computing power, translation work has shifted from manual translation to machine translation (also known as automatic translation, which is the process of converting one natural language into another natural language using a computer), and translation efficiency has been greatly improved. Machine translation has undergone the following developments: rule-based machine translation in the 1980s, statistics-based machine translation in the 1990s, and neural network-based machine translation from 2013 to the present. Neural network-based machine translation (NMT) has gradually become the mainstream in the field of machine translation technology due to its significantly improved fluency and translation effects that far exceed traditional statistics-based machine translation (SMT) in multiple language pairs. By building and training a translation model based on a neural network, efficient and high-quality translation of source language text to target language text can be achieved.
[0004] In the prior art, the training method for the translation model is to use the token information of the source language training sample after word segmentation as input, input it into the word embedding layer of the translation model, obtain the word embedding vector, and then convert the word embedding vector in the encoder and decoder to obtain the translation result of the target language, and then continuously train the translation model according to the translation result.
[0005] Among them, because the word embedding layer information input into the translation model only contains word-unit information, the translation result of the target language is not accurate enough, the training effect of the translation model is not good, and the accuracy of the translation model is low. Summary of the invention
[0006] In view of this, the embodiments of the present application provide a translation model training method and a text translation method to solve the technical defects existing in the prior art. The embodiments of the present application also provide a translation model training device, a text translation device, a computing device, and a computer-readable storage medium.
[0007] According to a first aspect of an embodiment of the present application, a method for training a translation model is provided, comprising:
[0008] Acquire a training sample, wherein the training sample includes a source language corpus and a target language corpus corresponding to the source language corpus;
[0009] Performing word segmentation processing on the source language corpus to extract pronunciation information and word structure information of each word in the source language corpus;
[0010] Inputting the source language corpus after word segmentation processing, the pronunciation information and word structure information of each word into the word embedding layer of the translation model to be trained to obtain a word feature vector, a pronunciation information feature vector, a word structure information feature vector and a position information feature vector;
[0011] Determine a word embedding vector of the source language corpus according to the word feature vector, the pronunciation information feature vector, the word structure information feature vector and the position information feature vector;
[0012] According to the word embedding vector, a translation result of the source language corpus is obtained through an encoder and a decoder of the translation model;
[0013] A loss value of the translation model is calculated according to the translation result and the target language corpus, and when the loss value is greater than a preset threshold, a model parameter of the translation model is adjusted according to the loss value.
[0014] Optionally, after the step of obtaining training samples, the method further includes:
[0015] Data cleaning is performed on the training samples to obtain preprocessed training samples.
[0016] Optionally, the step of extracting pronunciation information of each word in the source language corpus includes:
[0017] According to each word in the source language corpus after word segmentation processing, the pronunciation information of each word is searched using a pre-established dictionary database, wherein the correspondence between words and pronunciation information is recorded in the dictionary database.
[0018] Optionally, the step of extracting word structure information of each word in the source language corpus includes:
[0019] For each word in the source language corpus, the characters in the word are split into glyph components to obtain the glyph components of each character, and the word structure information of the word is determined based on the glyph components of each character.
[0020] Optionally, the step of determining the word embedding vector of the source language corpus according to the word feature vector, the pronunciation information feature vector, the word structure information feature vector and the position information feature vector comprises:
[0021] The word feature vector, the pronunciation information feature vector, the word structure information feature vector and the position information feature vector are added together to obtain a word embedding vector of the source language corpus.
[0022] Optionally, after the step of calculating the loss value of the translation model according to the translation result and the target language corpus, the method further includes:
[0023] When the loss value is less than or equal to the preset threshold, stopping the training and determining that the training of the translation model is completed;
[0024] or,
[0025] When the number of iterations is greater than a preset number, the training is stopped to determine that the training of the translation model is completed.
[0026] According to a second aspect of an embodiment of the present application, a text translation method is provided, comprising:
[0027] Get the text to be translated;
[0028] Performing word segmentation processing on the text to be translated, and extracting pronunciation information and word structure information of each word in the text to be translated;
[0029] The text to be translated after word segmentation processing, the pronunciation information and word structure information of each word are input into a pre-trained translation model to obtain a target language translation text corresponding to the text to be translated, wherein the translation model is trained using the training method of the translation model of the first aspect above.
[0030] According to a third aspect of an embodiment of the present application, a translation model training device is provided, comprising:
[0031] A first acquisition module is configured to acquire a training sample, wherein the training sample includes a source language corpus and a target language corpus corresponding to the source language corpus;
[0032] A first word segmentation module is configured to perform word segmentation processing on the source language corpus and extract pronunciation information and word structure information of each word in the source language corpus;
[0033] A word embedding module is configured to input the source language corpus after word segmentation processing, the pronunciation information and word structure information of each word into the word embedding layer of the translation model to be trained, to obtain a word feature vector, a pronunciation information feature vector, a word structure information feature vector and a position information feature vector; and determine the word embedding vector of the source language corpus according to the word feature vector, the pronunciation information feature vector, the word structure information feature vector and the position information feature vector;
[0034] An encoding and decoding module is configured to obtain a translation result of the source language corpus according to the word embedding vector through an encoder and a decoder of the translation model;
[0035] The training module is configured to calculate the loss value of the translation model according to the translation result and the target language corpus, and when the loss value is greater than a preset threshold, adjust the model parameters of the translation model according to the loss value.
[0036] Optionally, the device further comprises:
[0037] The data cleaning module is configured to perform data cleaning on the training samples to obtain preprocessed training samples.
[0038] Optionally, the first word segmentation module is further configured to search for pronunciation information of each word in the source language corpus after word segmentation processing using a pre-established dictionary database, wherein the correspondence between words and pronunciation information is recorded in the dictionary database.
[0039] Optionally, the first word segmentation module is further configured to split the characters in each word in the source language corpus into glyph component elements to obtain the glyph component elements of each character, and determine the word structure information of the word based on the glyph component elements of each character.
[0040] Optionally, the word embedding module is further configured to add the word feature vector, the pronunciation information feature vector, the word structure information feature vector and the position information feature vector to obtain a word embedding vector of the source language corpus.
[0041] Optionally, the training module is further configured to stop training when the loss value is less than or equal to the preset threshold, and determine that the training of the translation model is completed; or to stop training when the number of iterations is greater than a preset number, and determine that the training of the translation model is completed.
[0042] According to a fourth aspect of the embodiments of the present application, a text translation device is provided, including:
[0043] A second acquisition module is configured to acquire a text to be translated;
[0044] A second word segmentation module is configured to perform word segmentation processing on the text to be translated, and extract pronunciation information and word structure information of each word in the text to be translated;
[0045] The translation module is configured to input the text to be translated after word segmentation processing, the pronunciation information and word structure information of each word into a pre-trained translation model to obtain a target language translation text corresponding to the text to be translated, wherein the translation model is trained using the translation model training method of the first aspect of the embodiment of the present application.
[0046] According to a fifth aspect of an embodiment of the present application, there is provided a computing device, including:
[0047] Memory and processor;
[0048] The memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions to implement the translation model training method described in the first aspect of the embodiment of the present application or the text translation method described in the second aspect.
[0049] According to the sixth aspect of the embodiments of the present application, a computer-readable storage medium is provided, which stores computer-executable instructions. When the instructions are executed by a processor, the training method of the translation model described in the first aspect of the embodiments of the present application or the text translation method described in the second aspect is implemented.
[0050] According to a seventh aspect of an embodiment of the present application, a chip is provided, which stores a computer program. When the computer program is executed by the chip, the training method of the translation model described in the first aspect of the embodiment of the present application or the text translation method described in the second aspect is implemented.
[0051] The training method of the translation model provided in the present application extracts the pronunciation information and word structure information of each word in the source language corpus in the training sample, and then inputs the source language corpus after word segmentation processing, the pronunciation information and word structure information of each word into the word embedding layer of the translation model to be trained, so as to obtain a word feature vector, a pronunciation information feature vector, a word structure information feature vector and a position information feature vector, thereby increasing the information input into the word embedding layer of the translation model, and then determining the word embedding vector according to the word feature vector, the pronunciation information feature vector, the word structure information feature vector and the position information feature vector, and obtaining a more accurate translation result of the source language corpus through the translation model according to the word embedding vector, and then adjusting the model parameters of the translation model according to the translation result. It can be seen that the training of the translation model takes more into account the pronunciation information features and the word structure information features of the word, so that the trained translation model has higher accuracy. BRIEF DESCRIPTION OF THE DRAWINGS
[0052] Figure 1 It is a structural diagram of a translation system provided by an embodiment of the present application;
[0053] Figure 2 is a flowchart of a method for training a translation model provided in one embodiment of the present application;
[0054] Figure 3 It is a flow chart of a method for extracting pronunciation information of each word in a source language corpus in a translation model training method provided in one embodiment of the present application;
[0055] Figure 4 It is a flow chart of a method for extracting word structure information of each word in a source language corpus in a translation model training method provided in one embodiment of the present application;
[0056] Figure 5 It is a structural diagram of a Transformer model in a translation model training method provided in one embodiment of the present application;
[0057] Figure 6 It is a structural diagram of the embedding layer of a Transformer model in a translation model training method provided in one embodiment of the present application;
[0058] Figure 7 is a flowchart of another translation model training method provided in one embodiment of the present application;
[0059] Figure 8 is a flowchart of a text translation method provided by an embodiment of the present application;
[0060] Fig. 9 It is a structural schematic diagram of a training device for a translation model provided in one embodiment of the present application;
[0061] Fig.10 is a structural schematic diagram of a text translation device provided in one embodiment of the present application;
[0062] Fig.11 It is a structural block diagram of a computing device provided in one embodiment of the present application. DETAILED DESCRIPTION
[0063] Many specific details are described in the following description to facilitate a full understanding of the present application. However, the present application can be implemented in many other ways than those described herein, and those skilled in the art can make similar generalizations without violating the connotation of the present application, so the present application is not limited by the specific implementation disclosed below.
[0064] The terms used in one or more embodiments of the present application are only for the purpose of describing specific embodiments, and are not intended to limit one or more embodiments of the present application. The singular forms of "a", "said" and "the" used in one or more embodiments of the present application and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used in one or more embodiments of the present application refers to and includes any or all possible combinations of one or more associated listed items.
[0065] It should be understood that, although the terms first, second, etc. may be used to describe various information in one or more embodiments of the present application, such information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of one or more embodiments of the present application, the first may also be referred to as the second, and similarly, the second may also be referred to as the first.
[0066] First, the terms involved in one or more embodiments of the present application are explained.
[0067] Translation model: The main idea is to encode the sentence to be translated into an encoded vector through multiple encoding layers (Encoder), then use multiple decoding layers (Decoder) to decode the encoded vector to obtain a decoded vector, and then translate the decoded vector into the corresponding target sentence.
[0068] Encode: Convert the sentence to be translated from text into an encoding vector.
[0069] Decode: Convert the encoded vector into the language of the translation sentence.
[0070] Bilingual Evaluation Understudy (BLEU) value: a loss value indicator for evaluating machine translation results.
[0071] Neural Machine Translation (NMT): End-to-end neural machine translation based on the encoding and decoding model is the current mainstream research direction of machine translation. It uses the encoder to encode the source language text into a vector, and the decoder decodes the vector one by one to generate the corresponding target language translation result.
[0072] Out-of-set examples: corpus words / sentences outside the training sample set.
[0073] Out-of-set words: words that are not in the training sample set.
[0074] Word segmentation: When doing text processing, the first preprocessing to be done is word segmentation. English words are naturally separated by spaces, so it is easy to segment words according to spaces, but sometimes multiple words need to be segmented as one word, such as some nouns such as "NewYork", which need to be treated as one word. Since Chinese has no spaces, a special word segmentation method needs to be designed for Chinese word segmentation.
[0075] Translation model (Transformer): is a natural language processing model that combines the attention mechanism.
[0076] Convolutional Neural Network (CNN): used to extract features from input, and then classify, identify, predict, etc. the input based on the extracted features.
[0077] Word: Due to differences in languages, such as the smallest unit of Chinese is a character, and the smallest unit of English is a word, in order to unify the expressions, this application does not distinguish between "word" and "character".
[0078] Phrase: It can be a single word (character) or a phrase consisting of multiple words (characters), a natural language (NL) term stored in a dictionary database.
[0079] Word Vector: It is a general term for a set of language modeling and feature learning techniques in embedded natural language processing (NLP), in which words or phrases from the vocabulary are mapped to vectors of real numbers.
[0080] Word Embedding: It refers to the process of embedding a high-dimensional space with the dimension of all words into a low-dimensional continuous vector space, where each word or phrase is mapped to a vector in the real number field.
[0081] Gradient: A new multidimensional vector consisting of the rate of change of each dimension of the model vector.
[0082] Gradient dispersion: A gradient that is too small will make the model training results inaccurate.
[0083] Gradient explosion: The gradient is too large, resulting in a non-number problem (NaN, Not a Number) in the model.
[0084] Semantic knowledge and syntactic knowledge: the rigorous grammar, expression habits, and words in different contexts of each language correspond to the translation results of the target language.
[0085] In traditional manual translation methods, the translation of specific words will take into account the context and language environment. This translation method is called free translation. In the prior art, the machine translation system refers to the free translation method and translates the current word according to the context information.
[0086] For example, a graph convolutional neural network is used to encode the abstract meaning expression (AMR, Abstract Meaning Representation) semantic graph obtained by preprocessing the source language corpus as a reference to infer the translation result of the current word. By combining the attention mechanism, Transformer can consider the partial or overall word information in the word and combine it for text translation. Compared with the text translation method that only targets the current word one by one, the accuracy of text translation is improved to a certain extent.
[0087] However, due to the differences in grammar of various languages and various special complex sentences, there will be a large number of out-of-set examples. When faced with these out-of-set examples, the existing technology needs to consider partial or whole word information to train the translation model, and the resulting model is not accurate enough. In addition, since the translation model has too many model parameters, it is easy to produce overfitting problems, and the quality requirements for the training sample set are high. The translation effect of out-of-set examples and out-of-set words is not good.
[0088] In view of the technical problems arising from the above-mentioned prior art, in the present application, a translation model training method and a text translation method are provided. The present application also relates to a translation model training device, a text translation device, a computing device, and a computer-readable storage medium, which are described in detail one by one in the following embodiments.
[0089] Figure 1 A structural schematic diagram of a translation system provided by an embodiment of the present application is shown. The execution subject of the training method of the translation model provided by the embodiment of the present application can be a training terminal, and the training terminal can specifically be a training server or a terminal with a model training function. The execution subject of the text translation method provided by the embodiment of the present application is a translation terminal. The above-mentioned terminal can be any electronic product that can perform human-computer interaction with a user, such as a PC (Personal Computer), a mobile phone, a Pocket PC, a tablet computer, etc. The above-mentioned training server can be a server, or a server cluster composed of multiple servers, or a cloud computing service center, which is not limited by the embodiment of the present application.
[0090] The above training end mainly provides the training function of the translation model. The specific process of the translation model training method will be described in Figure 2-7The above-mentioned translation terminal mainly provides a text translation function, and the specific process of the text translation method will be described in detail in the embodiment shown in FIG. Figure 8 This is described in detail in the illustrated embodiment.
[0091] In an embodiment of the present application, when training a translation model, the pronunciation information and word structure information of each word in the source language corpus in the training sample are extracted, and then the source language corpus after word segmentation, the pronunciation information and word structure information of each word are input into the word embedding layer of the translation model to be trained to obtain a word feature vector, a pronunciation information feature vector, a word structure information feature vector and a position information feature vector, and the information input into the word embedding layer of the translation model is added. Then, according to the word feature vector, the pronunciation information feature vector, the word structure information feature vector and the position information feature vector, a word embedding vector is determined. The translation result of the source language corpus obtained by the translation model according to the word embedding vector is more accurate, and then the model parameters of the translation model are adjusted according to the translation result. It can be seen that the training of the translation model takes more into account the pronunciation information features and word structure information features of the word, so that the trained translation model has higher accuracy.
[0092] Figure 2 A flowchart of a translation model training method provided according to an embodiment of the present application is shown, which specifically includes the following steps:
[0093] Step 202: Obtain training samples, wherein the training samples include source language corpus and target language corpus corresponding to the source language corpus.
[0094] The training samples include sample corpora for training the translation model, which mainly include source language corpora and target language corpora. The source language corpora and target language corpora are corpora of different languages, which are translations of each other. In order to ensure the accuracy of the training samples, generally after obtaining language corpora of different languages, they need to be aligned. Alignment is to align the words, phrases, and sentences of translations of each other in language corpora of different languages, so that words, phrases, and sentences with the same meaning are located in corresponding positions. For example, the Chinese corpus "Today's weather is really good" and the English corpus "The weather is very goodtoday", after alignment, the English corpus is "Today, the weather is very good". Of course, the language corpora obtained can also be words and phrases. As long as the language corpora of different languages are bound as a pair, the accuracy of the training samples can be guaranteed.
[0095] The training samples can be manually input by humans. Humans can manually input language corpora in different languages that are translations of each other. The training samples can also be obtained from a pre-established database. The pre-established database can be constructed based on historical language corpora or can be an open-source parallel corpus provided by major platforms. Among them, the open-source parallel corpus is a storage of language corpora in different languages that are translations of each other and is open to developers. Currently, the mainstream open-source parallel corpora include the United Nations Parallel Corpus, the Peking University Chinese-English Corpus, the TED Corpus, etc.
[0096] In the embodiments of the present application, the words in the source language corpus include pronunciation information and word structure information.
[0097] The pronunciation information of each word in the source language corpus is a clear pronunciation corresponding to each word. For example, the pronunciation information can be directly obtained through the glyph structure of each character in Korean, or each character in Chinese corresponds to at least one pronunciation information. In Chinese, the pronunciation information can specifically refer to the pinyin of each character. In the embodiments of the present application, the pronunciation information of each word in the source language corpus is described by the pinyin of Chinese.
[0098] The word structure information of each word in the source language corpus is determined according to the glyph composition elements of each character. For example, in Chinese, a character is generally composed of specific glyph composition elements, that is, composed of radicals, and there will be specific radicals in the radicals. The radicals generally represent the semantic information of the Chinese character. For example, for the Chinese character "体", the radicals are "亻" and "本", and the radical is "亻", indicating the semantics related to people, and the radical "本" means root and foundation.
[0099] Taking Chinese as an example, each Chinese character corresponds to clear pronunciation (which can be represented by pinyin) information, and each Chinese character has a certain structure, and its word structure information can be correspondingly obtained. Japanese, Korean, Arabic, etc. all have the above characteristics and are not limited here.
[0100] In the embodiments of the present application, the target language corpus corresponding to the source language corpus does not require to contain pronunciation information and word structure information. For the convenience of description, the target language corpus in the embodiments of the present application is described by taking an English corpus as an example.
[0101] By obtaining the training samples, it can be input into the translation model for training after subsequent analysis and processing, providing a sample basis for the training of the translation model.
[0102] Step 204: Perform word segmentation on the source language corpus, and extract the pronunciation information and word structure information of each word in the source language corpus.
[0103] After obtaining the training samples, the source language corpus in the training samples can be segmented. Word segmentation refers to dividing the source language corpus into words one by one. Each word contains pronunciation information and word structure information. After word segmentation, the pronunciation information and word structure information of each word in the source language corpus can be extracted.
[0104] There are many methods for word segmentation at present, and the most commonly used ones are automatic word segmentation methods that rely on computer systems. Automatic word segmentation means that the computer system automatically adds spaces or other boundary marks between words according to the information of the words. Automatic word segmentation can use preset word segmentation tools. Commonly used word segmentation tools include Jieba, HanLP, SnowNLP, THULAC, FoolNLTK, etc. In addition, the automatic word segmentation method can also include: word segmentation methods based on dictionary databases [Forward Maximum Matching Method (FMM, Forward Maximum Matching method,), Backward Maximum Matching Method (BMM, Backward Maximum Matching method,)], word segmentation methods based on characters (giving each character a word position, i.e., marking the sequence position), word segmentation methods based on statistics (N-gram), etc. Of course, word segmentation can also be performed manually, or word segmentation can be performed in a fixed interval manner, which is not limited here.
[0105] Because the concept of "word" in natural language is not clearly defined, the first step in word segmentation is to standardize the word segmentation. The existence of ambiguous fields makes it difficult to segment the corpus. For example, there are a large number of ambiguous fields in Chinese, which generally have intersectional segmentation ambiguities and combinational segmentation ambiguities. For example, "college student" can be segmented into "university" and "student"; "I / work in the student union" and "I / work in the student union". It is necessary to combine semantic knowledge, syntactic knowledge and other information for segmentation.
[0106] In the embodiment of the present application, the FMM method in the word segmentation method based on the dictionary database is used as an example for explanation. Initialize the corpus to be segmented S1 "I love to eat apples", the segmented corpus S2, and the maximum word length Maxlen to 2; starting from the beginning of S1, take out the candidate string W "I love", the length of W is 2 and not greater than Maxlen; traverse the dictionary database to see if W is in the dictionary database; W "I love" is not in the dictionary database, remove the last word "love" of W, judge that W "I" is a single word, add W "I" to the segmented corpus S2 and mark the " / " character behind it as a word separator, and delete W in S1, at this time S1 is "love to eat apples", S2 is "I / "; repeat the above steps until S1 is empty, at this time the segmented corpus S2 "I / love / eat / apples" is obtained, and S2 is output.
[0107] The Chinese dictionary database stores words in order according to the pinyin and radicals mentioned above. Therefore, the pronunciation information (pinyin) and word structure information (radicals) of each word in the segmented corpus can be obtained by querying the dictionary database.
[0108] Optional, such as Figure 3 As shown, Figure 3 A flowchart of a method for extracting pronunciation information of each word in a source language corpus in a translation model training method provided in an embodiment of the present application is shown, which specifically includes the following steps:
[0109] Step 302: Perform word segmentation processing on the source language corpus.
[0110] Step 304: searching for pronunciation information of each word in the source language corpus after word segmentation using a pre-established dictionary database, wherein the correspondence between the word and the pronunciation information is recorded in the dictionary database.
[0111] In actual applications, the correspondence between words and pronunciation information is recorded in a pre-established dictionary database. After the source language corpus is segmented to obtain each word, the pronunciation information corresponding to each word can be found in the dictionary database. By searching the dictionary database, it is more efficient and more accurate to obtain pronunciation information, thereby improving the efficiency and accuracy of translation model training.
[0112] Optional, such as Figure 4 As shown, Figure 4 A flowchart of a method for extracting word structure information of each word in a source language corpus in a translation model training method provided in an embodiment of the present application is shown, which specifically includes the following steps:
[0113] Step 402: Perform word segmentation processing on the source language corpus.
[0114] Step 404: For each word in the source language corpus, the characters in the word are split into glyph component elements to obtain the glyph component elements of each character.
[0115] Step 406: Determine the word structure information of the phrase based on the glyph components of each character.
[0116] In practical applications, after segmenting the source language corpus into words, the characters in the words can be split into their component elements of the glyph. Specifically, the splitting method can adopt a neural network approach. The preset neural network is trained in advance based on character samples (the character samples are marked with the component elements of their radical and stroke). During the training process, when inputting a character sample, the glyph splitting result of the character sample can be obtained. The glyph splitting result is compared with the marked component elements of the glyph to obtain a loss value. Then, based on the loss value, the network parameters are adjusted until the loss value is lower than the preset threshold or the number of iterative training reaches the preset number, that is, the training is completed to obtain a glyph splitting model. By inputting each word into this glyph splitting model, the component elements of each character in the word can be obtained. Of course, the splitting method of the component elements of the glyph can also adopt a matching method, identify the glyph, and then match it with the elements in the preset glyph component element library to identify the component elements of each character's glyph.
[0117] The pronunciation information corresponding to each word can be found from the dictionary database. By searching the dictionary database, it is more efficient and accurate to obtain pronunciation information, which can improve the efficiency and accuracy of the translation model training.
[0118] After splitting the component elements of each character in the word, the word structure information of the word can be determined according to the component elements of each character. Specifically, the word structure information of the word is the set of the component elements of each character in the word. For example, in the word "apple", the component elements of the character "苹" are split into "艹", and the component elements of the character "果" are split into "木", then the word structure information of the word "apple" is "艹木".
[0119] By splitting the characters in the words of the source language corpus into their component elements of the glyph, the component elements of each character are obtained, and then according to the component elements of each character, the word structure information of the word is determined. The word structure information is more accurate, which can improve the accuracy of the translation model training.
[0120] By performing word segmentation on the source language corpus and further extracting the pronunciation information and word structure information of each word in the source language corpus, the characteristics of the words in the source language corpus can be more comprehensively reflected, increasing the information input into the word embedding layer of the translation model. The training of the translation model takes more into account the pronunciation information characteristics and word structure information characteristics of the words, making the trained translation model more accurate.
[0121] Step 206: Input the segmented source language corpus, the pronunciation information and word structure information of each word into the word embedding layer of the translation model to be trained, and obtain a word feature vector, a pronunciation information feature vector, a word structure information feature vector, and a position information feature vector.
[0122] The source language corpus after word segmentation, the pronunciation information and word structure information of each word are input into the word embedding layer of the translation model to be trained. According to the word feature information and position information in the source language corpus, the pronunciation information and word structure information of each word are combined to obtain the word feature vector, the pronunciation information feature vector, the word structure information feature vector and the position information feature vector.
[0123] The translation model refers to a neural network model with text translation function. The Transformer model is used as an example in this specification. Figure 5 As shown, Figure 5 A structural diagram of a Transformer model in a translation model training method provided in an embodiment of the present application is shown.
[0124] The Transformer model is a pre-trained translation model, including a word embedding layer, an encoder and a decoder. The word embedding layer includes word representation (Token) embedding, pronunciation information embedding, word structure information embedding and position information (Pos) embedding. The input is the source language corpus / target language corpus. The output of the encoder is the vector corresponding to the source language corpus. The encoder includes multiple encoding layers, each of which includes an Attention layer and a feedforward network layer. The input of the decoder includes the word embedding vector output by the word embedding layer and the vector corresponding to the source language corpus. The output of the decoder is the translation result of the source language corpus. The decoder includes multiple decoding layers, each of which includes an Attention layer, an encoding-decoding attention layer and a feedforward network layer. The Attention layer is used to calculate the degree of relevance. For example, in the translation process, different Chinese and English have different degrees of dependence. The Attention layer can usually be described as follows: the query vector (query(Q)) and the key value vector (key(K)) are mapped to the output. The output is the weighted value of all values in V, where the weight is calculated by the query vector of each word and each key value vector. The calculation method is divided into three steps: calculating and comparing the similarity between Q and K; performing Softmax operation on the obtained similarity and normalizing it; and performing weighted sum calculation on all values in V according to the calculated weight to obtain the Attention vector.
[0125] Specifically, the word embedding layer can convert words into vectors of specified dimensions, where each dimension corresponds to a feature of the word.
[0126] The word embedding layer tokenizes the input source language corpus and converts the sequence of Tokens corresponding to each word, that is, the words after source language tokenization, into vectors of a specified dimension. Among them, each dimension corresponds to a feature of the word. For example, the number of characters of the word can be represented under the Token dimension, the position information of the word in the sequence (beginning B, middle M, end E) can be represented under the position dimension, the pronunciation information of the word can be represented under the pronunciation dimension, and the structure information of the word can be represented under the word structure dimension.
[0127] For example, since the current mainstream Chinese input method is the pinyin input method, there are often incorrect inputs with the same pronunciation but different meanings when inputting text. As a result, out-of-vocabulary words are generated, making the difference between the translation result and the original meaning larger. For example, for "申请 (shēn ) 深情 (shēn qíng)", the pinyin input is both shen qing, but the meanings are completely different. Therefore, the words after input tokenization can be converted into pinyin, and in the encoding process of the subsequent model, the Attention mechanism can be used to correct and obtain the target language corpus in combination with the context.
[0128] Chinese is a special pictographic language, so there are many Chinese characters whose meanings can be indicated by structural information. As shown in the example in step 204 above, in another example, the glyph components of "苹果" are composed of "艹", "平", "田", "木", where the radicals "艹" and "木" both represent plants, and plants are a type of noun. Nouns generally appear in the subject and object positions in a sentence. Therefore, in the encoding process of the subsequent model, the Attention mechanism can be used to supplement the position information as the subject position (beginning B) and the object position (end E) in combination with the context to obtain the target language corpus.
[0129] In the embodiments of the present application, as Figure 6 shown, Figure 6 FIG. shows the structure diagram of the embedding layer of the Transformer model in a training method of a translation model provided by an embodiment of the present application. The word embedding layer has a 4-layer structure, namely, the word feature embedding layer (Token embedding layer), the pronunciation information feature embedding layer, the word structure information embedding layer, and the position information embedding layer. A source language corpus in the source language corpus is "我 / 爱 / 吃 / 苹果". Among them, the pronunciation information of "苹果" is The word structure information is "艹, 平, 田, 木", the word feature information (the number of information of each token word after tokenization) is 2, and the position information is the end E, obtaining the word feature vector E token is XXXXXX2, the pronunciation information feature vector E p1 is {364, 78}, and the word structure information (艹, 平, 田, 木) feature vector E p1is {15,78,33,17}, the position information (ending E) feature vector E p1 is {0011}. token is the word feature vector, E p1 is the pronunciation information feature, E p2 is the word structure information feature vector, E pos is the position information feature vector.
[0130] The various information of the source language corpus is converted into feature vectors through the word embedding layer, and the natural language information is converted into numerical values that can be recognized by the translation model, providing a data basis for the subsequent training of the translation model.
[0131] Step 208: Determine a word embedding vector of the source language corpus based on the word feature vector, the pronunciation information feature vector, the word structure information feature vector, and the position information feature vector.
[0132] The word embedding vector is determined by the word embedding layer according to a pre-established determination method based on the word feature vector, the pronunciation information feature vector, the word structure information feature vector and the position information feature vector.
[0133] Specifically, the word feature vector E can be token , pronunciation information feature vector E p1 , word structure information feature vector E p2 and the position information feature vector E pos Assign a certain weight A n , according to the word feature vector, pronunciation information feature vector, word structure information feature vector and position information feature vector after being assigned certain weights, the word embedding vector E of the source language corpus is determined.
[0134] The word embedding vector output by the word embedding layer is expressed by formula (1):
[0135]
[0136] Among them, G() represents the weight A n The coupling matrix, E token is the word feature vector, E p1 is the pronunciation information feature vector, E p2 is the word structure information feature vector, E pos is the position information feature vector.
[0137] Because the order of magnitude of each vector varies greatly, for example, the word feature vector can be on the order of 10^8, and the pronunciation information feature vector is generally on the order of 10^3. If a certain weight is not assigned, the proportion of the pronunciation information feature vector and the word structure information feature vector in the determined word embedding vector will be too low, and the pronunciation information and word structure information of the word cannot be expressed well. Subsequently, the encoder and decoder are input to obtain the translation result, among which the pronunciation information and word structure information of the word have little influence on the translation result, and the training effect of adjusting the parameters of the translation model according to the translation result is not good.
[0138] In one implementation of an embodiment of the present application, a method for determining a word embedding vector of a source language corpus may specifically be: adding a word feature vector, a pronunciation information feature vector, a word structure information feature vector, and a position information feature vector to obtain a word embedding vector of the source language corpus.
[0139] During the model training process, the word embedding vector output by the word embedding layer = word feature vector (the number of words in each token after word segmentation) + pronunciation information feature vector + word structure information feature vector + position information feature vector. The word embedding vector output by the word embedding layer is expressed by formula (2):
[0140] E=E token +E p1 +E p2 +E pos Formula (2)
[0141] E is the word embedding vector output by the word embedding layer for each word, E token is the word feature vector, E p1 is the pronunciation information feature, E p 2 is the word structure information feature vector, E pos is the position information feature vector. The word embedding vector output by the word embedding layer is input into the encoder for subsequent processing.
[0142] For example, the word “apple” is input into the word embedding layer, and its word feature vector E token It is XXXXXXXXX2, pronunciation information The feature vector is {364, 78}, the feature vector of the word structure information (艹, 平, 田, 木) is {15, 78, 33, 17}, and the feature vector of the position information (ending E) is {0011}. Therefore, the word embedding vector output by the word embedding layer of the word "苹果" is {XXXXXXXXX2, 364, 78, 15, 78, 33, 17, 0011}. Even if the word "苹果" is an out-of-vocabulary word, its pronunciation information and word structure information can still be given. In the subsequent input encoding layer and decoding layer, its position information can be corrected according to its pronunciation information and word structure information, and it can be obtained that it is a noun and placed in the subject or object position, improving the quality of the translation result. Thus, the performance of the translation model can be continuously improved during the subsequent translation model training process.
[0143] The word embedding vector containing the word feature vector, pronunciation information feature vector, word structure information feature vector, and position information feature vector as the input to the encoder and decoder can make the training process of the translation model more effective, enabling the trained translation model to provide high-quality translation results for out-of-vocabulary words.
[0144] Step 210: Obtain the translation result of the source language corpus according to the word embedding vector through the encoder and decoder of the translation model.
[0145] The translation model has an encoder and a decoder. The encoder contains multiple encoding layers, and each encoding layer is provided with an Attention mechanism layer.
[0146] Specifically, input the word embedding vector into the encoding layer of the encoder and the decoder of the translation model. After encoding and decoding the word embedding vector, obtain the translation result of the source language corpus, where the translation result of the source language corpus is the translation corresponding to the source language corpus.
[0147] Continuing with the above example, the word embedding vector of the word "我" is E 我 and the word embedding vector of the word "爱" is E 爱 and the word embedding vector of the word "吃" is E 吃 and the word embedding vector of the word "苹果" is E 苹果 . According to the above word embedding vectors, through the encoder and decoder of the translation model, the translation result of the source language corpus is obtained as "I / enjoy / eating / apples.".
[0148] According to the word embedding vector, through the encoder and decoder of the translation model, the translation result of the source language corpus is obtained. The translation result provides a basis for obtaining the subsequent loss value. Since the translation result is obtained according to the word embedding vector, it has a numerical basis and is interpretable. When adjusting the parameters of the subsequent translation model, the parameters of the word embedding layer that need to be modified are obtained according to the word embedding vector. Thus, the training of the translation model is made more accurate.
[0149] Step 212: Calculate the loss value of the translation model based on the translation result and the target language corpus. If the loss value is greater than a preset threshold, adjust the model parameters of the translation model based on the loss value.
[0150] According to the translation result and the target language corpus, the total loss value can be calculated. When the loss value is greater than a preset threshold, the model parameters of the translation model are adjusted according to the loss value. Specifically, the loss value can be the loss of each word in the translation result and the target language corpus, and then added together to obtain the total loss value. The loss value can be calculated using a traditional loss function, such as a cross entropy loss function.
[0151] The specific method of adjusting the model parameters of the translation model can be adjusted using the traditional gradient descent method, which will not be described in detail here.
[0152] In an implementation of the embodiment of the present application, after step 212, the training method further includes:
[0153] When the loss value is less than or equal to a preset threshold, the training is stopped to determine that the training of the translation model is completed. Alternatively, when the number of iterations is greater than a preset number, the training is stopped to determine that the training of the translation model is completed.
[0154] When the loss value is greater than the preset threshold, the model parameters will be adjusted. Therefore, the reasonable establishment of the preset threshold ensures the training efficiency of the translation model, and the adjustment of the model parameters can also improve the performance of the translation model. The specific condition for stopping training can be that the loss value is less than or equal to the preset threshold or the number of iterations is greater than the preset number.
[0155] By applying the embodiment of the present application, the pronunciation information and word structure information of each word in the source language corpus in the training sample are extracted, and then the source language corpus after word segmentation processing, the pronunciation information and word structure information of each word are input into the word embedding layer of the translation model to be trained to obtain a word feature vector, a pronunciation information feature vector, a word structure information feature vector and a position information feature vector, and the information input into the word embedding layer of the translation model is added. Then, according to the word feature vector, the pronunciation information feature vector, the word structure information feature vector and the position information feature vector, the word embedding vector is determined. The translation result of the source language corpus obtained by the translation model according to the word embedding vector is more accurate, and then the model parameters of the translation model are adjusted according to the translation result. It can be seen that the training of the translation model takes more into account the pronunciation information features and word structure information features of the word, so that the trained translation model has higher accuracy.
[0156] based on Figure 2 The embodiment shown, Figure 7A flowchart of another translation model training method provided in an embodiment of the present application is shown, which specifically includes the image step:
[0157] Step 702: Obtain training samples, wherein the training samples include source language corpus and target language corpus corresponding to the source language corpus.
[0158] Step 704: Perform data cleaning on the training samples to obtain preprocessed training samples.
[0159] Because the training samples in the parallel corpus have incomplete data, it is necessary to perform data cleaning on the training samples. Data cleaning is to delete the samples with incomplete data in the training samples to obtain the preprocessed training samples. Specifically, the perfect data in the training samples that can be used in subsequent processing and will not affect the training effect of the translation model is retained, and the incomplete data that cannot be used in subsequent processing and will affect the training effect of the translation model is deleted.
[0160] Common problems with incomplete training sample data include: word inconsistency, garbled characters, mixing of source and target languages, inconsistent half-width, differences in writing formats, etc. Training samples that have undergone data cleaning can make subsequent translation results more accurate and have a more obvious training effect on the translation model.
[0161] Of course, in addition to the above-mentioned deletion, data cleaning can also adopt methods such as data order adjustment and replacement with perfect data. For different types of imperfect data problems, corresponding data cleaning methods can be used. For example, deletion can be used to solve problems such as inconsistent half-width and writing format differences, and data order adjustment can be used to solve problems such as non-parallel words. In addition, for imperfect data in training samples, methods based on deep learning networks and feature matching can be used to identify them. After identification, the corresponding method can be selected for data cleaning.
[0162] Step 706: Perform word segmentation processing on the source language corpus to extract pronunciation information and word structure information of each word in the source language corpus.
[0163] Step 708: Input the source language corpus after word segmentation processing, the pronunciation information and word structure information of each word into the word embedding layer of the translation model to be trained to obtain a word feature vector, a pronunciation information feature vector, a word structure information feature vector and a position information feature vector.
[0164] Step 710: Determine a word embedding vector of the source language corpus based on the word feature vector, the pronunciation information feature vector, the word structure information feature vector, and the position information feature vector.
[0165] Step 712: According to the word embedding vector, the translation result of the source language corpus is obtained through the encoder and decoder of the translation model.
[0166] Step 714: Calculate the loss value of the translation model based on the translation result and the target language corpus. If the loss value is greater than a preset threshold, adjust the model parameters of the translation model based on the loss value.
[0167] The above steps 702, 706, 708, 710, 712 and 714 are Figure 2 The steps of the illustrated embodiment are the same and will not be repeated here.
[0168] By applying the embodiment of the present application, the pronunciation information and word structure information of each word in the source language corpus in the training sample are extracted, and then the source language corpus after word segmentation, the pronunciation information and word structure information of each word are input into the word embedding layer of the translation model to be trained, and the word feature vector, the pronunciation information feature vector, the word structure information feature vector and the position information feature vector are obtained, and the information input into the word embedding layer of the translation model is added, and then the word embedding vector is determined according to the word feature vector, the pronunciation information feature vector, the word structure information feature vector and the position information feature vector, and the translation result of the source language corpus obtained by the translation model according to the word embedding vector is more accurate, and then the model parameters of the translation model are adjusted according to the translation result. It can be seen that the training of the translation model takes more into account the pronunciation information characteristics and word structure information characteristics of the word, so that the translation model after training is more accurate. In addition, the training sample can make the subsequent translation results more accurate after data cleaning, and the training effect of the translation model is more obvious.
[0169] The present application also provides a text translation method, such as Figure 8 As shown, Figure 8 A flowchart of a text translation method provided by an embodiment of the present application is shown, which specifically includes the following steps:
[0170] Step 802: Obtain the text to be translated.
[0171] The text to be translated is the source language text that is input by the receiving client and subsequently translated into the translation model.
[0172] Step 804: Perform word segmentation on the text to be translated, and extract pronunciation information and word structure information of each word in the text to be translated.
[0173] The translation model is based on Figure 2 The method of step 204 in the embodiment performs word segmentation processing and extracts pronunciation information and word structure information of each word in the translation text.
[0174] Step 806: Input the text to be translated after word segmentation processing, the pronunciation information of each word and the word structure information into the pre-trained translation model to obtain the target language translation text corresponding to the text to be translated.
[0175] Among them, the translation model uses Figure 2 The translation model is obtained by training using the translation model training method in the embodiment.
[0176] By using the embodiment of the present application, the text to be translated after word segmentation processing, the pronunciation information and word structure information of each word are input into a pre-trained translation model, and after embedding processing of the word embedding layer of the translation model, the word feature vector, pronunciation information feature vector, word structure information feature vector and position information feature vector of the text to be translated are obtained. According to the word feature vector, pronunciation information feature vector, word structure information feature vector and position information feature vector, the word embedding vector of the text to be translated is determined, and according to the word embedding vector, the target language translation text corresponding to the text to be translated is obtained through the encoder and decoder of the translation model. Since the translation model is trained by the above training method, the trained translation model has high accuracy, so the target language translation text corresponding to the text to be translated is more accurate.
[0177] Corresponding to the above-mentioned translation model training method embodiment, the present application also provides a translation model training device embodiment, Fig. 9 A schematic diagram of the structure of a translation model training device provided in an embodiment of the present application is shown, and the device includes:
[0178] The first acquisition module 902 is configured to acquire a training sample, wherein the training sample includes a source language corpus and a target language corpus corresponding to the source language corpus.
[0179] The first word segmentation module 904 is configured to perform word segmentation processing on the source language corpus and extract pronunciation information and word structure information of each word in the source language corpus.
[0180] The word embedding module 906 is configured to input the source language corpus after word segmentation processing, the pronunciation information and word structure information of each word into the word embedding layer of the translation model to be trained, and obtain a word feature vector, a pronunciation information feature vector, a word structure information feature vector and a position information feature vector; according to the word feature vector, the pronunciation information feature vector, the word structure information feature vector and the position information feature vector, determine the word embedding vector of the source language corpus.
[0181] The encoding and decoding module 908 is configured to obtain the translation result of the source language corpus according to the word embedding vector through the encoder and decoder of the translation model.
[0182] The training module 910 is configured to calculate the loss value of the translation model according to the translation result and the target language corpus, and adjust the model parameters of the translation model according to the loss value when the loss value is greater than a preset threshold.
[0183] Optionally, the device further comprises:
[0184] The data cleaning module is configured to perform data cleaning on the training samples to obtain preprocessed training samples.
[0185] Optionally, the first word segmentation module 904 is further configured to search for pronunciation information of each word in the source language corpus after word segmentation using a pre-established dictionary database, wherein the correspondence between words and pronunciation information is recorded in the dictionary database.
[0186] Optionally, the first word segmentation module 904 is further configured to split the characters in each word in the source language corpus into glyph component elements to obtain the glyph component elements of each character, and determine the word structure information of the word based on the glyph component elements of each character.
[0187] Optionally, the word embedding module 906 is further configured to add the word feature vector, the pronunciation information feature vector, the word structure information feature vector and the position information feature vector to obtain the word embedding vector of the source language corpus.
[0188] Optionally, the training module 910 is further configured to stop training and determine that the training of the translation model is completed when the loss value is less than or equal to a preset threshold; or to stop training and determine that the training of the translation model is completed when the number of iterations is greater than a preset number.
[0189] By applying the embodiment of the present application, the pronunciation information and word structure information of each word in the source language corpus in the training sample are extracted, and then the source language corpus after word segmentation processing, the pronunciation information and word structure information of each word are input into the word embedding layer of the translation model to be trained to obtain a word feature vector, a pronunciation information feature vector, a word structure information feature vector and a position information feature vector, and the information input into the word embedding layer of the translation model is added. Then, according to the word feature vector, the pronunciation information feature vector, the word structure information feature vector and the position information feature vector, the word embedding vector is determined. The translation result of the source language corpus obtained by the translation model according to the word embedding vector is more accurate, and then the model parameters of the translation model are adjusted according to the translation result. It can be seen that the training of the translation model takes more into account the pronunciation information features and word structure information features of the word, so that the trained translation model has higher accuracy.
[0190] The above is a schematic scheme of a translation model training device of the present embodiment. It should be noted that the technical scheme of the translation model training device and the technical scheme of the translation model training method mentioned above belong to the same concept. For the details not described in detail in the technical scheme of the translation model training device, please refer to the description of the technical scheme of the translation model training method mentioned above. In addition, each component in the device embodiment should be understood as a functional module that must be established to implement each step of the program flow or each step of the method, and each functional module is not an actual functional division or separation definition. The device claim defined by such a group of functional modules should be understood as a functional module architecture that mainly implements the solution through the computer program recorded in the specification, and should not be understood as a physical device that mainly implements the solution through hardware.
[0191] Corresponding to the above text translation method embodiment, the present application also provides a text translation device embodiment, Fig.10 A schematic diagram of the structure of a text translation device provided in an embodiment of the present application is shown, and the device includes:
[0192] The second acquisition module 1002 is configured to acquire the text to be translated.
[0193] The second word segmentation module 1004 is configured to perform word segmentation processing on the text to be translated, and extract pronunciation information and word structure information of each word in the text to be translated.
[0194] The translation module 1006 is configured to input the text to be translated after word segmentation processing, the pronunciation information and word structure information of each word into a pre-trained translation model to obtain a target language translation text corresponding to the text to be translated, wherein the translation model is trained using a translation model training method.
[0195] By using the embodiment of the present application, the text to be translated after word segmentation processing, the pronunciation information and word structure information of each word are input into a pre-trained translation model, and after embedding processing of the word embedding layer of the translation model, the word feature vector, pronunciation information feature vector, word structure information feature vector and position information feature vector of the text to be translated are obtained. According to the word feature vector, pronunciation information feature vector, word structure information feature vector and position information feature vector, the word embedding vector of the text to be translated is determined, and according to the word embedding vector, the target language translation text corresponding to the text to be translated is obtained through the encoder and decoder of the translation model. Since the translation model is trained by the above training method, the trained translation model has high accuracy, so the target language translation text corresponding to the text to be translated is more accurate.
[0196] The above is a schematic scheme of a text translation device of the present embodiment. It should be noted that the technical scheme of the text translation device and the technical scheme of the above-mentioned text translation method belong to the same concept. For the details not described in detail in the technical scheme of the text translation device, please refer to the description of the technical scheme of the above-mentioned text translation method. In addition, each component in the device embodiment should be understood as a functional module that must be established to implement each step of the program flow or each step of the method, and each functional module is not an actual functional division or separation definition. The device claim defined by such a group of functional modules should be understood as a functional module architecture that mainly implements the solution through the computer program recorded in the specification, and should not be understood as a physical device that mainly implements the solution through hardware.
[0197] Fig.11 The block diagram of a computing device according to an embodiment of the present application is shown. The components of the computing device 1100 include but are not limited to a memory 1110 and a processor 1120. The processor 1120 is connected to the memory 1110 via a bus 1130, and the database 1150 is used to store data.
[0198] The computing device 1100 also includes an access device 1140, which enables the computing device 1100 to communicate via one or more networks 1160. Examples of these networks include a public switched telephone network (PSTN), a local area network (LAN), a wide area network (WAN), a personal area network (PAN), or a combination of communication networks such as the Internet. The access device 1140 may include one or more of any type of network interface (e.g., a network interface card (NIC)) of wired or wireless, such as an IEEE 802.11 wireless local area network (WLAN) wireless interface, a world-wide interoperability for microwave access (Wi-MAX) interface, an Ethernet interface, a universal serial bus (USB) interface, a cellular network interface, a Bluetooth interface, a near field communication (NFC) interface, and the like.
[0199] In one embodiment of the present application, the above components of the computing device 1100 and Fig.11Other components not shown in the figure may also be connected to each other, for example, via a bus. It should be understood that Fig.11 The computing device structure block diagram shown is only for the purpose of illustration, and is not intended to limit the scope of the present application. Those skilled in the art may add or replace other components as needed.
[0200] The computing device 1100 may be any type of stationary or mobile computing device, including a mobile computer or mobile computing device (e.g., a tablet computer, a personal digital assistant, a laptop computer, a notebook computer, a netbook, etc.), a mobile phone (e.g., a smart phone), a wearable computing device (e.g., a smart watch, smart glasses, etc.), or other types of mobile devices, or a stationary computing device such as a desktop computer or PC. The computing device 1100 may also be a mobile or stationary server.
[0201] The processor 1120 is used to execute computer executable instructions of the above-mentioned translation model training method or text translation method.
[0202] The above is a schematic scheme of a computing device of this embodiment. It should be noted that the technical scheme of the computing device and the technical scheme of the above-mentioned translation model training method or text translation method belong to the same concept, and the details not described in detail in the technical scheme of the computing device can be referred to the description of the technical scheme of the above-mentioned translation model training method or text translation method.
[0203] An embodiment of the present application also provides a computer-readable storage medium storing computer instructions, which, when executed by a processor, implement the above-mentioned translation model training method or text translation method.
[0204] The above is a schematic scheme of a computer-readable storage medium of this embodiment. It should be noted that the technical scheme of the storage medium and the technical scheme of the training method of the translation model or the text translation method mentioned above belong to the same concept, and the details not described in detail in the technical scheme of the storage medium can be referred to the description of the technical scheme of the training method of the translation model or the text translation method mentioned above.
[0205] An embodiment of the present application further provides a chip storing a computer program, which implements the above-mentioned translation model training method or text translation method when executed by the chip.
[0206] The above describes specific embodiments of the present application. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the accompanying drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0207] Computer instructions include computer program codes, which may be in source code form, object code form, executable files, or some intermediate form, etc. Computer readable media may include: any entity or device capable of carrying computer program codes, recording media, USB flash drives, mobile hard disks, magnetic disks, optical disks, computer memories, read-only memories (ROM), random access memories (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc.
[0208] It should be noted that, for the above-mentioned method embodiments, for the sake of simplicity of description, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described action sequence, because according to the present application, certain steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present application.
[0209] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0210] The preferred embodiments of the present application disclosed above are only used to help explain the present application. The optional embodiments do not describe all the details in detail, nor do they limit the invention to specific implementation methods. Obviously, many modifications and changes can be made according to the content of the present application. The present application selects and specifically describes these embodiments in order to better explain the principles and practical applications of the present application, so that those skilled in the art can understand and use the present application well. The present application is only limited by the claims and their full scope and equivalents.
Claims
1. A method for training a translation model, characterized in that: include: Acquire a training sample, wherein the training sample includes a source language corpus and a target language corpus corresponding to the source language corpus; Performing word segmentation processing on the source language corpus to extract pronunciation information and word structure information of each word in the source language corpus; Inputting the source language corpus after word segmentation processing, the pronunciation information and word structure information of each word into the word embedding layer of the translation model to be trained to obtain a word feature vector, a pronunciation information feature vector, a word structure information feature vector and a position information feature vector; Determine a word embedding vector of the source language corpus according to the word feature vector, the pronunciation information feature vector, the word structure information feature vector and the position information feature vector; According to the word embedding vector, a translation result of the source language corpus is obtained through an encoder and a decoder of the translation model; A loss value of the translation model is calculated according to the translation result and the target language corpus, and when the loss value is greater than a preset threshold, a model parameter of the translation model is adjusted according to the loss value.
2. The method for training a translation model according to claim 1, characterized in that: After the step of obtaining training samples, the method further includes: Data cleaning is performed on the training samples to obtain preprocessed training samples.
3. The method for training a translation model according to claim 1, characterized in that: The step of extracting pronunciation information of each word in the source language corpus includes: According to each word in the source language corpus after word segmentation processing, the pronunciation information of each word is searched using a pre-established dictionary database, wherein the correspondence between words and pronunciation information is recorded in the dictionary database.
4. The method for training a translation model according to claim 1, characterized in that: The step of extracting word structure information of each word in the source language corpus includes: For each word in the source language corpus, the characters in the word are split into glyph components to obtain the glyph components of each character, and the word structure information of the word is determined based on the glyph components of each character.
5. The method for training a translation model according to any one of claims 1 to 4, characterized in that: The step of determining the word embedding vector of the source language corpus according to the word feature vector, the pronunciation information feature vector, the word structure information feature vector and the position information feature vector comprises: The word feature vector, the pronunciation information feature vector, the word structure information feature vector and the position information feature vector are added together to obtain a word embedding vector of the source language corpus.
6. The method for training a translation model according to any one of claims 1 to 4, characterized in that: After the step of calculating the loss value of the translation model according to the translation result and the target language corpus, the method further includes: When the loss value is less than or equal to the preset threshold, stopping the training and determining that the training of the translation model is completed; or, When the number of iterations is greater than a preset number, the training is stopped to determine that the training of the translation model is completed.
7. A text translation method, characterized in that: include: Get the text to be translated; Performing word segmentation processing on the text to be translated, and extracting pronunciation information and word structure information of each word in the text to be translated; The text to be translated after word segmentation processing, the pronunciation information and word structure information of each word are input into a pre-trained translation model to obtain a target language translation text corresponding to the text to be translated, wherein the translation model is trained using the method described in any one of claims 1 to 6.
8. A translation model training device, characterized in that: include: A first acquisition module is configured to acquire a training sample, wherein the training sample includes a source language corpus and a target language corpus corresponding to the source language corpus; A first word segmentation module is configured to perform word segmentation processing on the source language corpus and extract pronunciation information and word structure information of each word in the source language corpus; A word embedding module is configured to input the source language corpus after word segmentation processing, the pronunciation information and word structure information of each word into the word embedding layer of the translation model to be trained, to obtain a word feature vector, a pronunciation information feature vector, a word structure information feature vector and a position information feature vector; and determine the word embedding vector of the source language corpus according to the word feature vector, the pronunciation information feature vector, the word structure information feature vector and the position information feature vector; An encoding and decoding module is configured to obtain a translation result of the source language corpus according to the word embedding vector through an encoder and a decoder of the translation model; The training module is configured to calculate the loss value of the translation model according to the translation result and the target language corpus, and when the loss value is greater than a preset threshold, adjust the model parameters of the translation model according to the loss value.
9. A text translation device, characterized in that: include: A second acquisition module is configured to acquire a text to be translated; A second word segmentation module is configured to perform word segmentation processing on the text to be translated, and extract pronunciation information and word structure information of each word in the text to be translated; The translation module is configured to input the text to be translated after word segmentation processing, the pronunciation information and word structure information of each word into a pre-trained translation model to obtain a target language translation text corresponding to the text to be translated, wherein the translation model is trained using the method described in any one of claims 1 to 6.
10. A computing device, characterized in that: include: Memory and processor; The memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions to implement the method of any one of claims 1 to 6 or the method of claim 7.
11. A computer-readable storage medium storing computer instructions, characterized in that: When the instruction is executed by a processor, the method described in any one of claims 1 to 6 or the method described in claim 7 is implemented.
Citation Information
Cited By
High-precision geographical name translation method integrating artificial intelligence and multi-language syllable segmentation
CN120012790A
High-precision Place Name Translation Method Integrating Artificial Intelligence and Multilingual Syllable Segmentation
CN120012790B
