ybornachot commited on
Commit
ddb501f
·
2 Parent(s): 2f2efdf 80d0a14

Merge remote-tracking branch 'origin/main' into fine-tuning-notebook

Browse files
.gitattributes CHANGED
@@ -33,3 +33,14 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ assets/paper_summary.jpg filter=lfs diff=lfs merge=lfs -text
37
+ assets/paper_summary.png filter=lfs diff=lfs merge=lfs -text
38
+ assets/output_tracks.png filter=lfs diff=lfs merge=lfs -text
39
+ notebooks_pipelines/bigwig_outputs/K562_DNAse.bw filter=lfs diff=lfs merge=lfs -text
40
+ notebooks_pipelines/bigwig_outputs/K562_H3k4me3.bw filter=lfs diff=lfs merge=lfs -text
41
+ notebooks_pipelines/bigwig_outputs/K562_RNA_seq.bw filter=lfs diff=lfs merge=lfs -text
42
+ notebooks_pipelines/bigwig_outputs/HepG2_CTCF.bw filter=lfs diff=lfs merge=lfs -text
43
+ notebooks_pipelines/bigwig_outputs/HepG2_DNAse.bw filter=lfs diff=lfs merge=lfs -text
44
+ notebooks_pipelines/bigwig_outputs/HepG2_H3k4me3.bw filter=lfs diff=lfs merge=lfs -text
45
+ notebooks_pipelines/bigwig_outputs/HepG2_RNA_seq.bw filter=lfs diff=lfs merge=lfs -text
46
+ notebooks_pipelines/bigwig_outputs/K562_CTCF.bw filter=lfs diff=lfs merge=lfs -text
README.md CHANGED
@@ -7,63 +7,91 @@ sdk: static
7
  pinned: false
8
  ---
9
 
10
- # NTv3 — Foundation Models for Long-Range Genomics
11
 
12
  This Space is the companion hub for NTv3 checkpoints on the Hugging Face Hub. It provides PyTorch notebooks and minimal examples for inference, sequence-to-function prediction (functional tracks), genome annotation, fine-tuning, model interpretation and sequence generation.
13
 
14
- ## Notebooks
 
 
 
 
 
 
15
 
16
  Notebooks live in `./notebooks/`:
17
 
18
- - `00_quickstart_inference.ipynb` — load a checkpoint + run inference
19
- - `01_tracks_prediction.ipynb` — sequence → functional tracks (+ plotting)
20
- - `02_genome_annotation_segmentation.ipynb` — sequence → annotation
21
- - `03_finetune_head.ipynb` — fine-tune on a bigwig track
22
- - `04_model_interpretation.ipynb` — interpretation of post-trained model
23
- - `05_sequence_generation.ipynb` — fine-tune NTv3 to generate enhancer sequences
24
 
25
- ## Install
26
 
27
  ```bash
28
  pip install torch transformers accelerate safetensors huggingface_hub numpy
29
  ```
30
 
31
- ## Load a model (To DO)
32
 
33
  ```python
 
34
 
 
 
 
35
 
 
 
 
 
 
 
36
  ```
37
 
38
- ## Pipelines (To DO)
 
 
39
 
40
  ```python
41
- from transformers import pipeline
42
- import torch
43
-
44
- pipe = pipeline(
45
- task="ntv3-tracks",
46
- model="InstaDeepAI/ntv3_106M_7downsample_post_trained_1mb",
47
- trust_remote_code=True,
48
- device="cuda",
49
- torch_dtype=torch.bfloat16,
 
 
 
 
 
 
 
50
  )
51
 
52
- out = pipe("ACGT...")
 
 
53
  ```
54
 
55
- ## Checkpoints
56
 
57
- **Pre-trained:** `InstaDeepAI/ntv3_8M_7downsample_pretrained_le_1mb`, `InstaDeepAI/ntv3_106M_7downsample_pretrained_le_1mb`, `InstaDeepAI/ntv3_650M_7downsample_pretrained_le_1mb`
58
 
59
- **Post-trained:** `InstaDeepAI/ntv3_650M_7downsample_post_trained_1mb`, `InstaDeepAI/ntv3_106M_7downsample_post_trained_1mb`
60
 
61
- ## Links
62
 
