Good book or other literature with attention model + working examples

GGPYTORCH000: <p>I hae been using two books earlier tensorflow and now switched to pytorch:</p>
<h1>
<a name="machine-learning-with-pytorch-and-scikit-learn-978-1801819312-1" class="anchor" href="#machine-learning-with-pytorch-and-scikit-learn-978-1801819312-1"></a>Machine Learning with PyTorch and Scikit-Learn: 978-1801819312</h1>
<p>Tensorflow book is "Hands-on machine learning with skigit-learn keras &amp; tensorflow 978-1-492-03264-9.</p>
<p>Both books have excellents coverage on all machine learning concepts starting from basic concepts to earlier linear models, cnn and up to rnn + working code examples.<br>
But on more recent technologies i.e. attn, self-attn, it seems coverage is partial. Both book explains theoretically well however working code examples only goes partial and left there.</p>
<p>I am suspecting this is due to transformer with attn self-attn being recent development.<br>
I am looking for any newer book or literature that has good code example that can construct fully functioning RNN with attn from start to end. I dont need theoretical explanation which is plenty.</p>

shivammehta007: <p>I personally really like Harvard’s notebook called <a href="https://nlp.seas.harvard.edu/2018/04/03/attention.html" rel="noopener nofollow ugc">The Annotated Transformer</a>. It has an explanation along with the code which makes it more hands-on and understanding at least for me.</p>

dreidizzle: <p>This book has an entire chapter on the transformer and does computations step by step: <a href="https://www.amazon.com/Machine-Learning-PyTorch-Scikit-Learn-learning/dp/1801819319" rel="noopener nofollow ugc">https://www.amazon.com/Machine-Learning-PyTorch-Scikit-Learn-learning/dp/1801819319</a></p>

GGPYTORCH000: <p>thanks this looks promising, i will see about it and get back.</p>

GGPYTORCH000: <p>yes, that was what i was learning from and mentioned. I see it has code coverage up to mult-head attention as basis for transformer. After that it resorted to pip examples. However, I was hoping full fledged example not using pip libraries:</p>
<ol>
<li>input-&gt;tokenizer-&gt;embed-&gt;(various transformer implementation)-&gt;output.</li>
<li>Simpler GPT/BERT implementation (or like implemenation) not using pip libraries + pretraining + finetuning.</li>
</ol>
<p>But regardless, the earlier examples in the book without pip imports were massively insightful for understanding the internal workings of various training models.</p>

dreidizzle: <p>This is a good one for GPT: <a href="https://github.com/karpathy/minGPT" class="inline-onebox" rel="noopener nofollow ugc">GitHub - karpathy/minGPT: A minimal PyTorch re-implementation of the OpenAI GPT (Generative Pretrained Transformer) training</a></p>
<p>Unsure about this, but for BERT here is one: <a href="https://github.com/illusions-LYY/annotated-BERT-pytorch/blob/master/README_back.md" class="inline-onebox" rel="noopener nofollow ugc">annotated-BERT-pytorch/README_back.md at master · illusions-LYY/annotated-BERT-pytorch · GitHub</a> … The BERT repo that was released btw is pretty good, but in TF: <a href="https://github.com/google-research/bert" class="inline-onebox" rel="noopener nofollow ugc">GitHub - google-research/bert: TensorFlow code and pre-trained models for BERT</a></p>

GGPYTORCH000: <p>Hi, Andrei, minGPT looks nice, however it is still using nn.module. I am literally looking for simple implementation of GPT like model totally hardcoded at least training parts (exception being embedding and PE using library). so that i can literally observe and graph the output of each layer at each epoch or even each sample while training samples are being fed. Ideally, the hardcoded implementation (not using library) of original attention model with 6 en/decoder (aka attention is all you need).</p>