Akshay 🚀 Profile picture
Feb 15 10 tweets 3 min read Read on X
Let's fine-tune DeepSeek-R1 (distilled Llama) 100% locally:
Before we begin, here’s what we’ll be doing:

We’ll fine-tune our private and locally running DeepSeek-R1 (a distilled Llama variant).

Tech stack:

- @UnslothAI for efficient fine-tuning.
- @Ollama to run it locally.

Let’s go! 🚀
1️⃣ Load the model

We begin by loading the Distilled Llama-8B model and the tokenizer for DeepSeek-R1 using Unsloth: Image
2️⃣ Define LoRA Config

We must use efficient techniques like LoRA to avoid fine-tuning the entire model's weights.

In this code, we utilize Unsloth's PEFT by specifying:

- The model
- LoRA low-rank (r)
- Modules for fine-tuning
- A few more parameters Image
3️⃣ Prepare dataset

Next, we use the Alpaca dataset to prepare a conversation dataset.

The conversation_extension parameter defines the number of user messages in a single conversation. Image
4️⃣ Define Trainer

Here, we create a Trainer object by specifying the training config like learning rate, model, tokenizer, and more.

Check this out👇 Image
5️⃣ Train

With that done, we initiate training. We notice a decreasing loss, which means the model is fine-tuning well.

Check this code and output👇 Image
6️⃣ Export to Ollama

Finally, we export the model to Ollama as follows.

Done! Image
We have fine-tuned DeepSeek (distilled Llama).

Now we can interact with it like any other model running on Ollama using:

- The CLI
- Ollama's Python package
- Ollama's LlamaIndex integration, etc. Image
That's a wrap!

And, if you enjoyed this breakdown:

Find me → @akshay_pachaar ✔️

Everyday, I share insights and tutorials around AI and Machine Learning.

• • •

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 13
10 great Python packages for Data Science not known to many:
1️⃣ CleanLab

You're missing out on a lot if you haven't started using Cleanlab yet!

Cleanlab helps you clean data and labels by automatically detecting issues in a ML dataset.

It's like a magic wand! 🪄✨

Check this out👇
github.com/cleanlab/clean…
2️⃣ PandasAI

Generative AI meets pandas!

PandasAI is a Python library that let's you interact with your dataframes in natural language.

Generate reports, create plots and do RAG over multiple dataframes!

Check this out👇
github.com/sinaptik-ai/pa…Image
Read 12 tweets
Feb 12
Let's build an enterprise-grade, agentic RAG over complex real-world docs, step-by-step:
We gonna do RAG over MIG 29 (a fighter aircraft) flight manual, which includes complex figures, diagrams, and more.

(Watch the video below)

Tech stack:

- @CrewAIInc for agent orchestration
- @EyelevelAI's GroundX for SOTA document parsing

Let's go! 🚀
The architecture diagram presented below illustrates some of the key components & how they interact with each other!

It will be followed by detailed descriptions & code for each component:
Read 12 tweets
Feb 11
Let's build a trustworthy RAG app that provides a confidence score for each response:
Before we dive in, here's a quick demo of what we're building!

Tech stack:

- @Llama_Index for orchestration
- @CleanlabAI's trustworthy LLM
- @Qdrant_engine to self-host a vectorDB
- LlamaParse to make complex docs LLM ready.

You get both score and reasoning! ✨

Let's go! 🚀
The architecture diagram presented below illustrates some of the key components & how they interact with each other!

It will be followed by detailed descriptions & code for each component: Image
Read 11 tweets
Feb 10
Let's build a multi-agent financial analyst, step-by-step:
Before we start, here's what we're building today.

Given a query the app analyses and plots stocks gains for the company you specify.

Tech stach:

- @crewAIInc for multi-agent orchestration.
- @SambaNovaAI's fastest inference engine to use DeepSeek-R1 as the LLM.

Let's go! 🚀
Here's an architecture diagram showcasing how the agents interact with each other and the tools they have access to.

This is followed by a step-by-step code tutorial.
Read 12 tweets
Feb 7
4 ways to run LLMs like DeepSeek-R1 locally on your computer:
Running LLMs locally is like having a superpower:

- Cost savings
- Privacy: Your data stays on your computer
- Plus, it's incredibly fun

Today, we'll explore some of the best methods to achieve this.

Let's go! 🚀 Image
1️⃣ Ollama

Running a model through Ollama is as simple as executing a command:

ollama run deepseek-r1

You can also install Ollama with a single command:

curl -fsSL https:// ollama. com/install .sh | sh

Check this out👇
Read 7 tweets
Feb 5
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
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!

:(