Inspiration

As a biomedical engineer and researcher, I have the opportunity to work with very young children with severe disabilities, especially children with cerebral palsy. Even the smallest improvement in their condition can change their daily life. Seeing their progress—and the relief and joy it brings to their families—drives me to look for medical solutions for populations that are often overlooked.

But rare diseases are not as rare as we tend to think.

Every year, 795,000 Americans suffer permanent disability or death due to diagnostic errors. At the same time, there are more than 10,000 rare and little-studied conditions—known in medicine as “zebras”—that affect around 300 million people worldwide.

In clinical slang, doctors are taught: “When you hear hoofbeats, think horses, not zebras.” The idea is to focus on common diagnoses first. But for millions of patients, they are the zebras. Their conditions are unusual, poorly documented, and often missed. ZebraLens was born from the need to make those cases visible, searchable, and understandable.

What it does

ZebraLens is a clinical intelligence system designed to help doctors navigate complex and rare cases.

Instead of relying on keyword search, ZebraLens compares a patient’s clinical description against a global archive of more than 250,000 medically reviewed case reports from PubMed using semantic similarity. The system focuses on meaning, context, and symptom patterns—not just words.

When a physician enters a case, ZebraLens retrieves the most similar real-world cases and presents them in an interactive interface. Each case is positioned on a 3D globe, allowing doctors to explore patterns by geography, time, and context.

Once relevant cases are found, the system performs an AI-guided analysis. It compares the patient’s symptoms with historical cases and generates a structured clinical summary, highlighting similarities, differences, and potential insights.

If deeper information is needed, ZebraLens provides direct access to the original study and its authors, helping clinicians connect with experts who have already treated similar cases.

How we built it

ZebraLens is a cloud-native Retrieval-Augmented Generation (RAG) application designed to assist medical professionals in identifying rare diseases through semantic similarity and geospatial context.

  1. Semantic Search Engine & Data Pipeline
    We built a custom ingestion pipeline that processes thousands of medical case reports. Using Sentence Transformers (all-MiniLM-L6-v2), we generate high-dimensional vector embeddings for each case, capturing the semantic meaning of clinical symptoms rather than just keyword matches. These vectors are indexed using FAISS (Facebook AI Similarity Search) for ultra-low latency retrieval.

  2. Advanced RAG with Gemini 3
    The core intelligence is powered by Google’s Gemini 3. When a user submits a query:

  3. The system retrieves the top-k most relevant historical cases from our FAISS vector store.

  4. A Cross-Encoder re-ranking step ensures the most clinically relevant results are prioritized.

  5. We construct a structured prompt injecting these retrieved cases as context.

Gemini 3 then analyzes the patient’s symptoms against the retrieved cases, generating a comparative clinical summary in real time.

  1. Geospatial Visualization
    We integrated CesiumJS to create an interactive 3D globe. The backend extracts geographical metadata from case reports using a custom Named Entity Recognition (NER) heuristic and geocodes them. This allows clinicians to visualize disease clusters and potential epidemiological patterns on a global scale.

  2. Real-time Streaming Architecture
    To ensure a responsive user experience, we implemented a Server-Sent Events (SSE) architecture in Python/Flask. This allows the application to stream Gemini 3’s analysis token by token to the frontend, providing immediate feedback while complex reasoning tasks complete in the background.

  3. Deployment & Optimization
    The application is containerized and deployed on a scalable serverless infrastructure. We optimized the inference pipeline using lazy loading for heavy ML models to minimize cold-start latency and reduce memory usage.

Why Gemini 3?

At the core of this process is Gemini 3, which acts as a clinical reasoning engine rather than a simple text generator. Rare disease cases are often described using inconsistent terminology, partial observations, or long narrative reports. Traditional systems struggle with this ambiguity. Gemini 3 allows ZebraLens to interpret these complex medical narratives, compare them across different contexts, and extract meaningful clinical insights in real time. Without this level of semantic understanding and reasoning, connecting rare cases across the globe would simply not be possible.

Challenges we ran into

  1. Unstructured Geospatial Data Extraction
    Medical reports often contain location data buried within free text.
    Solution: We engineered a lightweight NER heuristic pipeline combined with a fuzzy-matching geocoding service to structure location data dynamically without a heavy NLP model.

  2. Real-time RAG Streaming
    Implementing a smooth streaming output for Gemini 3 was challenging due to buffering issues.
    Solution: We configured the SSE protocol with specific HTTP headers to bypass intermediate buffering and ensure token-by-token streaming.

  3. Serverless Memory Constraints
    Running vector databases and embedding models in a 512MB environment caused memory crashes.
    Solution: We implemented lazy loading and singleton patterns for heavy libraries, reducing the startup memory footprint by over 60%.

  4. 3D Map & UI Synchronization
    Synchronizing the CesiumJS globe with the case list in the interface was complex.
    Solution: We built a unified state management system that links map entities with DOM elements, ensuring a cohesive interaction.

Accomplishments that we're proud of

  • Transforming thousands of static case reports into a living, interactive 3D globe that reveals patterns across time and geography.
  • Building a semantic search engine capable of matching complex patient histories against a vast database of medical literature in milliseconds.
  • Integrating Gemini 3 as a clinical reasoning partner that synthesizes and compares cases instead of simply retrieving documents.
  • Enabling direct contact with the original authors of similar case reports, fostering real-world collaboration between clinicians across the globe.

What we learned

While preparing this project, we knew diagnostic errors were a serious issue. But we did not fully grasp the scale of the problem.

Discovering that hundreds of thousands of people suffer permanent harm each year—and that rare diseases affect hundreds of millions globally—changed our perspective. It showed us that the “zebra problem” is not a niche issue; it is a systemic challenge.

We also learned that the value of AI in medicine is not just about prediction. It is about connection: connecting cases, clinicians, and knowledge across borders and specialties. Sometimes the most powerful insight is simply knowing that someone, somewhere, has already seen a similar patient.

What's next for ZebraLens

Our next steps focus on real-world clinical validation. We aim to collaborate with practicing clinicians to test ZebraLens in realistic diagnostic scenarios and gather structured feedback.

We also plan to explore its use as a research tool, helping identify emerging disease patterns and underreported conditions. This includes developing more rigorous evaluation metrics to measure semantic similarity and clinical relevance.

With time, validation, and collaboration, we hope ZebraLens can move from a prototype to a real clinical support system—one that helps doctors find the zebras before it is too late.

Disclosure

ZebraLens is a demonstration prototype and minimum viable product (MVP) created to showcase the potential of semantic search and AI-assisted reasoning in rare disease discovery.

It is not a certified medical device and is not intended for clinical diagnosis, treatment decisions, or direct patient care. The system is designed solely for research, educational, and exploratory purposes.

Any clinical use would require extensive validation, regulatory approval, and integration into established medical workflows. The goal of this prototype is to demonstrate how advanced AI models and global case data could support clinicians in the future, not to replace professional medical judgment.

Built With

  • antigravity
  • cesiumjs
  • css3
  • dotenv
  • faiss
  • flask
  • git-lfs
  • google-gemini-3-(api)
  • google-generative-ai-python-sdk
  • gunicorn
  • html5
  • hugging-face-transformers
  • javascript-(es6+)
  • json
  • langchain
  • numpy
  • openai-compatible-api-(integration)
  • python
  • pytorch
  • render-(cloud-platform)
  • rest-api
  • sentence-transformers
  • server-sent-events-(sse)
Share this project:

Updates