Machine translation method and computing device

Through the target index model, word vectors in parallel corpus are divided into clusters, and clustering is used to quickly query matching, which solves the problems of long query matching time and poor translation effect in the existing technology, and realizes efficient machine translation.

CN119204038APending Publication Date: 2024-12-27XFUSION DIGITAL TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411171235.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-23
Publication Date
2024-12-27

AI Technical Summary

Technical Problem

In the existing machine translation technology, the long query matching time leads to low efficiency and the inability to achieve machine translation, resulting in poor translation effect.

Method used

Using the target index model, the word vectors in the parallel corpus are divided into clusters, and the word vectors to be translated match the most similar clusters, reduce the number of word vectors compared, realize fast query matching, and similarity through the preset similarity algorithm. degree query to avoid exact match restrictions.

Benefits of technology

It significantly shortens the query matching time, improves machine translation efficiency, avoids unachievable translation situations, and improves translation effect and accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119204038A_ABST
    Figure CN119204038A_ABST
Patent Text Reader

Abstract

The invention discloses a machine translation method and computing equipment. The method comprises the steps of obtaining a to-be-translated text; converting the to-be-translated text into a corresponding to-be-translated word vector; obtaining a target language word vector corresponding to the to-be-translated text based on the to-be-translated word vector through the target index model; obtaining a target language text corresponding to the to-be-translated text based on the target language word vector corresponding to the to-be-translated text; the target index model is obtained by training word vector pairs corresponding to the parallel corpus and a preset number of word vector indexes. According to the method, the index model divides all word vector pairs into the preset number of clusters, through the multiple clusters, the number of word vectors needing to be compared during query matching is reduced, the time consumed by query matching is shortened, and therefore the efficiency of machine translation is improved; and query matching is carried out through the index model, and not only complete matching is carried out, so that the condition that machine translation cannot be realized is avoided, and the effect of machine translation is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of machine learning, and in particular to a machine translation method and computing device. Background Art

[0002] Machine Translation (MT) refers to the process of using a machine to automatically convert a natural language (hereinafter referred to as the source language) into another language with the same meaning (hereinafter referred to as the target language). With the acceleration of globalization, economic and cultural exchanges between people of different languages ​​are increasing day by day, and people's demand for translation is becoming more and more urgent. Automatic machine translation has played a huge role in promoting communication between people of different languages ​​due to its simplicity and efficiency.

[0003] In current technology, a common machine translation method is to create a structured parallel corpus based on parallel corpus. In order to realize machine translation, the structured parallel corpus needs to be a large parallel corpus, that is, the structured parallel corpus needs to include a large number of parallel corpora. In current technology, it is necessary to traverse all source language sentences in the structured large parallel corpus, resulting in a long time for query matching of source language sentences that are completely similar to the sentences to be translated, and for 100% string matching, each character needs to be compared one by one, which further causes a long time for query matching. Due to the long time consumed by query matching in current technology, the efficiency of machine translation is low, and there is a situation where machine translation cannot be realized, resulting in poor machine translation effect. Summary of the invention

[0004] The embodiments of the present application provide a machine translation method and a computing device, which shorten the time consumed for query matching, improve the efficiency of machine translation, and improve the effect of machine translation to a certain extent.

[0005] In order to achieve the above objectives, the embodiments of the present application adopt the following technical solutions:

[0006] The embodiment of the present application provides a machine translation method, which includes: obtaining a text to be translated; converting the text to be translated into a corresponding word vector to be translated; obtaining a target language word vector corresponding to the text to be translated based on the word vector to be translated through a target index model; obtaining a target language text corresponding to the text to be translated based on the target language word vector corresponding to the text to be translated, and completing the machine translation of the text to be translated. The target index model is obtained by training the word vector pairs corresponding to the parallel corpus and a preset number of word vector indexes, and the word vector index is a cluster center obtained based on the source language in all word vector pairs.

[0007] The target index model in the embodiment of the present application divides all word vector pairs corresponding to the parallel corpus into a preset number of clusters, and then matches the most similar / close cluster based on the word vector to be translated, and matches the source language word vector in the cluster with the most similar source language word vector, so as to obtain the corresponding target language word vector to realize machine translation of the text to be translated. By dividing into multiple clusters, the number of word vectors that need to be compared during query matching of machine translation is reduced, so as to shorten the time consumed by query matching, thereby improving the overall efficiency of machine translation; and query matching through the target index model does not only perform a complete match, but also avoids the situation where machine translation cannot be realized, thereby improving the effect of machine translation.

[0008] In a possible implementation, the method further includes: obtaining a parallel corpus; converting all sentence pairs in the parallel corpus into word vector pairs; clustering the source language word vectors in all word vector pairs to establish a preset number of word vector indexes; using the word vector pairs and the preset number of word vector indexes, training an index model to obtain a target index model. The target index model is able to achieve efficient large-scale word vector retrieval and quickly find the source language word vector that is most similar to the word vector to be translated.

[0009] In one possible implementation, a preset number of word vector indexes are added to the index model as base points; all word vector pairs are added to the index model, and the distance between the source language word vector in the word vector pair and each word vector index is calculated, and the word vector pair is assigned to the word vector index that is closest to the source language word vector in the word vector pair. In the embodiment of the present application, the target index model can organize similar source language word vectors and their corresponding target language word vectors together to form a local area centered on the word vector index, so that when the target index model is subsequently used for querying, these base points will be used to quickly narrow the search range, and then query matching will be performed in the source language word vector under the word vector index, which greatly improves the query efficiency.

[0010] In a possible implementation, the word vector to be translated is input into the target index model; the target index model calculates the distance between the word vector to be translated and each word vector index, and determines the word vector index that is most similar to the word vector to be translated; and through a preset similarity algorithm, calculates the similarity between the word vector to be translated and all source language word vectors under the most similar word vector index, determines the source language word vector that is most similar to the word vector to be translated, and based on the word vector pair corresponding to the most similar source language word vector, obtains and outputs the target language word vector corresponding to the word vector to be translated; receives the target language word vector corresponding to the word vector to be translated output by the target index model, so as to obtain the target language word vector corresponding to the text to be translated. The target index model first compares the word vector index closest to the word vector to be translated, and then compares it with the source language word vector under the closest word vector index to obtain the corresponding target language word vector, which greatly reduces the number of word vectors that need to be compared with the input word vector to be translated in the query matching, thereby achieving a significant improvement in the query matching speed, that is, shortening the time consumed by the query matching, thereby improving the overall efficiency of machine translation. Furthermore, similarity query matching of the word vectors to be translated is achieved through the target index model, not just complete (100% similarity) query matching, which avoids the situation where machine translation cannot be achieved, thereby improving the effect of machine translation.

[0011] In a possible implementation, the target index model determines the source language word vector that is most similar to the word vector to be translated, obtains the similarity between the word vector to be translated and the closest source language word vector, and outputs the similarity, so that the user can determine the accuracy of machine translation of the text to be translated.

[0012] In one possible implementation, the target index model is first loaded into the memory of the computing device. Loading the target index model into the memory of the computing device instead of a hard disk or other storage media can significantly reduce data access time because the read and write speed of the memory is much faster than that of the hard disk. When the target index model is in the memory, data can be read directly from the memory in response to the input, avoiding disk I / O delays and greatly improving the query speed.

[0013] In a possible implementation, a text to be translated is received, the document to be translated is parsed, and the text to be translated in the document to be translated is classified and identified to obtain the text to be translated.

