You need to agree to share your contact information to access this dataset

This repository is publicly accessible, but you have to accept the conditions to access its files and content.

Log in or Sign Up to review the conditions and access this dataset content.

PubMed-GraphRAG Dataset

A large-scale biomedical knowledge graph dataset for Graph-based Retrieval-Augmented Generation (GraphRAG).

Dataset Overview

Component Size Description
Papers 12.5M PubMed abstracts (2000-2024) with title, abstract, DOI
Entities 7.5M Genes, Diseases, Chemicals, Species, Mutations, Cell Lines
Relationships 266M+ MENTIONED_IN, TREAT, ASSOCIATE, CAUSE, INHIBIT, etc.
Embeddings 12.5M vectors MedCPT, BiCA, MedTE (768-dim)

Dataset Structure

pubmed-graphrag-data/
β”œβ”€β”€ graph_ready/                    # Papers & major MENTIONED_IN relationships
β”‚   β”œβ”€β”€ papers.csv                  # 12.5M papers (pmid, title, abstract, year, doi)
β”‚   β”œβ”€β”€ mentioned_in_gene.csv       # Gene-Paper relationships
β”‚   β”œβ”€β”€ mentioned_in_disease.csv    # Disease-Paper relationships
β”‚   β”œβ”€β”€ mentioned_in_chemical.csv   # Chemical-Paper relationships
β”‚   β”œβ”€β”€ entity_relations.csv        # Entity-Entity semantic relationships
β”‚   └── complete_papers_with_metadata.jsonl  # Full data in JSONL format
β”‚
β”œβ”€β”€ neo4j_csv/                      # Entity definitions & additional relationships
β”‚   β”œβ”€β”€ gene_entities.csv           # 3.8M genes (entity_id, mention)
β”‚   β”œβ”€β”€ disease_entities.csv        # 12K diseases
β”‚   β”œβ”€β”€ chemical_entities.csv       # 120K chemicals
β”‚   β”œβ”€β”€ species_entities.csv        # 359K species
β”‚   β”œβ”€β”€ mutation_entities.csv       # 3.2M mutations
β”‚   β”œβ”€β”€ cellline_entities.csv       # 63K cell lines
β”‚   β”œβ”€β”€ mentioned_in_species.csv    # Species-Paper relationships
β”‚   β”œβ”€β”€ mentioned_in_mutation.csv   # Mutation-Paper relationships
β”‚   β”œβ”€β”€ mentioned_in_cellline.csv   # CellLine-Paper relationships
β”‚   └── rel_*.csv                   # 32 semantic relationship files (TREAT, CAUSE, etc.)
β”‚
β”œβ”€β”€ medcpt/                         # MedCPT embeddings (recommended)
β”‚   β”œβ”€β”€ embeddings_000000.npz       # Each NPZ contains 'embeddings' and 'pmids' arrays
β”‚   β”œβ”€β”€ ...
β”‚   └── embeddings_000251.npz
β”‚
β”œβ”€β”€ bica_base/                      # BiCA embeddings
β”‚   └── embeddings_*.npz
β”‚
└── medte/                          # MedTE embeddings
    └── embeddings_*.npz

Quick Start: Building the Knowledge Graph

Prerequisites

  • Neo4j 5.x (Community Edition works)
  • Python 3.8+
  • ~50GB disk space
  • 16GB+ RAM recommended

Step 1: Download all CSV files

from huggingface_hub import snapshot_download

# Download all CSVs
snapshot_download(
    repo_id="dannyroxas/pubmed-graphrag-data",
    repo_type="dataset",
    local_dir="./pubmed-data",
    allow_patterns=["graph_ready/*.csv", "neo4j_csv/*.csv"]
)

Step 2: Import to Neo4j

# Stop Neo4j
sudo systemctl stop neo4j

# Import (adjust paths as needed)
cd ./pubmed-data

