Length constrained machine translation model

By using length tokens to control model output in machine translation, the problem of difficulty in controlling the output length in the existing technology is solved, and accurate length constraints and information retention of the translated text are achieved.

CN118742902APending Publication Date: 2024-10-01GOOGLE LLC
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202380012276.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-01-31
Publication Date
2024-10-01

AI Technical Summary

Technical Problem

Existing machine translation technology is difficult to accurately control the output length, especially in the case of length normalization. It is difficult to control the number of matching characters, display width and spoken duration, and the categorical nature of lengthy tokens cannot accurately control the translation length, resulting in The output may exceed or fall short of the length limit.

Method used

Use length tokens to control machine translation models during training and inference. By inserting length tokens into source and target text, the model learns and outputs length-constrained translations. If the output exceeds the limit, iteratively reduce the length limit until the requirements are met.

Benefits of technology

It achieves precise control over the length of machine translation output, ensuring that the translated text complies with length limits during storage, output, and display, avoids information loss, and improves the accuracy and usability of translation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118742902A_ABST
    Figure CN118742902A_ABST
Patent Text Reader

Abstract

Aspects of the present disclosure relate to controlling machine translation lengths based on length tokens. The length token is included in the machine translation source text and the target text during training, and is also included in the machine translation source text during reasoning. An output is generated from the length-constrained machine learning model if the output from the non-length-constrained machine learning model outputs a length-limited translation.
Need to check novelty before this filing date? Find Prior Art

Description

Background Art

[0001] Machine translation corresponds to using software to translate text or speech from one language into another. In some scenarios, such as in advertising, user interfaces or dubbing, it may be desirable to control the length of the machine translation output. Length normalization, lengthy tokens and positional encoding have been used to control the machine translation output length. However, in the case of length normalization, matching the number of characters, display width and / or spoken duration may be difficult. In addition, when implementing greedy beam search, length normalization can have a minimal impact on the length output. For lengthy tokens, due to the categorical nature of the tokens (e.g., short, normal, long), the translation length cannot be accurately controlled. With positional encoding, only the token number can be controlled, although it may be desirable to control the number of characters or display width. A character-level vocabulary can be implemented, but this will significantly increase latency. In addition, the model output with positional encoding results in a translation with an exact length constraint, contrary to the output that is less than or equal to the length constraint. Summary of the invention

[0002] Aspects of the present disclosure relate to controlling machine translation length based on length tokens. Length tokens are included in the machine translation source text and target text during training so that the machine learning model can learn the length of each token. During inference, length tokens are also included in the machine translation source text so that the machine learning model can output a translation subject to length constraints. If the output output from the machine learning model that is not subject to length constraints exceeds the translation subject to length constraints, a subsequent output is generated from the machine learning model subject to length constraints. If the subsequent output still exceeds the length limit, another output is generated from the machine learning model subject to length constraints with reduced length constraints. Controlling machine translation length can be implemented in titles and / or descriptions in advertisements, user interface messages on mobile or other computing devices, or dubbing translations of movies or television. Therefore, aspects of the present disclosure can provide improved machine translation, particularly in implementations where restrictions are imposed on fields or contexts for storing, outputting, or displaying translated texts. By controlling the machine translation length as described herein, for example, if the translated text exceeds the length limit, the information that may be lost is retained instead and can be stored, transmitted, or displayed to the user.

[0003] One aspect of the present disclosure provides a method for length-constrained machine translation. The method includes: receiving data corresponding to a source text by one or more processors; translating the source text by one or more processors using a machine learning model that is not length-constrained to generate data corresponding to a first translated text; determining by one or more processors that the first translated text exceeds a length limit; translating the source text by one or more processors using a machine learning model that is length-constrained to generate data corresponding to a second translated text; and outputting data corresponding to the second translated text by one or more processors.

[0004] In an example, the method further includes: determining, by one or more processors, that the second translated text exceeds a text length limit; and reducing, by one or more processors, a length limit of the length-constrained machine learning model; wherein the length limit of the length-constrained machine learning model is iteratively reduced until the translated text translated using the length-constrained machine learning model does not exceed the length limit.

[0005] In another example, the method further includes adding, by one or more processors, a length token to the beginning of the source text to indicate a length limit. In yet another example, the method further includes estimating, by one or more processors, a length of the first translated text. In yet another example, the method further includes increasing a randomness value of the length limit using the one or more processors.

[0006] In yet another example, the method further includes: using one or more processors to train a machine learning model subject to length constraints using training data including multiple source text and translation text pairs, each source text and translation text pair having one or more length tokens added. In yet another example, the source text of each pair includes a length token added to the beginning of the source text to indicate a text length restriction. In yet another example, the translation text of each pair includes one or more length markers added after each tokenized text element to indicate the remainder of the text length restriction. In yet another example, the method further includes merging the training data with the training data of the machine learning model not subject to length constraints using one or more processors.

[0007] Another aspect of the present disclosure provides a system, comprising: one or more processors; and one or more storage devices, coupled to the one or more processors and storing instructions, which when executed by the one or more processors cause the one or more processors to perform operations for length-constrained machine translation. The operations include: receiving data corresponding to a source text; translating the source text using a machine learning model that is not length-constrained to generate data corresponding to a first translated text; determining that the first translated text exceeds a length limit; translating the source text using a machine learning model that is length-constrained to generate data corresponding to a second translated text; and outputting data corresponding to the second translated text.

[0008] In the example, the operation also includes: determining that the second translated text exceeds a text length limit; and reducing the length limit of the length-constrained machine learning model; wherein the length limit of the length-constrained machine learning model is iteratively reduced until the translated text translated using the length-constrained machine learning model does not exceed the length limit.

