<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>akash5100</title><link>https://akash5100.github.io/</link><description>Recent content on akash5100</description><generator>Hugo</generator><language>en</language><lastBuildDate>Wed, 21 Aug 2024 00:00:00 +0000</lastBuildDate><atom:link href="https://akash5100.github.io/index.xml" rel="self" type="application/rss+xml"/><item><title>Global Attention</title><link>https://akash5100.github.io/posts/2024-08-21-global_attention/</link><pubDate>Wed, 21 Aug 2024 00:00:00 +0000</pubDate><guid>https://akash5100.github.io/posts/2024-08-21-global_attention/</guid><description>&lt;p&gt;To understand how global attention works quickly, take a long sentence, tokenize it, and then compare how the original attention mechanism (using Key-Value-Query, or KQV) works on the tokens versus how it operates with global tokens derived from blocks of those tokens.&lt;/p&gt;
&lt;h3 id="step-1-original-sentence-and-tokenization"&gt;Step 1: Original Sentence and Tokenization&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Sentence&lt;/strong&gt;:&lt;br&gt;
&lt;em&gt;&amp;ldquo;The quick brown fox jumps over the lazy dog near the riverbank in the sunny park.&amp;rdquo;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Tokenization&lt;/strong&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Tokens: &lt;code&gt;[&amp;quot;The&amp;quot;, &amp;quot;quick&amp;quot;, &amp;quot;brown&amp;quot;, &amp;quot;fox&amp;quot;, &amp;quot;jumps&amp;quot;, &amp;quot;over&amp;quot;, &amp;quot;the&amp;quot;, &amp;quot;lazy&amp;quot;, &amp;quot;dog&amp;quot;, &amp;quot;near&amp;quot;, &amp;quot;the&amp;quot;, &amp;quot;riverbank&amp;quot;, &amp;quot;in&amp;quot;, &amp;quot;the&amp;quot;, &amp;quot;sunny&amp;quot;, &amp;quot;park&amp;quot;]&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="step-2-kqv-attention-mechanism"&gt;Step 2: KQV Attention Mechanism&lt;/h3&gt;
&lt;h4 id="kqv-calculation"&gt;KQV Calculation&lt;/h4&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Input Tokens&lt;/strong&gt;:&lt;/p&gt;</description></item><item><title>Creating simple RAG</title><link>https://akash5100.github.io/posts/2024-06-22-creating_minrag/</link><pubDate>Sat, 22 Jun 2024 00:00:00 +0000</pubDate><guid>https://akash5100.github.io/posts/2024-06-22-creating_minrag/</guid><description>&lt;blockquote&gt;
&lt;p&gt;Life update, last week I joined &lt;a href="https://plane.so"&gt;Plane.so&lt;/a&gt; as AI engineer let&amp;rsquo;s see if I can make it up to AI researcher!&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;This is the &lt;a href="https://arxiv.org/abs/2005.11401"&gt;paper&lt;/a&gt; which introduced RAG. The problem with LLMs is that they &amp;ldquo;hallucinate&amp;rdquo; and have fixed world knowledge, bleh&amp;hellip; we already know that RAG architecture tries to address it. My main motive to create RAG is to understand vector embeddings more in-depth and how we create it, search it and what happens next if we find those retieved documents?&lt;/p&gt;</description></item><item><title>Interpretable Features from Neural Networks</title><link>https://akash5100.github.io/posts/2024-06-03-interpretable_features_from_nns/</link><pubDate>Mon, 03 Jun 2024 00:00:00 +0000</pubDate><guid>https://akash5100.github.io/posts/2024-06-03-interpretable_features_from_nns/</guid><description>&lt;p&gt;I watched a &lt;a href="https://www.youtube.com/results?search_query=Jensen+And+Ilya"&gt;podcast of Jensen and Ilya&lt;/a&gt;, in which Ilya talked about how multimodality enables neural networks to learn more features than just a single modality. For example, large language models like GPT-4, without vision, can recognize that the color pink is close to red, but they can&amp;rsquo;t explain why, because they haven&amp;rsquo;t seen a single pixel. Multimodality combines image and text, both trained in a unified way. And GPT-4 with vision can tell exactly which pixel is red and why. To achieve intelligence smarter than human-level intelligence, we will definitely need multimodality, because our world is very visual, and neural networks can learn a lot from it.&lt;/p&gt;</description></item><item><title>CNNs</title><link>https://akash5100.github.io/posts/2024-05-21-convolutional_neural_networks/</link><pubDate>Tue, 21 May 2024 00:00:00 +0000</pubDate><guid>https://akash5100.github.io/posts/2024-05-21-convolutional_neural_networks/</guid><description>&lt;p&gt;This is a quick skim notes for &lt;a href="https://www.youtube.com/watch?v=LxfUGhug-iQ&amp;amp;list=PLkt2uSq6rBVctENoVBg1TpCC7OQi31AlC&amp;amp;index=8"&gt;CS231n Introduction to CNN lecture 7&lt;/a&gt;, I used slides from this lecture to create notes and this is NOT an attempt to replicate &lt;a href="https://cs231n.github.io/convolutional-networks/"&gt;notes by cs231n&lt;/a&gt;, its already the best notes on CNNs out there.&lt;/p&gt;
&lt;p&gt;CNNs are similar to ordinary neural networks, they have trainable weights and bias, receives input, bunch of trainable layers followed with non-linearity. Each layer is completely differentiable, means they can learn. At the end an output layer predicting classes or so.&lt;/p&gt;</description></item><item><title>Gradient-Checkpointing</title><link>https://akash5100.github.io/posts/2024-05-16-deep_network_training_hack_gradient_checkpointing/</link><pubDate>Thu, 16 May 2024 00:00:00 +0000</pubDate><guid>https://akash5100.github.io/posts/2024-05-16-deep_network_training_hack_gradient_checkpointing/</guid><description>&lt;p&gt;You got a very deep neural network to train, lets say wide 128-layers. Does it fits in memory? Yes (barely). The activations and gradients in forward and backward pass respectively takes a lot of memory. But you want to train more deep NN. Why? because, we build the compute (stack more layer) ~= win. (&lt;a href="https://gwern.net/scaling-hypothesis#scaling-hypothesis"&gt;scaling hypothesis&lt;/a&gt;) / Blessing of scaling.&lt;/p&gt;
&lt;p&gt;See the original gradient checkpointing implementation.&lt;sup id="fnref:1"&gt;&lt;a href="#fn:1" class="footnote-ref" role="doc-noteref"&gt;1&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;p&gt;Here is a visualization of vanilla training:&lt;/p&gt;</description></item><item><title>Case Study on Transformer-based architecture</title><link>https://akash5100.github.io/posts/2024-05-09-case_study_transformer_based_architecture_development/</link><pubDate>Thu, 09 May 2024 00:00:00 +0000</pubDate><guid>https://akash5100.github.io/posts/2024-05-09-case_study_transformer_based_architecture_development/</guid><description>&lt;blockquote&gt;
&lt;p&gt;work in progress. publishing this but will be updated every few days, as I learn new stuffs. learning &amp;gt; blog&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;I am learning how the transformer-based architectures got evolved from 2017 (&amp;ldquo;Attention is all you need&amp;rdquo;) till today (May 2024). So, I thought why not write a case-study like &lt;a href="https://cs231n.github.io/convolutional-networks/#case-studies"&gt;this&lt;/a&gt; (by Andrej Karpathy).&lt;/p&gt;
&lt;h4 id="table-of-content"&gt;&lt;strong&gt;Table of content&lt;/strong&gt;&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="#how-can-unsupervised-learning-work"&gt;How can unsupervised learning work?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#gpt-june-2018"&gt;GPT (June 2018)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#bert-october-2018"&gt;BERT (October 2018)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#transformer-xl-september-2018-and-xlnet-june-2019"&gt;Transformer-XL (September 2018) &amp;amp; XLNet (June 2019)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#gpt-2-february-2019"&gt;GPT-2 (February 2019)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#sparse-transformers-april-2019"&gt;Sparse Transformers (April 2019)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;!-- - [Reformer](#reformer)
- [Linformer](#linformer)
- [Vision Transformer &amp; Image transformer (Niki parmar)](#vision-transformer-image-transformer-niki-paramr)
- [RoBERTa (July 2019)](#roberta-july-2019)
- [DistilBERT (March 2020)](#distilbert-march-2020) --&gt;
&lt;h4 id="how-can-unsupervised-learning-work"&gt;How can unsupervised learning work?&lt;/h4&gt;
&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=AKMuA_TVz3A"&gt;Why it works? Generalization?&lt;/a&gt;, hypothetically&amp;hellip;&lt;/p&gt;</description></item><item><title>Key-Value caching</title><link>https://akash5100.github.io/posts/2024-05-06-key-value_caching_for_fast_inference/</link><pubDate>Mon, 06 May 2024 00:00:00 +0000</pubDate><guid>https://akash5100.github.io/posts/2024-05-06-key-value_caching_for_fast_inference/</guid><description>&lt;p&gt;Long story short, Key value caching is used to reduce the inference speed of AR models (autoregressive / decoder-only). It does so by caching the already computed attention scores (K and V) of previous &lt;code&gt;1&lt;/code&gt;&amp;ndash; &lt;code&gt;t-1&lt;/code&gt; tokens. While the generated token is &lt;code&gt;t&lt;/code&gt;.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Inference refers to the process of using a trained model to make predictions or generate output for new, unseen input data. In other words, it&amp;rsquo;s the process of applying the model to real-world data to get a result or prediction.&lt;/p&gt;</description></item><item><title>I challenged myself to visualize attentions (nothing special)</title><link>https://akash5100.github.io/posts/2024-05-04-i_challenged_myself_to_visualize_attentions/</link><pubDate>Sat, 04 May 2024 00:00:00 +0000</pubDate><guid>https://akash5100.github.io/posts/2024-05-04-i_challenged_myself_to_visualize_attentions/</guid><description>&lt;blockquote&gt;
&lt;p&gt;nothing very special as I expected, because it was just a heat map of embeddings, next time, something better for sure. I aimed to create visualization like this &lt;a href="https://arxiv.org/pdf/1601.06733"&gt;research paper&lt;/a&gt; or by &lt;a href="https://karpathy.github.io/2015/05/21/rnn-effectiveness/"&gt;Andrej Karpathy&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;I started with creating vocabulary for my model using BPE (&lt;a href="https://en.wikipedia.org/wiki/Byte_pair_encoding"&gt;Byte Pair algorithm&lt;/a&gt;). Hyperparameter for BPE merges I used is &lt;code&gt;2000-256&lt;/code&gt;, it would create vocab of size &lt;code&gt;2000&lt;/code&gt;. How? recall your learning and solve that mystery. Before running BPE on &amp;lsquo;Elvis Presley&amp;rsquo; wiki page (because it was very long, no other reason), I split them into words using the Llama3 tokenizer Regex:&lt;/p&gt;</description></item><item><title>Transformers</title><link>https://akash5100.github.io/posts/2024-04-28-transformers/</link><pubDate>Sun, 28 Apr 2024 00:00:00 +0000</pubDate><guid>https://akash5100.github.io/posts/2024-04-28-transformers/</guid><description>&lt;p&gt;Back in 2017, the deep learning folks were trying to achieve state-of-the-art performance in sequence to sequence modeling. They used RNN&amp;rsquo;s like LSTM and GRU. The best performing model connects the encoder and decoder through an attention mechanism. Where the encoder is used to encode some sequence into rich embeddings and decoder decodes that embedding to different sequence. Example, language translation.&lt;/p&gt;
&lt;h3 id="table-of-contents"&gt;Table of contents&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="#sequence-to-sequence-modeling-and-limitations-of-rnns"&gt;Sequence to sequence modeling and limitations of RNNs&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#transformer"&gt;Transformer&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#model-architecture"&gt;Model Architecture&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#attention"&gt;Attention&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="#types-of-attention-function"&gt;Types of attention function&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#why-scaling"&gt;Why scaling&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#multihead-attention"&gt;Multihead attention&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#auto-regression-mask-for-self-attention-head-masked-attention"&gt;Auto-regression mask for self-attention Head (Masked-attention)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href="#feed-forward-linear-transformation"&gt;Feed Forward (Linear transformation)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#input-embeddings-vocab-and-positional"&gt;Input Embeddings (Vocab and Positional)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#regularizations-used-in-the-paper"&gt;Regularizations used in the paper&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#transformer-architectures"&gt;Transformer Architectures&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="#encoder-decoder"&gt;Encoder-Decoder&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#encoder-only"&gt;Encoder only&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#decoder-only"&gt;Decoder only&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href="#sources"&gt;Sources&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="sequence-to-sequence-modeling-and-limitations-of-rnns"&gt;Sequence to sequence modeling and limitations of RNNs&lt;/h2&gt;
&lt;p&gt;RNN had the vanishing gradient problem, models like LSTM and GRU emerged to tackle this problem but realized that altho the text may look better than rubbish, its still rubbish. It may look like English, but jumbled words and the sentence has no meaning.&lt;/p&gt;</description></item><item><title>Parameter updates</title><link>https://akash5100.github.io/posts/2024-04-12-optimization_techniques/</link><pubDate>Fri, 12 Apr 2024 00:00:00 +0000</pubDate><guid>https://akash5100.github.io/posts/2024-04-12-optimization_techniques/</guid><description>&lt;p&gt;Once the gradient is computed, it is then used to update the parameters. There are several approaches to perform the update.&lt;/p&gt;
&lt;!-- TOC --&gt;
&lt;h3 id="table-of-contents"&gt;Table of contents&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="#first-ordersgd-momentum-nesterov-momentum"&gt;First order(SGD), momentum, nesterov momentum&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="#stochastic-gradient-descent"&gt;Stochastic gradient descent&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#momentum-update"&gt;Momentum Update&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#nesterov-momentum-nag"&gt;Nesterov Momentum (NAG)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href="#per-parameter-adaptive-learning-rates-adagrad-rmsprop"&gt;Per-parameter adaptive learning rates (Adagrad, RMSProp)&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="#adagrad"&gt;Adagrad&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#rmsprop-gef-hinton"&gt;RMSProp (Gef. Hinton)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#adam"&gt;Adam&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#adamw"&gt;AdamW&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#adamschedulefree"&gt;AdamScheduleFree&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href="#second-order-methods"&gt;Second order methods&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#sources"&gt;Sources&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="first-ordersgd-momentum-nesterov-momentum"&gt;First order(SGD), momentum, nesterov momentum&lt;/h2&gt;
&lt;h3 id="stochastic-gradient-descent"&gt;Stochastic gradient descent&lt;/h3&gt;
&lt;p&gt;This is the &lt;strong&gt;vanilla&lt;/strong&gt; update, the simplest form of update that changes the parameters along the negative gradient direction, as the gradient indicates the direction of increase, whereas we usually wish to minimize a loss. Assuming a vector of parameters &lt;code&gt;x&lt;/code&gt; and the gradient &lt;code&gt;dx&lt;/code&gt;, the simplest form of the update is as follows.&lt;/p&gt;</description></item><item><title>Understanding loss.backward()</title><link>https://akash5100.github.io/posts/2024-04-02-understanding_loss.backward/</link><pubDate>Tue, 02 Apr 2024 00:00:00 +0000</pubDate><guid>https://akash5100.github.io/posts/2024-04-02-understanding_loss.backward/</guid><description>&lt;p&gt;Relying on any library is not good; therefore, this time, removing this black box and understand what&amp;rsquo;s happening inside. Writing a backward pass manually would be helpful. Backpropagation is not something that works magically or automatically if you are hoping to debug. In other words, it is easy to fall into the trap of abstracting away the learning process, believing that you can simply stack arbitrary layers together and backprop will magically make them work on your data. So let&amp;rsquo;s look at a few explicit examples where this is not the case in quite unintuitive ways.&lt;/p&gt;</description></item><item><title>Batch Normalization</title><link>https://akash5100.github.io/posts/2024-03-10-batch_normalization/</link><pubDate>Sun, 10 Mar 2024 00:00:00 +0000</pubDate><guid>https://akash5100.github.io/posts/2024-03-10-batch_normalization/</guid><description>&lt;h3 id="table-of-contents"&gt;Table of contents&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="#strange-output-of-coupling"&gt;Strange output of coupling&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#source"&gt;Source&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Understanding why training deep neural networks can be fragile is crucial. Issues like dead neurons or saturation of non-linearity, and the vanishing or exploding gradients have caused problem for deep learning for years. However, there&amp;rsquo;s a beacon of hope that emerged around 2015: Batch Normalization.&lt;/p&gt;
&lt;p&gt;Here is a visualization of problem using graph. Say we have 1000 datapoints and each has 500 embeddings (latent factors).&lt;/p&gt;</description></item><item><title>Dead Neurons</title><link>https://akash5100.github.io/posts/2024-03-04-dead_neurons/</link><pubDate>Mon, 04 Mar 2024 00:00:00 +0000</pubDate><guid>https://akash5100.github.io/posts/2024-03-04-dead_neurons/</guid><description>&lt;h3 id="table-of-contents"&gt;Table of contents&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="#peeking-inside-a-hidden-layer"&gt;Peeking inside a hidden layer&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#but-how-can-we-decide-which-number-to-multiply"&gt;But how can we decide which number to multiply? (Initialization)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#summary"&gt;Summary&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I implemented some techniques used in a research paper for n-gram language modeling. It is a simple MLP-based trigram language model that takes three characters&amp;rsquo; tokens as input, passes them into an embedding layer, then a hidden linear layer, and finally predicts the next character&amp;rsquo;s token.&lt;/p&gt;
&lt;p&gt;Here are the hyperparameters I used:&lt;/p&gt;</description></item><item><title>Gated Recurrent Unit (GRU)</title><link>https://akash5100.github.io/posts/2024-02-16-gru/</link><pubDate>Fri, 16 Feb 2024 00:00:00 +0000</pubDate><guid>https://akash5100.github.io/posts/2024-02-16-gru/</guid><description>&lt;h3 id="table-of-contents"&gt;Table of contents&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="#reset-gate"&gt;Reset Gate&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#update-gate"&gt;Update Gate&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#memory-cell"&gt;Memory Cell&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#final-memory"&gt;Final Memory&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#summary"&gt;Summary&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#sources"&gt;Sources&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;GRU was first proposed in 2014 (RNN was in 1986, LSTM in 1995).
GRU raised the question of whether we need to be that flexible like LSTM to learn the sequence. GRU is less flexible than LSTM but it is good enough for sequence learning.&lt;/p&gt;
&lt;p&gt;GRU redesigned the LSTM cell by introducing reset gate, update gate, and new memory cell; therefore, the number of gates were reduced from four to three. It was empirically shown in (Chung et al., 2014) that the performance of LSTM improves by using GRU cells. Later in 2017, the GRU was further simplified by merging the reset and update gates into a forget gate (Heck &amp;amp; Salem, 2017). Nowadays, GRU is the most commonly used LSTM structure.&lt;/p&gt;</description></item><item><title>Long Short-Term Memory (LSTMs)</title><link>https://akash5100.github.io/posts/2024-02-07-lstm/</link><pubDate>Wed, 07 Feb 2024 00:00:00 +0000</pubDate><guid>https://akash5100.github.io/posts/2024-02-07-lstm/</guid><description>&lt;h3 id="table-of-contents"&gt;Table of contents&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="#regularizing-lstm"&gt;Regularizing LSTM&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="#1-dropout"&gt;1. Dropout&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#2-activation-regularization-and-temporal-activation-regularization"&gt;2. Activation Regularization and Temporal Activation Regularization&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href="#gradient-clipping-good-to-know"&gt;Gradient Clipping (good to know)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#summary"&gt;Summary&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;LSTM were designed to deal with the issue of exploding or vanishing gradients in RNNs. This is challenging because, neural nets generally struggle to learn long-term dependencies.&lt;/p&gt;
&lt;p&gt;LSTM introduces gate mechanism and has 2 hidden state, that allows information to flow unmodified over many timesteps. Each LSTM cell has a set of gates (forget, input, cell/memory and out) that carefully regulate the information into and out of the cell.&lt;/p&gt;</description></item><item><title>Stateful Recurrent Neural Network</title><link>https://akash5100.github.io/posts/2024-02-06-tweaking_mlp_to_make_it_rnn/</link><pubDate>Tue, 06 Feb 2024 00:00:00 +0000</pubDate><guid>https://akash5100.github.io/posts/2024-02-06-tweaking_mlp_to_make_it_rnn/</guid><description>&lt;h3 id="table-of-contents"&gt;Table of contents&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="#we-can-remove-the-hardcoded-part-by-replacing-it-with-a-loop"&gt;We can remove the hardcoded part by replacing it with a loop&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="#improving-our-rnn"&gt;Improving our RNN&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href="#first-thing-first-lets-solve-the-resetting-of-hidden-state"&gt;First thing first, let&amp;rsquo;s solve the resetting of hidden state&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#creating-multilayer-rnn"&gt;Creating Multilayer RNN&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#exploding-and-disappearing-activations"&gt;Exploding and disappearing Activations&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If we have data like: (from the example of previous blog)&lt;/p&gt;
&lt;p&gt;&lt;code&gt;X&lt;/code&gt; &amp;ndash; &lt;code&gt;Y&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;'one', '.', 'two'&lt;/code&gt; &amp;ndash; &lt;code&gt;'.'&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;'.', 'three', '.'&lt;/code&gt; &amp;ndash; &lt;code&gt;'four'&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Where 3 words are used as input to predict 1 word from a vocabulary as an output, we can create a neural network architecture that takes three words as input and returns a prediction of the probability for each possible next word in the vocabulary.&lt;/p&gt;</description></item><item><title>Tokenize &amp; Numericalize</title><link>https://akash5100.github.io/posts/2024-02-05-tokenization_for_lm/</link><pubDate>Mon, 05 Feb 2024 00:00:00 +0000</pubDate><guid>https://akash5100.github.io/posts/2024-02-05-tokenization_for_lm/</guid><description>&lt;p&gt;Here are the main steps for language modeling:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Tokenization&amp;ndash; Converting Text into list of words (creating the vocab)&lt;/li&gt;
&lt;li&gt;Numericalization&amp;ndash; Converting each word in vocab to number, by replacing them with their indices (simple!)&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The next steps are: Language Model Data Creation (X&amp;amp;Y) and Language Model Creation&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Jargon: Token&lt;/strong&gt; &lt;br/&gt; One element of a list created by the tokenization process. It could be a word, part of a word (a subword), or a single character.&lt;/p&gt;</description></item><item><title>Self-Supervised &amp; Transfer Learning in Language Models</title><link>https://akash5100.github.io/posts/2024-02-03-selfsup_learning/</link><pubDate>Sat, 03 Feb 2024 00:00:00 +0000</pubDate><guid>https://akash5100.github.io/posts/2024-02-03-selfsup_learning/</guid><description>&lt;p&gt;A language model is a model that is trained to guess the next word in a text (having read the ones before). This kind of task is called self-supervised learning.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Jargon: self supervised learning&lt;/strong&gt; &lt;br /&gt; Training a model using labels that are embedded in the independent variable, rather than requiring external labels.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Self supervised learning is not usually used for the model that is trained directly, but instead is used for pretraining a model used for transfer learning. Self supervised learning is used to train a base model, and that base model is used to train different model for specific task like text classification!&lt;sup id="fnref:1"&gt;&lt;a href="#fn:1" class="footnote-ref" role="doc-noteref"&gt;1&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;</description></item><item><title>Embeddings in sequential Neural Network</title><link>https://akash5100.github.io/posts/2024-02-01-deep_learning_for_collaborative_filtering/</link><pubDate>Thu, 01 Feb 2024 00:00:00 +0000</pubDate><guid>https://akash5100.github.io/posts/2024-02-01-deep_learning_for_collaborative_filtering/</guid><description>&lt;p&gt;Alright who cares about the follow up blog, &lt;a href="https://akzsh.notion.site/Tabular-Data-analysis-and-Decision-Tree-9444c1ca59d7464dbc91e7cb6cb243fc?pvs=4"&gt;here&lt;/a&gt; is a notion notes to save me. This is the notes for tweaking Random forest on a tabular dataset to squeeze some performance, I tried this on a &lt;a href="https://www.kaggle.com/competitions/store-sales-time-series-forecasting/leaderboard"&gt;Kaggle compe&lt;/a&gt; and it worked out pretty badly. Score of something like 2.xx. Maybe I Will improve it when time comes. zzz&lt;/p&gt;
&lt;hr&gt;
&lt;br/&gt;
&lt;p&gt;As we already initialized the embeddings of our users and products for example, We take the result of the embedding lookup and concatenate those activations together. This gives us a matrix that we can then pass through linear layers and nonlinearities in the usual way.&lt;/p&gt;</description></item><item><title>Embeddings in Recommendation Systems</title><link>https://akash5100.github.io/posts/2024-01-15-embeddings/</link><pubDate>Mon, 15 Jan 2024 00:00:00 +0000</pubDate><guid>https://akash5100.github.io/posts/2024-01-15-embeddings/</guid><description>&lt;h3 id="table-of-contents"&gt;Table of contents&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="#collaborative-filtering"&gt;Collaborative Filtering&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#a-tabular-dataset---movie-recommendation-system"&gt;A Tabular Dataset -&amp;gt; Movie Recommendation System?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#embeddings"&gt;Embeddings?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#speed-up-the-calculation-of-scores"&gt;Speed up the calculation of scores&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#why-sharp-curves-of-learning-weights--overfitting"&gt;Why sharp curves of learning weights = overfitting&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#weight-decay-or-l2-regularization"&gt;Weight Decay or L2 Regularization&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#movie-recommendation-system-with-embeddings-movielens-dataset"&gt;Movie Recommendation System with Embeddings (MovieLens Dataset)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#direction-and-distance-of-embeddings"&gt;Direction and Distance of embeddings&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#otakus-are-kinda-poison-to-our-embeddings"&gt;Otakus are kinda poison to our embeddings&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I will write a follow up blog about Regression and Random Forest, today completes the half of the first month of 2024, I learned lots of stuffs that I am interested and participated on a Kaggle compe, predicing Energy consumption and production using solar panels, just to try what I learned and now I am one step closer to understanding the &amp;ldquo;Attention&amp;rdquo;. I will continue this journey and still be writing this blog for future me like creating notes, maybe in more readable form.&lt;/p&gt;</description></item><item><title>Cross Entropy in Classification</title><link>https://akash5100.github.io/posts/2023-12-22-titanic/</link><pubDate>Fri, 22 Dec 2023 00:00:00 +0000</pubDate><guid>https://akash5100.github.io/posts/2023-12-22-titanic/</guid><description>&lt;h3 id="table-of-contents"&gt;Table of contents&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="#hyperparameters"&gt;Hyperparameters&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#i-coded-the-titanic-dataset-in-a-simple-mlp"&gt;I coded the Titanic dataset in a simple MLP&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#regression-and-summarizing-loss-functions"&gt;Regression and Summarizing Loss functions&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#source"&gt;Source&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Multi label classification refers to the problem of identifying the categories of objects in images that may not contain exactly one type of object. So each data can have either single or multiple label(s). Example, a image has car, bicycle, person, tree.&lt;/p&gt;
&lt;hr&gt;
&lt;br /&gt;
&lt;p&gt;&lt;strong&gt;Why we cant use softmax and NLL loss?&lt;/strong&gt;&lt;/p&gt;</description></item><item><title>Logarithms in Deep Learning</title><link>https://akash5100.github.io/posts/2023-12-11-nll_loss/</link><pubDate>Mon, 11 Dec 2023 00:00:00 +0000</pubDate><guid>https://akash5100.github.io/posts/2023-12-11-nll_loss/</guid><description>&lt;h3 id="table-of-contents"&gt;Table of contents&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="#understanding-softmax"&gt;Understanding Softmax&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#logarithm"&gt;Logarithm&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#finding-a-right-learning-rate---a-technique"&gt;Finding a right Learning Rate - A technique&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#unfreezing--transfer-learning"&gt;Unfreezing &amp;amp; Transfer Learning&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="#unfreezing"&gt;Unfreezing?&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href="#discriminative-learning-rate"&gt;Discriminative learning rate&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;To learn the foundation very clearly, I coded MLP, from scratch and trained MNIST dataset. (it was a 3 vs 7 model, a binary classifier). For that I used a Linear function in each neuron, and Relu as activation. and for the final layer I used Sigmoid. I wanted to expand this model from just a binary classifier to multi-class classifier (where each instance belongs to one and only one class) I learned about Softmax activation that can be used in the final layer and then creating a loss function for MNIST model.
&lt;br /&gt;&lt;/p&gt;</description></item><item><title>Algorithm behind universal function approximator</title><link>https://akash5100.github.io/posts/2023-11-04-algo_behind_universal_function_approximator/</link><pubDate>Sat, 04 Nov 2023 00:00:00 +0000</pubDate><guid>https://akash5100.github.io/posts/2023-11-04-algo_behind_universal_function_approximator/</guid><description>&lt;p&gt;A artificial neural network can learn (almost) anything, and so its called a universal function approximator. To understand how it works, we need to know function.&lt;/p&gt;
&lt;p&gt;Function, let&amp;rsquo;s say f(x) is just a system of inputs and outputs, a number in, a number out.&lt;/p&gt;
&lt;p&gt;x -&amp;gt; f(x) -&amp;gt; y&lt;/p&gt;
&lt;p&gt;We give a input x, and it outputs y. We can plot all the functions on a graph, where it gives an output for an input. What is important is, if you know a function you can always calculate the output (y) for a given input (x).&lt;/p&gt;</description></item><item><title>Traffic on blocked ports</title><link>https://akash5100.github.io/posts/2023-09-30-firewall/</link><pubDate>Sat, 30 Sep 2023 00:00:00 +0000</pubDate><guid>https://akash5100.github.io/posts/2023-09-30-firewall/</guid><description>&lt;p&gt;While there are many blogs and tutorials available on accessing a Virtual Cloud Network in a VM instance, such as this &lt;a href="https://docs.oracle.com/en/learn/lab_virtual_network/index.html#introduction"&gt;comprehensive guide(by oracle)&lt;/a&gt;. Some of the VM instances I&amp;rsquo;m working with are not vanilla; they come with the distributor&amp;rsquo;s packet blockers and they block traffics on all the ports.&lt;/p&gt;
&lt;p&gt;I worked around &lt;a href="https://linux.die.net/man/8/iptables"&gt;Iptables&lt;/a&gt; a default firewall for linux, I think. It is used to set up, maintain, and inspect the tables of IP packet filter rules in the Linux kernel. Several different tables may be defined. Each table contains a number of built-in chains and may also contain user-defined chains.&lt;/p&gt;</description></item><item><title>I relearned entropy</title><link>https://akash5100.github.io/posts/2023-09-15-entropy/</link><pubDate>Fri, 15 Sep 2023 00:00:00 +0000</pubDate><guid>https://akash5100.github.io/posts/2023-09-15-entropy/</guid><description>&lt;p&gt;I learned about black hole, how are they possible? (just started). On the sunday morning, I started reading a paper about BBC Reith Lecture. It all started with &lt;strong&gt;Albert Einstein&lt;/strong&gt; writing a paper in 1939 claiming that stars could not collaspe under gravity because matter could not be compressed beyond a certain point, many scientist thought the same but an American scientist &lt;strong&gt;John Wheeler&lt;/strong&gt;, who in many ways is the hero of the black hole story. In his work in 1950s and 1960s, emphasized that many stars would eventually collapse and pointed out problems that possibility posed for theoretical physics. Durring most of the life of a normal star, over billons of years, it will support itself against its own gravity by thermal pressure caused by nuclear processes which convert hydrogen into helium.&lt;/p&gt;</description></item><item><title>About</title><link>https://akash5100.github.io/about/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://akash5100.github.io/about/</guid><description>About Akash Verma</description></item></channel></rss>