[0014] In a possible implementation, when a picture to be translated is identified by classification, the subject of the picture to be translated is identified; wherein the picture to be translated is a picture in a document to be translated; a text area and / or a table area in the picture to be translated is identified, and the text to be translated in the text area and / or the table to be translated in the table area are constructed; when the text to be translated in the text area of ​​the picture to be translated is identified, the type of the text to be translated is determined based on the character length of the text to be translated; when the type of the text to be translated is a phrase to be translated, the phrase to be translated is converted into a corresponding word vector to be translated; through a target index model, a target language word vector corresponding to the phrase to be translated is obtained based on the word vector to be translated; based on the target language word vector corresponding to the phrase to be translated, a target language phrase corresponding to the phrase to be translated of the picture to be translated is obtained; when the type of the text to be translated is a long sentence to be translated, a word vector to be translated corresponding to the long sentence to be translated is obtained based on the long sentence to be translated and the subject of the picture to be translated; through a target index model, a target language word vector corresponding to the long sentence to be translated is obtained based on the word vector to be translated; based on the target language word vector corresponding to the long sentence to be translated, a target language long sentence corresponding to the long sentence to be translated of the picture to be translated is obtained. The embodiment of the present application realizes targeted machine translation of text in image type data (i.e., images to be translated), solving the problem in the current technology that directly uses a large language model to translate documents to be translated, and the generated translation results have poor relevance to the context, and may even produce hallucinations. And for long texts, the corresponding word vectors to be translated are obtained by combining the long sentence to be translated and the theme of the image to be translated. The target index model can obtain the context information of the text in the image to be translated, so that the target index model can better understand the purpose and context of the long sentence to obtain a translation result with higher accuracy.

[0015] In a possible implementation, the long sentence to be translated is segmented through a window of a second preset size to obtain multiple phrases corresponding to the long sentence to be translated, and a prefix prompt word is constructed according to the theme of the picture to be translated; based on the prefix prompt word and the multiple phrases corresponding to the long sentence to be translated, multiple phrases to be translated corresponding to the long sentence to be translated are obtained; the multiple phrases to be translated are respectively converted into corresponding word vectors to be translated to obtain word vectors to be translated corresponding to the long sentence to be translated. Prefix prompt words are constructed according to the theme of the picture to be translated, and corresponding word vectors to be translated are obtained based on the prefix prompt word and the long sentence to be translated. The target index model obtains the context information of the picture to be translated through the prefix prompt word, so that the target index model can better understand the purpose and context of the long sentence to improve the accuracy of machine translation.

[0016] In a possible implementation, when a table to be translated is identified by classification or a table to be translated in a table area of ​​a picture to be translated is identified, the subject of the table to be translated is identified; based on the character length of the text in each cell of the table to be translated, the type of the cell is determined; wherein the types of cells include: short text cells and long text cells; when the cell is a short text cell, the phrases in the short text cell are converted into corresponding word vectors to be translated; through a target index model, based on the word vectors to be translated, the target language word vectors corresponding to the phrases in the short text cell are obtained; based on the target language word vectors corresponding to the phrases in the short text cell, the target language phrases corresponding to the phrases in the short text cell are obtained; and the corresponding target language phrases are replaced into the short text cell; when the cell is a long text cell, based on the long sentences in the long text cell and the subject of the table to be translated, the word vector to be translated corresponding to the long text cell is obtained; through a target index model, based on the word vectors to be translated, the target language word vectors corresponding to the long sentences in the long text cell are obtained; based on the target language word vectors corresponding to the long sentences in the long text cell, the target language long sentences corresponding to the long sentences in the long text cell are obtained; and the corresponding target language long sentences are replaced into the long text cell. The embodiment of the present application realizes targeted machine translation for table-type data (i.e., the table to be translated), and solves the problem in the current technology that the large language model is directly used to translate the document to be translated, and the generated translation result has poor relevance to the context, and even produces hallucinations. And for long text cells, the corresponding word vector to be translated is obtained by combining the long sentences in the long text cells and the theme of the table to be translated. The target index model can obtain the context information of the table to be translated, so that the target index model can better understand the purpose and context of the long sentences in the long text cells, so as to obtain a translation result with higher accuracy.

[0017] In a possible implementation, a long sentence in a long text cell is segmented through a window of a preset size to obtain multiple phrases corresponding to the long sentence, and a prefix prompt word is constructed according to the subject of the table to be translated; based on the prefix prompt word and the multiple phrases corresponding to the long sentence, multiple phrases to be translated corresponding to the long sentence are obtained; the multiple phrases to be translated are respectively converted into corresponding word vectors to be translated to obtain the word vector to be translated corresponding to the long text cell. Prefix prompt words are constructed according to the subject of the table to be translated, and corresponding word vectors to be translated are obtained based on the prefix prompt word and the long sentence in the long text cell. The target index model obtains the context information of the table to be translated through the prefix prompt word, so that the target index model can better understand the purpose and context of the long sentence in the long text cell to improve the accuracy of machine translation.

[0018] In a second aspect, an embodiment of the present application provides a computing device, including a processor and a memory, wherein the processor is coupled to the memory, and the memory stores computer program instructions. When the processor executes the computer program instructions, the machine translation method in the above-mentioned first aspect and its possible implementation methods is implemented.

[0019] In a third aspect, an embodiment of the present application provides a computer-readable storage medium having computer program instructions stored thereon. When the computer program instructions are executed on a computing device, the computing device implements the machine translation method in the above-mentioned first aspect and its possible implementation methods.

[0020] In a fourth aspect, an embodiment of the present application provides a computer program product, which includes computer program instructions. When the computer program instructions are executed on a computing device, the computing device implements the machine translation method in the above-mentioned first aspect and its possible implementation methods. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] Figure 1 A flowchart of a method for training an index model provided in an embodiment of the present application;

[0022] Figure 2 A schematic diagram of a process for generating word vectors using a BERT model provided in an embodiment of the present application;

[0023] Figure 3 A schematic diagram of a process for constructing and optimizing an ANN index model provided in an embodiment of the present application;

[0024] Figure 4 A flowchart of a machine translation method provided in an embodiment of the present application;

[0025] Figure 5 A flowchart of another machine translation method provided in an embodiment of the present application;

[0026] Figure 6 A schematic diagram of a process for implementing machine translation of a table to be translated provided in an embodiment of the present application;

[0027] Figure 7 A flowchart for implementing machine translation of a picture to be translated is provided in an embodiment of the present application. DETAILED DESCRIPTION

[0028] The terms "first", "second", etc. in the description of the embodiments of the present application, the claims, and the description of the drawings are used to distinguish different objects rather than to limit a specific order.

[0029] In the embodiments of the present application, words such as "exemplary" or "for example" are used to indicate examples, illustrations or descriptions. Any embodiment or design described as "exemplary" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary" or "for example" is intended to present related concepts in a specific way.

[0030] In order to make the description of the following embodiments clear and concise, a brief introduction to the related technology is first given:

[0031] Corpus refers to any text data collected for language analysis. Corpus can be collected randomly or carefully selected for a specific purpose.

[0032] A corpus is a well-organized, representative collection of a large number of texts. A corpus contains a large number of texts that can cover different topics, styles, and sources. Generally, a corpus contains a large collection of organized texts, in which the text has a prescribed format and tags.

[0033] Parallel texts refer to corresponding versions of the same content in two or more languages, for example, an English news report and its Chinese translation are a parallel text. In the embodiment of the present application, parallel texts refer to corresponding versions of the same content in two languages ​​(i.e., source language and target language), that is, parallel texts include source language sentences and their corresponding target language sentences. Specifically, target language sentences are obtained by translating source language sentences from experts in a specific technical field.

