thrumbel commited on
Commit
4bfe3f9
1 Parent(s): 1887d7c

Push model using huggingface_hub.

Browse files
Files changed (3) hide show
  1. README.md +165 -3
  2. config.json +5 -0
  3. model.safetensors +3 -0
README.md CHANGED
@@ -1,3 +1,165 @@
1
- ---
2
- license: apache-2.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: SmallMoleculeMultiView
3
+ license: apache-2.0
4
+ tags:
5
+ - chemistry
6
+ - model_hub_mixin
7
+ - molecules
8
+ - multiview
9
+ - pytorch
10
+ - pytorch_model_hub_mixin
11
+ ---
12
+
13
+ # sm.mv.te.84m
14
+ **SmallMoleculeMultiView**, multi-view molecular foundation model.
15
+
16
+ - **Developers:** IBM Research
17
+ - **GitHub Repository:** [https://github.com/BiomedSciAI/biomed.multi-view](https://github.com/BiomedSciAI/biomed.multi-view)
18
+ - **Paper:** [Multi-view biomedical foundation models for molecule-target and property prediction](https://arxiv.org/abs/TBD)
19
+ - **Release Date**: Oct 29th, 2024
20
+ - **License:** [apache-2.0](https://www.apache.org/licenses/LICENSE-2.0).
21
+
22
+ ## Model Description
23
+
24
+ This model contains the implementation of the Multi-view Molecular Embedding with Late Fusion (MMELON) architecture. MMELON combines molecular representations from three views — image, 2-dimensional chemically-bonded graph, and text (SMILES) —to learn a joint embedding that can be finetuned for downstream tasks in chemical and biological property prediction.
25
+
26
+ It was introduced in the paper [Multi-view biomedical foundation models for molecule-target and property prediction](https://arxiv.org/) by authors and first released in [this repository](https://github.com/BiomedSciAI/biomed.multi-view).
27
+
28
+ ![SmallMoleculeMultiView Overview](https://github.com/BiomedSciAI/biomed.multi-view/docs/overview.png)
29
+
30
+ * Image Representation: Captures the 2D visual depiction of molecular structures, highlighting features like symmetry, bond angles, and functional groups. Molecular images are generated using RDKit and undergo data augmentation during training to enhance robustness.
31
+ * Graph Representation: Encodes molecules as undirected graphs where nodes represent atoms and edges represent bonds. Atom-specific properties (e.g., atomic number, chirality) and bond-specific properties (e.g., bond type, stereochemistry) are embedded using categorical embedding techniques.
32
+ * Text Representation: Utilizes SMILES strings to represent chemical structures, tokenized with a custom tokenizer. The sequences are embedded using a transformer-based architecture to capture the sequential nature of the chemical information.
33
+
34
+ The embeddings from these single-view pre-trained encoders are combined using an attention-based aggregator module. This module learns to weight each view appropriately, producing a unified multi-view embedding. This approach leverages the strengths of each representation to improve performance on downstream predictive tasks.
35
+
36
+
37
+ ## Usage
38
+
39
+ Using `SmallMoleculeMultiView` requires [https://github.com/BiomedSciAI/biomed.multi-view](https://github.com/BiomedSciAI/biomed.multi-view)
40
+
41
+ ## Installation
42
+ Follow these steps to set up the `biomed.multi-view` codebase on your system.
43
+
44
+ ### Prerequisites
45
+ * Operating System: Linux or macOS
46
+ * Python Version: Python 3.11
47
+ * Conda: Anaconda or Miniconda installed
48
+ * Git: Version control to clone the repository
49
+
50
+
51
+ ### Step 1: Set up the project directory
52
+ Choose a root directory where you want to install biomed.multi-view. For example:
53
+
54
+ ```bash
55
+ export ROOT_DIR=~/biomed-multiview
56
+ mkdir -p $ROOT_DIR
57
+ ```
58
+
59
+ ### Step 2: Install anaconda3
60
+ If you have Anconda in your system you can skip this step.
61
+ ``` bash
62
+ cd $ROOT_DIR
63
+ # Download the Anaconda installer
64
+ wget https://repo.anaconda.com/archive/Anaconda3-2023.03-Linux-x86_64.sh
65
+
66
+ # Run the installer
67
+ bash Anaconda3-2023.03-Linux-x86_64.sh
68
+ # After installation, initialize Conda:
69
+ source activate $ROOT_DIR/anaconda3/bin/activate
70
+ ```
71
+
72
+ #### Step 3: Create and activate a Conda environment
73
+ ```bash
74
+ conda create -y python=3.11 --prefix $ROOT_DIR/envs/biomed-multiview
75
+ ```
76
+ Activate the environment:
77
+ ```bash
78
+ conda activate $ROOT_DIR/envs/biomed-multiview
79
+ ```
80
+
81
+ #### Step 4: Clone the repository
82
+ Navigate to the project directory and clone the repository:
83
+ ```bash
84
+ mkdir -p $ROOT_DIR/code
85
+ cd $ROOT_DIR/code
86
+
87
+ # Clone the repository using HTTPS
88
+ git clone https://github.com/BiomedSciAI/biomed.multi-view.git
89
+
90
+ # Navigate into the cloned repository
91
+ cd biomed.multi-view
92
+ ```
93
+ Note: If you prefer using SSH, ensure that your SSH keys are set up with GitHub and use the following command:
94
+ ```bash
95
+ git clone git@github.com:BiomedSciAI/biomed.multi-view.git
96
+ ```
97
+
98
+ #### Step 5: Install package dependencies
99
+ Install the package in editable mode along with development dependencies:
100
+ ``` bash
101
+ pip install -e .['dev']
102
+ ```
103
+ Install additional requirements:
104
+ ``` bash
105
+ pip install -r requirements.txt
106
+ ```
107
+
108
+ #### Step 6: macOS-Specific instructions (Apple Silicon)
109
+ If you are using a Mac with Apple Silicon (M1/M2/M3) and the zsh shell, you may need to disable globbing for the installation command:
110
+
111
+ ``` bash
112
+ noglob pip install -e .[dev]
113
+ ```
114
+ Install macOS-specific requirements optimized for Apple’s Metal Performance Shaders (MPS):
115
+ ```bash
116
+ pip install -r requirements-mps.txt
117
+ ```
118
+
119
+ #### Step 7: Installation verification (optional)
120
+ Verify that the installation was successful by running unit tests
121
+
122
+ ```bash
123
+ python -m unittest bmfm_sm.tests.all_tests
124
+ ```
125
+
126
+
127
+ ### Usage example
128
+
129
+ A simple example:
130
+ ```python
131
+ # Necessary imports
132
+ from bmfm_sm.api.smmv_api import SmallMoleculeMultiViewModel
133
+ from bmfm_sm.core.data_modules.namespace import LateFusionStrategy
134
+
135
+ # Load Model
136
+ model = SmallMoleculeMultiViewModel.from_pretrained(
137
+ LateFusionStrategy.ATTENTIONAL,
138
+ model_path="ibm/biomed.sm.mv-te-84m",
139
+ huggingface=True
140
+ )
141
+
142
+ # Load Model and get embeddings for a molecule
143
+ example_smiles = "CC(C)CC1=CC=C(C=C1)C(C)C(=O)O"
144
+ example_emb = SmallMoleculeMultiViewModel.get_embeddings(
145
+ smiles=example_smiles,
146
+ model_path="ibm/biomed.sm.mv-te-84m",
147
+ huggingface=True,
148
+ )
149
+ print(example_emb.shape)
150
+ ```
151
+
152
+ For more advanced usage, see our detailed examples at: https://github.com/BiomedSciAI/biomed.multi-view
153
+
154
+
155
+ ## Citation
156
+
157
+ If you found our work useful, please consider to give a star to the repo and cite our paper:
158
+ ```
159
+ @article{TBD,
160
+ title={TBD},
161
+ author={IBM Research Team},
162
+ jounal={arXiv preprint arXiv:TBD},
163
+ year={2024}
164
+ }
165
+ ```
config.json ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ {
2
+ "agg_arch": "coeff_mlp",
3
+ "agg_gate_input": null,
4
+ "inference_mode": true
5
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:74b7e159062b105c557d2459790ffc4617c906a660b14292656b11ab63ef8063
3
+ size 336571704