[0009] In another example, the operation also includes adding a length token to the beginning of the source text to indicate the length limit. In yet another example, the operation also includes estimating the length of the first translated text. In yet another example, the operation also includes increasing the randomness value of the length limit.

[0010] In yet another example, the operations further include training a length-constrained machine learning model using training data including a plurality of source text and translated text pairs, each source text and translated text pair having one or more length tokens added thereto. In yet another example, the source text of each pair includes a length token added to the beginning of the source text to indicate a text length constraint. In yet another example, the translated text of each pair includes one or more length tokens added after each tokenized text element to indicate a remainder of the text length constraint. In yet another example, the operations further include merging the training data with training data of a machine learning model that is not length-constrained.

[0011] Another aspect of the present disclosure provides a non-transitory computer-readable medium for storing instructions, which, when executed by one or more processors, causes the one or more processors to perform operations for length-constrained machine translation. The operations include: receiving data corresponding to a source text; translating the source text using a machine learning model that is not length-constrained to generate data corresponding to a first translated text; determining that the first translated text exceeds a length limit; translating the source text using a machine learning model that is length-constrained to generate data corresponding to a second translated text; and outputting data corresponding to the second translated text.

[0012] In the example, the operation also includes: determining that the second translated text exceeds a text length limit; and reducing the length limit of the length-constrained machine learning model; wherein the length limit of the length-constrained machine learning model is iteratively reduced until the translated text translated using the length-constrained machine learning model does not exceed the length limit.

[0013] In another example, the operation also includes adding a length token to the beginning of the source text to indicate the length limit. In yet another example, the operation also includes estimating the length of the first translated text. In yet another example, the operation also includes increasing the randomness value of the length limit.

[0014] In yet another example, the operations further include training a length-constrained machine learning model using training data including a plurality of source text and translated text pairs, each source text and translated text pair having one or more length tokens added thereto. In yet another example, the source text of each pair includes a length token added to the beginning of the source text to indicate a text length constraint. In yet another example, the translated text of each pair includes one or more length tokens added after each tokenized text element to indicate a remainder of the text length constraint. In yet another example, the operations further include merging the training data with training data of a machine learning model that is not length-constrained. BRIEF DESCRIPTION OF THE DRAWINGS

[0015] Figure 1 Depicted is a block diagram of an example length-constrained machine translation system in accordance with aspects of the present disclosure.

[0016] Figure 2 Depicted is a block diagram of an example environment for implementing a length-constrained machine translation system according to aspects of the present disclosure.

[0017] Figure 3 Depicted is a block diagram of an example machine translation model architecture in accordance with aspects of the present disclosure.

[0018] Figure 4 Depicted is a flow diagram of an example process for training a machine translation model according to aspects of the present disclosure.

[0019] Figure 5 Depicted is a flow diagram of an example process for length-constrained machine translation according to aspects of the present disclosure.

[0020] Figure 6 Depicted is a block diagram of an example length-constrained machine translation system in which unconstrained and constrained machine learning models can be unified, according to aspects of the present disclosure. DETAILED DESCRIPTION

[0021] This article generally discloses an implementation for controlling the length of a machine translation based on a length token. The length token is added to the machine translation source text and the target text during training so that the machine learning model can learn the length of each token. The source text can correspond to the text to be translated. In the source text, the length token is inserted at the beginning of the text to indicate the required length constraint. The target text can correspond to the translation of the source text. In the target text, one or more length tokens are inserted within the translated text to indicate the remainder of the length constraint. Controlling the machine translation length can be implemented in the title and / or description in an advertisement, a user interface message on a mobile or other computing device, or a voiceover translation.

[0022] To train a machine learning model, the training data may contain source-translation pairs and other metadata, such as timestamps, component types, products, etc. The training data may be used to train a sentence fragment model (SPM), which may contain a mapping from tokens to identifiers. Based on the output from the SPM model, the source-translation pairs in the training data may be tokenized and converted to identifiers to generate tokenized training data. The tokenized training data may be used to train a machine learning model.

[0023] To control the length of the machine translation, length tokens can be inserted into the source and target texts so that the machine learning model knows the length information. To train the machine learning model to take the length into account, the training data can also contain length constraints.

[0024] The length constraint may correspond to an actual length constraint or a pseudo-length constraint. The actual length constraint may correspond to a predetermined length constraint included in the training data. When the training data does not include an actual length constraint, the pseudo-length constraint may correspond to a length constraint that is the length of the translated text. As an example, the length constraint may be represented by a number and may limit the number of characters, words, or phrases.

[0025] Length tokens may be added to the source text and the target text to indicate the length constraint. The length token may be added at the beginning of the source text. One or more length tokens may also be added after each tokenized text element of the target text (such as after each word token) to indicate the remainder of the length constraint. For example, the remainder may be represented by a number to indicate the number of remaining characters, words, or phrases that may be generated.

[0026] The length constraint can also include a randomness value during model training, since forcing the machine learning model to output exactly the same length (as opposed to a length between ranges) may not be able to maintain translation quality with such restrictive constraints. Adding a randomness value provides the machine learning model with some flexibility in generating translation lengths. The length-flexibility can be represented by a hyperparameter.

[0027] For model inference, the model can tokenize the source text and then convert it into a source identifier. The source identifier can be input into a trained machine learning model, which can output a target identifier after encoding and decoding. The target identifier can be converted and de-tokenized for machine translation.

[0028] To control the length of machine translation, model inference is similar to training. For example, a length token can be added at the beginning of the source text. Model inference differs in that a length-constrained machine translation output is generated using the hybrid approach described below, and model inference is iteratively retried with a reduced length limit.