[0034] Private Domain Parallel Corpus refers to a collection of texts collected within a specific field or organization that contains corresponding translations between two or more languages. For example, parallel corpora in the fields of law, medicine, technical documents, product manuals, etc. can be called private domain parallel corpus.

[0035] A parallel corpus is a special type of corpus that does not contain texts in multiple languages, but rather corresponding translations of each other. In fact, a parallel corpus contains a large collection of parallel corpora, where the parallel corpora have a prescribed format and tags.

[0036] Sentence pairs refer to the combination of a source language sentence and its corresponding target language sentence. For example, an English sentence and its corresponding Chinese translation sentence are a sentence pair. Sentence pairs are the basic unit of a parallel corpus.

[0037] The embodiment of the present application provides a machine translation method, including: obtaining a text to be translated; converting the text to be translated into a corresponding word vector to be translated; obtaining a target language word vector corresponding to the text to be translated based on the word vector to be translated through a target index model; obtaining a target language text corresponding to the text to be translated based on the target language word vector corresponding to the text to be translated. The target index model is obtained by training the index model with word vector pairs corresponding to a parallel corpus and a preset number of word vector indexes, that is, the target index model divides the multiple word vector pairs corresponding to the parallel corpus into multiple smaller clusters, then matches the closest cluster based on the word vector to be translated, and matches the most similar source language word vector in the cluster, thereby obtaining the target language word vector corresponding to the text to be translated, so as to achieve the translation of the text to be translated.

[0038] The embodiment of the present application realizes machine translation through the target index model, which reduces the number of word vectors that need to be compared in query matching, thereby shortening the time consumed by query matching, thereby improving the overall efficiency of machine translation. In addition, similarity query matching of the word vectors to be translated is realized through the target index model, not just complete (100% similarity) query matching, avoiding the situation where machine translation cannot be realized, thereby improving the effect of machine translation.

[0039] Embodiment 1:

[0040] Combine the following Figure 1-Figure 4 , a machine translation method provided by an embodiment of the present application is introduced in detail.

[0041] First combine Figure 1 , the training method of the index model for machine translation provided by the embodiment of the present application, that is, the training method of the target index model is introduced in detail. It can be understood that the machine translation method may include the training method of the index model for machine translation.

[0042] S101. Obtain a parallel corpus.

[0043] The parallel corpus includes a large number of parallel corpora, and the parallel corpora are stored in the parallel corpus in the form of sentence pairs. It can be understood that the parallel corpus includes a large number of sentence pairs, that is, a combination of source language sentences and their corresponding target language sentences.

[0044] In the embodiment of the present application, a large number of source language sentences in the parallel corpus are collectively referred to as source language corpus, and a large number of target language sentences in the parallel corpus are collectively referred to as target language corpus.

[0045] S102. Convert all sentence pairs in the parallel corpus into word vector pairs.

[0046] Among them, the word vector pair refers to the vector representation of the corresponding vocabulary between two languages ​​in the parallel corpus, that is, the word vector pair is composed of the word vector of the source language word in the parallel corpus and the word vector of the target language word corresponding to the source language word.

[0047] Among them, word vectors are a representation method used in natural language processing (NLP), which converts words into vectors in multidimensional space for computer understanding and processing. This representation method can capture the semantic and grammatical relationships between words.

[0048] In a possible implementation, the source language text and the target language text in the parallel corpus are converted into corresponding word vectors, and their respective word vector spaces are generated, namely, the word vector space of the source language and the word vector space of the target language; the word vector spaces are aligned. Since the word vectors of the source language and the word vector space of the target language are constructed independently, there is no direct correspondence between them. Therefore, the two word vector spaces are aligned so that the word vector spaces of the source language and the target language can be mapped to each other to some extent; mapping relationship learning, using some known word-unit pairs (word-unit pairs obtained from sentence pairs in the parallel corpus) to train a mapping function, so that the word vector space of a source language word-unit can be mapped to the word vector space of the target language, thereby obtaining a word vector pair. Specifically, the source language text and the target language text in the parallel corpus are converted into corresponding word vectors through word embedding technology.

[0049] Word Embeddings technology is a technology in the field of Natural Language Processing (NLP) that is used to convert words in a text into numerical vector identifiers so that computers can understand and process these words.

[0050] In one possible implementation, the source language text and the target language text are converted into corresponding word vectors through the BERT model.

[0051] Among them, the BERT (Bidirectional Encoder Representations from Transformers) model is a deep learning model based on the Transformer architecture. The BERT model uses bidirectional context information to generate word vectors, aiming to create high-quality word vectors through deep bidirectional transformers.

[0052] Since the BERT model uses bidirectional context information to generate word vectors, that is, the BERT model uses a bidirectional Transformers encoder, the BERT model considers the context information before and after the word when generating the word vector. The generated word vector not only reflects the meaning of the word itself, but also integrates the context information of the word in the sentence in which it is located. That is, the word vector generated by the BERT model is context-sensitive. For example, the word vector based on context sensitivity can understand and distinguish between multiple meanings of a word or multiple words with one meaning. The BERT model is stacked by multiple layers of Transformers, and each layer abstracts the input at a deeper level, so that the word vector generated by the BERT model can capture more complex language structures and patterns. Due to the self-attention mechanism of the Transformer in the BERT model, the BERT model can better handle long-distance dependencies in sentences, so that the relationship between words can be captured even if they are far apart.

[0053] For ease of understanding, the following Figure 4 This article gives an example of how to use the BERT model to convert all source language texts in a parallel corpus into corresponding word vectors.

[0054] like Figure 2 As shown, first load the BERT model, that is, load a pre-trained BERT model, which can be selected according to the content of the parallel corpus; load the tokenizer, which is used to segment all source language sentences into words or phrases and convert them into an input format acceptable to the BERT model; text preprocessing, that is, preprocessing the source language sentences, which may include cleaning the text, removing unnecessary tags and formatting, etc., to ensure that the text corresponding to all source language sentences is in the format expected by the BERT model; text encoding, using the tokenizer to encode each source language sentence into a format that the BERT model can understand, usually including adding special start and end tags, and segmenting the text into tokens, which include complete words, word roots, etc.; generate word vectors, input the encoded text into the BERT model, and the BERT model will output the embedding vector of each token, that is, obtain the word vectors corresponding to all source language sentences; store word vectors, store the generated word vectors, and you can save them on the hard disk or load them into the memory for subsequent use.

[0055] It should be noted that the process of converting the target language text into the corresponding word vector is similar to the process of converting the source language text into the corresponding word vector, which will not be repeated here.

[0056] For the convenience of description, the word vectors in the word vector space of the source language (i.e., the word vectors corresponding to the source language text) are described in terms of the source language word vectors, and the word vectors in the word vector space of the target language (i.e., the word vectors corresponding to the target language text) are described in terms of the target language word vectors.

[0057] S103: Cluster all source language word vectors and establish a preset number of word vector indexes.

[0058] Specifically, a clustering algorithm is used to cluster all source language word vectors to obtain a preset number of cluster centers, and the cluster centers are word vector indexes.

[0059] Among them, clustering algorithm is an unsupervised learning method used to automatically group samples in a data set into different types (clusters). These categories are automatically discovered by the algorithm based on data similarity. Specifically, clustering algorithms include: K-Means variant algorithm, hierarchical clustering algorithm, density-based clustering algorithm, grid-based clustering algorithm, etc.

[0060] Cluster centers refer to representative points within a cluster, usually defined as the average position of all points in the cluster, i.e., the geometric center. For word vectors, cluster centers can represent the shared semantic features of word vectors in the cluster, so cluster centers are used as word vector indexes.

