Sunday, February 25

MedZa Assistant: Optimized RAG Chatbot based on Gemini, and Browser Data

 


Welcome to our blog! In today's digital landscape, chatbots like ChatGPT often face the challenge of providing accurate and up-to-date responses due to knowledge cutoff. 

To address this, we've developed a local chatbot solution leveraging RAG (Retrieval-Augmented Generation) with Gemini and real-time browser data integration using DuckDuckGo Api. 

In the following example, we can see how ChatGPT couldn't answer a simple question about SORA an OpenAI model!

Our solution: we call it MedZa Assistant, not only delivered the correct answer but also substantiated it with references, ensuring both its credibility and guarding against model hallucination.




Our innovative approach ensures precise and timely answers, surpassing limitations imposed by knowledge cutoff. Let's dive in!

Getting Fresh Data from the Internet with DuckDuckGo API

In our first part, we explored how we used the DuckDuckGo API to gather the latest info from the internet. When a user asked a question, our chatbot didn't just rely on what it already knew. Instead, it went online and checked out what was new. By tapping into the DuckDuckGo API, we found the top information on the topic, along with where it was coming from. This helped us stay up-to-date and provide the most recent data to our users, ensuring they got the freshest answers possible.

But why did we go through all this trouble? Well, it wasn't just about being current. By constantly updating our knowledge base with fresh info from the web, we were also helping our chatbot stay sharp. You see, sometimes our model might have gotten a bit confused or mixed things up – we called that "hallucination." But with the help of DuckDuckGo API, we could give it real-world examples to learn from, making sure it was always on the right track. So not only did our users get the most recent answers, but our chatbot also got a little boost in its smarts along the way.

The following are the top 2 results returned by DuckDuckGo API when we asked What is Python?



Making Chatbot Answers Better with Google Gemini

In our second part, we explored how we used the Google Gemini Pro model alongside prompts to handle each returned result from the web separately. After gathering information from different sources using the DuckDuckGo API, we fed each piece of data into the Google Gemini Pro model with a specific prompt designed to summarize it effectively. By breaking down the content into smaller parts and summarizing each one individually, we made sure that our summaries were clear and accurate.

But we didn't stop there. After generating summaries for each piece of information, we compiled them into a complete data digest. This digest provided a thorough overview of the topic, capturing the main points from multiple sources in a brief and easy-to-understand format. Each summary was linked back to its original source, giving users the option to explore further if they wanted to.

So, when users engaged with our chatbot, they could trust that the answers provided were not only accurate and recent but also carefully selected from reliable sources on the internet. Thanks to the integration of Google Gemini Pro and our meticulous curation process, we aimed to offer users a seamless and informative experience, giving them access to knowledge while maintaining transparency about our data sources.

The following is the Result we get from Google Gemini Pro when we asked about LLMOps, as you can see it is a pure hallucination.



And here's MedZa assistant answer:



Bringing MedZa Assistant to the Web with Streamlit

In an effort to make the MedZa Assistant more accessible, we leveraged the Streamlit library to develop a user-friendly web application.

This application allows users to interact with the chatbot directly through their web browser, eliminating the need for any downloads or installations.

Users can now visit the gallery and access the MedZa Assistant with just a few clicks, whether they're seeking information, assistance, or just a friendly chat.

The little backstory on the name "MedZa"! The secret behind this unique moniker is that it's a combination of the names of the creators: me, Ahmed, and Hamza. 🤫 We took the last part of each of our names and merged them together to create "MedZa," symbolizing our collaboration and dedication to building a helpful and innovative assistant for everyone to enjoy.

Future Directions and Improvements

Looking ahead, our focus shifts to enhancing the chatbot's capabilities beyond just question-answering.

While the current version excels in providing accurate responses, we aim to expand its functionality to include conversational interactions and logic-based queries. Additionally, we plan to refine its ability to handle straightforward questions like arithmetic calculations independently, without relying on additional context.

By addressing these areas, we aim to create a more versatile and intuitive chatbot experience for users.


Finally

To explore the Python code used in this project, visit my GitHub

I'm always eager to connect, so feel free to reach out to me on LinkedIn

Connect with Hamza Boulahia LinkedIn

Take a minute and visit Hamza Boulahia Amazing Blog


Share: