Advertisement · 728 × 90

Posts by Akshay 🚀

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 ✔️

1 year ago 3 0 1 0
Post image

F-strings also support formatting for different data types, such as dates and times:

1 year ago 3 0 1 0
Post image

If you need to use braces literally in an f-string, you can escape them with double braces:

1 year ago 2 0 1 0
Post image

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:

1 year ago 2 0 1 0
Post image

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:

1 year ago 1 0 1 0
Post image

Need to format numbers or strings❓

F-strings support format specifiers:

1 year ago 1 0 1 0
Post image

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👇

1 year ago 1 0 1 0
Post image

Simply put, f-strings are strings prefixed with 'f' that allow you to embed expressions inside string literals.

Here's an example:

1 year ago 2 0 1 0
Post image

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! 🚀

1 year ago 3 0 1 0
Advertisement

f-strings in Python clearly explained:

1 year ago 7 1 1 0

If you interested in:

- Python 🐍
- ML/AI Engineering ⚙️

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

Cheers! 🥂

1 year ago 0 0 0 0

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...

1 year ago 1 0 1 0
Post image

7️⃣ Evaluate finetuned T-5 small RAG program

**Notice the score, it beats a vanilla Mistral RAG 🔥

1 year ago 0 0 1 0
Post image

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👇

1 year ago 0 0 1 0
Post image

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👇

1 year ago 0 0 1 0
Post image

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👇

1 year ago 0 0 1 0
Post image

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👇

1 year ago 0 0 1 0
Post image

2️⃣ Load dataset

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

Check this out👇

1 year ago 0 0 1 0
Advertisement
Post image

1️⃣ Set Up

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

Check this out👇

1 year ago 0 0 1 0
Post image

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! 🚀

1 year ago 0 0 1 0

Let's learn how to finetune your RAG pipeline using DSPy, step-by-step:

1 year ago 2 1 1 0

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

1 year ago 0 0 0 0
Post image

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 👇

1 year ago 0 0 1 0

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! 🥂

1 year ago 0 0 1 0
Post image

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 👇

1 year ago 0 0 1 0
Post image

4️⃣ Encapsulation 🔐

Encapsulation helps to bundle data and methods inside a class, restricting direct access to certain attributes and methods.

We use private attributes/methods (with a `_` or `__` prefix) to achieve this.

Here's an example 👇

1 year ago 0 0 1 0
Post image

3️⃣ Inheritance 🧬

Let's say we want to create an Electric car & don't want to define all the properties and methods of the basic Car class.

Inheritance helps us to inherit all the properties/methods of parent class & add new ones or override existing.

Check this out👇

1 year ago 0 0 1 0
Advertisement
Post image

2️⃣ Class 🏗️

A class is like a blueprint for creating objects.

It defines a set of properties & functions (methods) that will be common to all objects created from the class.

So, we start with a simple example & follow along!

Let's define a class Car & create it's Object👇

1 year ago 0 0 1 0

For example, a Car is an object that has properties such as color & model, and behaviours such as accelerating, braking & turning.

But, how do we create these objects❓🤔

This is where we need to understand Classes!

...👇

1 year ago 0 0 1 0

1️⃣ Object 🚘

Just look around, everything you see can be treated as an object.

For instance a Car, Dog, your Laptop are all objects.

An Object can be defined using 2 things:

- Properties: that describe an object
- Behaviour: the functions that an object can perform

...👇

1 year ago 0 0 1 0