[0029] Given a length constraint, the machine learning model should produce a translation whose length is less than or equal to the length constraint. A hybrid approach takes this into account, where the translation is generated by a machine learning model that is not length constrained, and if the translation exceeds the length constraint, the translation is again generated by the machine learning model with a length constraint. Furthermore, to improve accuracy, if the translation still exceeds the length constraint of the machine learning model with a length constraint, the length constraint is reduced and the machine learning model with a length constraint is run again. The length constraint is repeatedly reduced until the translation is of the correct length.

[0030] The process for length-constrained machine translation reasoning can include some variations to unify unconstrained and constrained models to reduce complexity. For example, the target length of the machine translation can be estimated before running the model inference. The target length can be estimated by a rule or by a model. As another example, the length flexibility can be increased to a value greater than the length limit. In order to alleviate the sparsity problem, in addition to actual examples, the training data can also include multiple randomly generated examples. As another example, the distribution of length flexibility can be changed. As another example, the training data of the unconstrained model and the length-constrained model can be merged. Here, the machine learning model can learn that if the first token is not a length token, an unconstrained translation can be output, but if the first token is a length token, a constrained translation can be output.

[0031] Figure 1A block diagram of an example length-constrained machine translation system 100 is depicted. The length-constrained machine translation system 100 can be configured to receive input data, including training data 102 and inference data 104, via a user interface. For example, the length-constrained machine translation system 100 can receive the input data as part of a call to an API that exposes the length-constrained machine translation system 100. The length-constrained machine translation system 100 can be implemented on one or more computing devices. Input to the length-constrained machine translation system 100 can also be provided via a storage medium (including remote storage connected to one or more computing devices via a network), or provided as input through a user interface on a client computing device coupled to the length-constrained machine translation system 100.

[0032] The length-constrained machine translation system 100 can be configured to receive training data 102 for training a machine learning model in translation and inference data 104 of a specified target translation. The training data 102 can correspond to a machine learning task related to translation, such as a neural network task performed by a neural network. The training data 102 can be divided into a training set, a validation set, and / or a test set. An example training / test split can be an 80 / 20 split. The machine learning model can be configured to receive any type of input data to generate output data 106 for performing machine learning tasks related to translation. As an example, the output data 106 can be any kind of score, classification, or regression output of the translation input data. Accordingly, the machine learning task can be a scoring, classification, and / or regression task related to translation. These machine learning tasks can correspond to various different applications in processing images, videos, text, speech, or other types of data for translation.

[0033] The training data 102 may be in any form suitable for training a machine learning model according to one of a variety of different learning techniques. The learning techniques for training a machine learning model may include supervised learning, unsupervised learning, and semi-supervised learning techniques. For example, the training data 102 may include a plurality of training examples that may be received as input by a machine learning model. When processing labeled training examples, the training examples may be labeled with the desired output of the machine learning model. The labels and model outputs may be evaluated by a loss function to determine an error, which may be back-propagated through the machine learning model to update the weights of the machine learning model. For example, if the machine learning task is a classification task, the training examples may be images labeled with one or more classes that classify the subject depicted in the image. As another example, supervised learning techniques may be applied to calculate the error between the outputs, where the true label of the training example is processed by the machine learning model. Any of a variety of loss or error functions suitable for the type of task to train a machine learning model may be utilized, such as a cross entropy loss for a classification task or a mean squared error for a regression task. The error gradients of different weights of a candidate model on a candidate hardware may be calculated, for example, using a back-propagation algorithm, and the weights of the model may be updated. A machine learning model can be trained until a stopping criterion is met, such as the number of iterations used for training, a maximum epoch, convergence, or when a minimum accuracy threshold is met.

[0034] In addition to metadata, the training data 102 may also include source-translation pairs, such as timestamps, component types, products, etc. The source-translation pairs may be tokenized and converted into identifiers to generate tokenized training data based on the mapping. As an example, the mapping may be determined by a sentence fragment model (SPM). The tokenized training data may be used to train a machine learning model for translation.

[0035] For example, the source text of a source-translation pair can be “cheap rental cars Miami”. The source text can be tokenized into [“_cheap”, “_rental”, “_cars”, “_Mi”, “ami”, “]] and then converted into a list of identifiers [8174, 6509, 6984, 602, 5943, 2]. “_” can represent a word boundary, <s> " can indicate the beginning of a sentence in the source text, and "< / s> " can indicate the end of a sentence in the target text of a source-translation pair. Infrequent words such as "Miami" can be divided into subwords.

[0036] The training data 102 may include a length constraint for training a machine learning model to consider length when translating. For example, a source-translation pair may be formatted as follows: (source, length constraint) -> translation. The length constraint may correspond to an actual length constraint (such as a predetermined length limit included in the training data 102) or a pseudo-length constraint (such as the length of the target text in the source-translation pair). As an example, the length constraint may be represented by a number and may limit the number of characters, words, or phrases. For example, for training data 102 including a source-translation pair: "Nice to meet you!" -> "Nice to meet you!", the pseudo-length constraint may be 7, indicated by 6 Chinese characters and 1 exclamation mark. Here, the source-translation pair may be formatted as ("Nice to meet you!", 7) -> "Nice to meet you!". In another example, for training data 102 including a source-translation pair: "Hello" -> "Hello", the pseudo-length constraint may be 2, indicated by 2 Chinese characters. Here, the source-translation pair may be formatted as ("Hello", 2) -> "Hello".