[0061] In a possible implementation, all source language word vectors are clustered using the KMeans++ algorithm to obtain a preset number of cluster centers, where the cluster centers are word vector indexes.

[0062] Among them, the KMeans++ algorithm is an improved version of the K-Means algorithm. The Kmeans algorithm determines the location of the initial cluster center through a probabilistic selection strategy, thereby avoiding the sensitivity problem of the initial cluster center selection in the K-Means algorithm with a greater probability. In the K-Means algorithm, if the initial cluster center is not properly selected, it may cause the algorithm to converge to a suboptimal solution, that is, converge to a local optimal solution instead of a global optimal solution; while the KMeans++ algorithm determines the initial cluster center through a probabilistic selection strategy, which can avoid the problem of the K-Means algorithm converging to a local optimal solution with a greater probability, thereby improving the quality of the final clustering results.

[0063] Probabilistic selection strategy: In the KMeans++ algorithm, the distance from each data point to the currently selected cluster center is calculated, and these distances are used to determine the probability of selecting the next cluster center. Specifically, the probability of a data point being selected as the next cluster center is proportional to the square of its distance to the nearest selected cluster center. This ensures that relatively isolated points in the data space have a higher chance of being selected as cluster centers, making it more likely to form evenly distributed clusters.

[0064] For ease of understanding, the following is a detailed introduction on how to use the KMeans++ algorithm to cluster all source language word vectors to obtain multiple cluster centers.

[0065] First, a word vector is randomly selected from all source language word vectors as the first initial clustering center; next, for each source language word vector, its shortest distance to the currently selected first initial clustering center is calculated; then, the next initial clustering center is selected, and the probability of each source language word vector being selected is the square of its shortest distance divided by the sum of the squares of the shortest distances of all source language word vectors, that is, the source language word vector with a longer shortest distance has a greater probability of being selected as the next initial clustering center; the above process is repeated until k initial clustering centers are selected (where k represents a preset number and k is a positive integer).

[0066] Based on the selected k initial cluster centers, perform iterative training of the K-Means algorithm to obtain the final k cluster centers. Specifically, assign each source language word vector to the nearest cluster center; update the cluster center of each cluster to the mean of all source language word vectors in the cluster; repeat the above two steps until the change in the cluster center is less than the preset threshold or reaches the preset maximum number of iterations, end the iterative training, and obtain the final k cluster centers.

[0067] S104. Use the word vector pairs and a preset number of word vector indexes to train the index model to obtain a target index model.

[0068] Among them, the index model is a data result or algorithm used to optimize the data search process so that specific data records can be quickly located and retrieved. The index model can be designed for different data types and query requirements to provide the best query performance.

[0069] Specifically, the index model obtained by training word vector pairs and word vector indexes is an Approximate Nearest Neighbor (ANN) index model.

[0070] The Approximate Nearest Neighbor (ANN) index model is an efficient search structure specially designed to process high-dimensional data. The ANN index model can return the approximate nearest neighbors of a query point in a very short time and can process very large data sets. As the amount of data increases, the ANN index model can still maintain reasonable query efficiency. In an embodiment of the present application, the ANN index model can achieve efficient large-scale word vector retrieval, so that other word vectors that are most similar to a certain word vector can be quickly found.

[0071] It should be noted that the "training index model" in the embodiments of the present application is not machine learning training in the traditional sense, but actually refers to building and optimizing the index model.

[0072] Specifically, the word vector index of the training index model is a preset number of cluster centers obtained by the KMeans++ algorithm.

[0073] In one possible implementation, when an index model does not exist, word vector pairs and word vector indexes are used to build and optimize the index model; when an index model exists, word vector pairs and word vector indexes are used to optimize the previous round of index model.

[0074] For ease of understanding, the following Figure 3 This article gives examples of how to use word vectors and word vector indexes to build and optimize index models.

[0075] S1041. Determine the appropriate index library and index type based on the data volume and query requirements of all word vectors.

[0076] Among them, the index library and index type each play a key role in the process of building the ANN index model, and are jointly committed to providing efficient and accurate approximate nearest neighbor search capabilities.

[0077] The index library mainly provides search algorithms for the ANN index model. The index library has built-in optimized search algorithms, which are used to efficiently find approximate nearest neighbor points while minimizing the consumption of computing resources. In addition, the index library also provides data preprocessing and post-processing functions for the ANN index model to ensure the efficient operation of the ANN index model and the accuracy of the query results. Furthermore, the index library also provides users with an easy-to-use application programming interface (API) so that developers can quickly build and use the ANN index model without having to deeply understand the complexity of the underlying algorithm. Exemplarily, the index library can be the Annoy (Approximate Nearest Neighbors Oh Yeah, Approximate Nearest Neighbors Search) index library, the Faiss (Facebook AI Similarity Search, Facebook AI Similarity Search) index library, or the HNSWlib (Hierarchical Navigable Small World Graphs, Hierarchical Navigable Small World Graphs) index library, etc.

[0078] The index type provides a data organization method for the ANN index model. The index type defines how to organize vectors in the data space so that possible approximate nearest neighbor points can be quickly located during a query, and the index type provides a search strategy for the ANN index model, that is, it provides the basic principle for performing an approximate nearest neighbor search. Exemplarily, in an embodiment of the present application, the index type is a cluster-based index, that is, the data set is divided into multiple clusters, each cluster has a cluster midpoint, and when querying, the nearest cluster center is first found, and then an accurate search is performed within the cluster of the cluster center.

[0079] S1042: Create an ANN index model based on the determined index library and index type.

[0080] Specifically, the process of creating the ANN index model includes parameter configuration of the ANN index model.

[0081] Among them, the parameters of the ANN index model include: word vector dimension, index capacity, clustering parameters, search parameters, etc.

[0082] The latitude of a word vector refers to the number of spatial dimensions that constitute the word vector, that is, the number of numerical features contained in the vector. In the embodiment of the present application, the size of the latitude of a word vector generally reflects the amount of context information used / referenced when a word unit is converted into a word vector.

[0083] Index capacity refers to the maximum number of word vectors that the index can store.

[0084] The clustering parameter refers to the number of clusters, that is, how many clusters all word vectors are divided into. In the embodiment of the present application, the clustering parameter is related to the number of cluster centers (ie, word vector indexes) obtained.

[0085] The search parameters are used to control the search behavior during the query. Specifically, the search strategy of the index is adjusted during the query phase of the ANN index model to balance the query speed and the accuracy of the results.

[0086] S1043. Add a preset number of word vector indexes to the ANN index model as a base point.

[0087] Specifically, the word vector index is added to the ANN index model as a reference point or starting point for quickly locating and retrieving approximate nearest neighbor vectors. When the ANN index model is used for subsequent queries, the ANN index model will first use these base points to quickly narrow the search scope, thereby greatly improving query efficiency.

[0088] S1044. Add all word vector pairs to the ANN index model and associate them with the word vector index closest to the source language word vector in the word vector pair.

[0089] Specifically, all word vector pairs are added to the ANN index model, and the source language word vector in the word vector is calculated for similarity association with each word vector index, and the source language word vector is assigned to the word vector index with the highest similarity.

[0090] In a possible implementation, all word vector pairs are added to the ANN index model according to the source language word vector in the word vector pair as a sub-index. Each source language word vector is calculated to be at a distance from each word vector index, and then the word vector pair corresponding to the source language word vector is assigned to the nearest word vector index. The nearest word vector index starts with the word vector index with the highest similarity to the source language word vector.

