Akshay 🚀
banner
akshay-pachaar.bsky.social
Akshay 🚀
@akshay-pachaar.bsky.social
Simplifying LLMs, MLOps, Python & Machine Learning for you! • Co-founder DailyDoseofDS • BITS Pilani • 3 Patents • ex-AI Engineer @ LightningAI
That's a wrap, let me know in the comments if I missed any Ninja trick! 🔥

If you interested in:

- Python 🐍
- ML/AI Engineering ⚙️

Find me → @akshay_pachaar ✔️
December 25, 2024 at 12:30 PM
F-strings also support formatting for different data types, such as dates and times:
December 25, 2024 at 12:30 PM
If you need to use braces literally in an f-string, you can escape them with double braces:
December 25, 2024 at 12:30 PM
F-strings also support the `=` specifier, which can be handy for debugging or logging purposes.

It allows you to include the variable name and its value in the formatted string:
December 25, 2024 at 12:30 PM
F-strings support multiline strings using triple quotes!

It's one of my favourite features, I use it for creating prompt templates.

Here's an example:
December 25, 2024 at 12:30 PM
Need to format numbers or strings❓

F-strings support format specifiers:
December 25, 2024 at 12:30 PM
You can also perform operations & call functions inside the braces.

This makes f-strings incredibly versatile for constructing dynamic strings with computed values.

Check this out👇
December 25, 2024 at 12:30 PM
Simply put, f-strings are strings prefixed with 'f' that allow you to embed expressions inside string literals.

Here's an example:
December 25, 2024 at 12:30 PM
f-strings were introduced in Python 3.6 and have since become a favorite among developers for their simplicity and readability.

Today, we'll start with the basics and dive into all the ninja tricks of using f-strings.

Let's go! 🚀
December 25, 2024 at 12:30 PM
If you interested in:

- Python 🐍
- ML/AI Engineering ⚙️

Find me → @akshay_pachaar ✔️
My Newsletter on AI Engineering → @DailyDoseOfDS_ ✔️

Cheers! 🥂
December 12, 2024 at 12:30 PM
You can find all the code & details in the @LightningAI⚡️ studio shared below:
lightning.ai/lightning-a...

You should also check DSPy's official repo: github.com/stanfordnlp...
December 12, 2024 at 12:30 PM
7️⃣ Evaluate finetuned T-5 small RAG program

**Notice the score, it beats a vanilla Mistral RAG 🔥
December 12, 2024 at 12:30 PM
6️⃣ Define a T-5 small RAG & Finetune it

The code below will perform finetuning & provide a checkpoint for the best model weights saved during the process.

Check this out👇
December 12, 2024 at 12:30 PM
5️⃣ Evaluate RAG powered by Mistral

Let's first evaluate our RAG program that uses Mistral-7B as LLM

** Notice the score, this is what we want to beat!

Check this out👇
December 12, 2024 at 12:30 PM
4️⃣ Define the RAG program

Let's define a basic DSPy program which is a RAG pipeline for answer generation.

It's like defining a model that we want to finetune & evaluate.

Check this out👇
December 12, 2024 at 12:30 PM
3️⃣ Set eval metric

DSPy provides out of the box support for many evaluation metrics & you can define a custom metric as well.

Our program is expected to produce short factoid answers & hence, exact match with the ground truth is a good eval metric here.

Check this out👇
December 12, 2024 at 12:30 PM
2️⃣ Load dataset

Next we load the HotPotQA dataset for training & validation. HotPotQA dataset in available in `dspy.datasets`

Check this out👇
December 12, 2024 at 12:30 PM
1️⃣ Set Up

We start by setting up the LM (Mistral-7B served using @Ollama & retriever model, RM which is ColBERTv2)

Check this out👇
December 12, 2024 at 12:30 PM
DSPy is a framework for algorithmically optimizing LM prompts and weights.

DSPy : RAG :: PyTorch : DNNs

I'll make sure today's tutorial can be followed with minimal background knowledge!

Let's go! 🚀
December 12, 2024 at 12:30 PM
That's a wrap, if you're interested in:

- Python 🐍
- ML AI Engineering ⚙️

1. Find me → @akshay_pachaar ✔️
2. Sign up for our newsletter for in-depth lessons and get a FREE eBook with 150+ core DS/ML lessons: join.dailydoseofds.com
December 10, 2024 at 12:32 PM
6️⃣ Polymorphism 🌀

This allows us to use a single interface for different data types or classes.

We can achieve this through method overriding, where a subclass provides a different implementation for a method defined in its parent class.

Let's understand with an example 👇
December 10, 2024 at 12:32 PM
At this point if Abstraction and Encapsulation confuse you! 👇

Abstraction conceals the implementation details, but doesn't hide the data itself.

On the other hand, Encapsulation hides the data and restricts unwanted use from external sources.

Cheers! 🥂
December 10, 2024 at 12:31 PM
5️⃣ Abstraction 🎭

This concept focuses on exposing only essential information to the outside world while hiding implementation details.

We use abstract classes and methods to define a common interface.

Here's an example 👇
December 10, 2024 at 12:31 PM