Attention-based sequence-to-sequence neural network
Patent Information
- Application Number
- JP2024005428
- Authority / Receiving Office
- JP · JP
- Patent Type
- Patents
- Current Assignee / Owner
- Priority Date
- 2017-08-04
- Filing Date
- 2024-01-17
- Publication Date
- 2025-02-19
- Estimated Expiration
- 2038-05-23
AI Technical Summary
【0009】 本明細書の主題の1つまたは複数の実施形態の詳細は、添付の図面および以下の説明に示される。主題のその他の特徴、態様、および利点は、説明、図面、および特許請求の範囲から明らかとなろう。
Smart Images

Figure 0007633438000002 
Figure 0007633438000003 
Figure 0007633438000004
Abstract
Description
[Technical field]
[0001] CROSS-REFERENCE TO RELATED APPLICATIONS This application is a non-provisional application and claims priority to U.S. Provisional Application No. 62 / 510,256, filed May 23, 2017, and U.S. Provisional Application No. 62 / 541,594, filed August 4, 2017, the entire contents of which are incorporated herein by reference.
[0002] This specification relates to transforming sequences using neural networks. [Background technology]
[0003] A neural network is a machine learning model that employs one or more layers of nonlinear units to predict an output for a received input. Some neural networks include one or more hidden layers in addition to an output layer. The output of each hidden layer is used as the input to the next layer in the network, i.e. the next hidden layer or the output layer. Each layer of the network generates an output from the received input according to the current values of a respective set of parameters. Summary of the Invention [Means for solving the problem]
[0004] This specification describes a system, implemented as a computer program on one or more computers at one or more locations, that generates an output sequence, i.e., transforms an input sequence, from an input sequence that includes a respective input at each of a plurality of positions in an input order, to an output sequence that includes a respective output at each of a plurality of positions in an output order. In particular, the system generates the output sequence using an encoder neural network and a decoder neural network, both of which are attention-based.
[0005] Particular implementations of the subject matter described in this specification can be implemented to realize one or more of the following advantages.
[0006] Many existing approaches to sequence conversion using neural networks use recurrent neural networks in the encoder and decoder. Although these kinds of networks can achieve good performance in sequence conversion tasks, their computations are inherently sequential, i.e., the recurrent neural network generates an output at a current time step conditioned on the hidden state of the recurrent neural network at the previous time step. This sequential property hinders parallelization, resulting in long training and inference times and corresponding workloads that utilize large amounts of computational resources.
[0007] On the other hand, because the encoder and decoder of the described sequence-conversion neural network are attention-based, the sequence-conversion neural network can convert sequences more quickly, can be trained faster, or both, since the operation of the network can be parallelized more easily. That is, because the described sequence-conversion neural network relies entirely on the attention mechanism to extract global dependencies between inputs and outputs and does not employ any recurrent neural network layers, problems associated with long training and inference times and high resource usage caused by the sequential nature of recurrent neural network layers are mitigated.
[0008] Moreover, sequence-transformation neural networks can transform sequences more accurately than existing networks based on convolutional or recurrent layers, even if the training and inference times are short. In particular, in conventional models, the number of operations required to relate signals from two arbitrary input or output positions grows with the distance between the positions, which depends, for example, linearly or logarithmically on the model architecture. This makes it even more difficult to learn dependencies between distant positions during training. In the currently described sequence-transformation neural network, this number of operations is reduced to a constant number of operations through the use of attention (and, in particular, self-attention), without relying on recursion or convolution. Self-attention, sometimes referred to as intra-attention, is an attention mechanism that relates different positions of a single sequence to compute a representation of the sequence. The use of attention mechanisms allows sequence-transformation neural networks to effectively learn dependencies between distant positions during training, which can increase the accuracy of sequence-transformation neural networks in various transformation tasks, such as machine translation. Indeed, the described sequence-to-sequence neural networks are easier to train and produce output more quickly than conventional machine translation neural networks, yet can achieve state-of-the-art results for machine translation tasks. Sequence-to-sequence neural networks can also exhibit improved performance over conventional machine translation neural networks without task-specific tuning through the use of attention mechanisms.
[0009] The details of one or more embodiments of the subject matter herein are set forth in the accompanying drawings and the description below. Other features, aspects, and advantages of the subject matter will become apparent from the description, drawings, and claims. [Brief description of the drawings]
[0010] [Figure 1]FIG. 1 illustrates an example neural network system. [Diagram 2] FIG. 1 illustrates the attention mechanism applied by the attention sublayer in the subnetworks of the encoder neural network and the decoder neural network. [Diagram 3] 4 is a flow diagram illustrating an example process for generating an output sequence from an input sequence. DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS
[0011] Like numbers and designations in the various drawings indicate like elements.
[0012] This specification describes a system, implemented as a computer program on one or more computers at one or more locations, that generates an output sequence, i.e., transforms an input sequence, from an input sequence that includes respective inputs at each of a plurality of positions in an input order to an output sequence that includes respective outputs at each of a plurality of positions in an output order.
[0013] For example, the system may be a neural machine translation system, i.e. if the input sequence is a sequence of words in a source language, e.g. a sentence or a phrase, the output sequence may be a translation of the input sequence into a target language, i.e. a sequence of words in the target language that represents the sequence of words in the source language.
[0014] As another example, the system may be a speech recognition system, i.e., if the input sequence is a sequence of audio data representing an oral speech, the output sequence may be a sequence of graphemes, features, or words that represent the speech, i.e., that is a transcription of the input sequence.
[0015] As another example, the system may be a natural language processing system. For example, if the input sequence is a sequence of words in a source language, such as a sentence or phrase, the output sequence may be a summary of the input sequence in the source language, i.e., a sequence that has fewer words than the input sequence but preserves the essential meaning of the input sequence. As another example, if the input sequence is a sequence of words that form a question, the output sequence may be a sequence of words that form an answer to the question.
[0016] As another example, the system may be part of a computer-aided medical diagnosis system, for example, the input sequence may be a sequence of data from an electronic medical record and the output sequence may be a sequence of predicted treatments.
[0017] As another example, the system may be part of an image processing system. For example, the input sequence may be images, i.e. a sequence of intensities from the images, and the output may be a sequence of text describing the images. As another example, the input sequence may be a sequence of text or different contexts, and the output sequence may be images describing the contexts.
[0018] In particular, the neural network includes an encoder neural network and a decoder neural network. In general, both the encoder and the decoder are attention-based, i.e., both apply an attention mechanism over their respective received inputs while transforming the input sequence. In some cases, neither the encoder nor the decoder includes a convolutional layer or a recurrent layer.
[0019] 1 illustrates an example neural network system 100. Neural network system 100 is an example of a system in which the systems, components, and techniques described below may be implemented, implemented as a computer program on one or more computers at one or more locations.
[0020] The neural network system 100 receives an input sequence 102 and processes the input sequence 102 to convert the input sequence 102 into an output sequence 152 .
[0021] The input sequence 102 has a respective network input at each of a plurality of input positions in an input order, and the output sequence 152 has a respective network output at each of a plurality of output positions in an output order, i.e., the input sequence 102 has a plurality of inputs arranged according to an input order, and the output sequence 152 has a plurality of outputs arranged according to an output order.
[0022] As explained above, the neural network system 100 may perform any of a variety of tasks that require processing sequential inputs to produce sequential outputs.
[0023] The neural network system 100 includes an attention-based sequence-to-sequence neural network 108 , which includes an encoder neural network 110 and a decoder neural network 150 .
[0024] The encoder neural network 110 is configured to receive the input sequence 102 and generate a respective encoded representation of each network input in the input sequence. Typically, the encoded representations are vectors or other ordered collections of numerical values.
[0025] A decoder neural network 150 is then configured to use the encoded representation of the network inputs to generate an output sequence 152 .
[0026] In general, and as described in more detail below, both the encoder 110 and the decoder 150 are attention-based. In some cases, neither the encoder nor the decoder includes convolutional or recurrent layers.
[0027] The encoder neural network 110 includes an embedding layer 120 and a sequence of one or more encoder sub-networks 130. In particular, as shown in FIG.
[0028] The embedding layer 120 is configured to, for each network input in the input sequence, map the network input to a numerical representation of the network input in the embedding space, e.g., to a vector in the embedding space. The embedding layer 120 then provides the numerical representation of the network input to a first sub-network in the sequence of encoder sub-networks 130, i.e., the first of the N encoder sub-networks 130.
[0029] In particular, in some embodiments, the embedding layer 120 is configured to map each network input to an embedded representation of the network input, and then combine, e.g., sum or average, the embedded representations of the network inputs with positional embeddings of the input positions of the network inputs in input order to generate a combined embedded representation of the network inputs. That is, each position in the input sequence has a corresponding embedding, and for each network input, the embedding layer 120 combines the embedded representation of the network input with an embedding of the network input's position in the input sequence. Such positional embeddings can enable the model to fully exploit the order of the input sequence without relying on recursion or convolution.
[0030] In some cases, the positional embeddings are learned. As used herein, the term "learned" means that the actions or values are adjusted during training of the sequence-to-sequence neural network 108. Training of the sequence-to-sequence neural network 108 is described below with reference to FIG.
[0031] In some cases, the position embedding is fixed and different for each position. For example, the embedding may consist of sine and cosine functions of different frequencies, satisfying the following equation:
[0032]
number
[0033] where pos is the position, i is the dimension in the position embedding, and d model is the dimensionality of the position embedding (and of other vectors processed by neural network 108). The use of sinusoidal position embeddings allows the model to be extrapolated to longer sequence lengths, thereby increasing the range of applications in which the model can be employed.
[0034] The combined embedded representation is then used as the numerical representation of the network input.
[0035] Each of the encoder subnetworks 130 is configured to receive a respective encoder subnetwork input for each of a plurality of input locations, and to generate a respective subnetwork output for each of a plurality of input locations.
[0036] The encoder sub-network output produced by the last encoder sub-network in the sequence is then used as the encoded representation of the network input.
[0037] For the first encoder subnetwork in the sequence, the encoder subnetwork input is the numerical representation generated by the embedding layer 120, and for each encoder subnetwork other than the first encoder subnetwork in the sequence, the encoder subnetwork input is the encoder subnetwork output of the previous encoder subnetwork in the sequence.
[0038] Each encoder sub-network 130 includes an encoder self-attention sub-layer 132. The encoder self-attention sub-layer 132 is configured to receive a sub-network input for each of a plurality of input positions, and for each particular input position in input order, apply an attention mechanism across the encoder sub-network inputs at the input position using one or more queries derived from the encoder sub-network inputs at the particular input position to generate a respective output for the particular input position. In some cases, the attention mechanism is a multi-head attention mechanism. The attention mechanism and how it is applied by the encoder self-attention sub-layer 132 are described in more detail below with reference to FIG. 2.
[0039] In some implementations, each of the encoder sub-networks 130 also includes a residual connection layer that combines the output of the encoder self-attention sublayer with the input to the encoder self-attention sublayer to generate the encoder self-attention residual output, and a layer normalization layer that applies layer normalization to the encoder self-attention residual output. These two layers are collectively referred to as the "add and normalize" operation in FIG. 1.
[0040] Some or all of the encoder sub-networks may also include a per-position feedforward layer 134 configured to operate at each position in the input sequence, respectively. In particular, for each input sequence position, the feedforward layer 134 is configured to receive an input at the input position and apply a sequence of transformations to the input at the input position to generate an output for the input position. For example, the sequence of transformations may include two or more learned linear transformations, each divided by an activation function, such as a nonlinear element-wise activation function, such as a ReLU activation function, which may enable faster and more efficient training on large and complex databases. The input received by the per-position feedforward layer 134 may be the output of a layer normalization layer, if residual and layer normalization layers are included, or the output of the encoder self-attention sub-layer 132, if residual and layer normalization layers are not included. The transformations applied by the layer 134 are generally the same for each input position (but different feedforward layers of different sub-networks apply different transformations).
[0041] In the case where the encoder sub-network 130 includes a per-position feedforward layer 134, the encoder sub-network may also include a residual connection layer that combines the output of the per-position feedforward layer with the input to the per-position feedforward layer to generate a residual output per encoder position, and a layer normalization layer that applies layer normalization to the residual output per encoder position. These two layers are also collectively referred to as the "add and normalize" operation in FIG. 1. The output of this layer normalization layer may then be used as the output of the encoder sub-network 130.
[0042] Once the encoder neural network 110 has generated the encoded representation, the decoder neural network 150 is configured to generate an output sequence in an autoregressive manner.
[0043] That is, at each of a number of generation time steps, the decoder neural network 150 generates an output sequence by generating a network output at a corresponding output position conditioned on (i) the encoded representation and (ii) the network output at the output position that precedes the output position in the output order.
[0044] In particular, for a given output position, the decoder neural network generates an output that defines a probability distribution over the possible network outputs at the given output position. The decoder neural network can then select a network output for the output position by sampling from the probability distribution, or by selecting the network output with the highest probability.
[0045] Because the decoder neural network 150 is autoregressive, at each generation time step, the decoder 150 operates on the network outputs already generated prior to the generation time step, i.e., the network outputs at the output positions preceding the corresponding output positions in the output order. In some embodiments, to ensure that this is the case during inference and training, at each generation time step, the decoder neural network 150 shifts the already generated network outputs one output order position to the right (i.e., introduces one position offset into the already generated network output sequence) and masks certain operations (as described in more detail below) so that the positions can only pay attention to positions up to and including that position in the output sequence (and not subsequent positions). The remainder of the following description describes the various components of the decoder 150 operating on data at output positions preceding the given output position (and not on data at any other output positions) when generating a given output at a given output position, although it will be understood that this type of conditioning can be effectively implemented using the shifts described above.
[0046] The decoder neural network 150 includes an embedding layer 160, a sequence of decoder subnetworks 170, a linear layer 180, and a softmax layer 190. In particular, as shown in Figure 1, the decoder neural network includes N decoder subnetworks 170. However, although the example of Figure 1 shows the encoder 110 and the decoder 150 including the same number of subnetworks, in some cases, the encoder 110 and the decoder 150 include different numbers of subnetworks. That is, the decoder 150 may include more or fewer subnetworks than the encoder 110.
[0047] The embedding layer 160 is configured to, at each generation time step, for each network output at an output position preceding the current output position in output order, map the network output to a numerical representation of the network output in the embedding space. The embedding layer 160 then provides the numerical representation of the network output to a first sub-network 170 in the sequence of decoder sub-networks, i.e., the first decoder sub-network 170 of the N decoder sub-networks.
[0048] In particular, in some embodiments, embedding layer 160 is configured to map each network output to an embedded representation of the network output and combine the embedded representation of the network output with a positional embedding of the output position of the network output in output order to generate a combined embedded representation of the network output. The combined embedded representation is then used as a numerical representation of the network output. Embedding layer 160 generates the combined embedded representation in the same manner as described above with reference to embedding layer 120.
[0049] Each decoder subnetwork 170 is configured to receive, at each generation time step, a respective decoder subnetwork input for each of a plurality of output positions preceding the corresponding output position, and to generate a respective decoder subnetwork output for each of a plurality of output positions preceding the corresponding output position (or equivalently, if the output sequence is being moved to the right, a respective network output at positions up to and including the current output position).
[0050] In particular, each decoder sub-network 170 includes two different attention sub-layers: a decoder self-attention sub-layer 172 and an encoder-decoder attention sub-layer 174 .
[0051] Each decoder self-attention sublayer 172 is configured to receive, at each generation time step, an input for each output position preceding a corresponding output position, and for each particular output position, apply an attention mechanism over the input at the output position preceding the corresponding position using one or more queries derived from the input at the particular output position to generate an updated representation of the particular output position. That is, the decoder self-attention sublayer 172 applies an attention mechanism that is masked so as not to attend to or process any data that is not at a position preceding the current output position in the output sequence.
[0052] Meanwhile, each Encoder-Decoder Attention Sublayer 174 is configured to receive inputs for each output position preceding the corresponding output position at each generation time step, and for each of the output positions, to apply an attention mechanism over the representations encoded at the input positions using one or more queries derived from the output position's inputs to generate an updated representation of the output position. Thus, the Encoder-Decoder Attention Sublayer 174 applies attention over the encoded representations, whereas the Encoder Self-Attention Sublayer 172 applies attention over the inputs at the output positions.
[0053] The attention mechanisms applied by each of these attention sublayers are described in further detail below with reference to FIG.
[0054] 1, the decoder self-attention sublayer 172 is shown as being before the encoder-decoder attention sublayer in the processing order within the decoder sub-network 170. However, in other examples, the decoder self-attention sublayer 172 may be after the encoder-decoder attention sublayer 174 in the processing order within the decoder sub-network 170, or different sub-networks may have different processing orders.
[0055] In some embodiments, each decoder sub-network 170 includes a residual connection layer after the decoder self-attention sublayer 172, after the encoder-decoder attention sublayer 174, or after each of the two sublayers, which combines the output of the attention sublayer with the input to the attention sublayer to generate a residual output, and a layer normalization layer that applies layer normalization to the residual output. Figure 1 shows these two layers, both referred to as "add and normalize" operations, inserted after each of the two sublayers.
[0056] Some or all of the decoder sub-networks 170 also include a position-wise feedforward layer 176 configured to operate in a manner similar to the position-wise feedforward layer 134 from the encoder 110. In particular, the layer 176 is configured to receive an input at the output position, for each output position preceding the corresponding output position at each generation time step, and to apply a sequence of transformations to the input at the output position to generate an output for the output position. For example, the sequence of transformations may include two or more learned linear transformations, each divided by an activation function, e.g., a nonlinear element-wise activation function, e.g., a ReLU activation function. The input received by the position-wise feedforward layer 176 may be the output of a layer normalization layer (following the last attention sub-layer in the sub-network 170) if residual and layer normalization layers are included, or the output of the last attention sub-layer in the sub-network 170 if residual and layer normalization layers are not included.
[0057] In the case where the decoder sub-network 170 includes a per-position feedforward layer 176, the decoder sub-network may also include a residual connection layer that combines the output of the per-position feedforward layer with the input to the per-position feedforward layer to generate a residual output per decoder position, and a layer normalization layer that applies layer normalization to the residual output per decoder position. These two layers are also collectively referred to as the "add and normalize" operation in FIG. 1. The output of this layer normalization layer may then be used as the output of the decoder sub-network 170.
[0058] At each generation time step, the linear layer 180 applies a learned linear transformation to the output of the final decoder sub-network 170 to project the output of the final decoder sub-network 170 into a space suitable for processing by the softmax layer 190. The softmax layer 190 then applies a softmax function over the output of the linear layer 180 to generate a probability distribution over the possible network outputs at the generation time step. As described above, the decoder 150 can then use the probability distribution to select a network output from the possible network outputs.
[0059] FIG. 2 is a diagram 200 illustrating the attention mechanism applied by the attention sub-layer in the subnetworks of the encoder neural network 110 and the decoder neural network 150.
[0060] In general, attention mechanisms map a query and a set of key-value pairs to an output, where the query, key, and value are all vectors. The output is computed as a weighted sum of the values, where the weight assigned to each value is calculated by a fitness function of the query with the corresponding key.
[0061] More specifically, each attention sublayer applies a shrink-and-dot-product attention mechanism 230. In shrink-and-dot-product attention, for a given query, the attention sublayer computes the dot products of the query with all of the keys, divides each of the dot products by a scaling factor, e.g., the square root of the dimensions of the query and the keys, and applies a softmax function over the shrink-and-dot products to obtain weights on the values. The attention sublayer then computes a weighted sum of the values according to these weights. Thus, for shrink-and-dot-product attention, the fitness function is the dot product, and the output of the fitness function is further shrinked by a scaling factor.
[0062] In operation, and as shown on the left side of Figure 2, the attention sublayer computes attention simultaneously across a set of queries. In particular, the attention sublayer packs queries into a matrix Q, keys into a matrix K, and values into a matrix V. To pack a set of vectors into a matrix, the attention sublayer can generate a matrix that contains the vectors as rows of the matrix.
[0063] The attention sublayer then performs matrix multiplication (MatMul) between matrix Q and the transpose of matrix K to generate a matrix of fitness function outputs.
[0064] The attention sublayer then shrinks the fitness function output matrix, i.e., divides each element of the matrix by a scaling factor.
[0065] The attention sublayer then applies softmax to the reduced output matrix to generate a matrix of weights, and performs matrix multiplication (MatMul) between the weight matrix and the matrix V to generate an output matrix that contains the output of the attention mechanism per value.
[0066] For sublayers that use masking, i.e., the decoder attention sublayer, the attention sublayer masks the reduced output matrix before applying softmax, i.e., the attention sublayer masks out (sets to negative infinity) all values in the reduced output matrix that correspond to positions after the current output position.
[0067] In some embodiments, to enable the attention sublayer to jointly attend to information from different representation subspaces at different locations, the attention sublayer employs multi-head attention, as shown on the right side of FIG.
[0068] In particular, to implement multi-ahead attention, the attention sublayer applies h different attention mechanisms in parallel, in other words, the attention sublayer includes h different attention layers, such that each attention layer in the same attention sublayer receives the same original query Q, original key K, and original value V.
[0069] Each attention layer is configured to transform the original query, keys, and values using a learned linear transformation and apply the attention mechanism 230 to the transformed query, keys, and values. Each attention layer typically learns different transformations from other attention layers within the same attention sublayer.
[0070] In particular, each attention layer is configured to apply the learned query linear transformation to each original query to generate a layer-specific query for each original query, the learned key linear transformation to each original key to generate a layer-specific key for each original query, and the learned value linear transformation to each original value to generate a layer-specific value for each original value. The attention layer then applies the attention mechanism described above using these layer-specific queries, keys, and values to generate the initial output of the attention layer.
[0071] The attention sublayer then combines the initial outputs of the attention layer to generate the final output of the attention sublayer. As shown in Figure 2, the attention sublayer concates the outputs of the attention layer and applies the learned linear transformation to the concatenated outputs to generate the output of the attention sublayer.
[0072] In some cases, the learned transformations applied by the attention sublayer reduce the dimensionality of the original keys, values, and optionally the query. For example, if the original keys, values, and queries have dimensionality d, and there are h attention layers in the sublayer, the sublayer may reduce the dimensionality of the original keys, values, and queries to d / h. This keeps the computational cost of the multi-head attention mechanism similar to what it would have taken to run the attention mechanism once across the full dimensionality, while at the same time increasing the expressive power of the attention sublayer.
[0073] Although the attention mechanism applied by each attention sublayer is the same, the queries, keys, and values are different for different types of attention, i.e., different types of attention sublayers use different sources for the original queries, keys, and values received as input by the attention sublayer.
[0074] In particular, if the attention sublayer is an encoder self-attention sublayer, then the keys, values, and queries all come from the same place, in this case the output of the previous sub-network in the encoder, or for the encoder self-attention sublayer in the first sub-network, the input of the encoder and the embedding of each position can be attention to all positions in input order, so there is a respective key, value, and query for each position in input order.
[0075] If the attention sublayer is a decoder self-attention sublayer, then each position in the decoder pays attention to all positions in the decoder that precede it. Thus, the keys, values, and queries all come from the same location, in this case the output of the previous sub-network of the decoder, or, for the decoder self-attention sublayer in the first decoder sub-network, from embeddings of outputs already generated. Thus, there is a respective key, value, and query for each position in output order before the current position.
[0076] If the attention sublayer is an encoder-decoder attention sublayer, the queries come from the previous component in the decoder, and the keys and values come from the output of the encoder, i.e., from the encoded representation produced by the encoder. This allows every position in the decoder to pay attention across all positions in the input sequence. Thus, for each position before the current position in output order, there is a respective query, and for each position in input order, there is a respective key and a respective value.
[0077] More specifically, if the attention sublayer is an encoder self-attention sublayer, for each particular input position in the input order, the encoder self-attention sublayer is configured to apply an attention mechanism across the encoder subnetwork inputs at the input position using one or more queries derived from the encoder subnetwork inputs at the particular input position to generate a respective output for the particular input position.
[0078] When the encoder self-attention sublayer implements multi-head attention, each encoder self-attention layer in the encoder self-attention sublayer is configured to apply a learned query linear transformation to each encoder sub-network input at each input position to generate a respective query for each input position, apply a learned key linear transformation to each encoder sub-network input at each input position to generate a respective key for each input position, apply a learned value linear transformation to each encoder sub-network input at each input position to generate a respective value for each input position, and then apply an attention mechanism (i.e., the reduced dot-product attention mechanism described above) using the query, key, and value to determine an initial encoder self-attention output for each input position. The sublayer then combines the initial outputs of the attention layers as described above.
[0079] If the attention sublayer is a decoder self-attention sublayer, the decoder self-attention sublayer is configured to receive, at each generation time step, an input for each output position preceding a corresponding output position, and for each particular output position, apply an attention mechanism over the inputs at the output positions preceding the corresponding position using one or more queries derived from the input at the particular output position to generate an updated representation of the particular output position.
[0080] When the decoder self-attention sublayer implements multi-head attention, each attention layer in the decoder self-attention sublayer is configured to, at each generation time step, apply the learned query linear transformation to the input at each output position preceding the corresponding output position to generate a respective query for each output position, apply the learned key linear transformation to each input at each output position preceding the corresponding output position to generate a respective key for each output position, apply the learned value linear transformation to each input at each output position preceding the corresponding output position to generate a respective key for each output position, and then apply an attention mechanism (i.e., the reduced dot-product attention mechanism described above) using the query, key, and value to determine an initial decoder self-attention output for each output position. The sublayer then combines the initial outputs of the attention layers as described above.
[0081] If the attention sublayer is an encoder-decoder attention sublayer, the encoder-decoder attention sublayer is configured to receive, at each generation time step, an input for each output position that precedes a corresponding output position, and for each of the output positions, apply an attention mechanism over the representations encoded at the input positions using one or more queries derived from the input for the output position to generate an updated representation for the output position.
[0082] When the encoder-decoder attention sublayer implements multi-head attention, each attention layer is configured to, at each generation time step, apply a learned query linear transformation to the input at each output position preceding the corresponding output position to generate a respective query for each output position, apply a learned key linear transformation to each encoded representation at each input position to generate a respective key for each input position, apply a learned value linear transformation to each encoded representation at each input position to generate a respective value for each input position, and then apply an attention mechanism (i.e., the reduced dot-product attention mechanism described above) using the query, key, and value to determine an initial encoder-decoder attention output for each input position. The sublayer then combines the initial outputs of the attention layers as described above.
[0083] 3 is a flow diagram illustrating an example process for generating an output sequence from an input sequence. For convenience, process 300 is described as being performed by one or more computer systems located at one or more locations. For example, a neural network system, such as neural network system 100 of FIG. 1, suitably programmed in accordance with this specification, can perform process 300.
[0084] The system receives an input sequence (step 310).
[0085] The system processes the input sequence using an encoder neural network to generate respective encoded representations for each network input in the input sequence, step 320. In particular, the system processes the input sequence through an embedding layer to generate an embedded representation for each network input, and then processes the embedded representations through a sequence of encoder sub-networks to generate encoded representations for the network inputs.
[0086] The system processes the encoded representation using a decoder neural network to generate an output sequence (step 330). The decoder neural network is configured to generate an output sequence from the encoded representation in an autoregressive manner. That is, the decoder neural network generates one output from the output sequence at each generation time step. At a given generation time step where a given output is generated, the system processes the output before the given output in the output sequence through an embedding layer of the decoder to generate an embedded representation. The system then processes the embedded representation through a sequence of a decoder sub-network, a linear layer, and a softmax layer to generate the given output. Because the decoder sub-network includes an encoder-decoder attention sub-layer and a decoder self-attention sub-layer, the decoder utilizes both the already generated output and the encoded representation when generating the given output.
[0087] The system may execute the process 300 for an input sequence of desired outputs, ie, outputs where the output sequence that should be produced by the system for the input sequence is unknown.
[0088] The system may also perform process 300 on input sequences of a set of training data, i.e., a set of inputs for which output sequences to be generated by the system are known, to train the encoder and decoder to determine trained values for the encoder and decoder parameters. Process 300 may be performed repeatedly on selected inputs from the set of training data as part of a conventional machine learning training technique for training an initial neural network layer, such as, for example, gradient descent with backpropagation training techniques using a conventional optimizer such as the Adam optimizer. During training, the system may incorporate any number of techniques to improve the speed, effectiveness, or both of the training process. For example, the system may use dropout, label smoothing, or both to reduce overfitting. As another example, the system may perform training using a distributed architecture that trains multiple instances of a sequence-to-sequence neural network in parallel.
[0089] This specification uses the term "configured" in connection with systems and computer program components. A system of one or more computers configured to perform a particular operation or action means that the system has installed thereon software, firmware, hardware, or a combination thereof that, when in operation, causes the system to perform an operation or action. A computer program or programs configured to perform a particular operation or action means that one or more programs contain instructions that, when executed by a data processing device, cause the device to perform an operation or action.
[0090] Embodiments of the subject matter and functional operations described herein may be implemented in digital electronic circuitry, in tangibly embodied computer software or firmware, in computer hardware including the structures disclosed herein and their structural equivalents, or in one or more combinations thereof. Embodiments of the subject matter described herein may be implemented as one or more computer programs, i.e., one or more modules of computer program instructions encoded on a tangible, non-transitory storage medium for execution by or to control the operation of a data processing apparatus. The computer storage medium may be a machine-readable storage device, a machine-readable storage substrate, a random or serial access memory device, or one or more combinations thereof. Alternatively, or in addition, the program instructions may be encoded in an artificially generated propagated signal, e.g., a machine-generated electrical, optical, or electromagnetic signal, that is generated to encode information for transmission to an appropriate receiver apparatus for execution by the data processing apparatus.
[0091] The term "data processing apparatus" refers to data processing hardware and encompasses any kind of apparatus, device, and machine for processing data, including, by way of example, a programmable processor, computer, or multiple processors or computers. An apparatus may also be or further include special purpose logic circuitry, such as, for example, an FPGA (field programmable gate array) or an ASIC (application specific integrated circuit). In addition to hardware, an apparatus may optionally include code that creates an environment for the execution of computer programs, such as code that constitutes processor firmware, a protocol stack, a database management system, an operating system, or one or more combinations of these.
[0092] Such computer programs, which may be referred to or described as programs, software, software applications, applications, modules, software modules, scripts, or code, may be written in any form of programming language, including compiled or interpreted languages, or declarative or procedural languages, and computer programs may be deployed in any form, including as stand-alone programs or as modules, components, subroutines, or other units suitable for use in a computing environment. A program may correspond to a file in a file system, but this is not required. A program may be stored in one or more scripts stored in part of a file that holds other programs or data, in a single file dedicated to the program in question, or in multiple cooperating files, such as files that store one or more modules, subprograms, or portions of code. A computer program may be deployed to be executed on one computer located at one site, or on multiple computers distributed across multiple sites and interconnected by a data communication network.
[0093] As used herein, the term "database" is used broadly to denote any collection of data, which need not be structured in any particular way, or at all, and may be stored on storage devices in one or more locations. Thus, for example, an index database may contain multiple collections of data, each of which may be organized and accessed separately.
[0094] Similarly, the term "engine" is used broadly herein to denote a software-based system, subsystem, or process that is programmed to perform one or more specific functions. Generally, an engine is implemented as one or more software modules or components installed on one or more computers in one or more locations. In some cases, one or more computers are dedicated to a particular engine, and in other cases, multiple engines may be installed and run on the same computer or multiple computers.
[0095] The processes and logic flows described herein may be performed by one or more programmable computers executing one or more computer programs to perform functions by manipulating input data and generating output. The processes and logic flows may also be performed by special purpose logic circuitry, e.g., an FPGA or an ASIC, or by a combination of special purpose logic circuitry and one or more programmed computers.
[0096] A computer suitable for executing a computer program may be based on a general-purpose or special-purpose microprocessor, or both, or any other type of central processing unit. In general, the central processing unit receives instructions and data from a read-only memory or a random access memory, or both. The essential elements of a computer are a central processing unit for executing or carrying out instructions, and one or more memory devices for storing instructions and data. The central processing unit and memory may be supplemented by, or incorporated in, special-purpose logic circuitry. In general, a computer also includes one or more mass storage devices for storing data, such as, for example, magnetic, magneto-optical, or optical disks, or is operatively coupled to receive data from, or transmit data to, or both, the mass storage devices. However, a computer need not have such devices. Furthermore, a computer may be incorporated in another device, such as, for example, a mobile phone, a personal digital assistant (PDA), a mobile audio or video player, a game console, a global positioning system (GPS) receiver, or a portable storage device, such as a universal serial bus (USB) flash drive, to name just a few.
[0097] Computer readable media suitable for storing computer program instructions and data include, by way of example, all forms of non-volatile memory, media, and memory devices including, for example, semiconductor memory devices such as EPROM, EEPROM, and flash memory devices, magnetic disks such as internal hard disks or removable disks, magneto-optical disks, and CD-ROM disks and DVD-ROM disks.
[0098] To provide for user interaction, embodiments of the subject matter described herein may be implemented on a computer having a display device, e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor, for displaying information to the user, as well as a keyboard and a pointing device, e.g., a mouse or trackball, by which the user can provide input to the computer. Other types of devices may be used to provide for user interaction, e.g., feedback provided to the user may be any form of sensory feedback, e.g., visual feedback, auditory feedback, or tactile feedback, and input from the user may be received in any form, including acoustic, speech, or tactile input. In addition, the computer may interact with the user by sending and receiving documents to and from a device used by the user, e.g., by sending a web page to a web browser on the user's device in response to a request received from the web browser. The computer may also interact with the user by sending a text message or other form of message to a personnel device, e.g., a smartphone running a messaging application, and receiving a response message from the user in return.
[0099] A data processing device for implementing machine learning models may also include dedicated hardware accelerator units for handling common and computationally intensive parts of the workload, e.g. machine learning training or production, i.e. inference.
[0100] The machine learning model may be implemented and deployed using a machine learning framework, for example, the TensorFlow framework, the Microsoft Cognitive Toolkit framework, the Apache Singa framework, or the Apache MXNet framework.
[0101] An embodiment of the subject matter described herein may be implemented in a computing system that includes a back-end component, e.g., as a data server, or includes a middleware component, e.g., an application server, or includes a front-end component, e.g., a client computer having a graphical user interface, a web browser, or an application through which a user can interact with an embodiment of the subject matter described herein, or includes any combination of one or more such back-end, middleware, or front-end components. The components of the system may be interconnected by any form or medium of digital data communication, e.g., a communication network. Examples of communication networks include local area networks (LANs) and wide area networks (WANs), e.g., the Internet.
[0102] A computing system may include clients and servers. Clients and servers are generally remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. In some embodiments, a server sends data, e.g., HTML pages, to a user device for the purpose of displaying data to and receiving user input from a user interacting with the device, e.g., acting as a client. Data generated at the user device, e.g., a result of a user interaction, may be received at the server from the device.
[0103] Although this specification contains many specific implementation details, these should not be construed as limiting the scope of any invention or what may be claimed, but rather as descriptions of features that may be specific to a particular embodiment of a particular invention. Certain features described herein in the context of separate embodiments may also be implemented in combination in a single embodiment. Conversely, various features described in the context of a single embodiment may also be implemented in multiple embodiments separately or in any suitable subcombination. Moreover, even if features are described above as operating in a particular combination and initially claimed as such, one or more features from the claimed combination may in some cases be deleted from the combination, and the claimed combination may be directed to a subcombination or a variation of the subcombination.
[0104] Similarly, although operations are shown in the figures and recited in the claims in a particular order, this should not be understood as requiring that such operations be performed in the particular order or sequentially shown, or that all of the described operations be performed, to achieve desirable results. In certain circumstances, multitasking and parallel processing may be beneficial. Moreover, the separation of various system modules and components in the embodiments described above should not be understood as requiring such separation in all embodiments, and it should be understood that the program components and systems described may generally be integrated into a single software product or packaged into multiple software products.
[0105] Specific embodiments of the subject matter have been described. Other embodiments are within the scope of the following claims. For example, the actions recited in the claims may be performed in a different order and still achieve desirable results. As an example, the processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some cases, multitasking and parallel processing may be beneficial. [Explanation of symbols]
[0106] 100 Neural Network System 108 Attention-Based Sequence-to-Sequence Neural Network 110 Encoder Neural Network 120 Embedding Layer 130 Encoder Sub-Network 132 Encoder Self-Attention Sublayer 134 Position-wise feedforward layer 150 Decoder Neural Network 152 Output Sequence 160 Embedding Layer 170 Decoder Sub-Network 172 Decoder Self-Attention Sublayer 174 Encoder-Decoder Attention Sublayer 176 Position-wise feedforward layer 180 Linear Layers 190 Softmax Layer 230 Attention Mechanism
Claims
1. A method, implemented by one or more computers, for generating an output image, comprising: receiving a context input; generating a sequence of encoded representations of the context input; processing the sequence of encoded representations of the context inputs using a neural network to generate the output image, the neural network comprising: an encoder-decoder attention sublayer configured to perform an operation at each of a plurality of generation time steps, the operation comprising: receiving an input representation of each of the output image luminosities at the generation time step; receiving the sequence of encoded representations of the context input; applying an encoder-decoder attention mechanism across the sequence of encoded representations of the context inputs to update the respective input representations of the luminosity of the output image to generate an updated representation of the luminosity of the output image; A method comprising:
2. The method of claim 1, wherein the context input includes a text sequence.
3. The step of generating a sequence of encoded representations of the context input comprises: The method of claim 1 , comprising processing the sequence of encoded representations using an encoder neural network.
4. The method of claim 3, wherein the encoder neural network includes an encoder self-attention sublayer configured to receive an encoder sub-network input for each of a plurality of input positions of the context input, and for each particular input position, apply an attention mechanism across the encoder sub-network inputs at the input position to generate a respective output for the particular input position.
5. The neural network comprises: a decoder attention sublayer configured to perform an operation at each of a plurality of generation time steps, the operation comprising: receiving an input representation of each of said luminosities of said output image at said generation time step; and updating the respective input representations of the lightness of the output image by applying a decoder attention mechanism across the respective input representations of the lightness to generate an updated representation of the lightness of the output image.
6. Applying an encoder-decoder attention mechanism across the sequence of encoded representations of the context inputs to update the respective input representations of the luminosity of the output image to generate updated representations of the luminosity of the output image includes, for each attention head of a set of one or more attention heads: generating a key from the sequence of encoded representations of the context input; generating a value from the sequence of encoded representations of the context input; generating queries from the respective input representations of the lightness; and generating an initial updated representation using the query, keys, and values.
7. The set of attention heads includes a plurality of attention heads, and applying the encoder-decoder attention mechanism comprises: The method of claim 6 , further comprising combining the initial updated representations of the attention heads of the set.
8. The method of claim 7, further comprising: generating a key from the sequence of encoded representations of the context inputs, the sequence comprising:
7. The method of claim 6, comprising applying a learned key transformation to each encoded representation of the sequence of encoded representations of the context input to generate a respective key for each encoded representation.
9. Generating values from the sequence of encoded representations of the context inputs comprises:
7. The method of claim 6, comprising applying a learned value transformation to each encoded representation in the sequence of encoded representations of the context input to generate a respective value for each encoded representation.
10. The method of claim 6, wherein each of the input representations of the lightness comprises a sequence of expressions, and generating a query from each of the input representations of the lightness comprises applying a learned query transformation to each representation of the sequence of expressions to generate a respective query for each representation.
11. The step of generating an initial updated representation using the query, keys, and values comprises:
7. The method of claim 6, comprising: for each query, generating a respective weight for each encoded representation of the sequence from the query and the key; and combining the values according to the respective weights.
12. One or more computer storage media storing instructions that, when executed by one or more computers, cause the one or more computers to perform the operations described in any one of claims 1 to 11.
13. A system comprising one or more computers and one or more storage devices storing instructions that, when executed by the one or more computers, cause the one or more computers to perform the operations described in any one of claims 1 to 11.
Citation Information
Patent Citations
Unsupervised matching in fine-grained datasets for single-view object reconstruction
US20170124433A1
Generating target sequences from input sequences using partial conditioning
US20170140753A1
Inference device and inference method
WO2016194248A1