IP Library Granted Patent US 12,608,616
Granted Patent B2
US 12,608,616 · App. 19/360,280 · Granted Apr 21, 2026

Attention neural networks with linear units

Inventor: Noam M. Shazeer (Palo Alto, CA)
Assignee: Google LLC
G06N3/082G06N3/048
View Patent ↗
Loading inventors, assignments & file history…
Monitor This Case
Get email alerts when status or documents change.
Order Certified Copies
Most orders are placed with the USPTO same day — all within 24 business hours.
Order via The Patent Place →
Pre-filled with this patent's details
Quick Facts
Patent No.
US 12,608,616
App. No.
19/360,280
Granted
Apr 21, 2026
Kind
B2
Abstract

Methods, systems, and apparatus, including computer programs encoded on a computer storage medium, for performing a machine learning task on a network input to generate a network output. In one aspect, one of the systems includes an attention neural network configured to perform the machine learning task, the attention neural network including one or more attention layers, each attention layer comprising an attention sub-layer and a feed-forward sub-layer that applies an element-wise multiplication between two vectors generated as a result of two different linear transformations performed on the same attended layer input.

Claims (78)

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:

an attention neural network configured to process a network input to generate a network output for a machine learning task, the attention neural network comprising a plurality of attention layers, each attention layer comprising an attention sub-layer and a feed-forward sub-layer, the attention sub-layer configured to:

receive an input sequence for the attention layer comprising a respective layer input at each of one or more positions; and

generate an attended input sequence at least in part by applying an attention mechanism to the input sequence for the attention layer, the attended input sequence comprising a respective attended layer input at each of the one or more positions, and the feed-forward sub-layer configured to:

receive the attended input sequence; and

generate an output sequence for the attention layer from the attended input sequence, the output sequence comprising a respective layer output at each of the one or more positions, and the generating comprising, for each position of the one or more positions:

generating a first linear transformation output by applying a first linear transformation to the attended layer input at the position;

generating a first transformed input by applying a non-linear activation function to the first linear transformation output;

generating a second transformed input by applying a second linear transformation to the attended layer input at the position;

generating a third transformed input by performing an element-wise multiplication between the first transformed input and the second transformed input; and

generating the layer output at the position based on the third transformed input,

wherein

the first and second linear transformations have been learned during training of the attention neural network to perform the machine learning task,

the training of the attention neural network comprises training the attention neural network on an unsupervised data set through unsupervised learning,

the same first linear transformation is applied to the attended layer inputs at each of the positions in the input sequence,

the same second linear transformation is applied to the attended layer inputs at each of the positions in the input sequence, and

the attention neural network further comprises one or more output layers that are configured to process at least one of the layer outputs in the output sequence generated by one of the plurality of attention layers to generate at least a portion of the network output for the machine learning task.

2 . The system of claim 1 , wherein the non-linear activation function is a Swish activation function.

3 . The system of claim 1 , wherein the non-linear activation function is a ReLu activation function.

4 . The system of claim 1 , wherein the non-linear activation function is a sigmoid activation function.

5 . The system of claim 1 , wherein the non-linear activation function is a Gaussian Error Linear Units activation function.

6 . The system of claim 1 , wherein applying the first linear transformation to the attended layer input at the position comprises:

multiplying the attended layer input by a first weight matrix to generate a first product.

7 . The system of claim 1 , wherein applying the second linear transformation to the attended layer input at the position comprises:

multiplying the attended layer input by a second weight matrix to generate a second product.

8 . The system of claim 7 , wherein weights in the first weight matrix have different values than weights in the second weight matrix.

9 . The system of claim 1 , wherein the attention mechanism comprises a multi-head self-attention mechanism.

10 . The system of claim 1 , wherein the machine learning task comprises one of:

a text generation task where the network output comprises a sequence of text; or

an image generation task where the network output comprises a sequence of intensity values for pixels of an image.

11 . A method performed by one or more computers, the method comprising:

receiving a network input; and

processing the network input using an attention neural network to generate a network output for a machine learning task, the attention neural network comprising a plurality of layers, each layer comprising an attention sub-layer and a feed-forward sub-layer, the attention sub-layer configured to:

