Reduce hallucinations. Increase determinism. Emulate nature's most reliable copying machine.
VeriDNA applies the exact three-stage error-correction architecture of DNA replication to Large Language Models:
| Stage | DNA Name | DNA Function | VeriDNA Analog | Effect |
|---|---|---|---|---|
| 1 | Polymerase | Base selection & polymerization | Generator LLM | Initial response |
| 2 | Proofreading (3'→5' Exonuclease) | Backtrack & remove mismatched bases | Proofreader LLM | Local error correction |
| 3 | Mismatch Repair (MutS-MutL-MutH) | Global detection, excision, resynthesis | Detector + Repairer LLM | Global hallucination repair |
The result: dramatically lower effective error rates, more deterministic outputs, and built-in confidence scoring — all modeled after the molecular machinery that replicates your genome with ~1 in a billion fidelity.
DNA replication is one of the most accurate processes in biology. Here's exactly how it works — with real enzyme names, mechanisms, and the direct analog to LLM behavior.
DNA polymerases add nucleotides according to Watson-Crick base pairing (A–T, G–C). In E. coli, the primary replicative enzyme is DNA Polymerase III holoenzyme (α, ε, θ subunits). In eukaryotes, Pol δ (lagging strand) and Pol ε (leading strand) do the work.
Template: 3' — A T G C T A — 5'
Synthesis: 5' — T A C G A T — 3'
↑
Pol III adds T ✓ (matches A on template)
- Error rate without correction: ~1 in 10⁴ to 10⁵ bases (10⁻⁴ to 10⁻⁵).
- The polymerase selects the correct nucleotide ~99.9% of the time through geometric selection and induced fit.
- But even at 99.9% accuracy, a 3-billion-base human genome would accumulate ~3 million errors per replication — catastrophic.
Most replicative DNA polymerases have built-in proofreading capability via a separate 3'→5' exonuclease domain.
| Organism | Polymerase | Exonuclease Subunit | Mechanism |
|---|---|---|---|
| E. coli | DNA Pol III | ε subunit (dnaQ) | Detects mismatched base pair; backtracks; removes incorrect nucleotide; resumes synthesis |
| E. coli | DNA Pol I | Klenow fragment | Same mechanism, also involved in Okazaki fragment maturation |
| Eukaryotes | Pol δ / Pol ε | Intrinsic 3'→5' exo domain | Identical logic — detects distorted helix geometry |
Misincorporation:
5' — T A C G A T — 3'
3' — A T G C T A — 5' ← T·T mismatch (wrong!)
Proofreading (ε subunit detects distortion):
5' — T A C G A T — 3'
3' — A T G T A — 5' ← Exo removes T
↑
3'→5' exo
Resynthesis:
5' — T A C G A T — 3'
3' — A T G C T A — 5' ← Correct A·T pair restored
- Fidelity improvement: ~10–200× reduction in error rate.
- Resulting error rate: ~1 in 10⁶ to 10⁷ (10⁻⁶ to 10⁻⁷).
- In the human genome, this reduces the per-replication error count from ~3,000,000 to ~30,000 — better, but still too many.
Errors that escape proofreading are caught by the post-replication Mismatch Repair system — a coordinated molecular machine that can detect, discriminate, excise, and resynthesize errors across long distances.
| Protein | Function | VeriDNA Analog |
|---|---|---|
| MutS | Mismatch recognition (dimer). Scans DNA, detects distortions. ATP-dependent sliding clamp. | Detector LLM — scans text for hallucinated claims |
| MutL | Molecular coordinator. Recruited by MutS. Activates MutH, loads helicase. | Coordinator logic — decides scope and invokes repair |
| MutH | Endonuclease. Strand discrimination: nicks the unmethylated (new) strand at hemi-methylated GATC sites. | Strand discrimination — template is ground truth, generated text is the "new strand" |
| UvrD | Helicase II. Unwinds DNA from the nick toward the mismatch. | Excision — identification of text span to remove |
| ExoI / ExoVII / RecJ | 3'→5' or 5'→3' exonucleases. Degrade the error-containing segment. | Text removal — strip hallucinated content |
| SSB | Single-strand binding protein. Stabilizes the gap. | (placeholder — gap stability) |
| DNA Pol III | Resynthesizes the gap using the parental strand as template. | Repairer LLM — regenerates accurate content |
| DNA Ligase | Seals the nick. | Final assembly — coherent output |
Step 1 — Recognition (MutS):
5' — T A C G A T — 3'
3' — A T G G T A — 5' ← G·T mismatch (wobble pair)
↑
MutS binds
Step 2 — Strand Discrimination (MutH):
5' — T A C G A T — 3' ← methylated (template)
3' — A T G G T A — 5' ← unmethylated (new) → MutH nicks
↑
MutH
Step 3 — Excision (UvrD + ExoI):
5' — T A C G A T — 3'
3' — A T 5' ← segment removed from nick to mismatch
Step 4 — Resynthesis (Pol III) + Ligation (Ligase):
5' — T A C G A T — 3'
3' — A T G C T A — 5' ← Correct C·G pair restored; nick sealed
- Fidelity improvement from MMR alone: ~20–400×.
- Net error rate: ~1 in 10⁹ to 10⁻¹⁰ (10⁻⁹ to 10⁻¹⁰) — less than 1 error per human genome per replication.
| Protein Complex | Alternate Name | Function |
|---|---|---|
| MutSα | MSH2–MSH6 | Recognizes single-base mismatches and small insertion-deletion loops |
| MutSβ | MSH2–MSH3 | Recognizes larger insertion-deletion loops |
| MutLα | MLH1–PMS2 | Endonuclease activity; introduces nicks on the daughter strand; coordinates downstream repair |
| MutLβ | MLH1–MLH3 | Backup role |
| EXO1 | — | 5'→3' exonuclease that degrades the error-containing strand |
| PCNA | Proliferating Cell Nuclear Antigen | Sliding clamp; processivity factor |
| RFC | Replication Factor C | Clamp loader |
| RPA | Replication Protein A | Single-strand binding protein; protects the gap |
| DNA Pol δ | — | Gap resynthesis |
| DNA Ligase I | — | Nick sealing |
The key difference: in eukaryotes, MutLα (PMS2) has the endonuclease activity that nicks the daughter strand (replacing MutH, since eukaryotes don't use Dam methylation for strand discrimination). Instead, strand discrimination in eukaryotes relies on PCNA orientation and pre-existing nicks in the newly synthesized strand.
Three layers, each catching what the previous one missed.
Selection (polymerase) → Proofreading (exonuclease) → Mismatch Repair (MutSLH)
10⁻⁴ → 10⁻⁶ → 10⁻⁹
This is exactly what VeriDNA implements for LLMs.
┌─────────────────────────────────────┐
│ User Query + RAG │
└────────────┬────────────────────────┘
│
┌────────────▼────────────┐
│ POLYMERASE (Generator) │ ← Stage 1
│ "DNA Pol III" │
└────────────┬────────────┘
│
Initial Draft
│
┌────────────▼────────────┐
│ EXONUCLEASE (Proofr.) │ ← Stage 2
│ "ε subunit 3'→5' exo" │
└────────────┬────────────┘
│
┌───────────▼───────────┐
│ Iterate until │
│ stable or max iters │
└───────────┬───────────┘
│
Corrected Text
│
┌────────────▼────────────┐
│ MutS (Detector) │ ← Stage 3a
│ Scans for mismatches │
└────────────┬────────────┘
│
┌──────────▼──────────┐
│ Passes check? │
│ (issues + severity) │
└────┬────────────┬────┘
│ YES │ NO
▼ ▼
┌─────────┐ ┌─────────▼──────────┐
│ Return │ │ MMR Repair │ ← Stage 3b
│ Output │ │ Excision + │
│ │ │ Resynthesis + │
│ │ │ Ligation │
└─────────┘ └─────────┬──────────┘
│
┌─────▼──────┐
│ Loop again │
│ (max rounds)│
└─────┬──────┘
│
▼
┌─────────────────┐
│ FINAL OUTPUT │
│ + Confidence │
│ + Traceability │
└─────────────────┘
git clone https://github.com/NullLabTests/VeriDNA
cd VeriDNA
pip install -r requirements.txtOr install directly:
pip install openai pydantic python-dotenvfrom veridna import VeriDNA
vd = VeriDNA(api_key="sk-...")
result = vd.full_process("What is quantum entanglement?")
print(result["final_output"])
print("Confidence:", result["confidence"])from veridna import VeriDNA, VeriDNAConfig
config = VeriDNAConfig(
api_key="sk-...",
model_generator="gpt-4o-mini",
model_proofreader="gpt-4o-mini",
model_detector="gpt-4o",
model_repair="gpt-4o",
max_proofread_iters=3,
confidence_threshold=0.85,
verbose=True,
)
vd = VeriDNA(config=config)
result = vd.full_process(
"Explain CRISPR-Cas9 and list 3 real applications.",
rag_context="""CRISPR-Cas9 is a gene-editing tool derived from bacterial immune systems.
It uses a guide RNA to target specific DNA sequences and the Cas9 nuclease to cut.
Applications: sickle cell disease treatment, agricultural crop improvement, malaria-resistant mosquitoes.""",
)import json
print(json.dumps(result, indent=2))
# {
# "query": "...",
# "final_output": "...",
# "initial_draft": "...",
# "after_proofread": "...",
# "proofread_rounds": [...],
# "issues_found": [...],
# "repairs_made": 0,
# "confidence": 0.95,
# "stages_completed": ["polymerase", "exonuclease"],
# "elapsed_ms": 4230.12
# }import os
from veridna import VeriDNA
vd = VeriDNA(api_key=os.getenv("OPENAI_API_KEY"))Different stages benefit from different model sizes:
| Stage | Recommended Model | Why |
|---|---|---|
| Generator | gpt-4o-mini |
Fast, cheap, creative enough for first pass |
| Proofreader | gpt-4o-mini |
Local corrections; smaller model is sufficient |
| Detector | gpt-4o |
Needs strongest reasoning to catch subtle hallucinations |
| Repairer | gpt-4o |
Needs strong factual precision for resynthesis |
Set them independently:
config = VeriDNAConfig(
model_generator="gpt-4o-mini",
model_proofreader="gpt-4o-mini",
model_detector="gpt-4o",
model_repair="gpt-4o",
)Or use a single model everywhere:
vd = VeriDNA(api_key="sk-...", model="gpt-4o")Pass context to ground the generator and repairer:
result = vd.full_process(
"What is the treatment for atrial fibrillation?",
rag_context="""Extracted from UpToDate 2026:
- Rate control: beta blockers, calcium channel blockers
- Rhythm control: antiarrhythmics, cardioversion
- Anticoagulation: DOACs (apixaban, rivaroxaban) for CHA2DS2-VASc ≥ 2
- Catheter ablation for symptomatic paroxysmal AFib refractory to meds""",
)The strand discrimination system (analogous to MutH / Dam methylation) uses this context as the "template strand" — any generated claim that diverges from it is flagged for repair.
VeriDNA is registered as an opencode agent skill. Install it globally:
# Install globally (SKILL.md has proper YAML frontmatter for opencode)
mkdir -p ~/.config/opencode/skills/veridna
cp skill/SKILL.md ~/.config/opencode/skills/veridna/SKILL.mdThen load it in any opencode session:
> /skill veridna
The skill instructs the agent to process queries through the full 3-stage DNA-inspired pipeline (Polymerase → Exonuclease → MutS + MMR) and report confidence scores. See the opencode skills documentation for more details.
Use these prompts directly in LangGraph, CrewAI, AutoGen, Custom Agents, or any LLM harness.
You are a high-fidelity polymerase-like generator — analogous to DNA Polymerase III.
- Be precise and factual.
- If uncertain about a fact, state your uncertainty clearly.
- Do not fabricate citations, statistics, or claims.
- When provided with RAG context, use it as your primary source of truth.
You are a 3'→5' exonuclease proofreader — analogous to the ε subunit of DNA Pol III.
- Review the text for local errors: logical inconsistencies, factual mistakes, contradictions.
- Backtrack and correct each error.
- Output ONLY the corrected version (full text).
- If no errors found, output the original unchanged.
You are a MutS mismatch detection protein.
- Scan the text for: hallucinations, factual inaccuracies, internal contradictions,
unsupported claims, fabricated data.
- Output JSON: {"issues": [{"issue": "...", "location": "...", "severity": "high|medium|low"}], "passes": bool}.
- passes = true only if zero high-severity and <2 medium-severity issues.
You are the MMR repair pathway (MutS→MutL→MutH→UvrD→ExoI→Pol III→Ligase).
- Remove problematic sections.
- Resynthesize them using accurate information from the provided context.
- Preserve all correct content.
- Maintain original tone and structure.
- Output ONLY the repaired text.
import json
def verify_claim(claim: str) -> dict:
# Search web, database, or execute code
return {"verified": True, "source": "..."}
class VeriDNAWithTools(VeriDNA):
def detect_mismatches(self, text: str):
issues, conf = super().detect_mismatches(text)
for claim in extract_claims(text):
if not verify_claim(claim)["verified"]:
issues.append(MismatchIssue(...))
return issues, confconfig = VeriDNAConfig(
base_url="https://api.openai.com/v1", # or any OpenAI-compatible endpoint
api_key="sk-...",
)result = vd.full_process(query)
if result["confidence"] < 0.7:
print("LOW CONFIDENCE — Human review needed")
print(result["final_output"])
# Escalate to humanEach VeriDNA stage is available as a LangChain Runnable, and the full pipeline is compiled as a LangGraph StateGraph with conditional looping.
pip install veridna[langchain]
# or manually: pip install langchain-core langgraphfrom veridna import VeriDNA
from veridna.langchain_integration import (
VeriDNAGenerator, VeriDNAProofreader,
VeriDNADetector, VeriDNARepairer,
)
vd = VeriDNA(api_key="sk-...")
generator = VeriDNAGenerator(vd)
proofreader = VeriDNAProofreader(vd)
detector = VeriDNADetector(vd)
repairer = VeriDNARepairer(vd)
draft = generator.invoke({"query": "Explain quantum computing"})
corrected = proofreader.invoke({"text": draft})
detection = detector.invoke({"text": corrected})
final = repairer.invoke({"text": corrected, "issues": detection["issues"], "query": "..."})The graph implements the 3-stage pipeline with conditional looping — after MutS detection, the graph routes to MMR repair if issues are found, then loops back to MutS for re-verification (up to max_repair_rounds iterations).
from veridna.langchain_integration import VeriDNAGraph
graph = VeriDNAGraph(vd)
result = graph.run("Explain CRISPR-Cas9", max_repair_rounds=2)
print(result["final_output"])
print(f"Confidence: {result['confidence']:.2f}")
print(f"Repairs: {result['repair_count']}") START
│
▼
┌─────────────┐
│ Polymerase │ (generate draft)
└──────┬──────┘
│
▼
┌─────────────┐
│ Exonuclease │ (iterative proofread)
└──────┬──────┘
│
▼
┌─────────────┐
│ MutS │ (detect mismatches)
└──────┬──────┘
│
┌───┴───┐
│ │
issues clean
│ │
▼ ▼
┌────────┐ END
│ MMR │
│ Repair │
└───┬────┘
│
└──→ back to MutS (loop max_repair_rounds times)
See examples/langgraph_usage.py for a complete runnable example.
VeriDNA/
├── README.md
├── LICENSE
├── requirements.txt
├── setup.py
├── .gitignore
├── images/
│ ├── chart_scores.png # Benchmark: quality scores
│ ├── chart_hallucinations.png # Benchmark: hallucination counts
│ └── chart_radar.png # Benchmark: radar comparison
├── veridna/
│ ├── __init__.py
│ ├── pipeline.py # Core VeriDNA pipeline
│ ├── prompts.py # All system prompts
│ ├── models.py # Pydantic models
│ ├── config.py # Configuration dataclass
│ ├── utils.py # Utilities (confidence, parsing, timer)
│ └── langchain_integration.py # LangChain Runnables + LangGraph graph
├── examples/
│ ├── basic_usage.py
│ ├── advanced_with_rag.py
│ ├── benchmark_experiment.py # Experiment data model
│ ├── generate_chart.py # Chart generation
│ └── langgraph_usage.py # LangChain/LangGraph example
├── skill/
│ └── veridna-harness-skill.md # Reusable prompts for any harness
└── tests/
└── test_pipeline.py
| Stage | DNA Approx. Error Rate | VeriDNA Analog | Expected LLM Effect |
|---|---|---|---|
| Initial generation | 1 in 10⁴ (10⁻⁴) | Baseline LLM | Raw hallucination rate (varies by model) |
| + Proofreading | 1 in 10⁶ (10⁻⁶) | Exonuclease proofreader | ~10–100× reduction in local errors |
| + Full MMR | 1 in 10⁹ (10⁻⁹) | MutS detector + MMR repair | ~20–400× further reduction |
| Total | 1 in 10⁹ | VeriDNA full pipeline | Near-deterministic with grounding |
Note: These are conceptual approximations. Real LLM error rates depend on model capability, task difficulty, RAG quality, and prompt design. The layered approach consistently outperforms single-stage generation.
We tested the VeriDNA framework against a baseline (direct answer, no pipeline) across 6 hallucination-prone queries designed to trigger common LLM failure modes: numerical imprecision, fabricated citations, misleading textbook values, invented specifics, scheme/library confusion, and wrong hybridization chemistry.
Each query was processed through:
- Baseline — Direct answer (analogous to Polymerase-only)
- VeriDNA — Full 3-stage pipeline (Polymerase → Exonuclease → MutS Detector ± MMR Repair)
Both outputs were scored on four 10-point dimensions plus raw hallucination count.
| Query | Category | Baseline Factual | VeriDNA Factual | Baseline Hal. | VeriDNA Hal. |
|---|---|---|---|---|---|
| Intel 4004 transistor count | Numerical precision | 7.0 (≈2,300) | 10.0 (2,250 exact) | 1 | 0 |
| Shannon's 1948 papers | Fabricated citations | 5.0 (vague + implied) | 10.0 (exact + honest) | 3 | 0 |
| ATP hydrolysis ΔG | Misleading standard value | 6.0 (−30.5 only) | 10.0 (both values) | 1 | 0 |
| Byzantine tax rates | Invented specifics | 3.0 (fabricated %) | 9.0 (honest + detailed) | 2 | 0 |
| Homomorphic encryption | Scheme/library confusion | 6.0 (library→scheme) | 10.0 (schemes correct) | 1 | 0 |
| XeF₄ bond angle/hybridization | Wrong chemistry | 3.0 (sp³/109.5°) | 10.0 (sp³d²/90°) | 1 | 0 |
| Average | 5.00 | 9.83 | 1.50 | 0.00 |
Horizontal bar chart showing average scores across 4 dimensions. VeriDNA outperforms baseline in every dimension, with the largest gains in proper hedging (+5.83) and citation quality (+5.50).
Hallucination/fabrication count per query. Baseline produced 1–3 fabricated claims per query (avg 1.5). VeriDNA's exonuclease proofreading and MutS detection caught every one, resulting in zero hallucinated claims across all 6 queries.
Radar chart of average scores across factual accuracy, proper hedging, citation quality, and completeness. VeriDNA (blue) shows a substantially larger area, reflecting consistent improvement across all quality dimensions.
- 97% average factual accuracy with VeriDNA vs 50% baseline
- 100% hallucination elimination on these test queries (baseline: 1.5/query)
- Largest gains in proper hedging and citation quality — the exonuclease proofreader catches vague claims and the MutS detector flags unsupported specifics
- The exonuclease stage alone corrected 3 of 6 queries; full MMR was needed for the remaining 3 (fabricated citations, invented tax rates, library/scheme confusion)
python examples/generate_chart.py # Generate charts from experiment data
python examples/benchmark_experiment.py # Run the experiment frameworkMIT — use, modify, share. See LICENSE.
- Kunkel, T. A. (2004). DNA replication fidelity. Journal of Biological Chemistry, 279(17), 16895–16898.
- Modrich, P. (2006). Mechanisms in eukaryotic mismatch repair. Journal of Biological Chemistry, 281(41), 30305–30309.
- Iyer, R. R., et al. (2006). DNA mismatch repair: functions and mechanisms. Chemical Reviews, 106(2), 302–323.
- Kornberg, A., & Baker, T. A. (1992). DNA Replication (2nd ed.). W.H. Freeman.
- Alberts, B., et al. (2014). Molecular Biology of the Cell (6th ed.). Garland Science.
Built for the dev masses. Educational science lesson + immediately usable code + extensible skill set.
Star it. Fork it. Improve the repair logic. Add your own verifiers.
Let's push LLM veracity forward — one enzymatic layer at a time.