[0091] Doing so can organize similar source language word vectors and their corresponding target language word vectors together to form a local area centered on the word vector index. So that when the ANN index model is used for subsequent queries, the ANN index model first locates the word vector index closest to the query word vector, and then performs a more detailed query in the source language word vector near the word vector index to determine the source language word vector that is similar to the query word vector. According to the word vector pairs corresponding to the source language word vector, the target language word vector that is similar to the query word vector is obtained. Implementing queries through the ANN index model greatly reduces the number of word vectors that need to be compared and improves query efficiency.

[0092] In a possible implementation, after the ANN index model is created, the method further includes: adjusting parameters according to the performance of the ANN index model to achieve an optimal balance between query speed and result accuracy.

[0093] The training of the ANN index model is implemented through S1041-S1044 to obtain a trained ANN index model, that is, a target index model.

[0094] S105: Store the target index model.

[0095] Specifically, in order to be able to directly use the target index model later, the target index model needs to be stored to disk so that it can be directly loaded for subsequent use without retraining / building.

[0096] The above-mentioned Figure 1 S101-S105 shown in the figure obtains the trained index model for machine translation, namely the target index model. Figure 4 , a machine translation method provided in an embodiment of the present application is introduced in detail, and the method is applied to a computing device, such as a server.

[0097] First, before a computing device executes a machine translation method provided in an embodiment of the present application, it is necessary to pre-load the target index model into the memory of the computing device and keep it resident in the memory. The memory of the computing device may be a random access memory (RAM), a read-only memory (ROM), etc.

[0098] Loading the target index model into the memory of the computing device instead of the hard disk or other storage media can significantly reduce data access time, because the read and write speed of the memory is much faster than the hard disk. When the target index model is in the memory, data can be read directly from the memory in response to the input, avoiding disk I / O delays, thereby greatly improving the query speed. In addition, the target index model is resident in the memory, which means that the target index model remains in the memory after the computing device system is started, and will not be swapped out to the hard disk by the computing device's operating system due to idleness. This ensures that the target index model is immediately available after each input arrives, without waiting for loading time, further improving the query speed.

[0099] like Figure 4 As shown, a machine translation method provided in an embodiment of the present application includes the following steps:

[0100] S401: Obtain text to be translated.

[0101] The text to be translated refers to the source language text that needs to be translated into the target language. The text to be translated can be a single sentence, a continuous paragraph, or a part of a sentence in a document.

[0102] It should be noted that the “text to be translated” in the embodiment of the present application can actually also be understood as a “sentence to be translated”.

[0103] Exemplarily, a document to be translated is received; the document to be translated is parsed, and texts to be translated in the texts to be translated are classified and identified, thereby obtaining the texts to be translated.

[0104] S402: Convert the text to be translated into a corresponding word vector to be translated.

[0105] The word vector to be translated is the word vector corresponding to the text to be translated. In general, there are multiple word vectors to be translated.

[0106] Specifically, the text to be translated is converted into the corresponding word vector to be translated through word embedding technology.

[0107] In a possible implementation, the text to be translated is converted into the corresponding word vector to be translated through the BERT model.

[0108] It should be noted that the word vector to be translated is a name that describes the word vector corresponding to the text to be translated. In addition to this, the word vector corresponding to the text to be translated can also be represented by other names, which are not specifically limited in this application.

[0109] S403: Obtain a target language word vector corresponding to the text to be translated based on the word vector to be translated through the target index model.

[0110] Specifically, the word vector to be translated is input into the target index model loaded into the memory, so that the target index model outputs the target language word vector corresponding to the word vector to be translated.

[0111] For ease of understanding, the following example introduces how the target index model outputs the target language word vector corresponding to the word vector to be translated. Take one of all the word vectors to be translated as an example. For ease of description, one of the word vectors to be translated is called "word vector V".

[0112] After the word vector V is input into the target index model, the target index model calculates the distance from the word vector V to each word vector index (cluster center), determines the word vector index with the closest distance as the word vector index most similar to the word vector V, and the source language word vector similar to the word vector V is under the word vector index with the closest distance; under the word vector index with the closest distance (cluster), uses a preset similarity algorithm to determine the similarity between the word vector V and all source language word vectors under the word vector index with the closest distance, and determines the source language word vector most similar to the word vector V; determines the word vector pair corresponding to the most similar source language word vector, obtains the target language word vector corresponding to the most similar source language word vector and outputs it, so that the computing device obtains the target language word vector corresponding to the word vector V.

[0113] Among them, the preset similarity algorithms include: cosine similarity algorithm, Euclidean distance algorithm, etc.

[0114] The cosine similarity algorithm measures the cosine value of the angle between two word vectors, ranging from -1 to 1. The closer the cosine value of the angle between two word vectors is to 1, the more similar the two word vectors are. For the cosine similarity algorithm, the cosine value of the angle between two word vectors is used as the similarity.

[0115] The Euclidean distance algorithm measures the straight-line distance between two word vectors. The smaller the straight-line distance between two word vectors, the more similar the two word vectors are. For the Euclidean distance algorithm, the straight-line distance between two word vectors is used as the similarity.

[0116] In one possible implementation, the target index model uses a preset similarity algorithm under the nearest word vector index to determine the source language word vector that is most similar to the word vector V, and obtains the similarity of the source language word vector that is most similar to the word vector V. Subsequently, the target language word vector corresponding to the word vector V is output while outputting the similarity.

[0117] The target index model first indexes the nearest word vector to the word vector to be translated, and then compares it with the source language word vector under the nearest word vector index to obtain the corresponding target language word vector, which greatly reduces the number of word vectors that need to be compared with the input word vector to be translated during query / matching, thereby achieving a significant improvement in query / matching speed, that is, shortening the time consumed by query matching, thereby improving the overall efficiency of machine translation. In addition, similarity query matching of the word vector to be translated is achieved through the target index model, not just complete (100% similarity) query matching, avoiding the situation where machine translation cannot be achieved, thereby improving the effect of machine translation.

[0118] S404: Based on the target language word vector corresponding to the text to be translated, obtain the target language sentence corresponding to the text to be translated.

[0119] Among them, the target language word vectors corresponding to the text to be translated correspond to the word vectors to be translated one by one, that is, the number of target language word vectors corresponding to the text to be translated is the same as the number of word vectors to be translated.

[0120] Specifically, the target language word vectors corresponding to the text to be translated are decoded to obtain the target language word elements corresponding to the target language word vectors of the text to be translated; based on the corresponding target language word elements, a complete sentence is formed to obtain the target language sentence corresponding to the text to be translated, thereby realizing machine translation of the text to be translated.

[0121] A machine translation method provided by an embodiment of the present application includes: receiving a text to be translated; converting the text to be translated into a corresponding word vector to be translated; obtaining a target language word vector corresponding to the word vector to be translated through a target index model loaded in memory; obtaining a target language sentence corresponding to the text to be translated based on the target language word vector corresponding to the text to be translated. Wherein, the target index model queries the word vector index closest to the word vector to be translated based on the word vector to be translated, queries the source language word vector most similar to the word vector to be translated under the word vector index, and determines the target language word vector corresponding to the word vector to be translated based on the word vector pair corresponding to the source language word vector. In an embodiment of the present application, the target index model divides the word vector pair into multiple smaller clusters, and only needs to determine the nearest word vector index, and then queries the source language word vector in the word vector index to match the most similar source language word vector, which reduces the number of word vectors that need to be compared in query matching, thereby shortening the time consumed by query matching, thereby improving the efficiency of overall machine translation. Furthermore, similarity query matching of the word vectors to be translated is achieved through the target index model, not just complete (100% similarity) query matching, which avoids the situation where machine translation cannot be achieved, thereby improving the effect of machine translation.

