初始化项目,由ModelHub XC社区提供模型
Model: QizhiPei/BioMatrix-1.7B-SFT Source: Original Platform
This commit is contained in:
42
.gitattributes
vendored
Normal file
42
.gitattributes
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
*.7z filter=lfs diff=lfs merge=lfs -text
|
||||
*.arrow filter=lfs diff=lfs merge=lfs -text
|
||||
*.bin filter=lfs diff=lfs merge=lfs -text
|
||||
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
||||
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
||||
*.ftz filter=lfs diff=lfs merge=lfs -text
|
||||
*.gz filter=lfs diff=lfs merge=lfs -text
|
||||
*.h5 filter=lfs diff=lfs merge=lfs -text
|
||||
*.joblib filter=lfs diff=lfs merge=lfs -text
|
||||
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
||||
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
||||
*.model filter=lfs diff=lfs merge=lfs -text
|
||||
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
||||
*.npy filter=lfs diff=lfs merge=lfs -text
|
||||
*.npz filter=lfs diff=lfs merge=lfs -text
|
||||
*.onnx filter=lfs diff=lfs merge=lfs -text
|
||||
*.ot filter=lfs diff=lfs merge=lfs -text
|
||||
*.parquet filter=lfs diff=lfs merge=lfs -text
|
||||
*.pb filter=lfs diff=lfs merge=lfs -text
|
||||
*.pickle filter=lfs diff=lfs merge=lfs -text
|
||||
*.pkl filter=lfs diff=lfs merge=lfs -text
|
||||
*.pt filter=lfs diff=lfs merge=lfs -text
|
||||
*.pth filter=lfs diff=lfs merge=lfs -text
|
||||
*.rar filter=lfs diff=lfs merge=lfs -text
|
||||
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
||||
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
||||
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
||||
*.tar filter=lfs diff=lfs merge=lfs -text
|
||||
*.tflite filter=lfs diff=lfs merge=lfs -text
|
||||
*.tgz filter=lfs diff=lfs merge=lfs -text
|
||||
*.wasm filter=lfs diff=lfs merge=lfs -text
|
||||
*.xz filter=lfs diff=lfs merge=lfs -text
|
||||
*.zip filter=lfs diff=lfs merge=lfs -text
|
||||
*.zst filter=lfs diff=lfs merge=lfs -text
|
||||
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
||||
tokenizer.json filter=lfs diff=lfs merge=lfs -text
|
||||
figures/3D_tokenizers.png filter=lfs diff=lfs merge=lfs -text
|
||||
figures/biomatrix_arch_v1.png filter=lfs diff=lfs merge=lfs -text
|
||||
figures/biomatrix_cpt_data_v5.png filter=lfs diff=lfs merge=lfs -text
|
||||
figures/biomatrix_logo.png filter=lfs diff=lfs merge=lfs -text
|
||||
figures/molecule_tasks_v1.png filter=lfs diff=lfs merge=lfs -text
|
||||
figures/protein_tasks_v1.png filter=lfs diff=lfs merge=lfs -text
|
||||
213
README.md
Normal file
213
README.md
Normal file
@@ -0,0 +1,213 @@
|
||||
---
|
||||
license: apache-2.0
|
||||
language:
|
||||
- en
|
||||
tags:
|
||||
- biology
|
||||
- chemistry
|
||||
- molecule
|
||||
- protein
|
||||
- multimodal
|
||||
- foundation-model
|
||||
- drug-discovery
|
||||
- protein-design
|
||||
pipeline_tag: text-generation
|
||||
base_model: QizhiPei/BioMatrix-1.7B-Base
|
||||
library_name: transformers
|
||||
---
|
||||
|
||||
# BioMatrix-1.7B-SFT
|
||||
|
||||
<div align="center">
|
||||
<img src="figures/biomatrix_logo.png" width="60%" alt="BioMatrix" />
|
||||
</div>
|
||||
|
||||
**BioMatrix** is a multimodal biological foundation model that natively integrates **1D sequences**, **3D structures**, and **natural language** for both **molecules** and **proteins** within a single decoder-only architecture.
|
||||
|
||||
This is the **1.7B-parameter SFT (Supervised Fine-Tuned)** variant, instruction-tuned across 80 downstream biological tasks spanning 6 categories. For a larger and more capable model, see [BioMatrix-4B-SFT](https://huggingface.co/QizhiPei/BioMatrix-4B-SFT).
|
||||
|
||||
- 📄 **Paper**: [BioMatrix: Towards a Comprehensive Biological Foundation Model Spanning the Modality Matrix of Sequences, Structures, and Language](http://arxiv.org/abs/2606.22138)
|
||||
- 💻 **Code**: [https://github.com/QizhiPei/BioMatrix](https://github.com/QizhiPei/BioMatrix)
|
||||
- 🤗 **Model & Data Collection**: [https://huggingface.co/collections/QizhiPei/biomatrix](https://huggingface.co/collections/QizhiPei/biomatrix)
|
||||
|
||||
<p align="center">
|
||||
<img width="90%" src="figures/biomatrix_arch_v1.png" alt="BioMatrix Architecture">
|
||||
</p>
|
||||
|
||||
## Model Overview
|
||||
|
||||
BioMatrix closes the gap between native multimodality and broad entity coverage in biological foundation models. Unlike adapter-based approaches that bolt external encoders onto a language model, or prior native-tokenization models confined to a single entity type, BioMatrix maps **all modalities into a shared discrete token space** via a unified tokenization scheme:
|
||||
|
||||
- **Molecular 1D sequences** (both SMILES and SELFIES notations)
|
||||
- **Molecular 3D structures** (via MolStrucTok with branch-decoupled decoder)
|
||||
- **Protein 1D sequences** (residue-level tokens)
|
||||
- **Protein 3D structures** (via GCP-VQVAE backbone tokenizer)
|
||||
- **Natural language** (inherited from Qwen3 tokenizer)
|
||||
|
||||
All modalities are consumed and produced uniformly under a **single next-token prediction objective**—without external encoders, projection adapters, or modality-specific output heads.
|
||||
|
||||
| Model | Molecule 1D | Molecule 3D | Protein 1D | Protein 3D | Natural Language |
|
||||
|-------|:-----------:|:-----------:|:----------:|:----------:|:----------------:|
|
||||
| ESM3 | ✗ | ✗ | ✓ | ✓ | ✓ |
|
||||
| 3D-MoLM | ✓ | ✓ | ✗ | ✗ | ✓ |
|
||||
| AlphaFold3 | ✓ | ✓ | ✓ | ✓ | ✗ |
|
||||
| BioT5/BioT5+ | ✓ | ✗ | ✓ | ✗ | ✓ |
|
||||
| BioMedGPT | ✓ | ✗ | ✓ | ✗ | ✓ |
|
||||
| NatureLM | ✓ | ✗ | ✓ | ✗ | ✓ |
|
||||
| SciReasoner | ✓ | ✗ | ✓ | ✗ | ✓ |
|
||||
| **BioMatrix** | **✓** | **✓** | **✓** | **✓** | **✓** |
|
||||
|
||||
<p align="center">
|
||||
<img width="95%" src="figures/3D_tokenizers.png" alt="Molecule and Protein Structure Tokenizers">
|
||||
</p>
|
||||
|
||||
## Model Details
|
||||
|
||||
- **Base Architecture**: Qwen3-1.7B-Base
|
||||
- **Parameters**: 1.7B
|
||||
- **Training Stages**:
|
||||
- **Continual Pretraining** on 304.4B tokens (general/scientific text, molecular & protein 1D/3D data, cross-modal interleaved corpora)
|
||||
- **Instruction Tuning** on a comprehensive suite of 80 downstream tasks across 6 categories
|
||||
- **Context Length**: 8,192 tokens
|
||||
- **Tokenizer**: Extended Qwen3 vocabulary with:
|
||||
- 11,294 joint molecular 3D tokens (composed from SELFIES atom × MolStrucTok codes)
|
||||
- 4,096 protein 3D tokens (GCP-VQVAE codebook)
|
||||
- 26 protein 1D tokens (amino acids + non-standard/unknown)
|
||||
- SELFIES atom tokens and modality-specific control tokens
|
||||
|
||||
## Pretraining Corpus (304.4B tokens)
|
||||
|
||||
| Category | Tokens | Sources |
|
||||
|----------|--------|---------|
|
||||
| **Text** | 105.3B | FineWeb-Edu, FineFineWeb (biology/chemistry/medical/health), PubMed Full Articles |
|
||||
| **Molecule** | 73.7B | PubChem, PCQM4Mv2, PubChemQC, MolTextNet |
|
||||
| **Protein** | 77.4B | UniRef50, RCSB PDB, Swiss-Prot, TrEMBL, AlphaFold DB |
|
||||
| **Cross-entity** | 48.0B | Interleaved text (PubMed, bioRxiv, S2ORC, USPTO), Molecule–protein (BindingDB, STITCH, jglaser, CrossDocked), Protein–protein (AlphaSeq, PPIRef) |
|
||||
|
||||
<p align="center">
|
||||
<img width="95%" src="figures/biomatrix_cpt_data_v5.png" alt="BioMatrix Continual Pretraining Data">
|
||||
</p>
|
||||
|
||||
## Performance Highlights
|
||||
|
||||
Despite its compact 1.7B size, BioMatrix delivers strong performance across diverse biological tasks—often surpassing models several times larger. Selected highlights:
|
||||
|
||||
### Molecular Tasks
|
||||
- **Unconditional 1D Generation** (GuacaMol, SELFIES): 0.999 validity, 1.000 uniqueness
|
||||
- **Name Conversion (I2S EM)**: 87.22% (surpasses SciReasoner-8B at 84.40%)
|
||||
- **Text-Based Molecule Generation (EM)**: 56.35% (vs. SciReasoner-8B: 48.00%)
|
||||
- **MoleculeQA Total**: 70.07% (vs. prior best MolCA-1.3B: 64.79%)
|
||||
- **Property-Conditioned 3D Generation**: ~3-4× error reduction on QM9 electronic-structure targets
|
||||
|
||||
### Protein Tasks
|
||||
- **Fold Type Prediction (Family level)**: 85.84% accuracy
|
||||
- **EC Number Prediction (Price split, F1)**: 34.34% (surpasses SciReasoner-8B at 22.00%)
|
||||
- **Inverse Folding AAR**: 75.20% (vs. DPLM-2-3B: 61.67%)
|
||||
- **Sequence–Structure Co-generation**: scTM = 0.965, scRMSD = 2.81
|
||||
|
||||
### Interaction Tasks
|
||||
- **BindingDB Affinity (RMSE)**: 1.268
|
||||
- **PDBBindv2020 3D Affinity**: best Spearman correlation (0.717) among all baselines
|
||||
|
||||
## Quick Start
|
||||
|
||||
```python
|
||||
from transformers import AutoModelForCausalLM, AutoTokenizer
|
||||
|
||||
model_name = "QizhiPei/BioMatrix-1.7B-SFT"
|
||||
tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
|
||||
model = AutoModelForCausalLM.from_pretrained(
|
||||
model_name,
|
||||
torch_dtype="auto",
|
||||
device_map="auto",
|
||||
trust_remote_code=True
|
||||
)
|
||||
|
||||
# Example: Molecule captioning with SELFIES input
|
||||
instruction = "I need a brief explanation of the molecule denoted in this SELFIES notation. <|mol_sfi_start|>[Te]<|mol_sfi_end|>"
|
||||
|
||||
messages = [
|
||||
{"role": "user", "content": instruction}
|
||||
]
|
||||
prompt = tokenizer.apply_chat_template(
|
||||
messages,
|
||||
tokenize=False,
|
||||
add_generation_prompt=True
|
||||
)
|
||||
|
||||
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
|
||||
outputs = model.generate(**inputs, max_new_tokens=2048, do_sample=False)
|
||||
response = tokenizer.decode(outputs[0][inputs.input_ids.shape[1]:], skip_special_tokens=False)
|
||||
print(response)
|
||||
```
|
||||
|
||||
## Modality Wrapping
|
||||
|
||||
When constructing prompts, biomolecular content must be wrapped with the corresponding control tokens:
|
||||
|
||||
| Modality | Wrapping Example |
|
||||
|----------|------------------|
|
||||
| Molecule SMILES | `<\|mol_smi_start\|>CC#CC#N<\|mol_smi_end\|>` |
|
||||
| Molecule SELFIES | `<\|mol_sfi_start\|>[C][#C][C][#N]<\|mol_sfi_end\|>` |
|
||||
| Molecule 3D | `<\|mol_3d_start\|>[H 3][C 0][#C 6]...<\|mol_3d_end\|>` |
|
||||
| Protein 1D | `<\|prot_aa_start\|><A M><A R><A A>...<\|prot_aa_end\|>` |
|
||||
| Protein 3D | `<\|prot_3d_start\|><S 4012><S 153><S 2091>...<\|prot_3d_end\|>` |
|
||||
|
||||
Natural language text is left unwrapped and serves as the default carrier modality.
|
||||
|
||||
## Supported Tasks
|
||||
|
||||
BioMatrix-1.7B-SFT was instruction-tuned across the following task categories:
|
||||
|
||||
**Molecule (1D)**: unconditional generation, name conversion, property prediction, captioning, text-based generation, forward/retrosynthesis, editing, optimization, customized generation, question answering
|
||||
|
||||
**Molecule (3D)**: unconditional generation, property-conditioned generation
|
||||
|
||||
**Protein (1D)**: sequence understanding, annotation prediction, knowledge mining, text-based design, unconditional generation
|
||||
|
||||
**Protein (3D)**: structure understanding, folding, inverse folding, sequence-structure co-generation, unconditional backbone generation
|
||||
|
||||
**Interaction**: molecule-protein binding affinity (1D & 3D), protein-protein interaction
|
||||
|
||||
<p align="center">
|
||||
<img width="95%" src="figures/molecule_tasks_v1.png" alt="BioMatrix Molecule Tasks">
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<img width="95%" src="figures/protein_tasks_v1.png" alt="BioMatrix Protein Tasks">
|
||||
</p>
|
||||
|
||||
> **Note on task-group variants**: As detailed in the paper, the released SFT model is trained on the union of all sub-task corpora with mild oversampling for small-data tasks. For best performance on specific benchmarks, please refer to the paper's task-group-specific variants.
|
||||
|
||||
## SMILES vs. SELFIES
|
||||
|
||||
BioMatrix supports both notations as parallel 1D molecular representations. Empirically:
|
||||
|
||||
- **SELFIES** excels on tasks requiring validity-by-construction (unconditional generation, property optimization)
|
||||
- **SMILES** excels on tasks requiring surface-level structural anchoring (customized generation with atom/bond/functional-group constraints, forward synthesis, retrosynthesis)
|
||||
|
||||
See Section 9.2 of the paper for detailed analysis.
|
||||
|
||||
## Limitations
|
||||
|
||||
- Molecular and protein 3D structures are tokenized in **disjoint geometric reference frames**, so the model cannot natively represent biomolecular complexes (e.g., docking poses).
|
||||
- Heavy domain specialization may erode some general-purpose language capabilities of the underlying Qwen3 backbone.
|
||||
- Coverage is limited to **small molecules and proteins**; nucleic acids, carbohydrates, and lipids are not currently supported.
|
||||
- Fine-grained 3D geometry (e.g., bond lengths) shows residual quantization error from finite codebooks; a lightweight post-hoc force-field refinement (e.g., MMFF) closes most of this gap.
|
||||
|
||||
## Citation
|
||||
|
||||
If you find BioMatrix useful, please cite:
|
||||
|
||||
```bibtex
|
||||
@article{pei2026biomatrix,
|
||||
title={BioMatrix: Towards a Comprehensive Biological Foundation Model Spanning the Modality Matrix of Sequences, Structures, and Language},
|
||||
author={Pei, Qizhi and Zhou, Zhimeng and Duan, Yi and Zhao, Yiyang and Li, Wei and Guo, Han and He, Liang and Li, Chengping and Hsieh, Chang-Yu and He, Conghui and Yan, Rui and Wu, Lijun},
|
||||
journal={arXiv preprint arXiv:2606.22138},
|
||||
year={2026}
|
||||
}
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
This model is released under the Apache 2.0 license. The base model (Qwen3-1.7B-Base) is subject to its own license terms.
|
||||
16381
added_tokens.json
Normal file
16381
added_tokens.json
Normal file
File diff suppressed because it is too large
Load Diff
30
config.json
Normal file
30
config.json
Normal file
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"architectures": [
|
||||
"Qwen3ForCausalLM"
|
||||
],
|
||||
"attention_bias": false,
|
||||
"attention_dropout": 0.0,
|
||||
"bos_token_id": 151643,
|
||||
"eos_token_id": 151643,
|
||||
"head_dim": 128,
|
||||
"hidden_act": "silu",
|
||||
"hidden_size": 2048,
|
||||
"initializer_range": 0.02,
|
||||
"intermediate_size": 6144,
|
||||
"max_position_embeddings": 32768,
|
||||
"max_window_layers": 28,
|
||||
"model_type": "qwen3",
|
||||
"num_attention_heads": 16,
|
||||
"num_hidden_layers": 28,
|
||||
"num_key_value_heads": 8,
|
||||
"rms_norm_eps": 1e-06,
|
||||
"rope_scaling": null,
|
||||
"rope_theta": 1000000,
|
||||
"sliding_window": null,
|
||||
"tie_word_embeddings": true,
|
||||
"torch_dtype": "bfloat16",
|
||||
"transformers_version": "4.51.3",
|
||||
"use_cache": false,
|
||||
"use_sliding_window": false,
|
||||
"vocab_size": 168064
|
||||
}
|
||||
3
figures/3D_tokenizers.png
Normal file
3
figures/3D_tokenizers.png
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:e007796dfda9ed5badb1287bbe6a79905526a812c2090f143385c8edee7e7161
|
||||
size 849529
|
||||
3
figures/biomatrix_arch_v1.png
Normal file
3
figures/biomatrix_arch_v1.png
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:0f47ba2590471f3bcbf28c7fd1ba978891c00de0a6ea8aed8a508d594143edae
|
||||
size 833624
|
||||
3
figures/biomatrix_cpt_data_v5.png
Normal file
3
figures/biomatrix_cpt_data_v5.png
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:41ff1faa16f44286b388db0d8463dd9d51263db6f23ce99b429d53e9ea49b575
|
||||
size 511512
|
||||
3
figures/biomatrix_logo.png
Normal file
3
figures/biomatrix_logo.png
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:2eb845f564b1f8d6b3ad0caee11d70977103f2ccb058d8aabef5c0ed7dcaf0a3
|
||||
size 1197085
|
||||
3
figures/molecule_tasks_v1.png
Normal file
3
figures/molecule_tasks_v1.png
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:1c800920a4829cdb5f6b920b822a7a56f48e080047232fa9df574c566ea543e4
|
||||
size 881792
|
||||
3
figures/protein_tasks_v1.png
Normal file
3
figures/protein_tasks_v1.png
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:f45f3e5d774c516f137fe935da690653a05e47837747d07467226c06b0694ed8
|
||||
size 934114
|
||||
5
generation_config.json
Normal file
5
generation_config.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"eos_token_id": 151645,
|
||||
"max_new_tokens": 2048,
|
||||
"transformers_version": "4.51.3"
|
||||
}
|
||||
151388
merges.txt
Normal file
151388
merges.txt
Normal file
File diff suppressed because it is too large
Load Diff
3
model.safetensors
Normal file
3
model.safetensors
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:1d751b6f4e70f2efaed85d6e0c0d89cefc44ac005a23c9877fc11bcea189cd5c
|
||||
size 4195636216
|
||||
30
special_tokens_map.json
Normal file
30
special_tokens_map.json
Normal file
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"additional_special_tokens": [
|
||||
"<|mol_smi_start|>",
|
||||
"<|mol_smi_end|>",
|
||||
"<|mol_sfi_start|>",
|
||||
"<|mol_sfi_end|>",
|
||||
"<|mol_sfi_h_start|>",
|
||||
"<|mol_sfi_h_end|>",
|
||||
"<|mol_3d_start|>",
|
||||
"<|mol_3d_end|>",
|
||||
"<|prot_aa_start|>",
|
||||
"<|prot_aa_end|>",
|
||||
"<|prot_3d_start|>",
|
||||
"<|prot_3d_end|>"
|
||||
],
|
||||
"eos_token": {
|
||||
"content": "<|im_end|>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false
|
||||
},
|
||||
"pad_token": {
|
||||
"content": "<|endoftext|>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false
|
||||
}
|
||||
}
|
||||
3
tokenizer.json
Normal file
3
tokenizer.json
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:072d8c63700dabfae748c64dd88fdd218cd756a1220a19d60aa1277434fd7c73
|
||||
size 14441001
|
||||
131064
tokenizer_config.json
Normal file
131064
tokenizer_config.json
Normal file
File diff suppressed because it is too large
Load Diff
1
vocab.json
Normal file
1
vocab.json
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user