<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Mayukh Sarkar on Medium]]></title>
        <description><![CDATA[Stories by Mayukh Sarkar on Medium]]></description>
        <link>https://medium.com/@thedatageek?source=rss-7ed2417df592------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*isnKn2XBs_tfGHsP8cQF-w.jpeg</url>
            <title>Stories by Mayukh Sarkar on Medium</title>
            <link>https://medium.com/@thedatageek?source=rss-7ed2417df592------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 01:55:09 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@thedatageek/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[The Numbers That Define an LLM]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://ai.plainenglish.io/the-numbers-that-define-an-llm-a653edb0a0fd?source=rss-7ed2417df592------2"><img src="https://cdn-images-1.medium.com/max/2600/1*D6P0lQC08xaDrwG53StaJQ.png" width="3130"></a></p><p class="medium-feed-snippet">Imagine a general-purpose foundation model, or what people commonly call an LLM, as a next-token predictor. That&#x2019;s it. If I give it five&#x2026;</p><p class="medium-feed-link"><a href="https://ai.plainenglish.io/the-numbers-that-define-an-llm-a653edb0a0fd?source=rss-7ed2417df592------2">Continue reading on Artificial Intelligence in Plain English »</a></p></div>]]></description>
            <link>https://ai.plainenglish.io/the-numbers-that-define-an-llm-a653edb0a0fd?source=rss-7ed2417df592------2</link>
            <guid isPermaLink="false">https://medium.com/p/a653edb0a0fd</guid>
            <category><![CDATA[generative-ai-tools]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[llm]]></category>
            <dc:creator><![CDATA[Mayukh Sarkar]]></dc:creator>
            <pubDate>Thu, 18 Jun 2026 17:59:16 GMT</pubDate>
            <atom:updated>2026-07-07T07:26:41.824Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Evolution of Decoder-only models]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://ai.plainenglish.io/evolution-of-decoder-only-models-c1f05e49519c?source=rss-7ed2417df592------2"><img src="https://cdn-images-1.medium.com/max/2600/1*GWvrIHs8hBejPkfYlYztPA.png" width="3558"></a></p><p class="medium-feed-snippet">How encoder-only became champion modern day LLMs</p><p class="medium-feed-link"><a href="https://ai.plainenglish.io/evolution-of-decoder-only-models-c1f05e49519c?source=rss-7ed2417df592------2">Continue reading on Artificial Intelligence in Plain English »</a></p></div>]]></description>
            <link>https://ai.plainenglish.io/evolution-of-decoder-only-models-c1f05e49519c?source=rss-7ed2417df592------2</link>
            <guid isPermaLink="false">https://medium.com/p/c1f05e49519c</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[gpt]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Mayukh Sarkar]]></dc:creator>
            <pubDate>Tue, 02 Sep 2025 06:24:13 GMT</pubDate>
            <atom:updated>2025-09-04T06:50:19.641Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[CNN for RNNs — A gentle approach to use CNNs for NLP]]></title>
            <link>https://medium.com/good-audience/cnn-for-rnns-a-gentle-approach-to-use-cnns-for-nlp-53ab80768d43?source=rss-7ed2417df592------2</link>
            <guid isPermaLink="false">https://medium.com/p/53ab80768d43</guid>
            <category><![CDATA[convolutional-network]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[nlp]]></category>
            <dc:creator><![CDATA[Mayukh Sarkar]]></dc:creator>
            <pubDate>Mon, 04 Mar 2019 00:25:43 GMT</pubDate>
            <atom:updated>2019-03-06T11:20:01.041Z</atom:updated>
            <content:encoded><![CDATA[<h3>CNN for RNNs — A gentle approach to use CNNs for NLP</h3><figure><img alt="https://cdn-images-1.medium.com/max/1200/1*RXJ6tAmfN1AYLQr7p48L7w.png" src="https://cdn-images-1.medium.com/proxy/1*RXJ6tAmfN1AYLQr7p48L7w.png" /><figcaption>A typical deep Conv</figcaption></figure><blockquote>A picture is worth a thousand words</blockquote><p>If you are from Electronics background with enough understanding in Signal Systems, you might have heard about convolution of digital or analog signals. These are not at all images but we can still use it to do multiple signal processing stuffs. One university professor while having discussions with me on the following topic mentioned,</p><blockquote>Yes, of course anything can be used for anything, its just matter of changing the problem accordingly but will it work, it also depends on the problem.<br>For text type of data, you can certainly use CNN with 1d convolution.<br>Since it is based on convolution, you might recall our old signal and system class what convolution is for you can relate it with that convolution and understand why it should be less effective for text type data.<br>CNN is good with data changing over space and time with continues values, NOT just image, CNN is useful for speech, EEG, GSR, EMG, ECG, and many more sensor data. Usually, LSTM is one good approach for temporal data, but CNN is being used too, and combination of CNN-LSTM is also very useful.</blockquote><h4>Why this problem ?</h4><p>But before we jump right into how, let’s answer why. I actually have a habit of questioning everything. Before I ask what is the solution, I ask what are not solutions. Good or Bad, but this habit led me very deep into topics that I am studying. When I was learning machine leaning, I asked questions that why machine learning and why not rule based systems? Then when we stated Deep Learning with simple MLP(Multi-Layered Preceptron), I asked why deep learning instead of classical machine learning. Then we were taught CNNs for image data and I asked why to use CNNs for image data when I have already applied ANNs/MLPs on <a href="http://yann.lecun.com/exdb/mnist/"><strong><em>MNIST dataset</em></strong></a>! So it’s quiet natural that when I am being taught RNN (LSTMs or GRUs) for processing sequential data, I would ask questions; why RNN and not trusty old CNNs. Just because it’s not customary to do something, we should not stop experimenting.</p><p>In-fact some of the best works on non image type data are being done by CNNs. One of the biggest example is Google’s WAVENET. Not that I love Google, but they have done terrific job in replacing expensive LSTMs with something called Dilated CNNs for a larger reach of the spacial data but still making it parallel to process and there by deceasing the total time taken to train a sequence. But that’s a story for some other day.</p><h4>Can you give more examples ?</h4><p>There are multiple examples some example and research papers are as follows</p><ul><li><a href="https://arxiv.org/pdf/1609.03499.pdf"><strong><em>Google WAVENET</em></strong></a></li><li><a href="https://github.com/kristpapadopoulos/seriesnet"><strong><em>Stock Price Predictions</em></strong></a></li><li><a href="https://github.com/MayukhSobo/Conv4RNN"><strong><em>Sentiment Classification</em></strong></a></li></ul><h4>What is the core concept behind this ?</h4><p>Well in one word it’s <a href="https://www.quora.com/When-is-a-1D-Convolutional-Neural-Network-appropriate-to-use"><strong><em>1d Convolution</em></strong></a> among <a href="https://stackoverflow.com/questions/42883547/intuitive-understanding-of-1d-2d-and-3d-convolutions-in-convolutional-neural-n"><strong><em>2d and 3d convolution</em></strong></a>.</p><p>A depiction of 1D convolution reveals that it is very good in keeping a track of sequence like LSTMs specially over a long long sequence pattern. It somehow captures the n-gram information. In fact if you have to keep track of 3, 4 and 5-grams, instead of creating a model of 3, 4, 5 gram with <a href="https://scikit-learn.org/stable/modules/generated/sklearn.feature_extraction.text.CountVectorizer.html"><strong><em>CountVecorizer</em></strong></a><em> </em>and then applying classical <a href="https://en.wikipedia.org/wiki/Generalized_linear_model"><strong><em>GLM algorithms</em></strong></a>, I found it is much more convenient and in just 5 to 7 epochs we get phenomenal results. Although I haven’t benchmarked it against classical LSTMs/GRUs but I have a hunch that it would be comparable if not better. I would encourage any of you to benchmark it and inform me if possible.</p><h4>But How do we process the data ?</h4><p>Yeah it’s an impending question and the question arises because we have a habit of using some basic augmentation and reshaping of image data before we pass into a CNN but here we don’t have any such data so naturally question arises that how did you process the data?</p><p>Well the processing of the data was as it is done in case of LSTMs. In LSTM, we convert the text data into series of ranks. Let’s understand it in a step. But before that we need to pose a NLP problem. Let’s take the most basic NLP problem, a <a href="https://en.wikipedia.org/wiki/Sentiment_analysis"><em>sentiment classification</em></a> problem.</p><ul><li>Now first you calculate the frequency of all the words in the corpus.</li><li>Then you use this frequency to rank the words in non-decreasing order.</li><li>Then all the words in the corpus would get a rank according to the frequency in the corpus.</li><li>Sometime we also mention <em>maximum_size </em>to restrict the size of the vocabulary so that the dimension of the data remains low.</li></ul><p>So let’s say you have a rank table looks like following for a corpus</p><pre>ranks = {<br>   &quot;the&quot;: 56325,<br>   &quot;a&quot;: 53623&quot;<br>   &quot;to&quot;: 43521,   <br>   &quot;hello&quot;: 33009,<br>   .<br>   .<br>   .<br>   &quot;say&quot;: 23552,<br>   .<br>   .<br>   .<br>   &quot;man&quot;: 3466<br>}</pre><p>Now let’s say that you have a sentence in the corpus like the following</p><pre>&quot;Say hello to the man&quot;</pre><p>Then this sentence would be converted into rank vectors like following</p><pre>[23552, 33009, 43521, 56325, 3466]</pre><p>Now imagine a list of lists all containing ranks of the words and then passed into you network.</p><h4>But what about the corner cases ?</h4><blockquote>Uniformity is in the nature of math but not in the math of nature</blockquote><p>Different documents in a corpus has different length and hence if we convert all of the documents in a corpus into rank vectors, they would definitely have different lengths. But usually our dataset needs to be uniform meaning that the above mentioned list length should be same for all the documents. So what is the solution.</p><p>Well the natural solution is to first calculate the longest document in the corpus and then pad some dummy rank for the extra locations. We can add this padding at the beginning or at the end or even half in the beginning and half at the end. In my personal experience, the last mentioned technique worked better but however it would still be dependent on the dataset. For example lets say that the longest sequence in corpus is of length 10. So the above mentioned list would be</p><pre>[1, 1, 1, 23552, 33009, 43521, 56325, 3466, 1, 1]</pre><p>Here I am using 1 as a dummy token. The sentence which had already 10 words, there is no need for padding.</p><p>Some people like to be definite because of some architectural reasons and hence mention a fixed value say 8. In that case shorter sentences would be padded while longer sentences would be stripped down.</p><h4>Give one architectural reason when people don’t take maximum document length but gives a hard coded value. Like 8 instead of 10 mentioned above.</h4><p>There can be many and I may be missing out some. Frankly speaking I don’t consider myself a large deep learning solution architect and hence I may not know all of these. But one of the most important reason that I can see is when you have a large amount of dataset and each document is getting very long, you might need to strip down and take only a subset of the words and hence you strip the sentences.</p><p>For larger organizations with big compute power, they can consider it as hyperparamer and fine tune it to get the best performance. I can also see a use of <a href="https://en.wikipedia.org/wiki/Elbow_method_(clustering)"><strong><em>elbow method</em></strong></a><strong><em> </em></strong>to decide the right value of <em>maximum_size.</em></p><blockquote>But human beings made the math non-uniform</blockquote><p>I say this because some of the modern deep learning work that Microsoft has been doing whom I favor more than Google for AI research came up with <a href="https://github.com/Microsoft/CNTK"><strong><em>CNTK</em></strong></a><strong><em> </em></strong>which according the deep learning practitioner far better than <a href="https://www.tensorflow.org/"><strong><em>TensorFlow</em></strong></a><strong><em> </em></strong>does not need any padding for this kind of featurizations. This is the information that I received from my colleagues and friends and <strong><em>Rajarshee Mishra </em></strong><a href="https://www.quora.com/How-do-you-compare-Microsoft-CNTK-and-Google-Tensorflow-Does-one-hold-a-clear-advantage-over-the-other"><strong><em>here</em></strong></a> however I can’t corroborate that.</p><h4>But it seems pretty odd that simple ranks would work so well. This does’t even make proper intuitive sense.</h4><blockquote>There is more to it than you think</blockquote><p>No you are wrong. Superman is not the answer. Not even dark knight. The saviour is Embedding. Firstly let me tell you that whatever you guessed was actually correct. Simple ranking just won’t work. But for those who still thinks that simple ranking was enough, think again. The rankings doesn’t have any connection with the real corpus that the algorithm can know by any means. I mean you know it but how algorithm can relate number 56325with the word <em>“the” </em>? By no way it seems possible. But in reality there is a relation the sequence of how the words appear and their values.</p><p>So to learn this embedding comes into the picture. In true sense embedding is just a lookup and gather strategy but turns out well. It somehow represents a single word into <strong>embedding_dimension </strong>and then learn what the numbes should be during training the network according to the rank list. Because of larger number of values for each word as compared to single rank, it can learn far more internal patterns in the data corpus. Almost all the major neural network libraries have a separate embedding layer. In tensorflow, you can implement it like following</p><pre>tf.nn.embedding_lookup(params=[embedding_size], ids=[input_size])</pre><p>Now the question is what are <em>embedding_size </em>and <em>input_size </em>and how does it work.</p><p>Well as the name suggests the <em>input_size</em> is the size of the input data. So in this case the size would be None x 10<em>. None </em>because that would be decided during the runtime based on the batch size but the <em>10 </em>because we represented each document into a list of 10 ranks. So for batch_size of <em>50, </em>it would be 50x10.</p><p>The <em>embedding_size </em>is something very interesting. It’s size would maximum_size x vector_size</p><p><em>maximum_size </em>is something that I have already explained and <em>vector_size </em>is the size each rank needs to be converted into.</p><p>Some people would initialize the embedding layer before training with pre-trained word vector from <a href="https://code.google.com/archive/p/word2vec/"><strong><em>Word2Vec</em></strong></a><strong><em> </em></strong>or<strong><em> </em></strong><a href="https://nlp.stanford.edu/projects/glove/"><strong><em>GloVe</em></strong></a><strong><em> </em></strong>to get better performance. In my repository attached in this blog, you can do both. We shall see performances later on.</p><h4>Okay so Now what? How CNNs takes the data?</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/942/1*gM_xUyf482Sqbfefesyazg.png" /><figcaption>Architecture proposed at <a href="https://arxiv.org/pdf/1408.5882.pdf">https://arxiv.org/pdf/1408.5882.pdf</a></figcaption></figure><p>The idea is pretty simple. At each instance of convnet and maxpool, we use a certain number of feature maps. In this paper they decided to use 3 conv-maxpool units in parallel with each having 100 feature representations and having a certain amount of <a href="http://www.chioka.in/differences-between-l1-and-l2-as-loss-function-and-regularization/"><em>l2 regularization loss</em></a><em>.</em></p><p>But the key part is something else. The key part is convolution kernel sizes. They use 3 in the first unit, 4 in the second unit and 5 in the third unit. How did they find these numbers? Well it was part of their work but mostly empirical. Now they apply something like sliding window in because convolution is sliding window in nature.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/0*RNgjS4GqUi0MtOz3" /><figcaption>1D convolution for NLP</figcaption></figure><p>Imagine a 2d convolution sliding horizontally and also vertically but in case of 1d convolutions, it would be only sliding horizontally. Now if there are words horizontally and if your kernel size is 3 in the first layer, then you are taking w1, w2, w3 again w2, w3, w4 and so on and perform convolution and pass it to the next layer. This is how 1d-convolution is keeping the track of 3-grams. In another unit you do it for 4 grams with kernel size 4 and 5 gram in the 3rd unit with kernel value of 5 and then finally passing that vector representation to a Fully connected layer and a sigmoid layer the output and voilà, you get your network.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3SrC5mXypYS4K7kg1zwoSg.png" /><figcaption>Conv Layers in TensorBoard</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PRiyE-Kru3clw2IJYFdxZQ.png" /><figcaption>The Embedding Layer</figcaption></figure><p>Another good read would be <a href="https://www.aclweb.org/anthology/P14-1062"><strong><em>this paper</em></strong></a> where the authors proposed something called DCNN (Dynamic CNN) with max-pooling being dynamic part performs extensively well and some of the good fellows have even implemented the <a href="https://github.com/FredericGodin/DynamicCNN"><strong><em>code</em></strong></a> too. Dynamic CNN is being used in Aviation industry too as it is well mentioned in the following <a href="https://github.com/FredericGodin/DynamicCNN"><strong><em>paper</em></strong></a> but I am yet to read that.</p><p>Finally this is how the conv-layers look like on <a href="https://www.tensorflow.org/guide/summaries_and_tensorboard"><strong><em>TensorBoard</em></strong></a><strong><em> </em></strong><em>(Yeah the look sucks!!) </em>and this is how the embedding layer looks like at TensorBoard.</p><p>You can see how it converts datapoints of dimension 56 into 56x300 by looking into a lookup table like form in the embedding layer.</p><p><em>BTW thanks to their awful design sense, you can’t practically see the dimension even after zooming in enough. But it gets the job done!</em></p><h4>What were your results ? What are the datasets that you have used ? Did pretrained vectors line word2vec/GloVE helped?</h4><blockquote>Actions speak louder than words, but results literally yell</blockquote><blockquote>👉🏻 <strong>Dataset 1: </strong><a href="https://www.kaggle.com/iarunava/imdb-movie-reviews-dataset">IMDB Movie Review</a></blockquote><blockquote>👉🏻 <strong>Dataset 2:</strong><a href="https://www.kaggle.com/snap/amazon-fine-food-reviews"><strong> </strong>Amazon Fine Food Review Dataset</a></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9JSpQxTQ4kCB9SDhVQV9zg.png" /><figcaption>Train vs Validation Loss with Word2Vec Initialization (TensorBoard)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ICFM6RSBVKBQXArghraHxw.png" /><figcaption>Results on Datasets</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*N7gsNKxTJQXnrIvaX_sZ7A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XmnoHSYeBrtL4NtRQckMTw.png" /><figcaption>Weight Distributions for all 4 epochs in Amazon Food Review Datasets for both <strong>train </strong>&amp; <strong>validation</strong></figcaption></figure><blockquote>Time is more valuable than money</blockquote><p>I was surprised to see the results on Amazon fine food review dataset. I implemented a multi-layered LSTM too on the same dataset and performance was around <strong><em>95% </em></strong>which is a hell lot more that classical machine learning algorithms. But needless to that my LSTM took a lot more time to train over my CNN because of obvious reasons. So the million dollar question is that <strong>WOULD YOU SPENT ALMOST 3 TO 4 MORE HOURS JUST FOR 2% IMPROVEMENT ON THE SAME DATA ?</strong></p><p><strong>GitHub Repo for this:</strong> <a href="https://github.com/MayukhSobo/Conv4RNN"><em>https://github.com/MayukhSobo/Conv4RNN</em></a></p><p>Follow me on GitHub for more interesting projects and +1 and share this blog if you have liked my work.</p><p><strong>Upcoming Blog:</strong> <a href="https://www.cs.cmu.edu/~diyiy/docs/naacl16.pdf">Attention Mechanism using Context Vectors</a> for seq2seq models in LSTMs</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=53ab80768d43" width="1" height="1" alt=""><hr><p><a href="https://medium.com/good-audience/cnn-for-rnns-a-gentle-approach-to-use-cnns-for-nlp-53ab80768d43">CNN for RNNs — A gentle approach to use CNNs for NLP</a> was originally published in <a href="https://medium.com/good-audience">Good Audience</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>