[0122] The machine translation method described in the above embodiment 1 is aimed at the translation of sentences, that is, the translation of data in plain text form. In actual use, machine translation is also often used for the translation of documents, which may include various types of data, such as text, tables and pictures. Therefore, for the document translation task, a machine translation method provided by the embodiment of the present application is described in detail below in conjunction with the second embodiment.

[0123] Embodiment 2:

[0124] Combine the following Figure 5-Figure 7 , a machine translation method provided by an embodiment of the present application is introduced in detail. The method is applied to a computing device, and the memory of the computing device has loaded a target index model.

[0125] S501: Receive a document to be translated.

[0126] The document to be translated refers to the document that needs to be translated into the target language, including text, tables and pictures.

[0127] S502: Parse the document to be translated, and classify and identify the data carried by the document to be translated.

[0128] Specifically, the data carried by the document to be translated includes text to be translated, tables to be translated, and images to be translated.

[0129] The text to be translated is the text in the document to be translated, the table to be translated is the table in the document to be translated, and the picture to be translated is the picture in the document to be translated.

[0130] In a possible implementation, based on a preset recognition algorithm, in the process of parsing the document to be translated, the text to be translated, the table to be translated, and the image to be translated are classified and recognized. Exemplarily, in the process of parsing the document to be translated, if the text can be obtained from the part of the data and the table border is not recognized, the part of the data is recognized as the text to be translated; if the text can be obtained from the part of the data and the table border is recognized, the part of the data is recognized as the table to be translated; if the text cannot be obtained from the part of the data and the table border is not recognized, the part of the data is recognized as the image to be translated.

[0131] When the text to be translated is identified through classification, S503 is performed.

[0132] When the table to be translated is identified through classification, S504 is performed.

[0133] When the image to be translated is identified through classification, proceed to S505.

[0134] S503: Using the target index model, machine translation is performed on the text to be translated to obtain a target language text corresponding to the text to be translated.

[0135] Specifically, the text to be translated is first converted into the corresponding word vector to be translated; through the target index model, based on the word vector to be translated, the target language word vector corresponding to the text to be translated is obtained; based on the target language word vector corresponding to the text to be translated, the target language text corresponding to the text to be translated is obtained.

[0136] The specific implementation method of the above S503 is the same as S402-S404 in the first embodiment, so please refer to S402-S404 in the first embodiment for details of the specific implementation method of S503, which will not be repeated here.

[0137] The above S503 - S505 implement the machine translation of the text to be translated in the document to be translated. The following describes how to implement the machine translation of the table to be translated in the document to be translated.

[0138] S504: Using the target index model, machine translation is performed on the table to be translated, and a target language table corresponding to the table to be translated is obtained.

[0139] The sentences / phrases in the cells of the table to be translated are source language sentences / phrases, and the sentences / phrases in the cells of the corresponding target language table are target language sentences / phrases, and the cells of the target language table correspond one-to-one to the cells of the table to be translated.

[0140] For ease of understanding, the following Figure 6 How to implement S504, that is, how to implement machine translation of the table to be translated, is described in detail.

[0141] S601, identifying the subject of the table to be translated.

[0142] Tables in documents have a subject, and generally, the text above the table is used to describe the subject of the table. Exemplarily, the subject of the table to be translated is the source language text (sentence / phrase) located above the table to be translated in the document to be translated.

[0143] Specifically, based on the parsed document to be translated, the text above the table to be translated is identified to obtain the subject of the table to be translated.

[0144] S602: Determine the type of the cell based on the character length of the text in each cell of the table to be translated.

[0145] The cell types include: short text cells and long text cells.

[0146] Specifically, determine whether the character length of the text in the cell is less than a first preset character length. When the character length of the text in the cell is less than the first preset character length, the type of the cell is a short text cell, that is, the text in the short text cell is a phrase (word, phrase, etc.); when the character length of the text in the cell is not less than the first preset character length, the type of the cell is a long text cell, that is, the text in the long text cell is a long sentence.

[0147] For a short text cell, perform S603 - S606 .

[0148] For a long text cell, perform S607 - S610 .

[0149] S603: Convert the phrases in the short text cells into corresponding word vectors to be translated.

[0150] Specifically, through the word embedding technology, the phrases in the short text cells are converted into corresponding word vectors to be translated, that is, the word vectors to be translated corresponding to the phrases in the short text cells are word embedding vectors.

[0151] In one possible implementation, the phrases in the short text cells are converted into corresponding word vectors to be translated through the BERT model.

[0152] S604: Obtain the target language word vector corresponding to the phrase in the short text cell based on the to-be-translated word vector through the target index model.

[0153] S605 . Obtain a target language phrase corresponding to the phrase in the short text cell based on the target language word vector corresponding to the phrase in the short text cell.

[0154] S606: Replace the target language phrase corresponding to the phrase in the short text cell with the short text cell.

[0155] The target language phrase corresponding to the phrase in the short text unit is replaced into the short text cell, thereby realizing the machine translation of the short text cell in the table to be translated and ensuring that the cells of the translated table correspond one-to-one with the cells of the table to be translated, thus avoiding the problem of poor machine translation effect caused by the wrong output position of the translation result.

[0156] S607: Based on the long sentence in the long text cell and the subject of the table to be translated, obtain the word vector to be translated corresponding to the long sentence in the long text cell.

[0157] In a possible implementation, long sentences in long text cells are segmented through a window of a first preset size to obtain multiple phrases corresponding to the long sentences, and prefix prompt words are constructed according to the subject of the table to be translated; based on the prefix prompt words and the multiple phrases corresponding to the long sentences, multiple phrases to be translated corresponding to the long sentences are obtained, and the structure of the multiple phrases to be translated corresponding to the long sentences is: prefix prompt words + phrases; and the multiple phrases to be translated are respectively converted into corresponding word vectors to be translated.

[0158] Prefix prompts usually refer to the use of specific words or phrases in the machine translation process to guide the translation output of a specific type. Prefix prompts can affect the style and other characteristics of machine translation to a certain extent. Specifically, prefix prompts are added to the front of the text to be translated in order to guide the machine translation to produce a specific style or specific translation results.

[0159] Specifically, through word embedding technology, multiple phrases to be translated are converted into corresponding word vectors to be translated.

[0160] In another possible implementation, a prefix prompt word is constructed according to the subject of the table to be translated, and the prefix prompt word is converted into a corresponding word vector (hereinafter, "the word vector corresponding to the prefix prompt word" is referred to as "the prompt word vector"); through the BERT model, the long sentences in the long text cells are converted into corresponding multiple word vectors (hereinafter, "the word vector corresponding to the long sentence" is referred to as "the phrase word vector"); based on the prompt word vector and the multiple phrase word vectors, they are spliced ​​respectively to obtain multiple word vectors to be translated, and the structure of the word vector to be translated is: prompt word vector + phrase word vector.

[0161] For long text cells, the long sentences in the long text cells carry a large amount of complex information and may contain more details and potential meanings, which means that these details need to be understood and expressed more accurately in machine translation, rather than just literal conversion. However, since the table in the document and the text in the context of the table in the document are two types of data, it is difficult to effectively obtain context information for the long text cells in the table. Therefore, it is necessary to collaboratively obtain the word vector to be translated corresponding to the long sentence based on the long sentence in the long text cell and the prefix prompt words constructed according to the subject of the table to be translated, so as to obtain the table context information based on the prefix prompt words in the subsequent process, so that the target index model can better understand the purpose and context of the text, thereby obtaining a more accurate translation result.

