Setting up my ML environment from scratch: MedMind

Published: (May 2, 2026 at 03:50 AM EDT)
2 min read
Source: Dev.to

Source: Dev.to

Overview – Day 1: Setting Up the Environment

I decided to build a clinical AI system from scratch—no OpenAI API, no tutorial‑style wrapper. The goal is to train my own model, create a retrieval‑augmented generation (RAG) pipeline, and deploy the whole thing.

The project, MedMind, takes a clinical question, searches a database of medical knowledge, and generates an answer using a model fine‑tuned on real medical exam questions.

Full Stack

  • Download and clean a real medical dataset
  • Fine‑tune a language model on that data
  • Build a RAG pipeline with a vector database
  • Evaluate the model honestly
  • Serve it with FastAPI
  • Build a UI with Streamlit

Python Version

Python 3.11 is recommended because PyTorch and Hugging Face provide the best support for this version.

Virtual Environment

python -m venv venv
# Windows
venv\Scripts\activate
# macOS / Linux
source venv/bin/activate

Creating a virtual environment isolates the project’s dependencies from the rest of the system.

Core Libraries

pip install torch transformers datasets peft trl accelerate
pip install chromadb sentence-transformers
pip install fastapi uvicorn streamlit
LibraryPurpose
transformersAccess to pre‑trained models such as OPT, Mistral, LLaMA
peftEfficient fine‑tuning with LoRA
trlSimplifies instruction fine‑tuning
chromadbVector database for storing medical knowledge
sentence-transformersConverts text to vectors for similarity search
fastapiBackend API server
uvicornASGI server for FastAPI
streamlitFront‑end UI framework

Project Structure

medmind/
├── data/       # data acquisition and cleaning scripts
├── training/   # fine‑tuning code
├── rag/        # retrieval pipeline
├── eval/       # evaluation scripts
├── api/        # FastAPI backend
└── frontend/   # Streamlit UI

Hardware Considerations

My local machine has no GPU, and training a language model on CPU would take weeks. I therefore use Google Colab with a free T4 GPU, which is a common approach for developers without dedicated hardware.

0 views
Back to Blog

Related posts

Read more »