sudo neo4j-admin database import full \
  --nodes=Paper="graph_ready/papers.csv" \
  --nodes=Gene="neo4j_csv/gene_entities.csv" \
  --nodes=Disease="neo4j_csv/disease_entities.csv" \
  --nodes=Chemical="neo4j_csv/chemical_entities.csv" \
  --nodes=Species="neo4j_csv/species_entities.csv" \
  --nodes=Mutation="neo4j_csv/mutation_entities.csv" \
  --nodes=CellLine="neo4j_csv/cellline_entities.csv" \
  --relationships=MENTIONED_IN="graph_ready/mentioned_in_gene.csv" \
  --relationships=MENTIONED_IN="graph_ready/mentioned_in_disease.csv" \
  --relationships=MENTIONED_IN="graph_ready/mentioned_in_chemical.csv" \
  --relationships=MENTIONED_IN="neo4j_csv/mentioned_in_species.csv" \
  --relationships=MENTIONED_IN="neo4j_csv/mentioned_in_mutation.csv" \
  --relationships=MENTIONED_IN="neo4j_csv/mentioned_in_cellline.csv" \
  --relationships=ASSOCIATE="neo4j_csv/rel_*_ASSOCIATE.csv" \
  --relationships=TREAT="neo4j_csv/rel_*_TREAT.csv" \
  --relationships=CAUSE="neo4j_csv/rel_*_CAUSE.csv" \
  --relationships=INHIBIT="neo4j_csv/rel_*_INHIBIT.csv" \
  --relationships=STIMULATE="neo4j_csv/rel_*_STIMULATE.csv" \
  --relationships=INTERACT="neo4j_csv/rel_*_INTERACT.csv" \
  --relationships=POSITIVE_CORRELATE="neo4j_csv/rel_*_POSITIVE_CORRELATE.csv" \
  --relationships=NEGATIVE_CORRELATE="neo4j_csv/rel_*_NEGATIVE_CORRELATE.csv" \
  --relationships=COTREAT="neo4j_csv/rel_*_COTREAT.csv" \
  --relationships=COMPARE="neo4j_csv/rel_*_COMPARE.csv" \
  --relationships=PREVENT="neo4j_csv/rel_*_PREVENT.csv" \
  --relationships=DRUG_INTERACT="neo4j_csv/rel_*_DRUG_INTERACT.csv" \
  --skip-bad-relationships \
  --skip-duplicate-nodes \
  neo4j

# Fix permissions and start
sudo chown -R neo4j:neo4j /var/lib/neo4j/data
sudo systemctl start neo4j

Step 3: Create indexes

CREATE INDEX paper_pmid FOR (p:Paper) ON (p.pmid);
CREATE INDEX gene_mention FOR (g:Gene) ON (g.mention);
CREATE INDEX gene_id FOR (g:Gene) ON (g.entity_id);
CREATE INDEX disease_mention FOR (d:Disease) ON (d.mention);
CREATE INDEX chemical_mention FOR (c:Chemical) ON (c.mention);
CREATE INDEX species_mention FOR (s:Species) ON (s.mention);
CREATE INDEX mutation_mention FOR (m:Mutation) ON (m.mention);

Quick Start: Building FAISS Index

Step 1: Download embeddings

from huggingface_hub import snapshot_download

# Download MedCPT embeddings (recommended for biomedical)
snapshot_download(
    repo_id="dannyroxas/pubmed-graphrag-data",
    repo_type="dataset",
    local_dir="./pubmed-data",
    allow_patterns="medcpt/*.npz"
)

Step 2: Build IVF-PQ index

import numpy as np
import faiss
from pathlib import Path
from tqdm import tqdm

# Configuration
NPZ_DIR = Path("./pubmed-data/medcpt")
OUTPUT_DIR = Path("./faiss_index")
OUTPUT_DIR.mkdir(exist_ok=True)

NLIST = 4096      # Number of clusters
M = 96            # Subquantizers (768/96 = 8 dims each)
NBITS = 8         # Bits per code
TRAIN_SIZE = 500000

# Get all NPZ files
npz_files = sorted(NPZ_DIR.glob("embeddings_*.npz"))
print(f"Found {len(npz_files)} embedding files")

# Step 1: Sample vectors for training
print("Sampling vectors for training...")
train_vectors = []
for npz_file in tqdm(npz_files[:50], desc="Sampling"):
    data = np.load(npz_file)
    emb = data["embeddings"].astype(np.float32)
    idx = np.random.choice(len(emb), min(10000, len(emb)), replace=False)
    train_vectors.append(emb[idx])

train_vectors = np.vstack(train_vectors)[:TRAIN_SIZE]
faiss.normalize_L2(train_vectors)
dim = train_vectors.shape[1]
print(f"Training set: {len(train_vectors):,} vectors, dim={dim}")

# Step 2: Create and train index
print("Training IVF-PQ index...")
quantizer = faiss.IndexFlatIP(dim)
index = faiss.IndexIVFPQ(quantizer, dim, NLIST, M, NBITS, faiss.METRIC_INNER_PRODUCT)
index.train(train_vectors)
index.nprobe = 128
del train_vectors

# Step 3: Add all vectors
print("Adding all vectors...")
all_pmids = []
for npz_file in tqdm(npz_files, desc="Adding"):
    data = np.load(npz_file)
    emb = data["embeddings"].astype(np.float32)
    pmids = data["pmids"]
    faiss.normalize_L2(emb)
    index.add(emb)
    all_pmids.extend(pmids.tolist())

# Step 4: Save
print("Saving index...")
faiss.write_index(index, str(OUTPUT_DIR / "index.faiss"))
np.save(OUTPUT_DIR / "pmids.npy", np.array(all_pmids))