63
- - **Paper:** (add link)
64
- - **JAX research code (GitHub):** [https://github.com/instadeepai/nucleotide-transformer](https://github.com/instadeepai/nucleotide-transformer)
 
65
 
66
- ## Citation
67
 
68
  ```bibtex
69
  @article{ntv3,
@@ -74,7 +102,7 @@ out = pipe("ACGT...")
74
  }
75
  ```
76
 
77
- ## License
78
 
79
  **Code & notebooks in this Space:** (choose and add, e.g., Apache-2.0)
80
 
 
7
  pinned: false
8
  ---
9
 
10
+ # 🧬 NTv3 — Foundation Models for Long-Range Genomics
11
 
12
  This Space is the companion hub for NTv3 checkpoints on the Hugging Face Hub. It provides PyTorch notebooks and minimal examples for inference, sequence-to-function prediction (functional tracks), genome annotation, fine-tuning, model interpretation and sequence generation.
13
 
14
+ ## 📖 About NTv3
15
+
16
+ NTv3 is a multi-species genomic foundation model family that unifies representation learning, functional-track prediction, genome annotation, and controllable sequence generation within a single U-Net-style backbone. It models up to 1 Mb of DNA at single-base resolution, using a conv–Transformer–deconv architecture that efficiently captures both local motifs and long-range regulatory dependencies. NTv3 is first pretrained on ~9T base pairs from the OpenGenome2 corpus spanning >128k species using masked language modeling, and then post-trained with a joint objective on ~16k functional tracks and annotation labels across 24 animal and plant species, enabling state-of-the-art cross-species functional prediction and base-resolution genome annotation.
17
+
18
+ Beyond prediction, NTv3 can be fine-tuned into a controllable generative model via masked-diffusion language modeling, allowing targeted design of regulatory sequences (for example, enhancers with specified activity and promoter selectivity) that have been validated experimentally.
19
+
20
+ ## 📓 Notebooks
21
 
22
  Notebooks live in `./notebooks/`:
23
 
24
+ - 🚀 `00_quickstart_inference.ipynb` — load a checkpoint + run inference
25
+ - 📊 `01_tracks_prediction.ipynb` — sequence → functional tracks (+ plotting)
26
+ - 🏷️ `02_genome_annotation_segmentation.ipynb` — sequence → annotation
27
+ - 🎯 `03_finetune_head.ipynb` — fine-tune on bigwig tracks
28
+ - 🔍 `04_model_interpretation.ipynb` — interpretation of post-trained model
29
+ - 🧪 `05_sequence_generation.ipynb` — fine-tune NTv3 to generate enhancer sequences
30
 
31
+ ## 📦 Install
32
 
33
  ```bash
34
  pip install torch transformers accelerate safetensors huggingface_hub numpy
35
  ```
36
 
37
+ ## 🤖 Load a pre-trained model
38
 
39
  ```python
40
+ from transformers import AutoTokenizer, AutoModelForMaskedLM
41
 
42
+ repo = "InstaDeepAI/NTv3_650M_pre"
43
+ tok = AutoTokenizer.from_pretrained(repo, trust_remote_code=True)
44
+ model = AutoModelForMaskedLM.from_pretrained(repo, trust_remote_code=True)
45
 
46
+ batch = tok(["ATCGNATCG", "ACGT"], add_special_tokens=False, padding=True, pad_to_multiple_of=128, return_tensors="pt")
47
+ out = model(**batch, output_hidden_states=True, output_attentions=True)
48
+
49
+ print(out.logits.shape) # (B, L, V = 11)
50
+ print(len(out.hidden_states)) # convs + transformers + deconvs
51
+ print(len(out.attentions)) # equals transformer layers = 12
52
  ```
53
 
54
+ ## 💻 Pipelines
55
+
56
+ Here is a quick example of how to use the post-trained NTv3 650M model on a human genomic window.
57
 
58
  ```python
59
+ from transformers import AutoConfig
60
+
61
+ model_name = "InstaDeepAI/NTv3_100M"
62
+
63
+ # Load track prediction pipeline
64
+ cfg = AutoConfig.from_pretrained(model_name, trust_remote_code=True, force_download=True)
65
+ pipe = cfg.load_tracks_pipeline(model_name, device="auto") # or "cpu"/"cuda"/"mps"
66
+
67
+ # Run track prediction
68
+ out = pipe(
69
+ {
70
+ "chrom": "chr19",
71
+ "start": 6_700_000,
72
+ "end": 6_831_072,
73
+ "species": "human"
74
+ }
75
  )
76
 
77
+ print(out.bigwig_tracks_logits.shape) # functional track predictions
78
+ print(out.bed_tracks_logits.shape) # genome annotation predictions
79
+ print(out.mlm_logits.shape) # MLM logits: (B, L, V = 11)
80
  ```
81
 
82
+ ## 🤖 Checkpoints
83
 
84
+ **📦 Pre-trained:** `InstaDeepAI/NTv3_8M_pre`, `InstaDeepAI/NTv3_100M_pre`, `InstaDeepAI/NTv3_650M_pre`
85
 
86
+ **🎯 Post-trained:** `InstaDeepAI/NTv3_100M`, `InstaDeepAI/NTv3_650M`
87
 
88
+ ## 🔗 Links
89
 
90
+ - **📄 Paper:** (add link)
91
+ - **💻 JAX research code (GitHub):** [https://github.com/instadeepai/nucleotide-transformer](https://github.com/instadeepai/nucleotide-transformer)
92
+ - **🏆 NTv3 benchmark leaderboard: (add link)**
93
 
94
+ ## 📝 Citation
95
 
96
  ```bibtex
97
  @article{ntv3,
 
102
  }
103
  ```
104
 
105
+ ## 📜 License
106
 
107
  **Code & notebooks in this Space:** (choose and add, e.g., Apache-2.0)
108
 
assets/.gitkeep DELETED
File without changes
assets/instadeep_logo.png DELETED
Binary file (79.4 kB)
 
assets/output_tracks.png ADDED

Git LFS Details

  • SHA256: 5b0ffbfc022b87213f48a9d8a67dcd542227f990f936438e9fc86d49c2fa767e
  • Pointer size: 131 Bytes
  • Size of remote file: 204 kB
assets/paper_summary.png ADDED

Git LFS Details

  • SHA256: b9f3388251c53aa597596ee468a2ec352449dffc2d1bdc7eb9e9144215539ef0
  • Pointer size: 131 Bytes
  • Size of remote file: 548 kB
index.html CHANGED
@@ -3,8 +3,9 @@
3
  <head>
4
  <meta charset="utf-8" />
5
  <meta name="viewport" content="width=device-width,initial-scale=1" />
6
- <title>NTv3 — Foundation Models for Long-Range Genomics</title>
7
  <meta name="description" content="NTv3 companion hub: PyTorch notebooks for inference, fine-tuning, interpretation, and sequence generation on NTv3 models hosted on Hugging Face." />
 
8
  <style>
9
  :root {
10
  --bg: #0b1020;
@@ -53,9 +54,49 @@
53
  border-radius: var(--radius);
54
  box-shadow: 0 6px 18px rgba(0,0,0,0.22);
55
  }
 
 
 
 
 
 
 
 
 
 
56
  .card h2 { margin: 0 0 10px 0; font-size: 16px; letter-spacing: 0.01em; }
57
  .card ul { margin: 0; padding-left: 18px; color: var(--muted); }
58
  .card li { margin: 8px 0; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
  a { color: var(--link); text-decoration: none; }
60
  a:hover { text-decoration: underline; }
61
  .pillrow { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
@@ -85,10 +126,129 @@
85
  font-size: inherit;
86
  color: inherit;
87
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
88
  .footer { margin-top: 22px; color: var(--muted); font-size: 13px; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89
  @media (max-width: 860px) {
90
  .card { grid-column: span 12; }
91
  h1 { font-size: 28px; }
 
 
 
 
92
  }
93
  </style>
94
  </head>
@@ -96,77 +256,139 @@
96
  <body>
97
  <div class="wrap">
98
  <div class="hero">
99
- <h1>NTv3 — Foundation Models for Long-Range Genomics</h1>
100
  <p>
101
  This Space is the companion hub for <strong>NTv3</strong> models: runnable notebooks for inference, fine-tuning, interpretation, and sequence generation.
102
  </p>
103
 
104
  <div class="pillrow">
105
- <span class="pill">Long-context genomics</span>
106
- <span class="pill">Torch notebooks</span>
107
- <span class="pill">Inference • Fine-tune • Interpret • Generate</span>
 
 
108
  </div>
109
  </div>
110
 
111
- <div class="grid">
112
- <div class="card">
113
- <h2>Notebooks</h2>
114
- <ul>
115
- <li><a href="https://huggingface.co/spaces/InstaDeepAI/ntv3/tree/main/notebooks" target="_blank" rel="noopener">Browse notebooks folder</a></li>
116
- <li><a href="https://huggingface.co/spaces/InstaDeepAI/ntv3/blob/main/notebooks/00_quickstart_inference.ipynb" target="_blank" rel="noopener">00 — Quickstart inference</a></li>
117
- <li><a href="https://huggingface.co/spaces/InstaDeepAI/ntv3/blob/main/notebooks/01_tracks_prediction.ipynb" target="_blank" rel="noopener">01 — Tracks prediction</a></li>
118
- <li>02 — Genome annotation / segmentation</li>
119
- <li>03 — Fine-tune a head</li>
120
- <li>04 — Model interpretation</li>
121
- <li>05 — Sequence generation</li>
122
- </ul>
123
- </div>
124
-
125
- <div class="card">
126
- <h2>Models</h2>
127
- <ul>
128
- <li>Pretrained checkpoints:
129
- <div style="margin-top: 8px; margin-left: 0;">
130
- <div><a href="https://huggingface.co/InstaDeepAI/ntv3_8M_7downsample_pretrained_le_1mb"><code>InstaDeepAI/ntv3_8M_7downsample_pretrained_le_1mb</code></a></div>
131
- <div><a href="https://huggingface.co/InstaDeepAI/ntv3_106M_7downsample_pretrained_le_1mb"><code>InstaDeepAI/ntv3_106M_7downsample_pretrained_le_1mb</code></a></div>
132
- <div><a href="https://huggingface.co/InstaDeepAI/ntv3_650M_7downsample_pretrained_le_1mb"><code>InstaDeepAI/ntv3_650M_7downsample_pretrained_le_1mb</code></a></div>
133
- </div>
134
- </li>
135
- <li>Post-trained checkpoints:
136
- <div style="margin-top: 8px; margin-left: 0;">
137
- <div><a href="https://huggingface.co/InstaDeepAI/ntv3_650M_7downsample_post_trained_1mb"><code>InstaDeepAI/ntv3_650M_7downsample_post_trained_1mb</code></a></div>
138
- <div><a href="https://huggingface.co/InstaDeepAI/ntv3_106M_7downsample_post_trained_1mb"><code>InstaDeepAI/ntv3_106M_7downsample_post_trained_1mb</code></a></div>
139
- </div>
140
- </li>
141
- </ul>
142
- </div>
143
 
144
- <div class="card">
145
- <h2>Model usage (to update)</h2>
146
- <p>Here is a quick example of how to use NTv3 models.</p>
147
- <div class="code"><code>from transformers import pipeline
148
-
149
- pipe = pipeline(
150
- task="ntv3-tracks",
151
- model="InstaDeepAI/ntv3_106M_7downsample_post_trained_1mb",
152
- trust_remote_code=True,
153
- device="cuda",
154
- torch_dtype=torch.bfloat16,
155
- )</code></div>
156
- </div>
157
 
158
- <div class="card">
159
- <h2>Links</h2>
160
- <ul>
161
- <li>Paper: (add link)</li>
162
- <li><a href="https://github.com/instadeepai/nucleotide-transformer">JAX training code</a></li>
163
- </ul>
164
- </div>
165
  </div>
 
 
 
 
 
166
 
167
  <p class="footer">
168
  © instadeep-ai — NTv3 companion Space.
169
  </p>
170
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
171
  </body>
172
  </html>
 
3
  <head>
4
  <meta charset="utf-8" />
5
  <meta name="viewport" content="width=device-width,initial-scale=1" />
6
+ <title>NTv3 — Next-Gen Foundation Models for Genomics</title>
7
  <meta name="description" content="NTv3 companion hub: PyTorch notebooks for inference, fine-tuning, interpretation, and sequence generation on NTv3 models hosted on Hugging Face." />
8
+ <link href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/themes/prism-tomorrow.min.css" rel="stylesheet" />
9
  <style>
10
  :root {
11
  --bg: #0b1020;
 
54
  border-radius: var(--radius);
55
  box-shadow: 0 6px 18px rgba(0,0,0,0.22);
56
  }
57
+ .card-stack {
58
+ grid-column: span 6;
59
+ display: flex;
60
+ flex-direction: column;
61
+ gap: 14px;
62
+ }
63
+ .card-stack .card {
64
+ grid-column: span 1;
65
+ margin: 0;
66
+ }
67
  .card h2 { margin: 0 0 10px 0; font-size: 16px; letter-spacing: 0.01em; }
68
  .card ul { margin: 0; padding-left: 18px; color: var(--muted); }
69
  .card li { margin: 8px 0; }
70
+ .card table {
71
+ width: 100%;
72
+ margin-top: 12px;
73
+ border-collapse: collapse;
74
+ font-size: 13px;
75
+ }
76
+ .card table th {
77
+ text-align: left;
78
+ padding: 10px 12px;
79
+ border-bottom: 2px solid var(--border);
80
+ color: var(--text);
81
+ font-weight: 600;
82
+ font-size: 12px;
83
+ text-transform: uppercase;
84
+ letter-spacing: 0.05em;
85
+ }
86
+ .card table td {
87
+ padding: 10px 12px;
88
+ border-bottom: 1px solid var(--border);
89
+ color: var(--muted);
90
+ }
91
+ .card table tr:last-child td {
92
+ border-bottom: none;
93
+ }
94
+ .card table tr:hover {
95
+ background: rgba(255, 255, 255, 0.02);
96
+ }
97
+ .card table td .checkmark {
98
+ color: #4ade80 !important;
99
+ }
100
  a { color: var(--link); text-decoration: none; }
101
  a:hover { text-decoration: underline; }
102
  .pillrow { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
 
126
  font-size: inherit;
127
  color: inherit;
128
  }
129
+ /* Prism.js theme overrides to match dark theme */
130
+ .code pre[class*="language-"] {
131
+ background: transparent;
132
+ margin: 0;
133
+ padding: 0;
134
+ }
135
+ .code code[class*="language-"] {
136
+ background: transparent;
137
+ }
138
+ .summary {
139
+ margin-top: 18px;
140
+ padding: 24px;
141
+ border: 1px solid var(--border);
142
+ background: var(--card);
143
+ border-radius: var(--radius);
144
+ box-shadow: var(--shadow);
145
+ }
146
+ .summary h2 {
147
+ margin: 0 0 16px 0;
148
+ font-size: 18px;
149
+ letter-spacing: 0.01em;
150
+ }
151
+ .summary p {
152
+ margin: 0 0 14px 0;
153
+ color: var(--muted);
154
+ line-height: 1.7;
155
+ }
156
+ .summary p:last-child {
157
+ margin-bottom: 0;
158
+ }
159
+ .why-ntv3 {
160
+ margin-top: 18px;
161
+ padding: 24px;
162
+ border: 1px solid var(--border);
163
+ background: var(--card);
164
+ border-radius: var(--radius);
165
+ box-shadow: var(--shadow);
166
+ }
167
+ .why-ntv3 h2 {
168
+ margin: 0 0 16px 0;
169
+ font-size: 18px;
170
+ letter-spacing: 0.01em;
171
+ }
172
+ .why-ntv3 ul {
173
+ margin: 0;
174
+ padding-left: 0;
175
+ list-style: none;
176
+ color: var(--muted);
177
+ }
178
+ .why-ntv3 li {
179
+ margin: 12px 0;
180
+ padding-left: 0;
181
+ line-height: 1.7;
182
+ }
183
+ .paper-summary {
184
+ margin-top: 12px;
185
+ padding: 24px;
186
+ border: 1px solid var(--border);
187
+ background: var(--card);
188
+ border-radius: var(--radius);
189
+ box-shadow: var(--shadow);
190
+ }
191
+ .paper-summary h2 {
192
+ text-align: center;
193
+ margin: 0 0 20px 0;
194
+ }
195
+ .paper-summary img {
196
+ width: 100%;
197
+ height: auto;
198
+ display: block;
199
+ border-radius: 12px;
200
+ }
201
  .footer { margin-top: 22px; color: var(--muted); font-size: 13px; }
202
+
203
+ /* Tab navigation styles */
204
+ .tabs {
205
+ margin-top: 24px;
206
+ display: flex;
207
+ gap: 8px;
208
+ border-bottom: 2px solid var(--border);
209
+ overflow-x: auto;
210
+ }
211
+ .tab-button {
212
+ padding: 12px 20px;
213
+ background: transparent;
214
+ border: none;
215
+ border-bottom: 2px solid transparent;
216
+ color: var(--muted);
217
+ font-family: var(--sans);
218
+ font-size: 14px;
219
+ font-weight: 500;
220
+ cursor: pointer;
221
+ transition: all 0.2s ease;
222
+ white-space: nowrap;
223
+ margin-bottom: -2px;
224
+ }
225
+ .tab-button:hover {
226
+ color: var(--text);
227
+ background: rgba(255, 255, 255, 0.03);
228
+ }
229
+ .tab-button.active {
230
+ color: var(--link);
231
+ border-bottom-color: var(--link);
232
+ }
233
+ .tab-content {
234
+ display: none;
235
+ animation: fadeIn 0.3s ease;
236
+ }
237
+ .tab-content.active {
238
+ display: block;
239
+ }
240
+ @keyframes fadeIn {
241
+ from { opacity: 0; transform: translateY(8px); }
242
+ to { opacity: 1; transform: translateY(0); }
243
+ }
244
+
245
  @media (max-width: 860px) {
246
  .card { grid-column: span 12; }
247
  h1 { font-size: 28px; }
248
+ .tab-button {
249
+ padding: 10px 16px;
250
+ font-size: 13px;
251
+ }
252
  }
253
  </style>
254
  </head>
 
256
  <body>
257
  <div class="wrap">
258
  <div class="hero">
259
+ <h1>🧬 NTv3 — Next-Gen Foundation Models for Genomics</h1>
260
  <p>
261
  This Space is the companion hub for <strong>NTv3</strong> models: runnable notebooks for inference, fine-tuning, interpretation, and sequence generation.
262
  </p>
263
 
264
  <div class="pillrow">
265
+ <span class="pill">🤖 Foundation Models</span>
266
+ <span class="pill">🧬 Long-context genomics</span>
267
+ <span class="pill">🌍 Multi-species</span>
268
+ <span class="pill">⚡ Inference • Fine-tune • Interpret • Generate</span>
269
+ <span class="pill">📓 Torch notebooks</span>
270
  </div>
271
  </div>
272
 
273
+ <!-- Tab Navigation -->
274
+ <div class="tabs">
275
+ <button class="tab-button active" data-tab="home">🏠 Home</button>
276
+ <button class="tab-button" data-tab="demo">🚀 Live Demo</button>
277
+ </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
278
 
279
+ <!-- Home Tab (Content loaded from tabs/home.html) -->
280
+ <div id="home" class="tab-content active">
281
+ <!-- Content will be loaded dynamically -->
282
+ </div>
 
 
 
 
 
 
 
 
 
283
 
284
+ <!-- Live Demo Tab (Content loaded from tabs/demo.html) -->
285
+ <div id="demo" class="tab-content">
286
+ <!-- Content will be loaded dynamically -->
 
 
 
 
287
  </div>
288
+
289
+ <!-- <div class="paper-summary">
290
+ <h2>📄 A foundational model for joint sequence-function multi-species modeling at scale for long-range genomic prediction</h2>
291
+ <img src="assets/paper_summary.png" alt="NTv3 Paper Summary" />
292
+ </div> -->
293
 
294
  <p class="footer">
295
  © instadeep-ai — NTv3 companion Space.
296
  </p>
297
  </div>
298
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/components/prism-core.min.js"></script>
299
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/plugins/autoloader/prism-autoloader.min.js"></script>
300
+ <script>
301
+ // Tab content mapping
302
+ const tabFiles = {
303
+ 'home': 'tabs/home.html',
304
+ 'demo': 'tabs/demo.html',
305
+ 'functional_tracks': 'tabs/functional_tracks.html',
306
+ };
307
+
308
+ // Cache for loaded tab content
309
+ const tabCache = {};
310
+
311
+ // Function to load tab content
312
+ async function loadTabContent(tabId) {
313
+ // Return cached content if available
314
+ if (tabCache[tabId]) {
315
+ return tabCache[tabId];
316
+ }
317
+
318
+ // Load content from file
319
+ const filePath = tabFiles[tabId];
320
+ if (!filePath) {
321
+ console.error(`No file path defined for tab: ${tabId}`);
322
+ return '';
323
+ }
324
+
325
+ try {
326
+ const response = await fetch(filePath);
327
+ if (!response.ok) {
328
+ throw new Error(`Failed to load ${filePath}: ${response.statusText}`);
329
+ }
330
+ const content = await response.text();
331
+ tabCache[tabId] = content;
332
+ return content;
333
+ } catch (error) {
334
+ console.error(`Error loading tab content for ${tabId}:`, error);
335
+ return `<div class="summary"><p>Error loading content. Please refresh the page.</p></div>`;
336
+ }
337
+ }
338
+
339
+ // Function to show a tab
340
+ async function showTab(tabId) {
341
+ const tabContent = document.getElementById(tabId);
342
+ if (!tabContent) {
343
+ console.error(`Tab element not found: ${tabId}`);
344
+ return;
345
+ }
346
+
347
+ // Load content if not already loaded
348
+ if (!tabContent.dataset.loaded) {
349
+ tabContent.innerHTML = await loadTabContent(tabId);
350
+ tabContent.dataset.loaded = 'true';
351
+
352
+ // Re-run Prism.js syntax highlighting for code blocks in the loaded content
353
+ if (typeof Prism !== 'undefined') {
354
+ // Find all code blocks in the loaded content and highlight them
355
+ const codeBlocks = tabContent.querySelectorAll('code[class*="language-"]');
356
+ codeBlocks.forEach(block => {
357
+ Prism.highlightElement(block);
358
+ });
359
+ }
360
+ }
361
+ }
362
+
363
+ // Tab switching functionality
364
+ document.addEventListener('DOMContentLoaded', function() {
365
+ const tabButtons = document.querySelectorAll('.tab-button');
366
+ const tabContents = document.querySelectorAll('.tab-content');
367
+
368
+ // Load the default active tab (home)
369
+ const activeTab = document.querySelector('.tab-content.active');
370
+ if (activeTab) {
371
+ showTab(activeTab.id);
372
+ }
373
+
374
+ tabButtons.forEach(button => {
375
+ button.addEventListener('click', async () => {
376
+ const targetTab = button.getAttribute('data-tab');
377
+
378
+ // Remove active class from all buttons and contents
379
+ tabButtons.forEach(btn => btn.classList.remove('active'));
380
+ tabContents.forEach(content => content.classList.remove('active'));
381
+
382
+ // Add active class to clicked button and corresponding content
383
+ button.classList.add('active');
384
+ const tabElement = document.getElementById(targetTab);
385
+ tabElement.classList.add('active');
386
+
387
+ // Load and show the tab content
388
+ await showTab(targetTab);
389
+ });
390
+ });
391
+ });
392
+ </script>
393
  </body>
394
  </html>
notebooks/.gitkeep DELETED
File without changes
notebooks/01_tracks_prediction.ipynb DELETED
The diff for this file is too large to render. See raw diff
 
notebooks_pipelines/01_functional_track_prediction.ipynb ADDED
The diff for this file is too large to render. See raw diff
 
{notebooks → notebooks_tutorials}/00_quickstart_inference.ipynb RENAMED
@@ -5,33 +5,33 @@
5
  "id": "024bb8a8",
6
  "metadata": {},
7
  "source": [
8
- "# NTv3 Quickstart — Pre-trained and Post-trained models\n",
9
  "\n",
10
- "This notebook demonstrates how to run **quick inference** with bothe pre- and post-trained NTv3 checkpoints:\n",
11
  "\n",
12
- "- **Pre-trained (MLM-focused):** `InstaDeepAI/ntv3_8M_7downsample_pretrained_le_1mb`, `InstaDeepAI/ntv3_106M_7downsample_pretrained_le_1mb`, `InstaDeepAI/ntv3_650M_ntv3_650M_7downsample_pretrained_le_1mb7downsample_pre_trained_1mb`\n",
13
- "- **Post-trained (task heads):** `InstaDeepAI/ntv3_106M_7downsample_post_trained_1mb`, `InstaDeepAI/ntv3_650M_7downsample_post_trained_1mb`\n",
14
  "\n",
15
  "We show how to:\n",
16
  "\n",
17
  "1. Load tokenizers + models\n",
18
  "2. Run a forward pass on a DNA sequence window\n",
19
- "3. Inspect key outputs"
 
 
20
  ]
21
  },
22
  {
23
  "cell_type": "markdown",
24
- "id": "5d58bf1d",
25
  "metadata": {},
26
  "source": [
27
- "## 0) Install dependencies\n",
28
- "\n",
29
- "Skip if already installed."
30
  ]
31
  },
32
  {
33
  "cell_type": "code",
34
- "execution_count": null,
35
  "id": "38cc32a9",
36
  "metadata": {},
37
  "outputs": [],
@@ -39,17 +39,9 @@
39
  "!pip -q install \"transformers>=4.40\" \"huggingface_hub>=0.23\" safetensors torch numpy"
40
  ]
41
  },
42
- {
43
- "cell_type": "markdown",
44
- "id": "5827af7e",
45
- "metadata": {},
46
- "source": [
47
- "## 1) Imports + setup"
48
- ]
49
- },
50
  {
51
  "cell_type": "code",
52
- "execution_count": 7,
53
  "id": "d56c105b",
54
  "metadata": {},
55
  "outputs": [
@@ -93,7 +85,7 @@
93
  "id": "82146876",
94
  "metadata": {},
95
  "source": [
96
- "## 2) Pre-trained checkpoint (MLM-focused)\n",
97
  "\n",
98
  "This shows the simplest usage: load model + tokenizer, then run a forward pass.\n",
99
  "\n",
@@ -103,7 +95,7 @@
103
  },
104
  {
105
  "cell_type": "code",
106
- "execution_count": null,
107
  "id": "336bb40c",
108
  "metadata": {},
109
  "outputs": [
@@ -112,23 +104,12 @@
112
  "output_type": "stream",
113
  "text": [
114
  "torch.Size([2, 128, 11])\n",
115
- "16\n",
116
- "2\n",
117
  "MLM logits shape: (2, 128, 11)\n"
118
  ]
119
- },
120
- {
121
- "name": "stderr",
122
- "output_type": "stream",
123
- "text": [
124
- "/opt/anaconda3/envs/hf-finetune/lib/python3.10/site-packages/torch/amp/autocast_mode.py:283: UserWarning: In CPU autocast, but the target dtype is not supported. Disabling autocast.\n",
125
- "CPU Autocast only supports dtype of torch.bfloat16, torch.float16 currently.\n",
126
- " warnings.warn(error_message)\n"
127
- ]
128
  }
129
  ],
130
  "source": [
131
- "pretrained_model_name = \"InstaDeepAI/ntv3_8M_7downsample_pretrained_le_1mb\"\n",
132
  "\n",
133
  "# Load tokenizer/model\n",
134
  "tok_pre = AutoTokenizer.from_pretrained(pretrained_model_name, trust_remote_code=True)\n",
@@ -137,11 +118,9 @@
137
  "# Example: human sequence\n",
138
  "seqs = [\"ATCGNATCG\", \"ACGT\"]\n",
139
  "batch = tok_pre(seqs, add_special_tokens=False, padding=True, pad_to_multiple_of=128, return_tensors=\"pt\")\n",
140
- "out = model_pre(**batch, output_hidden_states=True, output_attentions=True)\n",
141
  "\n",
142
  "print(out.logits.shape) # (B, L, V = 11)\n",
143
- "print(len(out.hidden_states)) # convs + transformers + deconvs\n",
144
- "print(len(out.attentions))\n",
145
  "\n",
146
  "# Access MLM logits\n",
147
  "mlm_logits = out[\"logits\"]\n",
@@ -153,25 +132,19 @@
153
  "id": "60a01798",
154
  "metadata": {},
155
  "source": [
156
- "## 3) Post-trained checkpoint (task heads: BigWig + BED)\n",
157
  "\n",
158
- "Post-trained checkpoints add task-specific heads.\n",
159
- "\n",
160
- "In particular:\n",
161
- "- `condition_tokenizer` is used to tokenize a species condition like `\"human\"`\n",
162
- "- `file_assembly_idx` selects the assembly (e.g., `hg38`)\n",
163
  "\n",
164
  "Expected outputs:\n",
165
- "- `bigwig_tracks_logits`\n",
166
- "- `bed_tracks_logits`\n",
167
- "- `logits` (MLM)\n",
168
- "\n",
169
- "> If your post-trained checkpoint supports multiple assemblies, the config typically exposes a mapping like `cfg.bigwigs_per_file_assembly`."
170
  ]
171
  },
172
  {
173
  "cell_type": "code",
174
- "execution_count": null,
175
  "id": "6cc5f2df",
176
  "metadata": {},
177
  "outputs": [
@@ -179,45 +152,50 @@
179
  "name": "stdout",
180
  "output_type": "stream",
181
  "text": [
182
- "torch.Size([1, 768, 7362])\n",
183
- "torch.Size([1, 768, 21, 2])\n",
184
- "torch.Size([1, 2048, 11])\n"
 
185
  ]
186
  }
187
  ],
188
  "source": [
189
- "posttrained_model_name = \"InstaDeepAI/ntv3_106M_7downsample_post_trained_1mb\"\n",
190
- "\n",
191
- "# Load config/tokenizers/model\n",
192
- "cfg_pos = AutoConfig.from_pretrained(posttrained_model_name, trust_remote_code=True)\n",
193
- "tok_pos = AutoTokenizer.from_pretrained(posttrained_model_name, trust_remote_code=True)\n",
194
- "model_pos = AutoModel.from_pretrained(posttrained_model_name, trust_remote_code=True)\n",
195
- "condition_tokenizer = AutoTokenizer.from_pretrained(\n",
196
- " posttrained_model_name, subfolder=\"condition_tokenizer\", trust_remote_code=True\n",
197
- ")\n",
198
  "\n",
199
- "# Example: human sequence (sequence needs to be multiple of 128 due to 7 downsampling in model)\n",
200
- "seq = \"ATCG\" * 512\n",
201
- "batch = tok_pos([seq], add_special_tokens=False, return_tensors=\"pt\")\n",
202
- "condition = condition_tokenizer([\"human\"], return_tensors=\"pt\")\n",
203
  "\n",
204
- "# Get assembly index for human (hg38)\n",
205
- "assemblies = list(cfg_pos.bigwigs_per_file_assembly.keys())\n",
206
- "assembly_idx = torch.tensor([assemblies.index(\"hg38\")])\n",
207
  "\n",
208
- "out = model_pos(\n",
 
 
 
 
 
 
 
209
  " input_ids=batch[\"input_ids\"],\n",
210
- " condition_ids=[condition[\"input_ids\"][0]],\n",
211
- " file_assembly_idx=assembly_idx,\n",
212
- " output_hidden_states=True,\n",
213
- " output_attentions=True,\n",
214
  ")\n",
215
  "\n",
216
- "# Access model outputs\n",
217
- "print(out[\"bigwig_tracks_logits\"].shape) # per-assembly functional track predictions\n",
218
- "print(out[\"bed_tracks_logits\"].shape) # genomic element classifications\n",
219
- "print(out[\"logits\"].shape) # masked LM logits"
 
 
220
  ]
 
 
 
 
 
 
 
 
221
  }
222
  ],
223
  "metadata": {
 
5
  "id": "024bb8a8",
6
  "metadata": {},
7
  "source": [
8
+ "# 🚀 NTv3 Quickstart — Pre-trained and Post-trained models\n",
9
  "\n",
10
+ "This notebook demonstrates how to run **quick inference** with both the pre- and post-trained NTv3 checkpoints:\n",
11
  "\n",
12
+ "- **Pre-trained (MLM-focused):** `InstaDeepAI/NTv3_8M_pre`, `InstaDeepAI/NTv3_100M_pre`, `InstaDeepAI/NTv3_650M_pre`\n",
13
+ "- **Post-trained (functional tracks and genome annotation):** `InstaDeepAI/NTv3_100M_post`, `InstaDeepAI/NTv3_650M_post`\n",
14
  "\n",
15
  "We show how to:\n",
16
  "\n",
17
  "1. Load tokenizers + models\n",
18
  "2. Run a forward pass on a DNA sequence window\n",
19
+ "3. Inspect key outputs\n",
20
+ "\n",
21
+ "> 📝 **Note for Google Colab users:** This notebook is compatible with Colab! For faster inference, make sure to enable GPU: Runtime → Change runtime type → GPU (T4 or better recommended)."
22
  ]
23
  },
24
  {
25
  "cell_type": "markdown",
26
+ "id": "5827af7e",
27
  "metadata": {},
28
  "source": [
29
+ "## 0) 📦 Imports + setup"
 
 
30
  ]
31
  },
32
  {
33
  "cell_type": "code",
34
+ "execution_count": 1,
35
  "id": "38cc32a9",
36
  "metadata": {},
37
  "outputs": [],
 
39
  "!pip -q install \"transformers>=4.40\" \"huggingface_hub>=0.23\" safetensors torch numpy"
40
  ]
41
  },
 
 
 
 
 
 
 
 
42
  {
43
  "cell_type": "code",
44
+ "execution_count": 2,
45
  "id": "d56c105b",
46
  "metadata": {},
47
  "outputs": [
 
85
  "id": "82146876",
86
  "metadata": {},
87
  "source": [
88
+ "## 1) 🎯 Pre-trained checkpoint (MLM-focused)\n",
89
  "\n",
90
  "This shows the simplest usage: load model + tokenizer, then run a forward pass.\n",
91
  "\n",
 
95
  },
96
  {
97
  "cell_type": "code",
98
+ "execution_count": 3,
99
  "id": "336bb40c",
100
  "metadata": {},
101
  "outputs": [
 
104
  "output_type": "stream",
105
  "text": [
106
  "torch.Size([2, 128, 11])\n",
 
 
107
  "MLM logits shape: (2, 128, 11)\n"
108
  ]
 
 
 
 
 
 
 
 
 
109
  }
110
  ],
111
  "source": [
112
+ "pretrained_model_name = \"InstaDeepAI/NTv3_8M_pre\"\n",
113
  "\n",
114
  "# Load tokenizer/model\n",
115
  "tok_pre = AutoTokenizer.from_pretrained(pretrained_model_name, trust_remote_code=True)\n",
 
118
  "# Example: human sequence\n",
119
  "seqs = [\"ATCGNATCG\", \"ACGT\"]\n",
120
  "batch = tok_pre(seqs, add_special_tokens=False, padding=True, pad_to_multiple_of=128, return_tensors=\"pt\")\n",
121
+ "out = model_pre(**batch)\n",
122
  "\n",
123
  "print(out.logits.shape) # (B, L, V = 11)\n",
 
 
124
  "\n",
125
  "# Access MLM logits\n",
126
  "mlm_logits = out[\"logits\"]\n",
 
132
  "id": "60a01798",
133
  "metadata": {},
134
  "source": [
135
+ "## 2) 🧠 Post-trained checkpoint (task heads: BigWig + BED)\n",
136
  "\n",
137
+ "Post-trained checkpoints add task-specific heads for functional track prediction and genome annotation.\n",
 
 
 
 
138
  "\n",
139
  "Expected outputs:\n",
140
+ "- `bigwig_tracks_logits`: functional track predictions\n",
141
+ "- `bed_tracks_logits`: genome annotation predictions\n",
142
+ "- `logits`: masked language modeling logits"
 
 
143
  ]
144
  },
145
  {
146
  "cell_type": "code",
147
+ "execution_count": 4,
148
  "id": "6cc5f2df",
149
  "metadata": {},
150
  "outputs": [
 
152
  "name": "stdout",
153
  "output_type": "stream",
154
  "text": [
155
+ "Supported species: dict_keys(['<bos>', '<cls>', '<eos>', '<mask>', '<pad>', '<unk>', 'amphiprion_ocellaris', 'arabidopsis_thaliana', 'bison_bison_bison', 'caenorhabditis_elegans', 'canis_lupus_familiaris', 'chinchilla_lanigera', 'ciona_intestinalis', 'danio_rerio', 'drosophila_melanogaster', 'felis_catus', 'gallus_gallus', 'glycine_max', 'gorilla_gorilla', 'gossypium_hirsutum', 'human', 'macaca_nemestrina', 'mouse', 'oryza_sativa', 'rattus_norvegicus', 'salmo_trutta', 'serinus_canaria', 'tetraodon_nigroviridis', 'triticum_aestivum', 'zea_mays'])\n",
156
+ "bigwig_tracks_logits: (2, 48, 7362)\n",
157
+ "bed_tracks_logits: (2, 48, 21, 2)\n",
158
+ "language model logits: (2, 128, 11)\n"
159
  ]
160
  }
161
  ],
162
  "source": [
163
+ "# Load model\n",
164
+ "post_trained_model_name = \"InstaDeepAI/NTv3_100M_post\"\n",
 
 
 
 
 
 
 
165
  "\n",
166
+ "tok_post = AutoTokenizer.from_pretrained(post_trained_model_name, trust_remote_code=True)\n",
167
+ "model_post = AutoModel.from_pretrained(post_trained_model_name, trust_remote_code=True)\n",
 
 
168
  "\n",
169
+ "# Prepare inputs\n",
170
+ "batch = tok_post([\"ATCGNATCG\", \"ACGT\"], add_special_tokens=False, padding=True, pad_to_multiple_of=128, return_tensors=\"pt\")\n",
 
171
  "\n",
172
+ "# To show all supported species: \n",
173
+ "print(\"Supported species:\", model_post.config.species_to_token_id.keys())\n",
174
+ "# Species tokens\n",
175
+ "species = ['human', 'mouse']\n",
176
+ "species_ids = model_post.encode_species(species)\n",
177
+ "\n",
178
+ "# Forward pass\n",
179
+ "out = model_post(\n",
180
  " input_ids=batch[\"input_ids\"],\n",
181
+ " species_ids=species_ids,\n",
 
 
 
182
  ")\n",
183
  "\n",
184
+ "# 7k human tracks over 37.5 % center region of the input sequence\n",
185
+ "print(\"bigwig_tracks_logits:\", tuple(out[\"bigwig_tracks_logits\"].shape))\n",
186
+ "# Location of 21 genomic elements over 37.5 % center region of the input sequence\n",
187
+ "print(\"bed_tracks_logits:\", tuple(out[\"bed_tracks_logits\"].shape))\n",
188
+ "# Language model logits for whole sequence over vocabulary\n",
189
+ "print(\"language model logits:\", tuple(out[\"logits\"].shape))\n"
190
  ]
191
+ },
192
+ {
193
+ "cell_type": "code",
194
+ "execution_count": null,
195
+ "id": "037076cd",
196
+ "metadata": {},
197
+ "outputs": [],
198
+ "source": []
199
  }
200
  ],
201
  "metadata": {
notebooks_tutorials/01_tracks_prediction.ipynb ADDED
The diff for this file is too large to render. See raw diff
 
notebooks/03_fine_tuning.ipynb → notebooks_tutorials/02_fine_tuning.ipynb RENAMED
File without changes
notebooks_tutorials/03_model_interpretation.ipynb ADDED
The diff for this file is too large to render. See raw diff
 
tabs/demo.html ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="grid">
2
+ <div class="card" style="grid-column: span 12; text-align: center; padding: 60px 40px;">
3
+ <h2 style="margin-bottom: 20px;">🚀 NTv3 Live Demo</h2>
4
+ <p style="margin-bottom: 30px; color: var(--muted); line-height: 1.7;">
5
+ Try out the NTv3 model interactively in this live demo. Predict functional tracks and genome annotation directly in your browser. Click the button below to open the interactive demo in a new window.
6
+ </p>
7
+ <a
8
+ href="https://huggingface.co/spaces/InstaDeepAI/ntv3_tracks"
9
+ target="_blank"
10
+ rel="noopener noreferrer"
11
+ style="
12
+ display: inline-block;
13
+ padding: 16px 32px;
14
+ background: var(--link);
15
+ color: white;
16
+ text-decoration: none;
17
+ border-radius: 12px;
18
+ font-weight: 600;
19
+ font-size: 16px;
20
+ transition: all 0.2s ease;
21
+ box-shadow: 0 4px 12px rgba(125, 211, 252, 0.3);
22
+ "
23
+ onmouseover="this.style.background='#60b8e8'; this.style.transform='translateY(-2px)'; this.style.boxShadow='0 6px 16px rgba(125, 211, 252, 0.4)';"
24
+ onmouseout="this.style.background='var(--link)'; this.style.transform='translateY(0)'; this.style.boxShadow='0 4px 12px rgba(125, 211, 252, 0.3)';"
25
+ >
26
+ 🚀 Open Live Demo →
27
+ </a>
28
+ <p style="margin-top: 30px; font-size: 13px; color: var(--muted);">
29
+ The demo will open in a new tab. Make sure pop-ups are enabled for this site.
30
+ </p>
31
+ </div>
32
+ </div>
33
+
tabs/home.html ADDED
@@ -0,0 +1,193 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="summary">
2
+ <h2>📖 About NTv3</h2>
3
+ <p>
4
+ NTv3 is a multi-species genomic foundation model family that unifies representation learning, functional-track prediction, genome annotation, and controllable sequence generation within a single U-Net-style backbone. It models up to 1 Mb of DNA at single-base resolution, using a conv–Transformer–deconv architecture that efficiently captures both local motifs and long-range regulatory dependencies. NTv3 is first pretrained on ~9T base pairs from the OpenGenome2 corpus spanning >128k species using masked language modeling, and then post-trained with a joint objective on ~16k functional tracks and annotation labels across 24 animal and plant species, enabling state-of-the-art cross-species functional prediction and base-resolution genome annotation.
5
+ </p>
6
+ <p>
7
+ NTv3 also acts as a controllable generative model via masked-diffusion language modeling, allowing targeted design of regulatory sequences (for example, enhancers with specified activity and promoter selectivity) that have been validated experimentally.
8
+ </p>
9
+ </div>
10
+
11
+ <div class="paper-summary">
12
+ <!-- <h2>📄 A foundational model for joint sequence-function multi-species modeling at scale for long-range genomic prediction</h2> -->
13
+ <img src="assets/paper_summary.png" alt="NTv3 Paper Summary" />
14
+ </div>
15
+
16
+ <div class="why-ntv3">
17
+ <h2>✨ Why NTv3?</h2>
18
+ <ul>
19
+ <li>📏 <strong>1 Mb long context at nucleotide resolution</strong> — ~100× longer than typical genomics models.</li>
20
+ <li>🏗️ <strong>Unified architecture</strong> for: masked language modeling, functional-track prediction, genome annotation, and sequence generation.</li>
21
+ <li>🌍 <strong>Cross-species generalization</strong> across 24 animals + plants with a shared conditioned representation space.</li>
22
+ <li>⚡ <strong>U-Net–style architecture</strong> improves stability and GPU efficiency on very long sequences.</li>
23
+ <li>🎯 <strong>Controllable generative modeling</strong>, enabling targeted enhancer/promoter engineering validated by experimental assays.</li>
24
+ </ul>
25
+ </div>
26
+
27
+ <div class="grid">
28
+ <div class="card">
29
+ <h2>🤖 Models (see <a href="https://huggingface.co/collections/InstaDeepAI/nucleotide-transformer-v3" target="_blank" rel="noopener noreferrer">collection</a>)</h2>
30
+ <ul>
31
+ <li>📦 Pretrained checkpoints:
32
+ <div style="margin-top: 8px; margin-left: 0;">
33
+ <div><a href="https://huggingface.co/InstaDeepAI/NTv3_8M_pre" target="_blank" rel="noopener noreferrer"><code>InstaDeepAI/NTv3_8M_pre</code></a></div>
34
+ <div><a href="https://huggingface.co/InstaDeepAI/NTv3_100M_pre" target="_blank" rel="noopener noreferrer"><code>InstaDeepAI/NTv3_100M_pre</code></a></div>
35
+ <div><a href="https://huggingface.co/InstaDeepAI/NTv3_650M_pre" target="_blank" rel="noopener noreferrer"><code>InstaDeepAI/NTv3_650M_pre</code></a></div>
36
+ </div>
37
+ </li>
38
+ <li>🎯 Post-trained checkpoints:
39
+ <div style="margin-top: 8px; margin-left: 0;">
40
+ <div><a href="https://huggingface.co/InstaDeepAI/NTv3_100M_pos" target="_blank" rel="noopener noreferrer"><code>InstaDeepAI/NTv3_100M_pos</code></a></div>
41
+ <div><a href="https://huggingface.co/InstaDeepAI/NTv3_650M_pos" target="_blank" rel="noopener noreferrer"><code>InstaDeepAI/NTv3_650M_pos</code></a></div>
42
+ </div>
43
+ </li>
44
+ </ul>
45
+ <table>
46
+ <thead>
47
+ <tr>
48
+ <th>Model</th>
49
+ <th>Size</th>
50
+ <th>Pre-training</th>
51
+ <th>Post-training</th>
52
+ <th>Usage</th>
53
+ </tr>
54
+ </thead>
55
+ <tbody>
56
+ <tr>
57
+ <td><strong>NTv3-8M</strong></td>
58
+ <td>8M params</td>
59
+ <td><span class="checkmark">✅</span></td>
60
+ <td>❌</td>
61
+ <td>Embeddings, light inference</td>
62
+ </tr>
63
+ <tr>
64
+ <td><strong>NTv3-100M</strong></td>
65
+ <td>100M params</td>
66
+ <td><span class="checkmark">✅</span></td>
67
+ <td><span class="checkmark">✅</span></td>
68
+ <td>Embeddings, tracks, annotation</td>
69
+ </tr>
70
+ <tr>
71
+ <td><strong>NTv3-650M</strong></td>
72
+ <td>650M params</td>
73
+ <td><span class="checkmark">✅</span></td>
74
+ <td><span class="checkmark">✅</span></td>
75
+ <td>Embeddings, tracks, annotation, best accuracy</td>
76
+ </tr>
77
+ </tbody>
78
+ </table>
79
+ </div>
80
+
81
+ <div class="card-stack">
82
+ <div class="card">
83
+ <h2>📓 Tutorial notebooks (browse <a href="https://huggingface.co/spaces/InstaDeepAI/ntv3/tree/main/notebooks_tutorials" target="_blank" rel="noopener noreferrer">folder</a>)</h2>
84
+ <ul>
85
+ <li><a href="https://huggingface.co/spaces/InstaDeepAI/ntv3/blob/main/notebooks_tutorials/00_quickstart_inference.ipynb" target="_blank" rel="noopener noreferrer">🚀 00 — Quickstart inference</a></li>
86
+ <li><a href="https://huggingface.co/spaces/InstaDeepAI/ntv3/blob/main/notebooks_tutorials/01_tracks_prediction.ipynb" target="_blank" rel="noopener noreferrer">📊 01 — Tracks prediction</a></li>
87
+ <li><a href="https://huggingface.co/spaces/InstaDeepAI/ntv3/blob/main/notebooks_tutorials/02_fine_tuning.ipynb" target="_blank" rel="noopener noreferrer">🎯 02 — Fine-tune on bigwig tracks</a></li>
88
+ <li><a href="https://huggingface.co/spaces/InstaDeepAI/ntv3/blob/main/notebooks_tutorials/03_model_interpretation.ipynb" target="_blank" rel="noopener noreferrer">🔍 03 — Model interpretation</a></li>
89
+ <li>🧪 04 — Training NTv3-generative <em>(coming soon)</em></li>
90
+ <li>🪰 05 — Generating enhancer sequences <em>(coming soon)</em></li>
91
+ </ul>
92
+ </div>
93
+ <div class="card">
94
+ <h2>📓 Pipeline notebooks (browse <a href="https://huggingface.co/spaces/InstaDeepAI/ntv3/tree/main/notebooks_pipelines" target="_blank" rel="noopener noreferrer">folder</a>)</h2>
95
+ <ul>
96
+ <li><a href="https://huggingface.co/spaces/InstaDeepAI/ntv3/blob/main/notebooks_pipelines/01_functional_track_prediction.ipynb" target="_blank" rel="noopener noreferrer">🎯 01 — Generate bigwig predictions for certain tracks</a></li>
97
+ <li>🎯 02 — Fine-tune on bigwig tracks</li>
98
+ <li>🔍 03 — Interpret a given genomic region</li>
99
+ <li>🧪 04 — Sequence generation <em>(coming soon)</em></li>
100
+ </ul>
101
+ </div>
102
+ <div class="card">
103
+ <h2>🔗 Links</h2>
104
+ <ul>
105
+ <li>📄 Paper: (add link)</li>
106
+ <li><a href="https://github.com/instadeepai/nucleotide-transformer" target="_blank" rel="noopener noreferrer">💻 JAX model code (GitHub)</a></li>
107
+ <li><a href="https://huggingface.co/collections/InstaDeepAI/nucleotide-transformer-v3" target="_blank" rel="noopener noreferrer">🎯 HF Model Collection (all NTv3 models)</a></li>
108
+ <li><a href="https://huggingface.co/spaces/InstaDeepAI/ntv3/tree/main/notebooks_tutorials" target="_blank" rel="noopener noreferrer">📚 Tutorial </a> and <a href="https://huggingface.co/spaces/InstaDeepAI/ntv3/tree/main/notebooks_pipelines" target="_blank" rel="noopener noreferrer">🔧 Pipeline</a> notebooks</li>
109
+ <li><a href="https://huggingface.co/spaces/InstaDeepAI/ntv3_benchmark" target="_blank" rel="noopener noreferrer">🏆 NTv3 benchmark leaderboard</a></li>
110
+ </ul>
111
+ </div>
112
+ </div>
113
+
114
+ <div class="card">
115
+ <h2>🤖 Load a pre-trained model</h2>
116
+ <p>Here is an example of how to load and use a pre-trained NTv3 model.</p>
117
+ <div class="code"><pre><code class="language-python">from transformers import AutoTokenizer, AutoModelForMaskedLM
118
+
119
+ model_name = "InstaDeepAI/NTv3_650M_pre"
120
+
121
+ # Load model and tokenizer
122
+ model = AutoModelForMaskedLM.from_pretrained(model_name, trust_remote_code=True)
123
+ tok = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
124
+
125
+ # Tokenize input sequences
126
+ batch = tok(["ATCGNATCG", "ACGT"], add_special_tokens=False, padding=True, pad_to_multiple_of=128, return_tensors="pt")
127
+
128
+ # Run model
129
+ out = model(**batch)
130
+
131
+ # Print output shapes
132
+ print(out.logits.shape) # (B, L, V = 11)
133
+ </code></pre></div>
134
+ <p>Model embeddings can be used for fine-tuning on downstream tasks.</p>
135
+
136
+ <p style="margin-top: 40px;">TO DO: add pipeline for fine-tuning on functional tracks or genome annotation.</p>
137
+ </div>
138
+
139
+ <div class="card">
140
+ <h2>💻 Use a post-trained model</h2>
141
+ <p>Here is a quick example of how to use the post-trained NTv3 650M model to predict tracks for a human genomic window.</p>
142
+ <div class="code"><pre><code class="language-python">from transformers import pipeline
143
+ import torch
144
+
145
+ model_name = "InstaDeepAI/NTv3_650M_pos"
146
+
147
+ ntv3_tracks = pipeline(
148
+ "ntv3-tracks",
149
+ model=model_name,
150
+ trust_remote_code=True,
151
+ device=0 if torch.cuda.is_available() else -1,
152
+ )
153
+
154
+ # Run track prediction
155
+ out = ntv3_tracks(
156
+ {
157
+ "chrom": "chr19",
158
+ "start": 6_700_000,
159
+ "end": 6_831_072,
160
+ "species": "human"
161
+ }
162
+ )
163
+
164
+ # Print output shapes
165
+ # 7k human tracks over 37.5 % center region of the input sequence
166
+ print("bigwig_tracks_logits:", tuple(out.bigwig_tracks_logits.shape))
167
+ # Location of 21 genomic elements over 37.5 % center region of the input sequence
168
+ print("bed_tracks_logits:", tuple(out.bed_tracks_logits.shape))
169
+ # Language model logits for whole sequence over vocabulary
170
+ print("language model logits:", tuple(out.mlm_logits.shape))</code></pre></div>
171
+ <p>Predictions can also be plotted for a subset of functional tracks and genomic elements:</p>
172
+ <div class="code"><pre><code class="language-python">tracks_to_plot = {
173
+ "K562 RNA-seq": "ENCSR056HPM",
174
+ "K562 DNAse": "ENCSR921NMD",
175
+ "K562 H3k4me3": "ENCSR000DWD",
176
+ "K562 CTCF": "ENCSR000AKO",
177
+ "HepG2 RNA-seq": "ENCSR561FEE_P",
178
+ "HepG2 DNAse": "ENCSR000EJV",
179
+ "HepG2 H3k4me3": "ENCSR000AMP",
180
+ "HepG2 CTCF": "ENCSR000BIE",
181
+ }
182
+ elements_to_plot = ["protein_coding_gene", "exon", "intron", "splice_donor", "splice_acceptor"]
183
+
184
+ out = ntv3_tracks(
185
+ {"chrom": "chr19", "start": 6_700_000, "end": 6_831_072, "species": "human"},
186
+ plot=True,
187
+ tracks_to_plot=tracks_to_plot,
188
+ elements_to_plot=elements_to_plot,
189
+ )</code></pre></div>
190
+ <img src="assets/output_tracks.png" alt="Output tracks visualization" style="max-width: 100%; margin-top: 20px;" />
191
+ </div>
192
+ </div>
193
+