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

Jul 12
A Crash Course on Building AI Agents!

Here's what it covers:

- What is an AI agent
- Connecting agents to tools
- Overview of MCP
- Replacing tools with MCP servers
- Setting up observability and tracing

All with 100% open-source tools!
This course builds agents based on the following definition:

An AI agent uses an LLM as its brain, has memory to retain context, and can take real-world actions through tools, like browsing web, running code, etc.

In short, it thinks, remembers, and acts.
100% open-source tech stack:

- @crewAIInc for building MCP ready agents
- @zep_ai Graphiti to add human like memory
- @Cometml Opik for observability and tracing.

You can find the entire code here: github.com/patchy631/ai-e…
Read 5 tweets
Jul 11
MCP is on fire.

AI agents can now talk to real world tools, apps and actually get stuff done.

This changes everything.

Here are 10 amazing examples:
1️⃣ WhatsApp MCP

Exchange images, videos, and voice notes on WhatsApp!

Pair it with the ElevenLabs MCP server for AI-powered transcription & audio messages with 3,000+ voices.

Check this out👇
2️⃣ MCP-powered Agentic RAG

I created this server for Cursor and lets it perform deep web searches, as well as RAG over a specified directory.

Everything from the comforts of your IDE:
Read 12 tweets
Jul 10
90% of Python programmers don't know these 11 ways to declare type hints:
Type hints are incredibly valuable for improving code quality and maintainability.

Today, I'll walk you through 11 must-know principles to declare type hints in just two minutes.

Let's begin! 🚀 Image
1️⃣ Type hints for standard Python objects:

The most basic (and must-know) way to declare type hints for standard Python objects is as follows👇 Image
Read 15 tweets
Jul 7
Temperature in LLMs, clearly explained (with code):
Let's prompt OpenAI GPT-3.5 with a low temperature value twice.

It produces identical responses from the LLM.

Check the response below👇 Image
Now, let's prompt it with a high temperature value.

This time, it produces a gibberish output. Check the output below👇

What is going on here? Let's dive in! Image
Read 9 tweets
Jul 3
7 MCP projects for AI Engineers (with video tutorials):
1️⃣ MCP meets Ollama

An MCP client is a component in an AI app (like Cursor) that establishes connections to external tools.

Learn how to build it 100% locally.

Full walkthrough:
2️⃣ MCP-powered shared memory for Claude Desktop and Cursor

Devs use Claude Desktop and Cursor independently.

Learn how to add a knowledge graph based common memory layer to cross-operate without losing context.

Full walkthrough:
Read 10 tweets
Jun 28
I have tested 100+ MCP servers in the last 3 months!

Here are 6 must-use MCP servers for all developers (open-source):
1️⃣ Graphiti MCP server

Agents forget everything after each task.

Graphiti MCP server lets Agents build and query temporally-aware knowledge graphs, which act as an Agent's memory!

Check this👇
2️⃣ Opik MCP server

This enables traceability into AI Agents and lets you monitor your LLM applications, by @Cometml.

Tools include:
- Creating projects
- Enable tracing
- Getting tracing stats

Check this demo👇
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!

:(