# US 10,956,819 B2 · Attention-based sequence transduction neural networks

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 10,956,819 B2
- Document ID: US10956819B2
- Status: Granted
- Kind: B2
- Application number: 16/988,518
- Filed: 2020-08-07
- Published: 2021-01-21
- Granted: 2021-03-23
- Earliest claimed: 2017-05-23
- Assignees: Google Inc.
- Applicants: Google LLC
- Inventors: Noam M. Shazeer; Aidan Nicholas Gomez; Lukasz Mieczyslaw Kaiser; Jakob D. Uszkoreit; Llion Owen Jones; Niki J. Parmar; Illia Polosukhin; Ashish Teku Vaswani
- Web page: https://patentgrep.com/patent/US10956819B2

## CPC

- G06N 3/045: Combinations of networks
- G06N 3/08: Learning methods
- G06N 3/0455: Auto-encoder networks; Encoder-decoder networks
- G06N 3/0499: Feedforward networks
- G06N 3/09: Supervised learning
- G06N 20/00: Machine learning
- G06N: COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS

## Abstract

Methods, systems, and apparatus, including computer programs encoded on a computer storage medium, for generating an output sequence from an input sequence. In one aspect, one of the systems includes an encoder neural network configured to receive the input sequence and generate encoded representations of the network inputs, the encoder neural network comprising a sequence of one or more encoder subnetworks, each encoder subnetwork configured to receive a respective encoder subnetwork input for each of the input positions and to generate a respective subnetwork output for each of the input positions, and each encoder subnetwork comprising: an encoder self-attention sub-layer that is configured to receive the subnetwork input for each of the input positions and, for each particular input position in the input order: apply an attention mechanism over the encoder subnetwork inputs using one or more queries derived from the encoder subnetwork input at the particular input position.

## Claims

### Claim 1

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 implement a neural network for generating a network output by processing an input sequence having a respective network input at each of a plurality of input positions in an input order, the neural network comprising:
a first neural network configured to receive the input sequence and generate a respective encoded representation of each of the network inputs in the input sequence, the first neural network comprising a sequence of one or more subnetworks, each subnetwork configured to receive a respective subnetwork input for each of the plurality of input positions and to generate a respective subnetwork output for each of the plurality of input positions, and wherein each subnetwork comprises:
a self-attention sub-layer that is configured to receive the subnetwork input for each of the plurality of input positions and, for each particular input position in the input order:
apply a self-attention mechanism over the subnetwork inputs at the plurality of input positions to generate a respective output for the particular input position, wherein applying a self-attention mechanism comprises: determining a query from the subnetwork input at the particular input position, determining keys derived from the subnetwork inputs at the plurality of input positions, determining values derived from the subnetwork inputs at the plurality of input positions, and using the determined query, keys, and values to generate the respective output for the particular input position; and
a second neural network comprising one or more neural network layers that is configured to receive the encoded representations generated by the first neural network and process the encoded representations to generate the network output.

### Claim 2 (depends on 1)

The system of claim 1, wherein the first neural network further comprises:
an embedding layer configured to:
for each network input in the input sequence,
map the network input to an embedded representation of the network input, and
combine the embedded representation of the network input with a positional embedding of the input position of the network input in the input order to generate a combined embedded representation of the network input; and
provide the combined embedded representations of the network inputs as the subnetwork inputs for a first subnetwork in the sequence of subnetworks in the first neural network.

### Claim 3 (depends on 1)

The system of claim 1, wherein the respective encoded representations of the network inputs are the subnetwork outputs generated by the last subnetwork in the sequence.

### Claim 4 (depends on 1)

The system of claim 1, wherein the sequence of one or more subnetworks includes at least two subnetworks, and wherein, for each subnetwork other than a first subnetwork in the sequence, the subnetwork input is the subnetwork output of a preceding subnetwork in the sequence.

### Claim 5 (depends on 1)

The system of claim 1, wherein at least one of the subnetworks further comprises:
a position-wise feed-forward layer that is configured to:
for each input position:
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.

### Claim 6 (depends on 5)

The system of claim 5, wherein the sequence of transformations comprises two learned linear transformations separated by an activation function.

### Claim 7 (depends on 5)

The system of claim 5, wherein the at least one subnetwork further comprises:
a residual connection layer that combines the outputs of the position-wise feed-forward layer with the inputs to the position-wise feed-forward layer to generate a position-wise residual output, and
a layer normalization layer that applies layer normalization to the position-wise residual output.

### Claim 8 (depends on 1)

The system of claim 1, wherein each subnetwork further comprises:
a residual connection layer that combines the outputs of the self-attention sub-layer with the inputs to the self-attention sub-layer to generate a self-attention residual output, and
a layer normalization layer that applies layer normalization to the self-attention residual output.

### Claim 9 (depends on 1)

The system of claim 1, wherein each self-attention sub-layer comprises a plurality of self-attention layers.

### Claim 10 (depends on 9)

