✨ Visual Editor

close

palette Canvas & Background

Gradient:arrow_forward
Text Color:
135Β°

style Card Style

40px
16px

text_fields Typography

16px
Akshay πŸš€
@akshay_pachaar
Let's compare DeepSeek-R1 and OpenAI-o1 using RAG:
Akshay πŸš€
@akshay_pachaar
DeepSeek-R1 delivers OpenAI-o1 level intelligence at 90% less cost.

Today, we build a Streamlit app to compare and evaluate them using RAG.

Tech stack:

- @Llama_Index for orchestration
- @Cometml Opik for evaluation
- @Streamlit for the UI

Let's go! πŸš€
Video thumbnail
VIDEO
Akshay πŸš€
@akshay_pachaar
The architecture presented below illustrates some of the key components & how they interact with each other!

For those who are new, I've provided detailed descriptions & code for each component.
Thread image
Akshay πŸš€
@akshay_pachaar
1️⃣ & 2️⃣ : Loading the knowledge base

A knowledge base is a collection of relevant and up-to-date information that serves as a foundation for RAG. In our case it's the docs stored in a directory.

Here's how you can load it as document objects in LlamaIndex:
Thread image
Akshay πŸš€
@akshay_pachaar
3️⃣ The embedding model

The embedding model Embedding is a meaningful representation of text in form of numbers.

The embedding model is responsible for creating embeddings for the document chunks & user queries.
Thread image
Akshay πŸš€
@akshay_pachaar
4️⃣ Indexing & storing

Embeddings created by embedding model are stored in a vector store that offers fast retrieval and similarity search by creating an index over our data.

By default, LlamaIndex provides a in-memory vector store that’s great for quick experimentation.
Thread image
Akshay πŸš€
@akshay_pachaar
5️⃣ Creating a prompt template

Creating a prompt template A custom prompt template is use to refine the response from LLM & include the context as well:
Thread image
Akshay πŸš€
@akshay_pachaar
6️⃣ Setting up a query engine

The query engine takes a query string & use it to fetch relevant context and then sends them both as a prompt to the LLM to generate a final natural language response.

Here's how you set it up:
Thread image
Akshay πŸš€
@akshay_pachaar
8️⃣ The Chat interface

We create a UI using Streamlit to provide a chat interface for our RAG application.

The code for this & all we discussed so far is shared in the next tweet!

Check this outπŸ‘‡
Thread image
Akshay πŸš€
@akshay_pachaar
Finally, we will conduct a proper evaluation.

For this, we'll use @Cometml's Opik, a 100% open-source platform for evaluation and observability.

I have shared a notebook where you'll find all the code for this evaluation.
Thread image
Akshay πŸš€
@akshay_pachaar
I used @LightningAI ⚑️ Studio for developing this application!

The studio reads like a blog, encapsulating all my code & environment to run it!

Clone a FREE studio now & take it for a spin...πŸ‘‡
lightning.ai/akshay-ddods/s…
Akshay πŸš€
@akshay_pachaar
If you're interested in:

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

Find me β†’ @akshay_pachaar βœ”οΈ

Cheers! πŸ₯‚
Generated by Thread Navigator
100%
view_carousel Carousel Studio NEW
Press ⌘ + S to quick-export