Adding Backbones
Backbones are pre-trained foundation models.
Foundation models are essential to modern ML but are often difficult to work with. Design decisions made during pre-training (tokenization, architecture, io format) cannot be changed. At best, this results in many reimplementations for benchmarking or finetuning tasks, and a high risk of buggy code. At worst, these decisions can lock in users and exclude certain tasks and use-cases.
AIDO.ModelGenerator eliminates the need for reimplementation and makes backbones task-agnostic: wrap your backbone in a standard interface, and reuse it across all inference and finetuning tasks. It also makes compatibility transparent: if a backbone fits the required interface, it can be used for any data-appropriate task.
Note: Backbones for 1D sequence modeling are universally supported. Other types of backbones included in AIDO.ModelGenerator (e.g. structure, image) are not yet universally supported, but will be in the future.
Available Backbones:
- DNA:
aido_dna_7b,aido_dna_300m,aido_dna_dummy,aido_dna_debug,dna_onehot - RNA:
aido_rna_1b600m,aido_rna_1b600m_cds,aido_rna_650m,aido_rna_650m_cds,aido_rna_300m_mars,aido_rna_25m_mars,aido_rna_1m_mars,aido_dna_dummy,aido_dna_debug,dna_onehot - Protein:
aido_protein_16b,aido_protein_16b_v1,aido_protein2structoken_16b,aido_protein_debug,protein_onehot,aido_protein_rag_16b,aido_protein_rag_3b - Cell (gene expression):
aido_cell_100m,aido_cell_10m,aido_cell_3m,geneformer - OneHot: dummy model, only tokenizes, useful for non-FM baselines and quick tests
At their core, backbones are PyTorch nn.Module objects with a few extra interfaces.
To implement a new backbone, subclass a backbone interface and implement the required methods.
modelgenerator.backbones.SequenceBackboneInterface
Bases: Module
Interface class to ensure consistent implementation of essential methods for all backbones.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
enable_cache
|
bool
|
Whether to enable caching for the backbone model. |
False
|
file_cache_dir
|
str
|
Directory to store the cache files. |
None
|
overwrite_file_cache
|
bool
|
Whether to overwrite existing cache files. |
False
|
cache_write_buffer_size
|
int
|
Number of items to buffer before writing to disk. Only used when |
1000
|
cache_storage_backend
|
Literal
|
The storage backend to use for caching when |
'indexed'
|
Attributes:
| Name | Type | Description |
|---|---|---|
fsdp_wrap_modules |
List[str]
|
List of module paths to wrap when using distributed training with FSDP. |
model_path |
str
|
Path to the model weights. May be HF. |
Source code in modelgenerator/backbones/base.py
207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 | |