[0162] However, for single-text cells, the phrases in the cell consist of a few words and contain relatively little information, so context dependency issues are unlikely to occur during machine translation; and the meaning of the phrase itself is relatively stable, so the phrase has a low dependency on the parent context, and even if the context changes, the meaning of the phrase is relatively stable. Furthermore, the structure of the phrase is relatively simple and generally does not contain complex grammatical structures, which makes it easier for machine translation to understand its meaning. Therefore, for phrases in single-text cells, there is no need for prefix prompts to assist machine translation.

[0163] S608. Obtain the target language word vector corresponding to the long sentence in the long text cell based on the word vector to be translated through the target index model.

[0164] S609. Obtain the target language long sentence corresponding to the long sentence in the long text cell based on the target language word vector corresponding to the long sentence in the long text cell.

[0165] S610: Replace the target language long sentence corresponding to the long sentence in the long text cell with the long text cell.

[0166] After all cells in the table to be translated are translated and the target language table is obtained, S611 is performed.

[0167] S611, post-translate the target language table.

[0168] Among them, post-translation processing (Post-editing) is a series of operations performed after machine translation, aiming to improve the quality of machine translation output, thereby further improving the effect of machine translation. Post-translation processing includes: proofreading, editing, style adjustment and format adjustment, etc.

[0169] The above combination Figure 6 S601-S611 shown in detail introduces how to implement S504. The following will continue to introduce how to implement machine translation of the translation image in conjunction with S505.

[0170] S505, identifying the text and / or table in the image to be translated; and using the target index model to implement machine translation of the text and / or table in the image to be translated, to obtain the target language text and / or table corresponding to the image to be translated.

[0171] For ease of understanding, the following Figure 7 The following describes in detail how to implement S505, that is, how to implement machine translation of the translated image.

[0172] S701: Identify the subject of the image to be translated.

[0173] The pictures in the document will have a subject (or legend), and generally, the text below the picture is used to describe the subject of the picture. Exemplarily, the subject of the picture to be translated is the source language text located above the picture to be translated in the document to be translated.

[0174] S702: Identify a text area and / or a table area in the image to be translated.

[0175] Specifically, the image to be translated is preprocessed, for example, grayscale, binarization and denoising are performed on the image to be translated; edge detection algorithms (such as Canny edge detection) are used to find straight line edges in the image to be translated; line detection, for example, Hough transform is used to detect straight lines, especially horizontal and vertical lines; the image is divided into multiple areas according to the detected lines; these areas are analyzed separately to determine whether they contain tables or plain text, so as to identify text areas and / or table areas in the image to be translated.

[0176] For the text area in the image to be translated, S703 - S710 are performed.

[0177] For the table area in the image to be translated, perform S711 to S713.

[0178] S703: construct the text to be translated in the text area of ​​the image to be translated by using optical character recognition technology.

[0179] Among them, Optical Character Recognition technology is used to convert text in images into editable and searchable digital text.

[0180] S704: Determine the type of the text to be translated based on the character length of the text to be translated in the text area in the picture to be translated.

[0181] Specifically, it is determined whether the character length of the text to be translated in the text area in the image to be translated is less than the second preset character length. When the character length of the text to be translated in the text area in the image to be translated is less than the second preset character length, the text to be translated is a phrase to be translated (i.e., a short text), such as a word, a phrase, etc. When the character length of the text to be translated in the text area in the image to be translated is not less than the second preset character length, the text to be translated is a long sentence to be translated.

[0182] When the type of the text to be translated is a phrase to be translated, S705 to S707 are performed.

[0183] When the type of the text to be translated is a long sentence to be translated, S708-S710 are performed.

[0184] S705 , converting the phrases to be translated in the text area of ​​the image to be translated into corresponding word vectors to be translated.

[0185] S706 , obtaining a target language word vector corresponding to the to-be-translated phrase in the text region of the to-be-translated image based on the to-be-translated word vector through the target index model.

[0186] S707 . Obtain a target language phrase corresponding to the phrase to be translated in the text region in the image to be translated based on the corresponding target language word vector.

[0187] The specific implementation method of the above S705-S707 is the same as that of S603-S605, so for details of the specific implementation method of S705-S707, please refer to S603-S605, and will not be repeated here.

[0188] S708 . Obtain a word vector to be translated corresponding to the long sentence to be translated in the picture to be translated based on the long sentence to be translated in the text area in the picture to be translated and the theme of the picture to be translated.

[0189] In a possible implementation, the long sentence to be translated is segmented through a window of a second preset size to obtain a plurality of corresponding phrases, and a prefix prompt word is constructed according to the theme of the picture to be translated; based on the prefix prompt word and the plurality of phrases corresponding to the long sentence to be translated, a plurality of phrases to be translated corresponding to the long sentence to be translated are obtained; and the plurality of phrases to be translated are respectively converted into corresponding word vectors to be translated to obtain a word vector to be translated corresponding to the long sentence to be translated.

[0190] Specifically, a prefix prompt word is constructed according to the theme of the image to be translated, so as to obtain a word vector to be translated corresponding to the long sentence to be translated in the text area of ​​the image to be translated based on the prefix prompt word and the long sentence to be translated in the text area of ​​the image to be translated. The prefix prompt word constructed according to the long sentence to be translated in the text area of ​​the image to be translated and the theme of the image to be translated are used to jointly obtain the corresponding word vector to be translated, so as to obtain the context information of the image to be translated based on the prefix prompt word in the subsequent process, so as to enable the target index model to better understand the purpose and context of the long sentence, so as to obtain a translation result with higher accuracy.

[0191] It should be noted that the window of the first preset size and the window of the second preset size may be windows of the same size or windows of different sizes, and this application does not make any specific limitation.

[0192] S709 , obtaining the target language word vector corresponding to the long sentence to be translated in the text area in the image to be translated based on the word vector to be translated through the target index model.

[0193] S710 . Obtain a target language long sentence corresponding to a long sentence to be translated in a text region in the image to be translated based on the corresponding target language word vector.

[0194] The specific implementation method of the above S708-S710 is the same as the specific implementation method of S607-S609, so for details of the specific implementation method of S707-S709, please refer to S607-S609, which will not be repeated here.

[0195] S711, constructing a table to be translated in a table area in the picture to be translated.

[0196] Specifically, a table in a table area in the image to be translated is identified, and the text in each cell of the table in the table area in the image to be translated is identified by optical character recognition technology, thereby obtaining the table to be translated in the table area.

[0197] Exemplarily, based on the lines detected in the table area of ​​the image to be translated, the rows and columns of the table are identified, and the intersections are detected to determine the cell boundaries; the table is divided into individual cells based on the detected cell boundaries; and the text of each cell is identified through optical character recognition technology, thereby obtaining the table to be translated in the table area.

[0198] S712: Use the target index model to implement machine translation of the table in the table area in the image to be translated, and obtain a target language table corresponding to the table in the table area in the image to be translated.

[0199] The specific implementation method of the above S712 is the same as the specific implementation method of S504, so please refer to S504 for details of the specific implementation method of S712, which will not be repeated here.

[0200] The machine translation method provided in the embodiment of the present application realizes the machine translation of text, table, and image data in the translation document. The method solves the problem that the translation result generated by directly using a large language model to translate the translation document is poorly related to the context and may even produce hallucinations in the current technology.

[0201] In addition, an embodiment of the present application further provides a computing device, which includes a processor and a memory, the processor is connected to the memory, the memory stores computer-executable instructions, and when the processor executes the computer-executable instructions, the steps of the machine translation method in the above embodiment are implemented.

