Akshay ๐Ÿš€ Profile picture
Feb 7 โ€ข 10 tweets โ€ข 3 min read โ€ข Read on X
How LLMs work, clearly explained:
Before diving into LLMs, we must understand conditional probability.

Let's consider a population of 14 individuals:

- Some of them like Tennis ๐ŸŽพ
- Some like Football โšฝ๏ธ
- A few like both ๐ŸŽพ โšฝ๏ธ
- And few like none

Here's how it looks ๐Ÿ‘‡ Image
So what is Conditional probability โ‰๏ธ

It's a measure of the probability of an event given that another event has occurred.

If the events are A and B, we denote this as P(A|B).

This reads as "probability of A given B"

Check this illustration ๐Ÿ‘‡ Image
For instance, if we're predicting whether it will rain today (event A), knowing that it's cloudy (event B) might impact our prediction.

As it's more likely to rain when it's cloudy, we'd say the conditional probability P(A|B) is high.

That's conditional probability for you! ๐ŸŽ‰
Now, how does this apply to LLMs like GPT-4โ“

These models are tasked with predicting the next word in a sequence.

This is a question of conditional probability: given the words that have come before, what is the most likely next word? Image
To predict the next word, the model calculates the conditional probability for each possible next word, given the previous words (context).

The word with the highest conditional probability is chosen as the prediction. Image
The LLM learns a high-dimensional probability distribution over sequences of words.

And the parameters of this distribution are the trained weights!

The training or rather pre-training** is supervised.

I'll talk about the different training steps next time!**

Check this ๐Ÿ‘‡ Image
Hopefully, this thread has demystified a bit of the magic behind LLMs and the concept of conditional probability.

Here's the gist of what we learned today: Image
Working with LLMs is going to to be a high leverage skill!

@LightningAI provides state of the art tutorials on LLMs & LLMOps!

On top of that you get an integrated AI developer platform with access to FREE GPUs & VSCode right in your browser!

Check this: lightning.ai
That's a wrap!

If you interested in:

- Python ๐Ÿ
- ML/MLOps ๐Ÿ› 
- Maths for ML ๐Ÿงฎ
- CV/NLP ๐Ÿ—ฃ
- LLMs ๐Ÿง 
- AI Engineering โš™๏ธ

Find me โ†’ @akshay_pachaar โœ”๏ธ
Everyday, I share tutorials on above topics!

Cheers! ๐Ÿฅ‚

โ€ข โ€ข โ€ข

Missing some Tweet in this thread? You can try to force a refresh
ใ€€

Keep Current with Akshay ๐Ÿš€

Akshay ๐Ÿš€ Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @akshay_pachaar

Feb 9
10 great Python packages for Data Science not known to many:
1๏ธโƒฃ Mitosheets

Write Python code by editing a spreadsheet in your Jupyter Notebook, so you can easily explore and transform your data with Excel spreadsheet formulas, pivot tables, and graphs

Check this out๐Ÿ‘‡ | cc: @tryMito
trymito.io/?source=pc&utmโ€ฆ
2๏ธโƒฃ LazyPredict

A Python library that enables you to train, test, and evaluate multiple ML models at once using just a few lines of code.

Supports both regression & classification! โœจ

Check this out๐Ÿ‘‡
pypi.org/project/lazyprโ€ฆ
Image
Read 12 tweets
Feb 2
Python *args & **kwargs clearly explained:
*args allows you to pass a variable number of non-keyword arguments to a function.

It collects all non-keyword arguments passed to the function and stores them as a tuple.

Consider the following example: Image
Similarly, **kwargs allows you to pass a variable number of keyword arguments to a function.

It collects all keyword arguments passed to the function and stores them as a dictionary.

Consider the following example: Image
Read 6 tweets
Jan 29
PCA from scratch using Python ๐Ÿ”ฅ

Principal Component Analysis is a powerful technique for dimensionality reduction and data visualisation.

-- step by step explanation with code --

Let's go! ๐Ÿš€ Image
We'll use wine_dataset which has 13 features (dimensions) originally!!

Check this out ๐Ÿ‘‡ Image
Let's apply PCA on the above data!

Check this out ๐Ÿ‘‡ Image
Read 5 tweets
Jan 28
PyTorch 101: Dataset Class clearly explained!

Today, we learn how to build a PyTorch Dataset for:

- Text
- Tabular
- and Imagery Data

Let's go! ๐Ÿš€ Image
First things first, let's look at a simple example of a `Dataset` class.

Here's what it generally looks like: Image
For tabular data, let's consider the famous Iris dataset. ๐ŸŒธ

Here's how to create a `Dataset` class for it: Image
Read 7 tweets
Jan 27
Self-attention clearly explained:
Before we start a quick primer on tokenization!

Raw text โ†’ Tokenization โ†’ Embedding โ†’ Model

Embedding is a meaningful representation of each token (roughly a word) using a bunch of numbers.

This embedding is what we provide as an input to our language models.

Check this๐Ÿ‘‡ Image
The core idea of Language modelling is to understand the structure and patterns within language.

By modeling the relationships between words (tokens) in a sentence, we can capture the context and meaning of the text. Image
Read 9 tweets
Jan 25
Run Mistral-7B almost 3x faster on a single GPU!

Introducing AWQ: Activation-aware Weight Quantization! ๐Ÿš€

A hands-on tutorial with code...๐Ÿ‘‡ Image
In this tutorial we'll be using vLLM, a fast and easy-to-use library for LLM inference and serving.

The tutorial has 3 parts:

- Part 1: Inference on 1 GPU!
- Part 2: Distributed Inference on 4 GPUs
- Part 3: Inference on 1 GPU + AWQ!โšก๏ธ

Continue reading... ๐Ÿ“– Image
Part 1:

We'll use Mistral-7B-v0.1 & run inference on a single GPU.

And record the inference time to compare it later with other inference methods provided by vLLM.

Here's the minimal code to do so๐Ÿ‘‡
(explanation in the studio at the end) Image
Read 9 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us!

:(