Skip to content

AI-powered clinical trial matcher using semantic search and LLM reasoning. Find experimental treatments and clinical trials matching your health profile. Built with FastAPI, FAISS embeddings, and Gemma reasoning.

Notifications You must be signed in to change notification settings

qsilv/TrialBridge

Repository files navigation

TrialBridge

TrialBridge preview

Find clinical trials that match your health profile.

TrialBridge helps volunteers and patients discover experimental treatments and clinical trials suited to their medical condition, age, location, and health history. Using AI-powered semantic search and eligibility reasoning, TrialBridge matches you with relevant clinical trials from ClinicalTrials.gov in seconds.

How It Works

  1. You describe your condition, age, sex, location, and clinical notes
  2. AI searches 10,000+ clinical trials using semantic embeddings
  3. AI reasons about your eligibility using language models
  4. You get ranked trial matches with fit scores and eligibility explanations

Tech Stack

Backend

  • FastAPI — REST API server with CORS support
  • FAISS — Vector similarity search (HNSW index with L2 distance)
  • Qwen Embeddings — Semantic text embeddings (Qwen/Qwen3-Embedding-8B)
  • Gemma LLM — Eligibility reasoning & scoring (google/gemma-3-27b-it)

Frontend

  • React — Component-based UI
  • Vite — Fast build tool and dev server

Data Pipeline

  • ClinicalTrials.gov API — Live clinical trial data
  • JSONL — Streaming data format for efficient processing
  • Text chunking & normalization — Prepare trials for embedding

Deployment

  • Uvicorn — ASGI server for FastAPI

Project Structure

  • backend/main.py — FastAPI /match endpoint
  • backend/matching_engine.py — FAISS vector search over embeddings
  • backend/reasoning.py — Qwen embeddings + Gemma eligibility reasoning
  • data/Fetch_Clinic_Data.py — Fetch trials from ClinicalTrials.gov API
  • data/Normalize_Data.py — Normalize, chunk, embed, and build FAISS index
  • frontend/react — Vite/React UI with responsive design
  • tests/test_api.py — API testing harness

Setup

  1. Python env
python -m venv .venv
.venv\Scripts\activate
pip install -r requirements.txt
  1. Environment (.env at repo root)
Configure .env based on .env.example template to include API keys and other settings
  1. Data prep
cd data
python Fetch_Clinic_Data.py        # writes trials.jsonl
python Normalize_Data.py           # builds data/cache/index.faiss + metadata.jsonl
  1. Run backend
uvicorn backend.main:app --reload --port 8000
  1. Run frontend (new shell)
cd frontend/react
npm install
npm run dev

API

  • POST /match?top_k=5&nearby_only=false&proximity_boost=0
    Payload:
{
  "condition": "Type 2 Diabetes",
  "age": 55,
  "sex": "M",
  "notes": "HbA1c 8.1, on metformin",
  "location": "Boston, Massachusetts, United States"
}

Response: { "results": [ { nct_id, title, status, locations, fit_score, eligibility, explanation } ] }

Tips

  • Use 127.0.0.1 instead of localhost if you hit hostname issues.
  • Ensure .env is loaded; missing keys fall back to a neutral “Possibly eligible” response.
  • Re-run Normalize_Data.py if you refresh trials data or embeddings.

About

AI-powered clinical trial matcher using semantic search and LLM reasoning. Find experimental treatments and clinical trials matching your health profile. Built with FastAPI, FAISS embeddings, and Gemma reasoning.

Resources

Stars

Watchers

Forks