receive an input sequence for the attention layer comprising a respective layer input at each of one or more positions; and

generate an attended input sequence at least in part by applying an attention mechanism to the input sequence for the attention layer, the attended input sequence comprising a respective attended layer input at each of the one or more positions, and the feed-forward sub-layer configured to:

receive the attended input sequence; and

generate an output sequence for the attention layer from the attended input sequence, the output sequence comprising a respective layer output at each of the one or more positions, and the generating comprising, for each position of the one or more positions:

generating a first linear transformation output by applying a first linear transformation to the attended layer input at the position;

generating a first transformed input by applying a non-linear activation function to the first linear transformation output;

generating a second transformed input by applying a second linear transformation to the attended layer input at the position;

generating a third transformed input by performing an element-wise multiplication between the first transformed input and the second transformed input; and

generating the layer output at the position based on the third transformed input,

wherein

the first and second linear transformations have been learned during training of the attention neural network to perform the machine learning task,

the training of the attention neural network comprises training the attention neural network on an unsupervised data set through unsupervised learning,

the same first linear transformation is applied to the attended layer inputs at each of the positions in the input sequence,

the same second linear transformation is applied to the attended layer inputs at each of the positions in the input sequence, and

the attention neural network further comprises one or more output layers that are configured to process at least one of the layer outputs in the output sequence generated by one of the plurality of attention layers to generate at least a portion of the network output for the machine learning task.

12 . The method of claim 11 , wherein the non-linear activation function is a Swish activation function.

13 . The method of claim 11 , wherein the non-linear activation function is a ReLu activation function.

14 . The method of claim 11 , wherein the non-linear activation function is a sigmoid activation function.

15 . The method of claim 11 , wherein the non-linear activation function is a Gaussian Error Linear Units activation function.

16 . The method of claim 11 , wherein applying the first linear transformation to the attended layer input at the position comprises:

multiplying the attended layer input by a first weight matrix to generate a first product.

17 . The method of claim 11 , wherein applying the second linear transformation to the attended layer input at the position comprises:

multiplying the attended layer input by a second weight matrix to generate a second product.

18 . The method of claim 17 , wherein weights in the first weight matrix have different values than weights in the second weight matrix.

19 . The method of claim 11 , wherein the attention mechanism comprises a multi-head self-attention mechanism.

20 . The method of claim 11 , wherein the machine learning task comprises one of:

a text generation task where the network output comprises a sequence of text; or

an image generation task where the network output comprises a sequence of intensity values for pixels of an image.

21 . 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:

an attention neural network configured to process a network input to generate a network output for a machine learning task, the attention neural network comprising a plurality of attention layers, each attention layer comprising an attention sub-layer and a feed-forward sub-layer, the attention sub-layer configured to:

receive an input sequence for the attention layer comprising a respective layer input at each of one or more positions; and

generate an attended input sequence at least in part by applying an attention mechanism to the input sequence for the attention layer, the attended input sequence comprising a respective attended layer input at each of the one or more positions, and the feed-forward sub-layer configured to:

receive the attended input sequence; and

generate an output sequence for the attention layer from the attended input sequence, the output sequence comprising a respective layer output at each of the one or more positions, and the generating comprising, for each position of the one or more positions:

generating a first linear transformation output by applying a first linear transformation to the attended layer input at the position;

generating a first transformed input by applying a non-linear activation function to the first linear transformation output;

generating a second transformed input by applying a second linear transformation to the attended layer input at the position;

generating a third transformed input by performing an element-wise multiplication between the first transformed input and the second transformed input; and

generating the layer output at the position based on the third transformed input,

wherein

the first and second linear transformations have been learned during training of the attention neural network to perform the machine learning task,

the training of the attention neural network comprises training the attention neural network on an unsupervised data set through unsupervised learning,

the same first linear transformation is applied to the attended layer inputs at each of the positions in the input sequence,

the same second linear transformation is applied to the attended layer inputs at each of the positions in the input sequence, and

the attention neural network further comprises one or more output layers that are configured to process at least one of the layer outputs in the output sequence generated by one of the plurality of attention layers to generate at least a portion of the network output for the machine learning task.

