mirror of
https://github.com/labmlai/annotated_deep_learning_paper_implementations.git
synced 2025-08-26 08:41:23 +08:00
primer links
This commit is contained in:
@ -96,6 +96,7 @@ implementations.</p>
|
|||||||
<li><a href="transformers/mlp_mixer/index.html">MLP-Mixer: An all-MLP Architecture for Vision</a></li>
|
<li><a href="transformers/mlp_mixer/index.html">MLP-Mixer: An all-MLP Architecture for Vision</a></li>
|
||||||
<li><a href="transformers/gmlp/index.html">Pay Attention to MLPs (gMLP)</a></li>
|
<li><a href="transformers/gmlp/index.html">Pay Attention to MLPs (gMLP)</a></li>
|
||||||
<li><a href="transformers/vit/index.html">Vision Transformer (ViT)</a></li>
|
<li><a href="transformers/vit/index.html">Vision Transformer (ViT)</a></li>
|
||||||
|
<li><a href="transformers/primer_ez/index.html">Primer EZ</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
<h4>✨ <a href="recurrent_highway_networks/index.html">Recurrent Highway Networks</a></h4>
|
<h4>✨ <a href="recurrent_highway_networks/index.html">Recurrent Highway Networks</a></h4>
|
||||||
<h4>✨ <a href="lstm/index.html">LSTM</a></h4>
|
<h4>✨ <a href="lstm/index.html">LSTM</a></h4>
|
||||||
|
@ -121,12 +121,15 @@ It does single GPU training but we implement the concept of switching as describ
|
|||||||
<h2><a href="vit/index.html">Vision Transformer (ViT)</a></h2>
|
<h2><a href="vit/index.html">Vision Transformer (ViT)</a></h2>
|
||||||
<p>This is an implementation of the paper
|
<p>This is an implementation of the paper
|
||||||
<a href="https://papers.labml.ai/paper/2010.11929">An Image Is Worth 16x16 Words: Transformers For Image Recognition At Scale</a>.</p>
|
<a href="https://papers.labml.ai/paper/2010.11929">An Image Is Worth 16x16 Words: Transformers For Image Recognition At Scale</a>.</p>
|
||||||
|
<h2><a href="primer_ez/index.html">Primer EZ</a></h2>
|
||||||
|
<p>This is an implementation of the paper
|
||||||
|
<a href="https://papers.labml.ai/paper/2109.08668">Primer: Searching for Efficient Transformers for Language Modeling</a>.</p>
|
||||||
</div>
|
</div>
|
||||||
<div class='code'>
|
<div class='code'>
|
||||||
<div class="highlight"><pre><span class="lineno">93</span><span></span><span class="kn">from</span> <span class="nn">.configs</span> <span class="kn">import</span> <span class="n">TransformerConfigs</span>
|
<div class="highlight"><pre><span class="lineno">98</span><span></span><span class="kn">from</span> <span class="nn">.configs</span> <span class="kn">import</span> <span class="n">TransformerConfigs</span>
|
||||||
<span class="lineno">94</span><span class="kn">from</span> <span class="nn">.models</span> <span class="kn">import</span> <span class="n">TransformerLayer</span><span class="p">,</span> <span class="n">Encoder</span><span class="p">,</span> <span class="n">Decoder</span><span class="p">,</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">EncoderDecoder</span>
|
<span class="lineno">99</span><span class="kn">from</span> <span class="nn">.models</span> <span class="kn">import</span> <span class="n">TransformerLayer</span><span class="p">,</span> <span class="n">Encoder</span><span class="p">,</span> <span class="n">Decoder</span><span class="p">,</span> <span class="n">Generator</span><span class="p">,</span> <span class="n">EncoderDecoder</span>
|
||||||
<span class="lineno">95</span><span class="kn">from</span> <span class="nn">.mha</span> <span class="kn">import</span> <span class="n">MultiHeadAttention</span>
|
<span class="lineno">100</span><span class="kn">from</span> <span class="nn">.mha</span> <span class="kn">import</span> <span class="n">MultiHeadAttention</span>
|
||||||
<span class="lineno">96</span><span class="kn">from</span> <span class="nn">labml_nn.transformers.xl.relative_mha</span> <span class="kn">import</span> <span class="n">RelativeMultiHeadAttention</span></pre></div>
|
<span class="lineno">101</span><span class="kn">from</span> <span class="nn">labml_nn.transformers.xl.relative_mha</span> <span class="kn">import</span> <span class="n">RelativeMultiHeadAttention</span></pre></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class='footer'>
|
<div class='footer'>
|
||||||
|
158
docs/transformers/primer_ez/readme.html
Normal file
158
docs/transformers/primer_ez/readme.html
Normal file
@ -0,0 +1,158 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="content-type" content="text/html;charset=utf-8"/>
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||||
|
<meta name="description" content=""/>
|
||||||
|
|
||||||
|
<meta name="twitter:card" content="summary"/>
|
||||||
|
<meta name="twitter:image:src" content="https://avatars1.githubusercontent.com/u/64068543?s=400&v=4"/>
|
||||||
|
<meta name="twitter:title" content="Primer: Searching for Efficient Transformers for Language Modeling"/>
|
||||||
|
<meta name="twitter:description" content=""/>
|
||||||
|
<meta name="twitter:site" content="@labmlai"/>
|
||||||
|
<meta name="twitter:creator" content="@labmlai"/>
|
||||||
|
|
||||||
|
<meta property="og:url" content="https://nn.labml.ai/transformers/primer_ez/readme.html"/>
|
||||||
|
<meta property="og:title" content="Primer: Searching for Efficient Transformers for Language Modeling"/>
|
||||||
|
<meta property="og:image" content="https://avatars1.githubusercontent.com/u/64068543?s=400&v=4"/>
|
||||||
|
<meta property="og:site_name" content="LabML Neural Networks"/>
|
||||||
|
<meta property="og:type" content="object"/>
|
||||||
|
<meta property="og:title" content="Primer: Searching for Efficient Transformers for Language Modeling"/>
|
||||||
|
<meta property="og:description" content=""/>
|
||||||
|
|
||||||
|
<title>Primer: Searching for Efficient Transformers for Language Modeling</title>
|
||||||
|
<link rel="shortcut icon" href="/icon.png"/>
|
||||||
|
<link rel="stylesheet" href="../../pylit.css">
|
||||||
|
<link rel="canonical" href="https://nn.labml.ai/transformers/primer_ez/readme.html"/>
|
||||||
|
<!-- Global site tag (gtag.js) - Google Analytics -->
|
||||||
|
<script async src="https://www.googletagmanager.com/gtag/js?id=G-4V3HC8HBLH"></script>
|
||||||
|
<script>
|
||||||
|
window.dataLayer = window.dataLayer || [];
|
||||||
|
|
||||||
|
function gtag() {
|
||||||
|
dataLayer.push(arguments);
|
||||||
|
}
|
||||||
|
|
||||||
|
gtag('js', new Date());
|
||||||
|
|
||||||
|
gtag('config', 'G-4V3HC8HBLH');
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id='container'>
|
||||||
|
<div id="background"></div>
|
||||||
|
<div class='section'>
|
||||||
|
<div class='docs'>
|
||||||
|
<p>
|
||||||
|
<a class="parent" href="/">home</a>
|
||||||
|
<a class="parent" href="../index.html">transformers</a>
|
||||||
|
<a class="parent" href="index.html">primer_ez</a>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
|
||||||
|
<a href="https://github.com/labmlai/annotated_deep_learning_paper_implementations/tree/master/labml_nn/transformers/primer_ez/readme.md">
|
||||||
|
<img alt="Github"
|
||||||
|
src="https://img.shields.io/github/stars/labmlai/annotated_deep_learning_paper_implementations?style=social"
|
||||||
|
style="max-width:100%;"/></a>
|
||||||
|
<a href="https://twitter.com/labmlai"
|
||||||
|
rel="nofollow">
|
||||||
|
<img alt="Twitter"
|
||||||
|
src="https://img.shields.io/twitter/follow/labmlai?style=social"
|
||||||
|
style="max-width:100%;"/></a>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class='section' id='section-0'>
|
||||||
|
<div class='docs'>
|
||||||
|
<div class='section-link'>
|
||||||
|
<a href='#section-0'>#</a>
|
||||||
|
</div>
|
||||||
|
<h1><a href="https://nn.labml.ai/transformers/primer_ez/index.html">Primer: Searching for Efficient Transformers for Language Modeling</a></h1>
|
||||||
|
<p>This is a <a href="https://pytorch.org">PyTorch</a> implementation of the paper
|
||||||
|
<a href="https://papers.labml.ai/paper/2109.08668">Primer: Searching for Efficient Transformers for Language Modeling</a>.</p>
|
||||||
|
<p>The authors do an evolutionary search for transformer architectures.
|
||||||
|
They name the architecture found using the search Primer (PRIMitives searched transformER).
|
||||||
|
<strong>Primer EZ</strong> is the architecture with the two most robust modifications in Primer compared to
|
||||||
|
the original transformer.
|
||||||
|
Primer EZ trains a lot faster than the vanilla transformer.</p>
|
||||||
|
<h3>Squared ReLU</h3>
|
||||||
|
<p>The most effective modification found by the search is using a square ReLU instead of ReLU in
|
||||||
|
the <a href="https://nn.labml.ai/transformers/feed_forward.html">position-wise feedforward module</a>.</p>
|
||||||
|
<h3>Multi-DConv-Head Attention (MDHA)</h3>
|
||||||
|
<p>The next effective modification is a depth-wise 3 X 1 convolution after multi-head projection
|
||||||
|
for queries, keys, and values.
|
||||||
|
The convolution is along the sequence dimension and per channel (depth-wise).
|
||||||
|
To be clear, if the number of channels in each head is d_k the convolution will have 1 X 3
|
||||||
|
kernels for each of the d_k channels.</p>
|
||||||
|
<p><a href="https://nn.labml.ai/transformers/primer_ez/experiment.html">Here is the experiment code</a>, for Primer EZ.</p>
|
||||||
|
<p><a href="https://app.labml.ai/run/30adb7aa1ab211eca7310f80a114e8a4"><img alt="View Run" src="https://img.shields.io/badge/labml-experiment-brightgreen" /></a></p>
|
||||||
|
</div>
|
||||||
|
<div class='code'>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class='footer'>
|
||||||
|
<a href="https://papers.labml.ai">Trending Research Papers</a>
|
||||||
|
<a href="https://labml.ai">labml.ai</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.4/MathJax.js?config=TeX-AMS_HTML">
|
||||||
|
</script>
|
||||||
|
<!-- MathJax configuration -->
|
||||||
|
<script type="text/x-mathjax-config">
|
||||||
|
MathJax.Hub.Config({
|
||||||
|
tex2jax: {
|
||||||
|
inlineMath: [ ['$','$'] ],
|
||||||
|
displayMath: [ ['$$','$$'] ],
|
||||||
|
processEscapes: true,
|
||||||
|
processEnvironments: true
|
||||||
|
},
|
||||||
|
// Center justify equations in code and markdown cells. Elsewhere
|
||||||
|
// we use CSS to left justify single line equations in code cells.
|
||||||
|
displayAlign: 'center',
|
||||||
|
"HTML-CSS": { fonts: ["TeX"] }
|
||||||
|
});
|
||||||
|
|
||||||
|
</script>
|
||||||
|
<script>
|
||||||
|
function handleImages() {
|
||||||
|
var images = document.querySelectorAll('p>img')
|
||||||
|
|
||||||
|
console.log(images);
|
||||||
|
for (var i = 0; i < images.length; ++i) {
|
||||||
|
handleImage(images[i])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleImage(img) {
|
||||||
|
img.parentElement.style.textAlign = 'center'
|
||||||
|
|
||||||
|
var modal = document.createElement('div')
|
||||||
|
modal.id = 'modal'
|
||||||
|
|
||||||
|
var modalContent = document.createElement('div')
|
||||||
|
modal.appendChild(modalContent)
|
||||||
|
|
||||||
|
var modalImage = document.createElement('img')
|
||||||
|
modalContent.appendChild(modalImage)
|
||||||
|
|
||||||
|
var span = document.createElement('span')
|
||||||
|
span.classList.add('close')
|
||||||
|
span.textContent = 'x'
|
||||||
|
modal.appendChild(span)
|
||||||
|
|
||||||
|
img.onclick = function () {
|
||||||
|
console.log('clicked')
|
||||||
|
document.body.appendChild(modal)
|
||||||
|
modalImage.src = img.src
|
||||||
|
}
|
||||||
|
|
||||||
|
span.onclick = function () {
|
||||||
|
document.body.removeChild(modal)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
handleImages()
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -32,6 +32,7 @@ implementations.
|
|||||||
* [MLP-Mixer: An all-MLP Architecture for Vision](transformers/mlp_mixer/index.html)
|
* [MLP-Mixer: An all-MLP Architecture for Vision](transformers/mlp_mixer/index.html)
|
||||||
* [Pay Attention to MLPs (gMLP)](transformers/gmlp/index.html)
|
* [Pay Attention to MLPs (gMLP)](transformers/gmlp/index.html)
|
||||||
* [Vision Transformer (ViT)](transformers/vit/index.html)
|
* [Vision Transformer (ViT)](transformers/vit/index.html)
|
||||||
|
* [Primer EZ](transformers/primer_ez/index.html)
|
||||||
|
|
||||||
#### ✨ [Recurrent Highway Networks](recurrent_highway_networks/index.html)
|
#### ✨ [Recurrent Highway Networks](recurrent_highway_networks/index.html)
|
||||||
|
|
||||||
|
@ -88,6 +88,11 @@ This is an implementation of the paper
|
|||||||
|
|
||||||
This is an implementation of the paper
|
This is an implementation of the paper
|
||||||
[An Image Is Worth 16x16 Words: Transformers For Image Recognition At Scale](https://papers.labml.ai/paper/2010.11929).
|
[An Image Is Worth 16x16 Words: Transformers For Image Recognition At Scale](https://papers.labml.ai/paper/2010.11929).
|
||||||
|
|
||||||
|
## [Primer EZ](primer_ez/index.html)
|
||||||
|
|
||||||
|
This is an implementation of the paper
|
||||||
|
[Primer: Searching for Efficient Transformers for Language Modeling](https://papers.labml.ai/paper/2109.08668).
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from .configs import TransformerConfigs
|
from .configs import TransformerConfigs
|
||||||
|
27
labml_nn/transformers/primer_ez/readme.md
Normal file
27
labml_nn/transformers/primer_ez/readme.md
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
# [Primer: Searching for Efficient Transformers for Language Modeling](https://nn.labml.ai/transformers/primer_ez/index.html)
|
||||||
|
|
||||||
|
This is a [PyTorch](https://pytorch.org) implementation of the paper
|
||||||
|
[Primer: Searching for Efficient Transformers for Language Modeling](https://papers.labml.ai/paper/2109.08668).
|
||||||
|
|
||||||
|
The authors do an evolutionary search for transformer architectures.
|
||||||
|
They name the architecture found using the search Primer (PRIMitives searched transformER).
|
||||||
|
**Primer EZ** is the architecture with the two most robust modifications in Primer compared to
|
||||||
|
the original transformer.
|
||||||
|
Primer EZ trains a lot faster than the vanilla transformer.
|
||||||
|
|
||||||
|
### Squared ReLU
|
||||||
|
|
||||||
|
The most effective modification found by the search is using a square ReLU instead of ReLU in
|
||||||
|
the [position-wise feedforward module](https://nn.labml.ai/transformers/feed_forward.html).
|
||||||
|
|
||||||
|
### Multi-DConv-Head Attention (MDHA)
|
||||||
|
|
||||||
|
The next effective modification is a depth-wise 3 X 1 convolution after multi-head projection
|
||||||
|
for queries, keys, and values.
|
||||||
|
The convolution is along the sequence dimension and per channel (depth-wise).
|
||||||
|
To be clear, if the number of channels in each head is d_k the convolution will have 1 X 3
|
||||||
|
kernels for each of the d_k channels.
|
||||||
|
|
||||||
|
[Here is the experiment code](https://nn.labml.ai/transformers/primer_ez/experiment.html), for Primer EZ.
|
||||||
|
|
||||||
|
[](https://app.labml.ai/run/30adb7aa1ab211eca7310f80a114e8a4)
|
@ -37,6 +37,7 @@ implementations almost weekly.
|
|||||||
* [MLP-Mixer: An all-MLP Architecture for Vision](https://nn.labml.ai/transformers/mlp_mixer/index.html)
|
* [MLP-Mixer: An all-MLP Architecture for Vision](https://nn.labml.ai/transformers/mlp_mixer/index.html)
|
||||||
* [Pay Attention to MLPs (gMLP)](https://nn.labml.ai/transformers/gmlp/index.html)
|
* [Pay Attention to MLPs (gMLP)](https://nn.labml.ai/transformers/gmlp/index.html)
|
||||||
* [Vision Transformer (ViT)](https://nn.labml.ai/transformers/vit/index.html)
|
* [Vision Transformer (ViT)](https://nn.labml.ai/transformers/vit/index.html)
|
||||||
|
* [Primer EZ](https://nn.labml.ai/transformers/primer_ez/index.html)
|
||||||
|
|
||||||
#### ✨ [Recurrent Highway Networks](https://nn.labml.ai/recurrent_highway_networks/index.html)
|
#### ✨ [Recurrent Highway Networks](https://nn.labml.ai/recurrent_highway_networks/index.html)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user