🧬 Genomic Reasoning Agent
LLM-driven agentic system for personal genomic variant interpretation
Overview
This project builds a multi-step reasoning agent that interprets personal genomic data from 23andMe against biomedical knowledge databases (ClinVar, GWAS Catalog, gnomAD). The agent is trained with GRPO (Group Relative Policy Optimization) using fully verifiable reward signals — no human labelers needed.
The core insight mirrors DeepSeek-R1's approach to mathematics: genomic variant interpretation has verifiable ground truth (ClinVar classifications, GWAS p-values, population frequencies), making it ideal for RL-based reasoning training.
23andMe SNPs (631K)
↓
ClinVar Annotation ← rs1801133 → MTHFR → Pathogenic
↓
Tool-Using LLM Agent ← 5 tools: lookup / scan / haplotype / stats / reward
↓
GRPO Training Loop ← verifiable reward from ClinVar ground truth
↓
Reasoning Model ← factual · calibrated · evidence-grounded
↓
HF Spaces Demo ← upload 23andMe → ask questions → reasoning trace
Motivation
Standard LLMs hallucinate on genomic questions. This project trains a model that:
Cites sources (ClinVar review status, GWAS p-values, PubMed IDs)
Shows reasoning chains (mechanism → evidence → conclusion)
Calibrates uncertainty (risk factor ≠ diagnosis)
Uses tools to look up live databases rather than relying on memorised weights
The training signal is 100% verifiable — reward is computed by checking responses against ClinVar annotations, not scored by humans.
Repository Structure
genomic-reasoning-agent/
├── genomic_pipeline.py # Step 1: Parse 23andMe .txt → DataFrame
├── clinvar_pipeline_full.py # Step 2: Annotate variants via ClinVar API
├── genomic_agent_huggingface.py # Step 3: smolagents tool-using agent (5 tools)
├── train_grpo.py # Step 4: GRPO training with TRL
├── app.py # HF Spaces Gradio UI
├── data/
│ ├── clinvar_annotations.json # 12 variants with full ClinVar metadata
│ └── genomic_qa_dataset.json # 36 Q&A pairs (3 task types × 12 variants)
└── README.md
Pipeline: Step by Step
Step 1 — Parse 23andMe
Reads the raw .txt export (Build GRCh37) into a DataFrame of 631,455 SNPs.
1 from genomic_pipeline import parse_23andme
2
3 df = parse_23andme ( "genome_23andme.txt" )
4 # → 631,455 SNPs across chromosomes 1–22, X, Y, MT
5 # → 104,617 heterozygous (16.6%) | 522,909 homozygous (82.8%)
Step 2 — ClinVar Annotation
Queries NCBI E-utilities and GWAS Catalog for each rsID. Builds a Q&A dataset with verifiable answers.
1 from clinvar_pipeline_full import query_clinvar_batch , build_qa_dataset
2
3 annotations = query_clinvar_batch ( rsids , email = "your@email.com" )
4 qa_dataset = build_qa_dataset ( annotations , genome_df )
5 # → 12 variants annotated
6 # → 36 Q&A pairs: variant_interpretation / genotype_interpretation / pathway_reasoning
Sample annotation:
rsID Gene Genotype Significance Condition rs1801133 MTHFR GG Pathogenic/Likely pathogenic Homocystinuria rs429358 + rs7412 APOE TT / CC risk factor Alzheimer disease rs9939609 FTO AT risk factor Obesity rs762551 CYP1A2 AC drug response Caffeine metabolism
Step 3 — Tool-Using Agent (smolagents)
A ToolCallingAgent with 5 tools that plans multi-step queries across databases.
1 from smolagents import ToolCallingAgent , InferenceClientModel
2 from genomic_agent_huggingface import (
3 VariantLookupTool , # rsID → ClinVar + genotype
4 GeneScannerTool , # gene/trait → all patient variants
5 HaplotypeCallerTool , # APOE ε2/ε3/ε4 from two SNPs
6 GenomeStatsTool , # 631K SNPs overview
7 RewardEvaluatorTool , # GRPO reward score (used during training)
8 )
9
10 model = InferenceClientModel ( "meta-llama/Llama-3.1-8B-Instruct" )
11 agent = ToolCallingAgent ( tools = [ . . . ] , model = model , max_steps = 10 )
12
13 answer = agent . run ( "What is my APOE haplotype and what does it mean?" )
6-step reasoning trace for "Give me a genomic health summary":
Step 1 [genome_stats] → 631,455 SNPs | 16.6% heterozygous
Step 2 [variant_lookup] → rs1801133 | MTHFR | GG | Pathogenic
Step 3 [call_haplotype] → APOE ε3/ε3 | Neutral Alzheimer's risk
Step 4 [scan_gene_variants] → dopamine: ANKK1 GG (risk), COMT GG (Val/Val)
Step 5 [scan_gene_variants] → caffeine: CYP1A2 AC (intermediate), ADORA2A CT
Step 6 [evaluate_reasoning] → reward: 0.93 / 1.00 (excellent)
Step 4 — GRPO Training
Trains the base LLM to reason better about genomic questions using reinforcement learning with verifiable rewards — no human annotation required.
1 from train_grpo import train , TrainingConfig
2
3 config = TrainingConfig (
4 model_name = "meta-llama/Llama-3.1-8B-Instruct" ,
5 num_epochs = 3 ,
6 num_generations = 4 , # G: completions per question
7 beta = 0.04 , # KL penalty
8 use_lora = True ,
9 )
10 trainer = train ( config )
Reward function — 6 verifiable components:
Component Weight Verifiable against Factual accuracy 0.35 ClinVar clinical significance Condition coverage 0.25 ClinVar associated conditions Gene mention 0.15 ClinVar gene annotation Reasoning chain 0.15 Presence of causal language Uncertainty calibration 0.05 Hedging language Response completeness 0.05 Word count
Training progression (simulated):
untrained reward=0.06 |█░░░░░░░░░░░░░░░░░░░░░░░░░░░░░|
epoch_1 reward=0.56 |████████████████░░░░░░░░░░░░░░|
epoch_3 reward=0.71 |█████████████████████░░░░░░░░░|
epoch_5 reward=0.93 |███████████████████████████░░░|
epoch_10 reward=1.00 |██████████████████████████████|
GRPO advantage formula:
advantage_i = (reward_i − mean(rewards)) / std(rewards)
No critic network. No value function. No human labeler.
Just relative comparison within each group of G=4 completions.
Key Results from Real Genome Data
Running the full pipeline on a real 23andMe export (Zalina Dezhina, v5 chip):
Variant Gene Genotype Clinical Note 🔴 rs1801133 MTHFR GG Pathogenic — folate metabolism (p.Ala222Val) 🟡 rs9939609 FTO AT Risk factor — obesity, 1 risk allele (40.4% population) 🧠 APOE — ε3/ε3 Neutral — most common haplotype, no elevated AD risk 💊 rs762551 CYP1A2 AC Drug response — intermediate caffeine metabolizer 🟡 rs1800497 ANKK1 GG Risk factor — reward pathway / DRD2 association 🟢 rs6265 BDNF CC Benign (Val/Val) — better episodic memory
⚠️ This is a research and portfolio project, not medical advice.
All interpretations are for educational purposes only.
Tech Stack
Layer Technology Genome parsing pandas, Python Variant annotation NCBI E-utilities (ClinVar), EBI GWAS Catalog Agentic framework smolagents (HuggingFace)RL training TRL GRPOTrainerFine-tuning LoRA (PEFT) + 4-bit quantization (bitsandbytes) Base model meta-llama/Llama-3.1-8B-Instruct Demo UI Gradio (HF Spaces) Evaluation Per-task reward breakdown, 3 task types
HuggingFace Deployment
Spaces (interactive demo):
1. Create new Space → Gradio SDK
2. Upload: genomic_agent_huggingface.py, app.py, data/
3. Add secret: HF_TOKEN
4. Upload your 23andMe .txt → ask questions in chat
Model Hub (trained weights):
trainer.push_to_hub("mioulin/genomic-reasoning-llm")
Dataset Hub:
1 from datasets import Dataset
2 Dataset . from_list ( qa_dataset ) . push_to_hub ( "mioulin/genomic-reasoning-qa" )
Connection to ML Scientist Role
This project was built to demonstrate the exact skills required for ML Scientist roles in AI×biology:
Agentic systems — 5-tool ToolCallingAgent with multi-step planning
RL/RLHF training — GRPO with verifiable reward, no human labelers
Biomedical data integration — ClinVar, GWAS Catalog, gnomAD, PubMed
Evaluation framework — 6-component reward breakdown across 3 task types
Real scientific domain — 631,455 SNPs from real 23andMe genome
Reasoning over evidence — multi-hop: SNP → gene → pathway → phenotype
Running Locally
1 git clone https://huggingface.co/spaces/mioulin/genomic-reasoning-agent
2 cd genomic-reasoning-agent
3
4 pip install smolagents trl transformers accelerate peft datasets gradio
5
6 # Annotate your genome
7 python clinvar_pipeline_full.py \
8 --genome your_23andme.txt \
9 --output data/clinvar_annotations.json \
10 --email your@email.com
11
12 # Run agent (requires HF token for model inference)
13 export HF_TOKEN = hf_ .. .
14 python genomic_agent_huggingface.py
15
16 # Train with GRPO (requires GPU)
17 python train_grpo.py \
18 --model meta-llama/Llama-3.1-8B-Instruct \
19 --epochs 3 --lora --G 4
Author
Zalina Dezhina, PhD
HuggingFace
Citation
1 @misc{dezhina2026genomic,
2 title = {Genomic Reasoning Agent: GRPO Training on Personal SNP Data},
3 author = {Dezhina, Zalina},
4 year = {2026},
5 url = {https://huggingface.co/spaces/mioulin/genomic-reasoning-agent}
6 }
License
MIT — research and educational use only.
Not intended for clinical or medical decision-making.
Built with 🧬 smolagents · TRL · HuggingFace · ClinVar · 23andMe