The system of claim 9,
wherein each self-attention layer is configured to:
apply a learned query linear transformation to each subnetwork input at each input position to generate a respective query for each input position,
apply a learned key linear transformation to each subnetwork input at each input position to generate a respective key for each input position,
apply a learned value linear transformation to each subnetwork input at each input position to generate a respective value for each input position, and
for each input position,
determine a respective input-position specific weight for the input position by applying a comparison function between the query for the input position and the keys generated for the plurality of input positions, and
determine an initial self-attention output for the input position by determining a weighted sum of the values weighted by the corresponding input-position specific weights for the plurality of input positions, the values being generated for the plurality of input positions.

### Claim 11 (depends on 10)

The system of claim 10, wherein the self-attention sub-layer is configured to, for each input position, combine the initial self-attention outputs for the input position generated by the self-attention layers to generate the output for the self-attention sub-layer.

### Claim 12 (depends on 9)

The system of claim 9, wherein the self-attention layers operate in parallel.

### Claim 13

One or more non-transitory computer storage media storing instructions that when executed by one or more computers cause the one or more computers to implement a neural network for generating a network output by processing an input sequence having a respective network input at each of a plurality of input positions in an input order, the neural network comprising:
a first neural network configured to receive the input sequence and generate a respective encoded representation of each of the network inputs in the input sequence, the first neural network comprising a sequence of one or more subnetworks, each subnetwork configured to receive a respective subnetwork input for each of the plurality of input positions and to generate a respective subnetwork output for each of the plurality of input positions, and wherein each subnetwork comprises:
a self-attention sub-layer that is configured to receive the subnetwork input for each of the plurality of input positions and, for each particular input position in the input order:
apply a self-attention mechanism over the subnetwork inputs at the plurality of input positions to generate a respective output for the particular input position, wherein applying a self-attention mechanism comprises: determining a query from the subnetwork input at the particular input position, determining keys derived from the subnetwork inputs at the plurality of input positions, determining values derived from the subnetwork inputs at the plurality of input positions, and using the determined query, keys, and values to generate the respective output for the particular input position; and
a second neural network comprising one or more neural network layers that is configured to receive the encoded representations generated by the first neural network and process the encoded representations to generate the network output.

### Claim 14 (depends on 13)

The non-transitory computer storage media of claim 13, wherein the first neural network further comprises:
an embedding layer configured to:
for each network input in the input sequence,
map the network input to an embedded representation of the network input, and
combine the embedded representation of the network input with a positional embedding of the input position of the network input in the input order to generate a combined embedded representation of the network input; and
provide the combined embedded representations of the network inputs as the subnetwork inputs for a first subnetwork in the sequence of subnetworks in the first neural network.

### Claim 15 (depends on 13)

The non-transitory computer storage media of claim 13, wherein the respective encoded representations of the network inputs are the subnetwork outputs generated by the last subnetwork in the sequence.

### Claim 16 (depends on 13)

The non-transitory computer storage media of claim 13, wherein the sequence of one or more subnetworks includes at least two subnetworks, and wherein, for each subnetwork other than a first subnetwork in the sequence, the subnetwork input is the subnetwork output of a preceding subnetwork in the sequence.

### Claim 17

A method comprising:
receiving an input sequence having a respective input at each of a plurality of input positions in an input order;
processing the input sequence through a first neural network to generate a respective encoded representation of each of the inputs in the input sequence, the first neural network comprising a sequence of one or more subnetworks, each subnetwork configured to receive a respective subnetwork input for each of the plurality of input positions and to generate a respective subnetwork output for each of the plurality of input positions, and each subnetwork comprising:
a self-attention sub-layer that is configured to receive the subnetwork input for each of the plurality of input positions and, for each particular input position in the input order:
apply a self-attention mechanism over the subnetwork inputs at the plurality of input positions to generate a respective output for the particular input position, wherein applying a self-attention mechanism comprises: determining a query from the subnetwork input at the particular input position, determining keys derived from the subnetwork inputs at the plurality of input positions, determining values derived from the subnetwork inputs at the plurality of input positions, and using the determined query, keys, and values to generate the respective output for the particular input position; and
processing the encoded representations through a second neural network to generate a network output.

### Claim 18 (depends on 17)

The method of claim 17, wherein the first neural network further comprises:
an embedding layer configured to:
for each network input in the input sequence,
map the network input to an embedded representation of the network input, and
combine the embedded representation of the network input with a positional embedding of the input position of the network input in the input order to generate a combined embedded representation of the network input; and
provide the combined embedded representations of the network inputs as the subnetwork inputs for a first subnetwork in the sequence of subnetworks in the first neural network.

### Claim 19 (depends on 17)

The method of claim 17, wherein the respective encoded representations of the network inputs are the subnetwork outputs generated by the last subnetwork in the sequence.

### Claim 20 (depends on 17)

The method of claim 17, wherein the sequence of one or more subnetworks includes at least two subnetworks, and wherein, for each subnetwork other than a first subnetwork in the sequence, the subnetwork input is the subnetwork output of a preceding subnetwork in the sequence.