print(f"\nDone!")
print(f"  Index: {index.ntotal:,} vectors")
print(f"  Size: ~{index.ntotal * M / 1e9:.1f} GB (compressed)")

NPZ File Format

Each .npz file contains:

  • embeddings: numpy array of shape (N, 768) - float32 vectors
  • pmids: numpy array of shape (N,) - corresponding PubMed IDs
import numpy as np

data = np.load("medcpt/embeddings_000000.npz")
print(data["embeddings"].shape)  # (50000, 768)
print(data["pmids"].shape)       # (50000,)

Entity Types

Type Count ID Format Example
Gene 3.8M NCBI Gene ID 348 (APOE)
Disease 12K MeSH ID MESH:D000544 (Alzheimer Disease)
Chemical 120K MeSH ID MESH:D001241 (Aspirin)
Species 359K NCBI Taxonomy 9606 (Homo sapiens)
Mutation 3.2M dbSNP/HGVS rs121912438
Cell Line 63K Cellosaurus CVCL_0030

Relationship Types

Type Count Example
MENTIONED_IN 248M (Gene)-[:MENTIONED_IN]->(Paper)
ASSOCIATE 9.2M (Gene)-[:ASSOCIATE]->(Disease)
TREAT 3.1M (Chemical)-[:TREAT]->(Disease)
POSITIVE_CORRELATE 1.8M (Chemical)-[:POSITIVE_CORRELATE]->(Gene)
NEGATIVE_CORRELATE 1.8M (Chemical)-[:NEGATIVE_CORRELATE]->(Gene)
CAUSE 1.3M (Mutation)-[:CAUSE]->(Disease)
STIMULATE 388K (Chemical)-[:STIMULATE]->(Gene)
INHIBIT 307K (Chemical)-[:INHIBIT]->(Gene)
COTREAT 237K (Chemical)-[:COTREAT]->(Chemical)
COMPARE 208K (Chemical)-[:COMPARE]->(Chemical)
INTERACT 123K (Gene)-[:INTERACT]->(Gene)
PREVENT ~5K (Mutation)-[:PREVENT]->(Disease)

Embedding Models

Model HuggingFace Dimensions Recommended For
MedCPT ncbi/MedCPT-Article-Encoder 768 Medical literature search
BiCA bisectgroup/BiCA-base 768 Biomedical contrastive learning
MedTE MohammadKhodadad/MedTE 768 Medical text embeddings

Sample Neo4j Queries

Find genes associated with Alzheimer's disease

MATCH (d:Disease)-[:ASSOCIATE]-(g:Gene)
WHERE d.mention CONTAINS "Alzheimer"
RETURN g.mention AS gene, g.entity_id AS ncbi_id
LIMIT 20

Find drugs that treat diabetes

MATCH (c:Chemical)-[:TREAT]->(d:Disease)
WHERE d.mention CONTAINS "Diabetes"
RETURN c.mention AS drug, count(*) AS evidence_count
ORDER BY evidence_count DESC
LIMIT 10

Multi-hop: Find genes related to drugs treating a disease

MATCH (c:Chemical)-[:TREAT]->(d:Disease)
WHERE d.mention CONTAINS "Breast"
MATCH (c)-[r:ASSOCIATE|INHIBIT|STIMULATE]-(g:Gene)
RETURN DISTINCT g.mention AS gene, c.mention AS drug, type(r) AS relationship
LIMIT 25

Find papers discussing a specific gene

MATCH (g:Gene {mention: "BRCA1"})-[:MENTIONED_IN]->(p:Paper)
RETURN p.pmid, p.title, p.year
ORDER BY p.year DESC
LIMIT 10

Data Sources

Source Description Link
PubMed 12.5M biomedical abstracts (2000-2024) pubmed.ncbi.nlm.nih.gov
PubTator3 Pre-extracted entities & relationships ncbi.nlm.nih.gov/research/pubtator3
NCBI Gene Gene symbols and metadata ncbi.nlm.nih.gov/gene
MeSH Medical Subject Headings (diseases, chemicals) meshb.nlm.nih.gov
NCBI Taxonomy Species classification ncbi.nlm.nih.gov/taxonomy
Cellosaurus Cell line database cellosaurus.org
dbSNP Mutation/variant identifiers ncbi.nlm.nih.gov/snp

Citation

@dataset{pubmed_graphrag_2025,
  author = {Roxas, Danny},
  title = {PubMed-GraphRAG: A Large-scale Biomedical Knowledge Graph Dataset},
  year = {2025},
  publisher = {Hugging Face},
  howpublished = {\url{https://huggingface.co/datasets/dannyroxas/pubmed-graphrag-data}}
}

License

This dataset is derived from publicly available biomedical databases:

Released under CC-BY-4.0 for academic research purposes.

Acknowledgments

Downloads last month
462