Artificial Intelligence

Posts on Machine Learning, Deep Learning and Large Language Models — transformers, PyTorch, optimization, probability and the mathematics behind them.  ·  ← Home

Thinking beyond localized activations

Every network you’ve trained almost certainly leans on the same handful of activation functions — ReLU, GELU, SiLU, tanh. They differ in shape, but they share one quiet assumption: the nonlinearity itself is fixed. You pick one function, wide enough to cover the whole range of inputs a neuron wil...

Read more

More Is Different

When we scale a neural network to billions of parameters, new capabilities emerge. But we still lack a complete explanation of why certain capabilities emerge or how they arise. Well, this is not unique to neural networks! I recently came across a beautiful essay, “More Is Different,” by Philip ...

Read more

Will Conscious AI Conquer or Be Content?

Given modern language models’ ability to execute actions and their vast accumulation of knowledge, it is compelling to ask: What would happen if AI were to become truly conscious? Conventional wisdom fears a “Terminator” scenario. Yet the outcome might be the opposite. A truly conscious AI may n...

Read more

🕉️ (AUM) and the Vector Space

I was asked about the significance of saying “Om”. The friend who asked me this question is a scientist. Before responding, I made sure to understand his intention (genuine interest? yes) I responded by asking him something else. “Are you comfortable with the concept of the span of basis vecto...

Read more

Pre-training GPT-2 from scratch

Let us train a GPT-2 (small,124 million parameters) model from scratch using the Hugging Face library. Instead of using WebText dataset (due to limited compute resources) I preferred to use the book corpus dataset that contains 74 Million samples (far lower than today’s standard). The book corpus...

Read more

All About nn.Modules in Pytorch

If you are a researcher or someone who builds/tweaks the deep learning models regularly using the Pytorch framework or any other high-level frameworks that are built on top of Pytorch such as Huggingface, then it is extremely important to understand Pytorch’s nn.Modules. This is because your mode...

Read more

Model Training Strategies

Training large language models from scratch is the job of tech giants. Often, the pre-trained proprietary models are adapted to downstream tasks using instruction fine-tuning. However, doing full fine-tuning of model parameters increases the model performance. Of course, full fine- tuning of larg...

Read more

Introduction to Large Language Models - Course

For the past three months, I have been quite busy building course materials (lecture slides, graded assignments and coding assignments) for the first offering of the course Introduction to Large Language Models by Prof.Mitesh Khapra. It has been challenging work as we have committed to offer the ...

Read more

Positional Encoding In Transformers

Introduction One question that bothers our mind when we read positional encoding is whether it helps the model or not. It is observed that adding position embeddings only helps marginally in a convolutional neural network as CNN uses relative position embedding (implicitly). It is not the case f...

Read more

Data Pipeline for Large Language models

Data is the fuel for any machine learning model despite the type of learning algorithm (Gradient-based or tree-based) being used. To train and test the model’s generalization capacity, typically, we divide the available samples into three sets: Training, Validation and Test. The typical requireme...

Read more

Experimental Settings of Famous Language Models

GPT (Generative Pre-trained Transformer) Pre-training Dataset: Book corpus (0.8 Billion words) Unsupervised objective: CLM (Autoregressive) Tokenizer: Byte Pair Encoding (BPE) Vocab size: 40K Architecture: Decoder only (12 Layers) Activation: GELU Attention: Dense FFN: D...

Read more

Emergence of Large Language Models (LLMs)

Motivation Usually, in traditional machine learning, we use numerous approaches (model selection) like $K-$fold cross-validation and grid search to find the best model that generalizes well in the real world. However, when it comes to deep learning, it is quite challenging due to compute-cost con...

Read more

Maximum Likelihood Estimation

Introduction The concept of estimation of an unknown quantity from the given observations has been a fascinating area of study for many centuries. However, it remains elusive for many beginners. Let’s start with a concept that we are already familiar with. Here is a sequence $x_1=[1,3,5,7,9,11, \...

Read more

Representation Learning

Motivation Let’s start with a simple question. How do you represent a number on a real line?. That’s straightforward. How do you represent a 2D point $\begin{bmatrix}x \ y \end{bmatrix}$ in a coordinate system?. Well, we use two real lines that are orthogonal to each other. Move $x$ unit on the a...

Read more

Interplay of Indices in Math - Illustrated

Introduction When we have a sequence of elements, we use an index to locate a particular element in the sequence. The sequence of elements can be arranged into 2D,3D or n-dimensional arrays. Therefore, it is extremely important to make ourselves comfortable with using indexes to manipulate such a...

Read more

Transfer Learning

Imagine now that we are just beggining to learn to ride a bicycle. Initially, we need to put a lot of effort into learning to balance the cycle. Then gradually we learn to balance and eventually take a full control over the ride. Suppose that we also wish to learn to ride a simple electric bike. ...

Read more

Softmax and Its Derivative

Introduction The Softmax function is one of the most commonly used activation functions at the output layer of neural networks (be it CNN, RNN or Transformers). In fact, Large Language Models(LLMs) based on transformer architecture (like ChatGPT) use softmax in the output layer for many NLP(Natu...

Read more

Running Jupyter Notebook from a Remote Server

Introduction If you are training a deep learning model or fine-tuning LLMs (Large Language Models), then at some point in time you need to connect with a remote machine that has required amount of computing power (about 80GB or 320 GB of GPU Memory). Data scientists often use Jupyter Notebooks f...

Read more

Pytorch for Deep Learning

Theory is not enough, you must apply. The objective of this workshop is to give you hands on experience in building models using the pytorch's core component called Tensor . Beleive me, everything you are gonna build is simply stacking or connecting copies of this single core component!. It make...

Read more

Bringing Python to Browser!

Jupyter notebook has always been a de-facto choice when you teach the Python programming language or while developing prototype machine learning models or doing exploratory data analysis. The reasons are manifold. The most important reason is due to its ability to interleave the rich set of...

Read more

A Random Process

3.RandomProcess A Random process could be thought of as a collection of indexed random variables (i.e., a vector) that evolves in time . Each RV (element) in a collection (vector) follows a specific distribution. If all RVs in a collection have the ...

Read more

Linear Estimator For Random Process

layout: page keywords: “Estimation, Jupyter notebook” title: “Linear Estimator for a Random Process” date: 2021-05-25 tags: Probability Mathematics key: “LERP-2105” comment: true — 2.CovarianceAndEstimator Oftentimes, statistical averages such a...

Read more