Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -3,125 +3,101 @@ license: apache-2.0
|
|
| 3 |
tags:
|
| 4 |
- dna
|
| 5 |
- genomics
|
| 6 |
-
- mutation
|
| 7 |
-
- sad
|
| 8 |
- omni-dna
|
| 9 |
-
-
|
| 10 |
-
|
| 11 |
-
base_model: zehui127/Omni-DNA-20M
|
| 12 |
pipeline_tag: text-generation
|
| 13 |
---
|
| 14 |
|
| 15 |
-
# Omni-DNA SAD
|
| 16 |
-
|
| 17 |
-
Fine-tuned Omni-DNA-20M for cross-domain HGT (Horizontal Gene Transfer) mutation prediction using **SAD (Sequential Attenuation Denoising)**.
|
| 18 |
-
|
| 19 |
-
## Architecture
|
| 20 |
-
|
| 21 |
-
- **Base**: [Omni-DNA-20M](https://huggingface.co/zehui127/Omni-DNA-20M) (OLMo-based, 20M params, BPE tokenizer, 250-token context)
|
| 22 |
-
- **Purpose**: Given a parent DNA sequence, predict the mutated child sequence
|
| 23 |
-
- **Format**: `"mutate: {parent} -> {child}"` — instruction-tuned as a causal LM
|
| 24 |
|
| 25 |
-
|
| 26 |
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
Every 3 codons, a 1-codon gap is introduced; both models predict the gap
|
| 31 |
-
Agreement = consensus (high quality), disagreement = contested (kept, weighted lower)
|
| 32 |
-
→ Produces 8,112 synthetic mutation pairs
|
| 33 |
-
|
| 34 |
-
Stage 2 (SAD — Sequential Attenuation Denoising):
|
| 35 |
-
Fine-tune on synthetic pairs first (builds broad mutation prior)
|
| 36 |
-
Then fine-tune on real data at 10x lower LR
|
| 37 |
-
Uncontradicted synthetic patterns persist, contradicted ones get attenuated
|
| 38 |
-
```
|
| 39 |
|
| 40 |
-
##
|
| 41 |
|
| 42 |
| Parameter | Value |
|
| 43 |
-
|---
|
| 44 |
-
|
|
| 45 |
-
|
|
| 46 |
-
|
|
| 47 |
-
|
|
| 48 |
-
|
|
|
|
|
| 49 |
| Precision | fp32 |
|
| 50 |
|
| 51 |
-
|
|
|
|
|
|
|
|
|
|
| 52 |
|
| 53 |
-
|
| 54 |
-
|------|-------------|
|
| 55 |
-
| `stage1_ici/` | Weights after synthetic pre-training (ICI stage) |
|
| 56 |
-
| `stage2_sad/` | Weights after real-data attenuation (final SAD model) |
|
| 57 |
|
| 58 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
|
| 60 |
-
|
| 61 |
-
|-------|:---:|:---:|:---:|:---:|
|
| 62 |
-
| Base Omni (no fine-tune) | 360.4 | 43.9% | **30.1%** | — |
|
| 63 |
-
| SAD coeff=4.89 (5 real ep) | **264.3** | 43.7% | 26.3% | 4.89 |
|
| 64 |
-
| SAD coeff=1.5 (16 real ep) | 271.7 | 43.1% | 29.4% | 1.50 |
|
| 65 |
|
| 66 |
-
|
| 67 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
|
| 69 |
-
|
| 70 |
-
(637→445 bp, matching ground truth 443) and Levenshtein distance (360→264),
|
| 71 |
-
but mutation recall remains flat. The 20M param model learns sequence structure
|
| 72 |
-
but struggles to localize specific mutations.
|
| 73 |
|
| 74 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
|
| 80 |
## Usage
|
| 81 |
|
| 82 |
```python
|
| 83 |
-
import torch
|
| 84 |
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 85 |
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
prompt = f"mutate: {parent} -> "
|
| 93 |
-
input_ids = tokenizer(prompt, return_tensors="pt")["input_ids"].to(model.device)
|
| 94 |
-
generated = input_ids
|
| 95 |
-
suppress = {0, 1, 2, 3} # UNK, CLS, SEP, PAD
|
| 96 |
-
|
| 97 |
-
with torch.inference_mode():
|
| 98 |
-
for _ in range(max_new_tokens):
|
| 99 |
-
logits = model(input_ids=generated).logits[:, -1, :] / max(temperature, 0.01)
|
| 100 |
-
for s in suppress:
|
| 101 |
-
logits[0, s] = float("-inf")
|
| 102 |
-
probs = torch.softmax(logits, dim=-1)
|
| 103 |
-
next_token = torch.multinomial(probs, num_samples=1)
|
| 104 |
-
generated = torch.cat([generated, next_token], dim=-1)
|
| 105 |
-
|
| 106 |
-
text = tokenizer.decode(generated[0, input_ids.shape[1]:], skip_special_tokens=True)
|
| 107 |
-
return "".join(c for c in text.upper() if c in "ACGT")
|
| 108 |
-
|
| 109 |
-
parent = "ATGGCTAGCTGATCGATCGATCG..."
|
| 110 |
-
child = predict_child(parent)
|
| 111 |
-
print(child)
|
| 112 |
```
|
| 113 |
|
| 114 |
-
##
|
| 115 |
|
| 116 |
-
|
|
|
|
| 117 |
|
| 118 |
## Source Code
|
| 119 |
|
| 120 |
-
|
| 121 |
|
| 122 |
-
##
|
| 123 |
|
| 124 |
-
-
|
| 125 |
-
-
|
| 126 |
-
-
|
| 127 |
-
- **Total**: <20 min training time
|
|
|
|
| 3 |
tags:
|
| 4 |
- dna
|
| 5 |
- genomics
|
| 6 |
+
- mutation
|
|
|
|
| 7 |
- omni-dna
|
| 8 |
+
- sad
|
| 9 |
+
base_model: Nhoodie/omni-dna-ici-dc
|
|
|
|
| 10 |
pipeline_tag: text-generation
|
| 11 |
---
|
| 12 |
|
| 13 |
+
# Omni-DNA SAD Checkpoint
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
+
**Sequential Attenuation Denoising (SAD)** — ICI-DC checkpoint fine-tuned on real mutation data.
|
| 16 |
|
| 17 |
+
Starting from the [ICI-DC checkpoint](https://huggingface.co/Nhoodie/omni-dna-ici-dc), this model
|
| 18 |
+
undergoes attenuation: real mutation pairs at 10x lower learning rate. Weights that don't contradict
|
| 19 |
+
real data persist from ICI-DC; contradicted patterns get corrected.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
+
## SAD Training Details
|
| 22 |
|
| 23 |
| Parameter | Value |
|
| 24 |
+
|---|---|
|
| 25 |
+
| Base model | `Nhoodie/omni-dna-ici-dc` (ICI-DC pre-trained) |
|
| 26 |
+
| Training data | 3,317 real mutation pairs |
|
| 27 |
+
| Epochs | 5 |
|
| 28 |
+
| Learning rate | 1e-5 (10x lower than ICI-DC) |
|
| 29 |
+
| **SAD coefficient** | **4.89** (81,120 synthetic exposures / 16,585 real exposures) |
|
| 30 |
+
| Batch size | 32 effective |
|
| 31 |
| Precision | fp32 |
|
| 32 |
|
| 33 |
+
> **Note**: SAD coefficient of 4.89 is considered too high. A coefficient of ~1.5 was also tested
|
| 34 |
+
> (16 real epochs) with similar results. See benchmarks below.
|
| 35 |
+
|
| 36 |
+
## Multi-Axis Benchmark (100 test pairs, 4 models)
|
| 37 |
|
| 38 |
+
### Axis 6: Discriminative (most important)
|
|
|
|
|
|
|
|
|
|
| 39 |
|
| 40 |
+
| Model | AUC | Best F1 | Score Gap |
|
| 41 |
+
|-------|:---:|:---:|:---:|
|
| 42 |
+
| Base Omni (no fine-tune) | 0.588 | 0.688 | 25.6 |
|
| 43 |
+
| [ICI-DC](https://huggingface.co/Nhoodie/omni-dna-ici-dc) | 0.887 | 0.858 | 370.2 |
|
| 44 |
+
| **SAD coeff=4.89 (this)** | **0.904** | **0.862** | **411.4** |
|
| 45 |
+
| SAD coeff=1.5 | 0.908 | 0.862 | 413.7 |
|
| 46 |
|
| 47 |
+
### Axis 5: Mutation Surprise
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
|
| 49 |
+
| Model | Surprise | p-value | Interpretation |
|
| 50 |
+
|-------|:---:|:---:|---|
|
| 51 |
+
| Base Omni | +0.777 | <0.0001 | Expects parent (mutations are surprising) |
|
| 52 |
+
| ICI-DC | -0.216 | 0.0001 | Expects mutations everywhere |
|
| 53 |
+
| **SAD coeff=4.89** | -0.203 | 0.0003 | Partially attenuated |
|
| 54 |
+
| SAD coeff=1.5 | -0.169 | 0.0026 | More attenuation |
|
| 55 |
|
| 56 |
+
### Full 6-Axis Comparison
|
|
|
|
|
|
|
|
|
|
| 57 |
|
| 58 |
+
| Axis | Metric | Base | ICI-DC | SAD 4.89 | SAD 1.5 |
|
| 59 |
+
|---|---|:---:|:---:|:---:|:---:|
|
| 60 |
+
| A1: Detection | Recall | 0.511 | 0.518 | 0.517 | 0.497 |
|
| 61 |
+
| A2: Logits | Top-3 acc | 0.846 | 0.846 | 0.846 | 0.846 |
|
| 62 |
+
| A3: Ti/Tv | Predicted ratio | 0.20 | 0.41 | 0.42 | 0.43 |
|
| 63 |
+
| A4: Embeddings | Seq AUC | 0.41 | 0.35 | 0.40 | 0.40 |
|
| 64 |
+
| A5: Surprise | ΔLL | +0.78 | -0.22 | -0.20 | -0.17 |
|
| 65 |
+
| **A6: Discrim.** | **AUC** | **0.588** | **0.887** | **0.904** | **0.908** |
|
| 66 |
|
| 67 |
+
### Interpretation
|
| 68 |
+
|
| 69 |
+
- **ICI-DC provides the main training signal** (AUC 0.59→0.89). Synthetic data builds a strong
|
| 70 |
+
internal representation of valid mutation pairs.
|
| 71 |
+
- **SAD fine-tunes that representation** (0.887→0.908). The attenuation step does help, but the
|
| 72 |
+
marginal gain over ICI-DC is modest.
|
| 73 |
+
- **The model is a judge, not a generator.** 90.8% discriminative AUC but ~30% generative recall.
|
| 74 |
+
The representations encode mutation structure, but autoregressive decoding can't access it efficiently.
|
| 75 |
+
- **Ti/Tv ratio converges** from 0.20 (base) to 0.43 (SAD 1.5), approaching the biological value of 0.48.
|
| 76 |
|
| 77 |
## Usage
|
| 78 |
|
| 79 |
```python
|
|
|
|
| 80 |
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 81 |
|
| 82 |
+
tokenizer = AutoTokenizer.from_pretrained("Nhoodie/omni-dna-sad-mutation", trust_remote_code=True)
|
| 83 |
+
model = AutoModelForCausalLM.from_pretrained("Nhoodie/omni-dna-sad-mutation", trust_remote_code=True)
|
| 84 |
+
|
| 85 |
+
# Score a mutation pair (discriminative use)
|
| 86 |
+
prompt = "mutate: ATGGCTAGCTGA -> ATAGCTGGCTAA"
|
| 87 |
+
logits = model(**tokenizer(prompt, return_tensors="pt")).logits
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 88 |
```
|
| 89 |
|
| 90 |
+
## Related
|
| 91 |
|
| 92 |
+
- **[Nhoodie/omni-dna-ici-dc](https://huggingface.co/Nhoodie/omni-dna-ici-dc)** — ICI-DC checkpoint (synthetic-only)
|
| 93 |
+
- **[Nhoodie/omni-dna-sad-mutation-dataset](https://huggingface.co/datasets/Nhoodie/omni-dna-sad-mutation-dataset)** — Training data
|
| 94 |
|
| 95 |
## Source Code
|
| 96 |
|
| 97 |
+
Git commit: `7be4e73` (branch `dev/sad-omni-hyena`, private repo)
|
| 98 |
|
| 99 |
+
## Citation
|
| 100 |
|
| 101 |
+
- Omni-DNA: Zehui127 et al.
|
| 102 |
+
- HyenaDNA: Nguyen et al., NeurIPS 2023
|
| 103 |
+
- ENBED: Malusare et al., Bioinformatics Advances, 2024 (arXiv: 2311.02333)
|
|
|