Assignments (1)
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Nov 4, 2025
From: SHAZEER, NOAM M.
To: GOOGLE LLC
Reel/Frame 072781/0473 →
Continuity (4)
Continuation 19052151 · Feb 12, 2025
Continuation 17175567 · Feb 12, 2021
Provisional Application 62975707 · Feb 12, 2020
Related Publication 20260044738A1 · Feb 12, 2026
References Cited (23)
US 20180261214A1 · Gehring · 2018 [cited by examiner]
US 20180341860A1 · Shazeer · 2018 [cited by examiner]
US 20200258496A1 · Yang · 2020 [cited by examiner]
Medina, “Parallel Attention Mechanisms in Neural Machine Translation”, 2018 17th IEEE International Conference on Machine Learning and Applications. (Previously supplied). (Year: 2018). [cited by examiner]
Sukhbaatar, “Augmenting Self-attention with Persistent Memory”, 2019. (Previously supplied). (Year: 2019). [cited by examiner]
Gehring, “Convolutional Sequence to Sequence Learning”, Proceedings of the 34th International Conference on Machine Learning, Sydney, Australia, PMLR 70, 2017. (Previously supplied). (Year: 2017). [cited by examiner]
Dai et al., “Transformer-xl: Attentive language models beyond a fixed-length context,” arXiv preprint arXiv:1901.02860, Jan. 2019, 20 pages. [cited by applicant]
Dauphin et al., “Language modeling with gated convolutional networks,” International conference on machine learning, Jul. 2017, pp. 933-941. [cited by applicant]
Devlin et al., “Bert: Pre-training of deep bidirectional transformers for language understanding,” arXiv preprint arXiv:1810.04805, Oct. 2018, 16 pages. [cited by applicant]
Gehring, “Convolutional Sequence to Sequence Learning”, Proceedings of the 34th International Conference on Machine Learning, Sydney, Australia, PMLR70, 2017. (Year: 2017). [cited by applicant]
Glorot et al., “Deep sparse rectifier neural networks,” Proceedings of the fourteenth international conference on artificial intelligence and statistics, Jun. 2011, pp. 315-323. [cited by applicant]
Hendrycks et al., “Gaussian error linear units (gelus),” arXiv preprint arXiv:1606.08415, Jun. 2016, 9 pages. [cited by applicant]
Kitaev et al., “Reformer: The efficient transformer,” arXiv preprint arXiv:2001.04451, Jan. 2020, 12 pages. [cited by applicant]
Medina, “Parallel Attention Mechanisms in Neural Machine Translation”, 2018 17th IEEE International Conference on Machine Learning and Applications. (Year: 2018). [cited by applicant]
Mnih et al., “Three new graphical models for statistical language modelling,” Proceedings of the 24th international conference on Machine learning, Jun. 2007, pp. 641-648. [cited by applicant]
Raffel et al., “Exploring the limits of transfer learning with a unified text-to-text transformer,” arXiv preprint arXiv:1910.10683, Oct. 2019, 67 pages. [cited by applicant]
Rajpurkar et al., “Squad: 100,000+ questions for machine comprehension of text,” arXiv preprint arXiv:1606.05250, Jun. 2016, 10 pages. [cited by applicant]
Ramachandran et al., “Searching for activation functions,” arXiv preprint arXiv:1710.05941, Oct. 2017, 13 pages. [cited by applicant]
Shazeer et al., “Adafactor: Adaptive learning rates with sublinear memory cost,” International Conference on Machine Learning, Jul. 2018, pp. 4596-4604. [cited by applicant]
Sukhbaatar, “Augmenting Self-attention with Persistent Memory”, 2019. (Year: 2019). [cited by applicant]
Vaswani et al., “Attention is all you need,” arXiv preprint arXiv:1706.03762, Jun. 2017, 15 pages. [cited by applicant]
Wang et al., “Glue: A multi-task benchmark and analysis platform for natural language understanding,” arXiv preprint arXiv:1804.07461, Apr. 2018, 20 pages. [cited by applicant]
Wang et al., “Superglue: A stickier benchmark for general-purpose language understanding systems,” arXiv preprint arXiv:1905.00537, May 2019, 29 pages. [cited by applicant]