[0037] The source-translation pairs of the training data 102 may include length tokens in the source text and the target text to indicate the length constraint. For example, the length token may be represented as "TOKxx", where "xx" is the length constraint. The source text may include a length token before its text is translated. The target text may include one or more length tokens after each tokenized text element of the translated text, indicating the remainder of the length constraint. As an example, the remainder may be represented by a number to indicate the number of remaining characters, words, or phrases that may be generated.

[0038] The following are example source-translation pairs for training data 102 for a machine learning model translating from English to Spanish when the pseudo-length constraint is 49:

[0039] Source_word(source word):[" <tok49>”, "_He", "_looks", "_around", ",", "_seemingly", "_un", "sure", "_of", "_where", "_he", "_is", ".", "”]。

[0040] Target_word(Target word): [" <s>”,"_Mira”," <tok45>","_around"," <tok35>","_as"," <tok30>”,"_yes”,"TOK27>”,"_no”," <tok24>”,"_sup”," <tok20>”,"iera”," <tok16>","_where"," <tok10>","_se"," <tok7>","_tilt"," <tok1> ”,".”," <tok0>”].

[0041] Since the pseudo-length constraint is 49, the length token " <tok49>" is inserted into the source text. In the target text, <tokxx>represents the number of remaining characters that can be generated. Therefore, after outputting "_Mira", the remaining characters are reduced to 45, and after outputting "_alrededor", the remaining characters are further reduced to 35. This is repeated until all tokens have been output. Since the pseudo-length constraint is equal to the length of the target text, the last token in target_word should be " <tok0>”, indicating that no characters remain.

[0042] The length constraints in the training data 102 may also include a randomness value, since forcing the machine learning model to output exactly the same length (as opposed to a length between ranges) may not maintain translation quality with such restrictive constraints. Adding a randomness value provides the machine learning model with some flexibility in generating translation lengths.

[0043] For example, the length constraint can be expressed as follows: length_constraint = len(target) + uniform_random(0, R), where R is a hyperparameter representing the length-flexibility of the machine learning model. For example, if the length constraint is 50 characters and R is 10, the machine learning model can output translation lengths between 40 and 50 characters. Increasing R allows the machine learning model to generate a wider range of translation lengths, but also increases the sparsity of the training data 102, which may increase the difficulty of the machine learning model to learn the length constraint.

[0044] Inferred data 104 may correspond to data to be translated based on a machine learning model trained using training data 102. Inferred data 104 may include source text as well as other metadata such as timestamps, component types, products, etc. The source text of inferred data 104 may include a length token at the beginning of the text to be translated. For example, a length token may be represented as "TOKxx", where "xx" represents a length constraint.

[0045] The source text may be tokenized and converted to an identifier to generate tokenized inference data based on a mapping. As an example, the mapping may be determined by an SPM. The tokenized inference data may be input into a trained machine learning model to output a target identifier. The target identifier may be converted and de-tokenized into a machine translation. The output data 106 may correspond to the machine translation. The output data may also correspond to the target identifier to be converted to a machine translation by another computing device. Length-constrained machine translation may be performed using a hybrid approach, including unconstrained machine learning and length-constrained machine learning models, and iteratively retrying model inferences with reduced length constraints.

[0046] From the training data 102 and the inference data 104, the machine translation system 100 of the length constraint can be configured to output one or more results of the machine learning task related to the translation, which is generated as output data 106. As an example, the output data 106 can be sent to be displayed on the user display. In some embodiments, the machine translation system 100 of the length constraint can be configured to provide the output data 106 as a set of computer-readable instructions, such as one or more computer programs. The computer program can be written in any type of programming language, and according to any programming paradigm, such as declarative, procedural, compiled, object-oriented, data-oriented, functional or imperative. A computer program can be written to perform one or more different functions and operate in a computing environment, for example, on a physical device, a virtual machine or across multiple devices. The computer program can also implement the functions described herein, for example, the functions performed by a system, an engine, a module or a model.

[0047] The length-constrained machine translation system 100 may be configured to forward the output data 106 to one or more other devices configured to convert the output data 106 into an executable program written in a computer programming language. The length-constrained machine translation system 100 may also be configured to send the output data 106 to a storage device for storage and later retrieval.

[0048] The length-constrained machine translation system 100 may include an unconstrained length engine 108. The unconstrained length engine 108 may be implemented as one or more computer programs, specially configured electronic circuits, or any combination of the foregoing. The unconstrained length engine 108 may be configured to generate machine translations from the training data 102 and / or the inference data 104 using a machine learning model that is not length-constrained.

[0049] The length-constrained machine translation system 100 may also include a length restriction engine 110. The length restriction engine 110 may be implemented as one or more computer programs, specially configured electronic circuits, or any combination of the foregoing. The length restriction engine 110 may be configured to determine whether the machine translation generated by the unconstrained length engine 108 exceeds the length restriction. The length restriction engine 110 may compare the length of the machine translation output from the unconstrained machine learning model with a predetermined length restriction. If the machine translation is less than or equal to the predetermined length restriction, the machine translation may be output as output data 106. If the machine translation is greater than the predetermined length restriction, the machine translation is not output.

[0050] The length-constrained machine translation system 100 may also include a constrained length engine 112. The constrained length engine 112 may be implemented as one or more computer programs, specially configured electronic circuits, or any combination of the foregoing. The constrained length engine 112 may be configured to generate a machine translation from the training data 102 and / or the inference data 104 using a machine learning model constrained by a length limit. If the machine translation generated by the unconstrained length engine 108 exceeds the length limit, the machine translation is generated again by the constrained length engine 112.

[0051] The length constraint engine 110 may also be configured to determine whether the machine translation generated by the constraint length engine 112 exceeds a length constraint. The length constraint engine 110 may compare the length of the machine translation output from the length-constrained machine learning model to a predetermined length constraint. If the machine translation is less than or equal to the predetermined length constraint, the machine translation may be output as output data 106.

[0052] If the machine translation is greater than a predetermined length limit, the machine translation is not output. Conversely, the length constraint engine 110 can reduce the length limit of the length-constrained machine learning model, such as by 1 character, word, or phrase. The constraint length engine 112 can generate subsequent machine translations from the training data 102 and / or inference data 104 using the machine learning model constrained by the reduced length limit. The length constraint engine 110 can iteratively reduce the length limit of the length-constrained machine learning model, and the constraint length engine 112 can iteratively generate machine translations based on the iteratively reduced length limit until the generated machine translation meets the length limit, such as by being less than or equal to the original length limit.

[0053] Figure 2 A block diagram of an example environment 200 for implementing a length-constrained machine translation system is depicted. The system 200 may be implemented on one or more devices having one or more processors in one or more locations, such as in a server computing device 202. The client computing device 204 and the server computing device 202 may be communicatively coupled to one or more storage devices 206 via a network 208. The storage device 206 may be a combination of volatile and non-volatile memory and may be located in the same or different physical location as the computing devices 202, 204. For example, the storage device 206 may include any type of non-transitory computer-readable medium capable of storing information, such as a hard drive, a solid-state drive, a tape drive, an optical storage device, a memory card, a ROM, a RAM, a DVD, a CD-ROM, a writeable and a read-only memory.

[0054] The server computing device 202 may include one or more processors 210 and memory 212. The memory 212 may store information accessible by the processor 210, including instructions 214 that may be executed by the processor 210. The memory 212 may also include data 216 that may be retrieved, manipulated, or stored by the processor 210. The memory 212 may be a non-transitory computer-readable medium, such as volatile and non-volatile memory, capable of storing information accessible by the processor 210. The processor 210 may include one or more central processing units (CPUs), graphics processing units (GPUs), field programmable gate arrays (FPGAs), and / or application specific integrated circuits (ASICs), such as tensor processing units (TPUs).

[0055] Instructions 214 may include one or more instructions that, when executed by processor 210, cause one or more processors to perform actions defined by instructions 214. Instructions 214 may be stored in an object code format for direct processing by processor 210, or in other formats including interpretable scripts or a collection of independent source code modules that are interpreted on demand or pre-compiled. Instructions 214 may include instructions for implementing a length-constrained machine translation system 218, which may correspond to Figure 1 The length-constrained machine translation system 100. The length-constrained machine translation system 218 can be executed using the processor 210 and / or using another processor remote from the server computing device 202.

[0056] Data 216 may be retrieved, stored, or modified by processor 210 in accordance with instructions 214. Data 216 may be stored in a computer register, in a relational or non-relational database as a table with a plurality of different fields and records, or as a JSON, YAML, proto, or XML document. Data 216 may also be formatted in a computer readable format, such as, but not limited to, binary values, ASCII, or Unicode. In addition, data 216 may include information sufficient to identify the relevant information, such as numbers, descriptive text, proprietary codes, pointers, references to data stored in other storage (including other network locations), or information used by a function to calculate the relevant data.

[0057] The client computing device 204 may also be configured similarly to the server computing device 202, with one or more processors 220, memory 222, instructions 224, and data 226. The client computing device 204 may also include user input 228 and user output 230. The user input 228 may include any suitable mechanism or technology for receiving input from a user, such as a keyboard, mouse, mechanical actuator, soft actuator, touch screen, microphone, and sensor.

[0058] The server computing device 202 may be configured to transmit data to the client computing device 204, and the client computing device 204 may be configured to display at least a portion of the received data on a display implemented as part of the user output 230. The user output 230 may also be used to display an interface between the client computing device 204 and the server computing device 202. The user output 230 may alternatively or additionally include one or more speakers, transducers or other audio outputs, haptic interfaces or other tactile feedback that provide non-visual and non-auditory information to a platform user of the client computing device 204.

[0059] although Figure 2 The processors 210, 220 and memories 212, 222 are shown as being within the computing devices 202, 204, but the components described herein may include multiple processors and memories that may operate in different physical locations and are not within the same computing device. For example, some of the instructions 214, 224 and data 216, 226 may be stored on a removable SD card, while other instructions are stored within a read-only computer chip. Some or all of the instructions and data may be stored in a location physically away from the processors 210, 220 but still accessible by the processors 210, 220. Similarly, the processors 210, 220 may include a collection of processors that may perform concurrent and / or sequential operations. The computing devices 202, 204 may each include one or more internal clocks that provide timing information that may be used for time measurement of operations and programs run by the computing devices 202, 204.

[0060] The server computing device 202 can be connected to a data center 232 that houses any number of hardware accelerators 232A-N via a network 208. The data center 232 can be one of multiple data centers or other facilities where various types of computing devices, such as hardware accelerators, are located. The computing resources housed in the data center 232 can be designated for deploying a machine learning model for translation as described herein.

[0061] The server computing device 202 may be configured to receive a request to process data from the client computing device 204 on a computing resource in the data center 232. For example, the environment 200 may be part of a computing platform that is configured to provide various services to users through various user interfaces and / or application programming interfaces (APIs) that expose platform services. The various services may include generating one or more machine learning models for translation. The client computing device 204 may send data specifying the text to be translated along with a length limit for the translated text. The length-constrained machine translation system 218 may receive data specifying the text to be translated and the length limit, and in response, generate output data including the translated text that complies with the length limit.

[0062] As other examples of potential services provided by the platform implementing environment 200, server computing device 202 may maintain various machine learning models based on different potential length limits or translation details available at data center 232. For example, server computing device 202 may maintain different families for deploying neural networks on various types of TPUs and / or GPUs housed in data center 232 or otherwise available for processing.

[0063] Figure 3 A block diagram 300 is depicted showing one or more machine translation model architectures 302, and more specifically, 302A-N for each architecture, for deployment in a data center 304 housing a hardware accelerator 306 on which the deployed machine translation model 302 is to be executed to provide translations subject to length constraints. The hardware accelerator 306 may be any type of processor, such as a CPU, GPU, FPGA, or ASIC, such as a TPU.

[0064] The architecture 302 of the machine translation model may refer to the characteristics of the model, such as the characteristics of the layers of the model, how the layers process inputs, or how the layers interact with each other. The machine translation model architecture 302 may be used for a machine learning model that is not length-constrained or a machine learning model that is length-constrained. The machine translation model architecture 302 may correspond to an encoder-decoder architecture, such as a transformer. Input data (such as input text) may be parsed into tokens, such as by a byte pair encoding tokenizer. Each token may be converted into a vector, such as via a word embedding.

[0065] The encoder may include encoding layers that iteratively process input data layer by layer, and the decoder may include decoding layers that iteratively process output data of the encoder layer by layer. Each encoder layer may generate an encoding containing information about which parts of the input data are related to each other. Each encoder layer then sends its encoding as input to the next encoder layer. Each decoder layer may consider all encodings and use their contextual information to generate an output sequence. For each part of the input, an attention unit (such as a scaled dot product attention unit) may weight the relevance of each other part and produce an output from them. Each decoder layer may have an additional attention mechanism to extract information from the output of the previous decoder before the decoder layer draws information from the encoding. Both the encoder layer and the decoder layer may include a feedforward neural network for additional processing of the output, as well as residual connections and layer normalization steps.

[0066] One or more machine translation model architectures 302 may be generated that may output translation results that comply with the length constraints.

[0067] Return to reference Figure 2 , devices 202, 204 and data center 232 are able to communicate directly and indirectly over network 208. For example, using network sockets, a client computing device 204 can connect to a service operating in data center 232 over the Internet Protocol. Devices 202, 204 can establish listening sockets that can accept initiated connections for sending and receiving information. The network 208 itself can include a variety of configurations and protocols, including the Internet, the World Wide Web, an intranet, a virtual private network, a wide area network, a local network, and a private network using one or more company-proprietary communication protocols. The network 208 can support a variety of short-range and long-range connections. The short-range and long-range connections can be made over different bandwidths, such as those typically associated with a wireless network. 2.402 GHz to 2.480 GHz, usually associated with the 2.4 GHz and 5 GHz associated with communication protocols; or with various communication standards such as for wireless broadband communication Additionally or alternatively, the network 208 may also support wired connections between the devices 202, 204 and the data center 232, including through various types of Ethernet connections.

[0068] Despite Figure 2 A single server computing device 202, client computing device 204, and data center 232 are shown in FIG, but it should be understood that aspects of the present disclosure may be implemented according to a variety of different configurations and numbers of computing devices, including in paradigms for sequential or parallel processing, or through a distributed network of multiple devices. In some embodiments, aspects of the present disclosure may be performed on a single device connected to a hardware accelerator configured to process a machine learning model, and any combination thereof.

[0069] Figure 4 A flow chart of an example process 400 for training a machine translation model is depicted. The example process 400 may be performed on a system of one or more processors in one or more locations, such as Figure 1 A machine translation system 100 with length constraints.

[0070] As shown in block 410, the unconstrained length engine 108 and / or the constrained length engine 112 may receive training data 102. The training data 102 may include source-translation pairs. The training data 102 for the unconstrained length engine 108 may not include length constraints, while the training data 102 for the constrained length engine 112 may include length constraints. The length constraints may correspond to actual length constraints or pseudo-length constraints. The length constraints may also include randomness values ​​to add flexibility to the machine translation length.

[0071] As shown in block 420, the unconstrained length engine 108 and / or the constrained length engine 112 can tokenize and convert the training data 102. The unconstrained length engine 108 can convert the training data 102 into identifiers based on a mapping that can be determined by the SPM. The constrained length engine 112 can tokenize the training data 102 by inserting length tokens in the source text and the target text of the source-translation pair to represent the length constraint. The source text can include the length token before its text is translated. The target text can include one or more length tokens after each tokenized text element of the translated text, indicating the remainder of the length constraint. Then, the constrained length engine 112 can convert the tokenized training data 102 into identifiers based on a mapping that can be determined by the SPM.

[0072] As shown in block 430, the unconstrained length engine 108 may train an unconstrained machine learning model for translation based on the training data 102 converted to identifiers. The unconstrained length engine 108 may train the unconstrained machine learning model using a variety of learning techniques, including supervised learning, unsupervised learning, or semi-supervised learning. The unconstrained machine learning model may correspond to a transformer having an encoder-decoder architecture.

[0073] As shown in block 440, the constraint length engine 112 may train a length constraint machine learning model for translation based on the training data 102 that is tokenized and converted to an identifier. The constraint length engine 112 may train the length constraint machine learning model using a variety of learning techniques, including supervised learning, unsupervised learning, or semi-supervised learning. The constraint machine learning model may correspond to a transformer having an encoder-decoder architecture.

[0074] Figure 5 A flow chart of an example process 500 for length-constrained machine translation is depicted. The example process 500 may be performed on a system of one or more processors in one or more locations, such as Figure 1 A machine translation system 100 with length constraints.

[0075] As shown in block 510, the unconstrained length engine 108 may receive the inference data 104. The inference data 104 may include source text with a length token at the beginning of the text to be translated to indicate a length constraint.

[0076] As shown in block 520 , the unconstrained length engine 108 may perform machine translation using the unconstrained machine learning model to generate a translation.

[0077] As shown in block 530, the length limit engine 110 may determine whether the translation from the unconstrained machine learning model exceeds a length limit. The length limit engine 110 may compare the length of the translation from the unconstrained machine learning model to the length limit. If the translation is less than or equal to the length limit, the translation may be output.

[0078] If the translation is greater than the length limit, the constrained length engine 112 may perform machine translation using the constrained machine learning model to generate another translation, as shown in block 540. The constrained machine learning model may output additional length tokens in its output translation compared to the unconstrained machine learning model output. If additional length tokens are output, the additional length tokens may be removed by post-processing.

[0079] As shown in block 550, the length constraint engine 110 may determine whether the translation from the constrained machine learning model exceeds a length constraint. The length constraint engine 110 may compare the length of the translation from the constrained machine learning model to the length constraint. If the translation is less than or equal to the length constraint, the translation may be output.

[0080] If the translation is greater than the length limit, the length limit engine 110 may reduce the length limit, as shown in block 560. For example, the length limit engine 110 may reduce the length limit by 1 character, word, or phrase.

[0081] As shown in box 570, the constraint length engine 112 can perform a subsequent machine translation using the constraint machine learning model with the reduced length limit to generate another translation. The length limit engine 110 can determine whether the subsequent translation from the constraint machine learning model exceeds the original length limit. If the translation is less than or equal to the original length limit, the translation can be output. If the translation is greater than the original length limit, the length limit engine 110 can reduce the length limit again, such as by 1 character, word, or phrase. The length limit engine 110 and the constraint length engine 112 can iteratively reduce the length limit and perform machine translation using the constraint machine learning model until the translation meets the original length limit.

[0082] The general process of length-constrained machine translation inference can be further described as follows:

[0083] Input: source text source, length limit L, unconstrained MT model m1, length-constrained MT model m2, maximum number of attempts max_retry_count.

[0084] Output: length-constrained MT output.

[0085] mt=runInference(m1,source)

[0086] current_limit=L

[0087] while len(mt)>L and max_retry_count>=0:

[0088] mt=runInference(m2,source,current_limit)

[0089] current_limit=current_limit–1

[0090] max_retry_count=max_retry_count–1

[0091] return mt

[0092] Figure 6 A block diagram of an example length-constrained machine translation system 600 is depicted in which unconstrained and constrained machine learning models can be unified to reduce complexity. The training data 602, inference data 604, and output data 606 may correspond to Figure 1 The training data 102, inference data 104 and output data 106 are provided.

[0093] The length-constrained machine translation system 600 may include a combined constrained / unconstrained length engine 608. The combined length engine 608 may be implemented as one or more computer programs, specially configured electronic circuits, or any combination of the foregoing. The combined length engine 608 may be configured to train a machine learning model for length-constrained translation and perform length-constrained translation using the trained machine learning model.

[0094] The length-constrained machine translation system 600 may also include a length restriction engine 610. The length restriction engine 610 may be implemented as one or more computer programs, specially configured electronic circuits, or any combination of the foregoing.

[0095] For example, the length restriction engine 610 can be configured to estimate the target length of the machine translation before running the model inference using the combined length engine 608. The length restriction engine 610 can estimate the target length by rules or by models. For rule-based estimation, as an example, the length restriction engine 610 can estimate the target length by multiplying the length of the source text by a predetermined factor. For model-based estimation, the length restriction engine 610 can estimate the target length by running a machine learning model for length estimation.

[0096] As another example, the length limit engine 610 may increase the length flexibility to a value greater than the length limit.To mitigate the sparsity problem, the training data 602 may include a plurality of randomly generated examples in addition to actual examples.

[0097] As yet another example, the combined length engine 608 can change the distribution of length flexibility. Here, the training data 602 can be generated using lower length flexibility values ​​and higher length flexibility values. The combined length engine 608 can merge two training data sets.

[0098] As yet another example, the combined length engine 608 can merge the training data 602 of the unconstrained model and the length-constrained model. Here, the machine learning model can learn that if the first token is not a length token, an unconstrained translation can be output as output data 606, but if the first token is a length token, a constrained translation can be output as output data 606.

[0099] Aspects of the present disclosure may be implemented in digital circuits, computer-readable storage media as one or more computer programs, or a combination of one or more of the foregoing. The computer-readable storage medium may be non-transitory, for example, as one or more instructions executable by a cloud computing platform and stored on a tangible storage device.

[0100] The phrase "configured to" is used in different contexts in relation to a portion of a computer system, hardware, or computer program. When a system is referred to as being configured to perform one or more operations, this means that the system has appropriate software, firmware, and / or hardware installed on the system that, when operated, causes the system to perform the one or more operations. When some hardware is referred to as being configured to perform one or more operations, this means that the hardware includes one or more circuits that, when operated, receive input and generate output corresponding to the one or more operations based on the input. When a computer program is referred to as being configured to perform one or more operations, this means that the computer program includes one or more program instructions that, when executed by one or more computers, cause the one or more computers to perform the one or more operations.

[0101] Unless otherwise stated, the foregoing alternative examples are not mutually exclusive, but may be implemented in various combinations to achieve unique advantages. Since these and other variations and combinations of the features discussed above may be utilized without departing from the subject matter defined by the claims, the foregoing description of the embodiments should be made by way of illustration rather than by way of limitation of the subject matter defined by the claims. In addition, the provision of examples described herein and the terms "such as", "including", etc. should not be interpreted as limiting the subject matter of the claims to specific examples; rather, these examples are intended to illustrate only one of many possible embodiments. In addition, the same reference numerals in different figures may identify the same or similar elements. < / tokxx> < / tok1> < / s>

Claims

1. A method for length-constrained machine translation, comprising: Receiving, by one or more processors, data corresponding to source text; translating, by one or more processors, the source text using the machine learning model without length constraints to generate data corresponding to the first translated text; determining, by one or more processors, that the first translated text exceeds a length limit; translating, by one or more processors, the source text using the length-constrained machine learning model to generate data corresponding to a second translated text; as well as Data corresponding to the second translated text is output by the one or more processors.

2. The method according to claim 1, further comprising: determining, by one or more processors, that the second translated text exceeds a text length limit; as well as reducing, by one or more processors, a length constraint of a length-constrained machine learning model; Therein, a length limit of the length-constrained machine learning model is iteratively reduced until the translated text translated using the length-constrained machine learning model does not exceed the length limit.

3. The method according to claim 1 or claim 2, further comprising: A length token is added to the beginning of the source text by one or more processors to indicate a length limit.

4. The method according to any one of claims 1 to 3, further comprising: The length of the first translated text is estimated by one or more processors.

5. The method of any one of claims 1 to 4, further comprising increasing the randomness value of the length limit using one or more processors.

6. The method according to any one of claims 1 to 5, further comprising: A length-constrained machine learning model is trained, using one or more processors, using training data including a plurality of source text and translated text pairs, each source text and translated text pair having one or more length tokens appended thereto.

7. The method according to claim 6, wherein: The source text of each pair includes a length token, which is added to the beginning of the source text to indicate the text length limit.

8. The method according to claim 6 or claim 7, wherein: The translated text for each pair includes one or more length tokens added after each tokenized text element to represent the remainder of the text length limit.

9. The method according to any one of claims 6 to 8 further includes merging the training data with the training data of the machine learning model that is not length-constrained using one or more processors.

10. A system comprising: one or more processors; as well as One or more storage devices coupled to the one or more processors and storing instructions that, when executed by the one or more processors, cause the one or more processors to perform operations for length-constrained machine translation, the operations comprising: receiving data corresponding to a source text; translating the source text using a machine learning model that is not length-constrained to generate data corresponding to the first translated text; Determining that the first translation text exceeds the length limit; translating a source text using a length-constrained machine learning model to generate data corresponding to a second translated text; and Data corresponding to the second translated text is output.

11. The system according to claim 10, wherein: The operations also include: determining that the second translated text exceeds the text length limit; and Reduce the length limit of length-constrained machine learning models; Therein, a length limit of the length-constrained machine learning model is iteratively reduced until the translated text translated using the length-constrained machine learning model does not exceed the length limit.

12. A system according to claim 10 or claim 11, wherein: The operations also include adding a length token to the beginning of the source text to indicate a length limit.

13. A system according to any one of claims 10 to 12, wherein: The operations also include estimating a length of the first translated text.

14. A system according to any one of claims 10 to 13, wherein: The operations also include increasing a randomness value of the length limit.

15. A system according to any one of claims 10 to 14, wherein: The operations also include training a length-constrained machine learning model using training data including a plurality of source text and translated text pairs, each source text and translated text pair having one or more length tokens appended thereto.

16. The system of claim 15, wherein: The source text of each pair includes a length token, which is added to the beginning of the source text to indicate the text length limit.

17. A system according to claim 15 or claim 16, wherein: The translated text for each pair includes one or more length tokens added after each tokenized text element to represent the remainder of the text length limit.

18. A system according to any one of claims 15 to 17, wherein: The operations also include merging the training data with training data of a machine learning model that is not length constrained.

19. A non-transitory computer-readable medium for storing instructions that, when executed by one or more processors, cause the one or more processors to perform operations for length-constrained machine translation, the operations comprising: receiving data corresponding to a source text; translating the source text using a machine learning model that is not length-constrained to generate data corresponding to the first translated text; Determining that the first translation text exceeds the length limit; translating a source text using a length-constrained machine learning model to generate data corresponding to a second translated text; and Data corresponding to the second translated text is output.

20. The non-transitory computer readable medium of claim 19, wherein: The operations also include: determining that the second translated text exceeds the text length limit; and Reduce the length limit of length-constrained machine learning models; Therein, a length limit of the length-constrained machine learning model is iteratively reduced until the translated text translated using the length-constrained machine learning model does not exceed the length limit.

21. The non-transitory computer readable medium of claim 19 or claim 20, wherein: The operations also include adding a length token to the beginning of the source text to indicate a length limit.

22. The non-transitory computer readable medium of any one of claims 19 to 21, wherein: The operations also include estimating a length of the first translated text.

23. The non-transitory computer readable medium of any one of claims 19 to 22, wherein: The operations also include increasing a randomness value of the length limit.

24. The non-transitory computer readable medium of any one of claims 19 to 23, wherein: The operations also include training a length-constrained machine learning model using training data including a plurality of source text and translated text pairs, each source text and translated text pair having one or more length tokens appended thereto.

25. The non-transitory computer readable medium of claim 24, wherein: The source text of each pair includes a length token, which is added to the beginning of the source text to indicate the text length limit.

26. The non-transitory computer readable medium of claim 24 or claim 25, wherein: The translated text for each pair includes one or more length tokens added after each tokenized text element to represent the remainder of the text length limit.

27. The non-transitory computer readable medium of any one of claims 24 to 26, wherein: The operations also include merging the training data with training data of a machine learning model that is not length constrained.

Citation Information

Cited By

  • Content generation method and related equipment

    CN121479080A