[0202] The embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed on a computer, the computer is enabled to execute the machine translation method in the above embodiment.

[0203] For the explanation of the relevant contents and description of the beneficial effects of any of the above-mentioned computer-readable storage media, reference may be made to the above-mentioned corresponding embodiments, which will not be repeated here.

[0204] The embodiment of the present application also provides a computer program product including instructions, when the instructions are run on a computer, the computer performs any one of the machine translation methods in the above embodiments. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on the computer, the process or function according to the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from a website site, a computer, a server, or a data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (digital subscriber line, DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server, or data center. The computer-readable storage medium may be any available medium that a computer can access or a data storage device such as a server, a data center, etc. that may be integrated with one or more media. The available medium may be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., an SSD), etc.

[0205] It should be noted that the above-mentioned devices for storing computer instructions or computer programs provided in the embodiments of the present application, such as but not limited to the above-mentioned memories, computer-readable storage media and communication chips, etc., are all non-transitory.

[0206] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using a software program, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When loading and executing computer program instructions on a computer, the process or function according to the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. Computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, computer instructions can be transmitted from a website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (digital subscriber line, DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server, data center, etc. that contains one or more servers that can be integrated with a medium. The available medium may be a magnetic medium (eg, a floppy disk, a hard disk, a magnetic tape), an optical medium (eg, a DVD), or a semiconductor medium (eg, a solid state disk (SSD)).

[0207] Although the present application is described herein in conjunction with various embodiments, in the process of implementing the claimed application, those skilled in the art may understand and implement other changes to the disclosed embodiments by viewing the drawings, the disclosure, and the appended claims. In the claims, the word "comprising" does not exclude other components or steps, and "one" or "an" does not exclude multiple situations. A single processor or other unit may implement several functions listed in the claims. Certain measures are recorded in different dependent claims, but this does not mean that these measures cannot be combined to produce good results.

[0208] Although the present application has been described in conjunction with specific features and embodiments thereof, it is obvious that various modifications and combinations may be made thereto without departing from the spirit and scope of the present application. Accordingly, this specification and the drawings are merely exemplary illustrations of the present application as defined by the appended claims, and are deemed to have covered any and all modifications, variations, combinations or equivalents within the scope of the present application. Obviously, those skilled in the art may make various modifications and variations to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.

[0209] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions within the technical scope disclosed in the present application should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

Claims

1. A machine translation method, characterized in that: The method comprises: Get the text to be translated; Convert the text to be translated into a corresponding word vector to be translated; The target language word vector corresponding to the text to be translated is obtained through the target index model based on the word vector to be translated; wherein the target index model is obtained by training the index model with the word vector pairs corresponding to the parallel corpus and a preset number of word vector indexes, wherein the word vector pair is a combination of the source language word vector and the target language word vector corresponding to the source language word vector, and the word vector index is a cluster center obtained based on the source language word vectors in all the word vector pairs; the corresponding target language word vector is: the target language word vector corresponding to the source language word vector with the highest similarity to the word vector to be translated in the word vector index corresponding to the word vector to be translated in the target index model; Based on the target language word vector corresponding to the text to be translated, a target language text corresponding to the text to be translated is obtained.

2. The method according to claim 1, characterized in that: The method further comprises: Acquire a parallel corpus; wherein the parallel corpus includes a plurality of sentence pairs, each of which is a combination of a source language sentence and a target language sentence corresponding to the source language sentence; Convert all sentence pairs in the parallel corpus into word vector pairs; Clustering the source language word vectors in all the word vector pairs to establish a preset number of word vector indexes; The index model is trained using all the word vector pairs and the preset number of word vector indexes to obtain a target index model.

3. The method according to claim 2, characterized in that The method of training an index model by using all the word vector pairs and the preset number of word vector indexes to obtain a target index model includes: Adding the preset number of word vector indexes to the index model as a base point; Add all the word vector pairs to the index model, calculate the distance between the source language word vectors in the word vector pairs and each word vector index, and assign the word vector pairs to the word vector index that is closest to the source language word vector in the word vector pairs.

4. The method according to claim 2, characterized in that: The step of obtaining the target language word vector corresponding to the text to be translated based on the word vector to be translated by using the target index model includes: Input the word vector to be translated into the target index model; so that the target index model calculates the distance between the word vector to be translated and each word vector index, and determines the word vector index that is most similar to the word vector to be translated; and calculates the similarity between the word vector to be translated and all source language word vectors under the most similar word vector index through a preset similarity algorithm, determines the source language word vector that is most similar to the word vector to be translated, and based on the word vector pair corresponding to the most similar source language word vector, obtains the target language word vector corresponding to the word vector to be translated and outputs it; The target language word vector corresponding to the word vector to be translated output by the target index model is received to obtain the target language word vector corresponding to the text to be translated.

5. The method according to claim 4, characterized in that The method further comprises: While the index model determines the source language word vector that is most similar to the word vector to be translated, it obtains the similarity between the word vector to be translated and the closest source language word vector, and outputs the similarity.

6. The method according to claim 1, characterized in that Before obtaining the text to be translated, the method further includes: loading a target index model into a memory of the computing device; The step of obtaining the target language word vector corresponding to the text to be translated based on the word vector to be translated by using the target index model includes: The target language word vector corresponding to the text to be translated is obtained based on the word vector to be translated through the target index model loaded into the memory.

7. The method according to claim 1, characterized in that The step of obtaining the text to be translated includes: Receive documents to be translated; The document to be translated is parsed, and the text to be translated in the document to be translated is classified and identified.

8. The method according to claim 7, characterized in that The method further comprises: When the image to be translated is identified by classification, the subject of the image to be translated is identified; wherein the image to be translated is a picture in the document to be translated; Identify a text area and / or a table area in the image to be translated, and construct the text to be translated in the text area and / or the table to be translated in the table area; When identifying the text to be translated in the text area of ​​the picture to be translated, determining the type of the text to be translated based on the character length of the text to be translated; When the type of the text to be translated is a phrase to be translated, the phrase to be translated is converted into a corresponding word vector to be translated; through a target index model, based on the word vector to be translated, a target language word vector corresponding to the phrase to be translated is obtained; based on the target language word vector corresponding to the phrase to be translated, a target language phrase corresponding to the phrase to be translated of the picture to be translated is obtained; When the type of the text to be translated is a long sentence to be translated, based on the themes of the long sentence to be translated and the picture to be translated, a word vector to be translated corresponding to the long sentence to be translated is obtained; through a target index model, based on the word vector to be translated, a target language word vector corresponding to the long sentence to be translated is obtained; based on the target language word vector corresponding to the long sentence to be translated, a target language long sentence corresponding to the long sentence to be translated of the picture to be translated is obtained.

9. The method according to claim 8, characterized in that The obtaining, based on the subject of the long sentence to be translated and the picture to be translated, a word vector to be translated corresponding to the long sentence to be translated includes: Segmenting the long sentence to be translated through a window of a second preset size to obtain a plurality of phrases corresponding to the long sentence to be translated, and constructing prefix prompt words according to the theme of the picture to be translated; Based on the prefix prompt word and the multiple phrases corresponding to the long sentence to be translated, a plurality of phrases to be translated corresponding to the long sentence to be translated are obtained; The plurality of phrases to be translated are respectively converted into corresponding word vectors to be translated, so as to obtain word vectors to be translated corresponding to the long sentence to be translated.

10. A computing device, characterized in that include: Processor and memory; The processor is coupled to the memory; The memory is used to store computer program instructions; The processor is used to execute the computer program instructions stored in the memory to implement the machine translation method according to any one of claims 1 to 9.