Akshay πŸš€ Profile picture
May 8, 2024 β€’ 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!

An integrated AI developer platform with access to FREE GPUs & VSCode right in your browser!

Check this: lightning.ai/lightning-ai/h…
If you interested in:

- Python 🐍
- Machine Learning πŸ€–
- AI Engineering βš™οΈ

Find me β†’ @akshay_pachaar βœ”οΈ
My weekly Newsletter on AI Engineering, Join 9k+ readers: @ML_Spring

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

Aug 12
Traditional RAG vs. Agentic RAG, clearly explained (with visuals):
Traditional RAG has many issues:

- It retrieves once and generates once. If the context isn't enough, it cannotΒ dynamically search for more info.

- It cannot reason through complex queries.

- The system can't modify its strategy based on the problem.
Agentic RAG attempts to solve this.

The following visual depicts how it differs from traditional RAG.

The core idea is to introduce agentic behaviors at each stage of RAG.
Read 7 tweets
Aug 10
Let's build a Browser Automation Agent using gpt-oss (100% local):
Browser is still the most universal interface with 4.3 billion page visited every day!

Here's a quick demo of how we can completely automate it!

Tech stack:

- @stagehanddev open-source AI browser automation
- @crewAIInc for orchestration
- @ollama to run gpt-oss

Let's go!πŸš€
System overview:

- User enters an automation query.
- Planner Agent creates an automation plan.
- The Browser Automation Agent executes it using the Stagehand tool.
- The Response Agent generates a response.

Now, let's dive into the code!
Read 13 tweets
Aug 9
I switched to AI Engineering 2 years ago!

It was the best career move I ever made.

If you want to start today, here's a roadmap:
1️⃣ Master Python

While many are busy vibe coding, those with strong coding fundamentals will always stand out.

Python is the language AI community speaks, and Harvard's CS50p is the best place to learn it.

πŸ”— pll.harvard.edu/course/cs50s-i…Image
2️⃣ AI with Python

Once you're done with the fundamentals, it's the right time to understand how Python is used in AI.

This 4 hours course by Andrew Ng is a great starting point.

πŸ”— deeplearning.ai/short-courses/…Image
Read 12 tweets
Aug 8
Let's compare GPT-5 and Claude Opus-4.1 for code generation:
Today, we're building a CodeArena, where you can compare any two code-gen models side-by-side.

Tech stack:

- @LiteLLM for orchestration
- @Cometml's Opik to build the eval pipeline
- @OpenRouterAI to access cutting-edge models
- @LightningAI for hosting CodeArena

Let's go!πŸš€
Here's the workflow:

- Choose models for code generation comparison
- Import a GitHub repository and offer it as context to LLMs
- Use context + query to generate code from both models
- Evaluate generated code using Opik's G-Eval

Let’s implement this!
Read 16 tweets
Aug 6
Let's compare OpenAI gpt-oss and Qwen-3 on maths & reasoning:
Before we dive in, here's a quick demo of what we're building!

Tech stack:

- @LiteLLM for orchestration
- @Cometml's Opik to build the eval pipeline (open-source)
- @OpenRouterAI to access the models

You'll also learn about G-Eval & building custom eval metrics.

Let's go! πŸš€
Here's the workflow:

- User submits query
- Both models generate reasoning tokens along with the final response
- Query, response and reasoning logic are sent for evaluation
- Detailed evaluation is conducted using Opik's G-Eval across four metrics.

Let’s implement this!
Read 14 tweets
Aug 5
Tech giants use Multimodal RAG every day in production!

- Spotify uses it to answer music queries
- YouTube uses it to turn prompts into tracks
- Amazon Music uses it to create playlist from prompt

Let's learn how to build a Multimodal Agentic RAG (with code):
Today, we'll build a multimodal Agentic RAG that can query documents and audio files using the user's speech.

Tech stack:

- @AssemblyAI for transcription.
- @milvusio as the vector DB.
- @beam_cloud for deployment.
- @crewAIInc Flows for orchestration.

Let's build it!
Here's the workflow:

- User inputs data (audio + docs).
- AssemblyAI transcribes the audio files.
- Transcribed text & docs are embedded in the Milvus vector DB.
- Research Agent retrieves info from user query.
- Response Agent uses it to craft a response.

Check thisπŸ‘‡
Read 13 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!

:(