I Built My Own AI Medical Chatbots Using Open-Source LLMs (No GPUs, No API Bills!)



Ever thought of creating your own intelligent chatbot without using expensive APIs or paid LLMs? I did, and I built not one, but two AI-powered medical bots using free, open-source tools available.


In this blog, I want to tell you my story of how I created  MediChat and MediVoiceBot, two healthcare-oriented AI bots using HuggingFace, LangChain, and many such tools available - and all without needing OpenAI access or a high-end GPU setup.


🩺 What are MediVoiceBot & MediChat?

Both bots are conversational AI apps focused on medical use-cases:

  1. MediVoiceBot: A chatbot that takes voice input and responds like a smart medical assistant.
  2. MediChat: A chatbot similar to the first one where users can ask health related queries.

These aren’t just fun demos, they simulate what it takes to build an AI assistant in healthcare, from scratch, on a beginner-friendly setup.

GitHub Repos:

  1. 🔗 MediVoiceBot
  2. 🔗 MediChat
Live sites:
    1. 🔗 MediVoiceBot
    2. 🔗 Medichat

🛠️ Tools & Tech stack (Totally open-source & free!)

Here’s what powered both bots:



Component Tool Used
Embeddings   sentence-transformers/all-MiniLM (HuggingFace)
Vector Store   FAISS (for fast similarity search)
LLM Integration   LangChain (prompt handling & retrieval)
UI   Streamlit (lightweight and deployable)
Voice Input   SpeechRecognition, gTTS (in MediVoiceBot)
Text generation   Groq (Free)
Text To Speech   gTTS & Elevenlabs (Built in(gTTS) and Free API(Elevenlabs))
UI   Gradio (Simple)

Minimal RAM, Free API keys, max efficiency. 


💡 How It Works (Behind The Scenes)

Let me break it down even simpler.

🔍 1. Embedding the Knowledge

I used HuggingFace’s lightweight embedding model:

from langchain_huggingface import HuggingFaceEmbeddings

embeddings = HuggingFaceEmbeddings(model_name="sentence-transformers/all-MiniLM")

This model turns your medical documents or text into vector embeddings, basically, math representations of meaning.


📦 2. Store & Search with FAISS

To quickly find relevant chunks when a user asks a question:

from langchain_community.vectorstores import FAISS
db = FAISS.load_local("vector_db", embeddings)

FAISS does the magic of finding the closest match to your query, blazing fast even on a laptop.


🧠 3. Connecting Everything with LangChain

LangChain handles the retrieval + prompting:

retriever = db.as_retriever()
retriever.search_kwargs["k"] = 3

We fetch top-k similar chunks, format them as a prompt, and pass them to the LLM. In MediVoiceBot, we even wrap this inside a voice pipeline using SpeechRecognition and gTTS.


💬 4. Chat Interface with Streamlit (MediChat) & Gradio (MediVoiceBot)

Streamlit & Gradio are those which made these things usable (and visually good):

import streamlit as st

st.text_input("Ask your medical question here:")

For voice input:

import speech_recognition as sr
# record → transcribe → reply → speak

Things Broke (Of Course)💔

Yup, it wasn’t smooth sailing.

  1. LangChain threw random errors due to version mismatches. Solution? Pin your versions carefully.
  2. API Keys, Creation and using them is crucial and should be taken care of.
  3. FFmpeg & portaudio errors when loading data? Fixed by carefully downloading and installing them before using.

But each halt taught me something new about Python’s ecosystem and open-source flexibility.


🧠 What I Learned

  1. You don’t need ChatGPT or any other paid APIs to build smart bots.
  2. Open-source models are powerful enough for real projects.
  3. LangChain, Huggingface, Streamlit, Gradio and are 🔥 for student prototypes.

📢 What’s Next?

I’m planning to:

  1. Add multi-language support
  2. Improve medical terminology handling
  3. Explore more deployment options by building a full stack website.

Wanna try it yourself? Clone the repo and test it out:


Final Thoughts

  1. AI isn't just for tech giants anymore, it’s accessible, open, and ready for you to start and build with.

If you’re a student or a dev who’s curious about LLMs, this is your moment. Dive into HuggingFace, play with LangChain, break things, build them back, and share your journey. It’s more valuable than you think.

Have questions or want to collaborate? Drop a comment or DM me. Let’s build together.


Post a Comment

0 Comments