Spaces:
Running
Running
File size: 3,560 Bytes
d515e2b 6e92226 d515e2b | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | ---
title: Candle Fire
emoji: 🕯️
colorFrom: blue
colorTo: indigo
sdk: gradio
sdk_version: "6.14.0"
app_file: app.py
pinned: false
---
# 🕯️ Candle-Fire
**ALS Research Intelligence for Physicians**
Candle-fire is a physician-facing tool that synthesizes evidence from ~500 curated ALS research papers and a biomedical knowledge graph. Ask a free-text question about ALS biology, drug targets, or clinical trials — get a structured, cited answer in under 30 seconds.
## What It Does
- **Two-layer retrieval**: Knowledge graph expansion (BioLORD-2023-C embeddings + NetworkX) → RAG over ~500 ALS papers
- **Citation-weighted ranking**: Highly-cited papers surface first
- **Structured synthesis**: Claude Sonnet produces mechanism summaries, entity tables, evidence strength assessments, and trial links
- **Biomedical synonyms**: BioLORD understands that "TDP-43" = "TARDBP" = "TAR DNA-binding protein 43"
## Setup
### Prerequisites
```bash
# Python 3.11+, uv package manager
pip install uv
uv sync
```
### Environment variables
```bash
cp .env.example .env
# Fill in:
# ANTHROPIC_API_KEY — required
# ENTREZ_EMAIL — required for PubMed ingestion
# NCBI_API_KEY — optional, raises rate limit 3→10 req/s
```
### Run the offline pipeline (once)
Build the knowledge assets before launching the app. Each step is resumable.
```bash
# 1. Ingest ~500 ALS papers from PubMed + PMC full text + citation counts (~15 min)
uv run python scripts/ingest_papers.py
# 2. Ingest ALS clinical trials from ClinicalTrials.gov (< 1 min, run in parallel)
uv run python scripts/ingest_trials.py
# 3. Extract biomedical entities using Claude Sonnet (~$1.50, ~50 min, resumable)
uv run python scripts/extract_entities.py
# 4. Build the knowledge graph (~5 sec)
uv run python scripts/build_graph.py
# 5. Build the ChromaDB vector index with BioLORD embeddings (~10 min, one-time model download)
uv run python scripts/build_index.py
```
### Launch
```bash
# Web UI (auto-reloads on file changes — use during development)
uv run gradio app.py
# Web UI (production / one-shot)
uv run python app.py
# CLI
uv run python main.py "What is the evidence for tofersen targeting SOD1?"
```
## Architecture
```
Physician query
→ agents/research_agent.py
1. Claude: extract query entities → ["SOD1", "tofersen"]
2. graph/query.py: KG expansion → ["SOD1", "TARDBP", "antisense oligonucleotide", ...]
3. rag/retriever.py: BioLORD semantic search + entity search → top 15 papers
(re-ranked by: similarity × log(citation_count + 2))
4. graph/query.py: find linked clinical trials
5. Claude Sonnet (streaming): synthesize research landscape
→ Gradio UI (streaming response with citations)
```
**Embedding model**: `FremyCompany/BioLORD-2023-C` — anchored to UMLS/SNOMED CT/MeSH ontologies, natively resolves biomedical synonyms.
**Knowledge graph**: NetworkX DiGraph with Gene/Protein/Compound/Pathway/Phenotype/Mechanism/ClinicalTrial nodes. 1-hop BFS expansion before RAG retrieval.
## Data Sources
| Source | Content | Volume |
|---|---|---|
| PubMed Entrez | ALS paper abstracts + metadata | ~500 papers (2018–2024) |
| PubMed Central | Full text for Open Access papers | ~50% coverage |
| Semantic Scholar | Citation counts per paper | All papers |
| ClinicalTrials.gov v2 | Active ALS recruiting trials | ~112 trials |
## Disclaimer
Research synthesis tool. Always verify claims with primary sources before applying to patient care. Not a substitute for clinical judgment.
|