Feature Extraction
Transformers
Safetensors
English
roberta
pharmacore
sparse
drug-discovery
apple-silicon
chemberta
molecular-language-model
cheminformatics
smiles
pruning
efficient-inference
Eval Results (legacy)
text-embeddings-inference
Instructions to use stephenjun8192/chemberta-zinc-sparse50 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use stephenjun8192/chemberta-zinc-sparse50 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("feature-extraction", model="stephenjun8192/chemberta-zinc-sparse50")# Load model directly from transformers import AutoTokenizer, AutoModel tokenizer = AutoTokenizer.from_pretrained("stephenjun8192/chemberta-zinc-sparse50") model = AutoModel.from_pretrained("stephenjun8192/chemberta-zinc-sparse50", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -1,32 +1,101 @@
|
|
| 1 |
---
|
| 2 |
license: mit
|
|
|
|
|
|
|
| 3 |
tags:
|
| 4 |
- pharmacore
|
| 5 |
- sparse
|
| 6 |
- drug-discovery
|
| 7 |
- apple-silicon
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
base_model: seyonec/ChemBERTa-zinc-base-v1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
---
|
| 10 |
|
| 11 |
-
#
|
| 12 |
|
| 13 |
-
50% magnitude-pruned version of [seyonec/ChemBERTa-zinc-base-v1](https://huggingface.co/seyonec/ChemBERTa-zinc-base-v1)
|
| 14 |
-
for efficient drug discovery on Apple Silicon.
|
| 15 |
|
| 16 |
-
##
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
## Usage
|
| 22 |
|
| 23 |
```python
|
| 24 |
from transformers import AutoModel, AutoTokenizer
|
|
|
|
| 25 |
|
| 26 |
model = AutoModel.from_pretrained("stephenjun8192/chemberta-zinc-sparse50")
|
| 27 |
tokenizer = AutoTokenizer.from_pretrained("seyonec/ChemBERTa-zinc-base-v1")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
```
|
| 29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
## Part of PharmaCore
|
| 31 |
|
| 32 |
-
[PharmaCore](https://github.com/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
license: mit
|
| 3 |
+
language:
|
| 4 |
+
- en
|
| 5 |
tags:
|
| 6 |
- pharmacore
|
| 7 |
- sparse
|
| 8 |
- drug-discovery
|
| 9 |
- apple-silicon
|
| 10 |
+
- chemberta
|
| 11 |
+
- molecular-language-model
|
| 12 |
+
- cheminformatics
|
| 13 |
+
- smiles
|
| 14 |
+
- pruning
|
| 15 |
+
- efficient-inference
|
| 16 |
+
library_name: transformers
|
| 17 |
+
pipeline_tag: feature-extraction
|
| 18 |
base_model: seyonec/ChemBERTa-zinc-base-v1
|
| 19 |
+
model-index:
|
| 20 |
+
- name: chemberta-zinc-sparse50
|
| 21 |
+
results:
|
| 22 |
+
- task:
|
| 23 |
+
type: feature-extraction
|
| 24 |
+
name: Molecular Embedding
|
| 25 |
+
metrics:
|
| 26 |
+
- type: cosine_similarity
|
| 27 |
+
value: 0.973
|
| 28 |
+
name: Quality Retention vs Dense
|
| 29 |
---
|
| 30 |
|
| 31 |
+
# ChemBERTa-zinc Sparse 50% — PharmaCore
|
| 32 |
|
| 33 |
+
A **50% magnitude-pruned** version of [seyonec/ChemBERTa-zinc-base-v1](https://huggingface.co/seyonec/ChemBERTa-zinc-base-v1) optimized for efficient molecular encoding on Apple Silicon.
|
|
|
|
| 34 |
|
| 35 |
+
## Why This Model?
|
| 36 |
+
|
| 37 |
+
| Metric | Dense (Original) | Sparse (This) | Improvement |
|
| 38 |
+
|--------|-----------------|---------------|-------------|
|
| 39 |
+
| Parameters (active) | 44.1M | 22M | 50% reduction |
|
| 40 |
+
| Inference (M4 MPS) | 5.1ms | 4.9ms | 4% faster |
|
| 41 |
+
| Quality Retention | 100% | 97.3% | Minimal loss |
|
| 42 |
+
|
| 43 |
+
## Use Case
|
| 44 |
+
|
| 45 |
+
Molecular encoder in the [PharmaCore](https://github.com/reacherwu/PharmaCore) drug discovery pipeline:
|
| 46 |
+
- Encode SMILES strings into dense embeddings for drug-target scoring
|
| 47 |
+
- Molecular similarity computation for drug repurposing
|
| 48 |
+
- Drug-likeness assessment and ADMET property prediction
|
| 49 |
+
- Runs entirely on consumer Apple Silicon hardware (M1/M2/M3/M4)
|
| 50 |
|
| 51 |
## Usage
|
| 52 |
|
| 53 |
```python
|
| 54 |
from transformers import AutoModel, AutoTokenizer
|
| 55 |
+
import torch
|
| 56 |
|
| 57 |
model = AutoModel.from_pretrained("stephenjun8192/chemberta-zinc-sparse50")
|
| 58 |
tokenizer = AutoTokenizer.from_pretrained("seyonec/ChemBERTa-zinc-base-v1")
|
| 59 |
+
|
| 60 |
+
# Encode a drug molecule (Erlotinib — EGFR inhibitor)
|
| 61 |
+
smiles = "COCCOc1cc2ncnc(Nc3cccc(C#C)c3)c2cc1OCCOC"
|
| 62 |
+
inputs = tokenizer(smiles, return_tensors="pt", padding=True, truncation=True)
|
| 63 |
+
|
| 64 |
+
with torch.no_grad():
|
| 65 |
+
outputs = model(**inputs)
|
| 66 |
+
embedding = outputs.last_hidden_state.mean(dim=1) # [1, 768]
|
| 67 |
+
|
| 68 |
+
print(f"Embedding shape: {embedding.shape}")
|
| 69 |
```
|
| 70 |
|
| 71 |
+
## Sparsification Method
|
| 72 |
+
|
| 73 |
+
- **Technique:** Global magnitude pruning (unstructured)
|
| 74 |
+
- **Sparsity:** 50% of all weight parameters set to zero
|
| 75 |
+
- **Layers pruned:** All linear layers (attention Q/K/V/O, FFN)
|
| 76 |
+
- **Validation:** Cosine similarity of embeddings vs dense model ≥ 0.973
|
| 77 |
+
- **Training data:** Pre-trained on 100K ZINC molecules (SMILES)
|
| 78 |
+
|
| 79 |
+
## Benchmarks (Apple M4 Mac mini, 16GB)
|
| 80 |
+
|
| 81 |
+
| Task | Time |
|
| 82 |
+
|------|------|
|
| 83 |
+
| Single molecule embedding | 4.9ms |
|
| 84 |
+
| Batch of 12 molecules | ~45ms |
|
| 85 |
+
| Molecular fingerprint + embedding | ~6ms |
|
| 86 |
+
| Drug repurposing (full screen) | ~18s |
|
| 87 |
+
|
| 88 |
## Part of PharmaCore
|
| 89 |
|
| 90 |
+
[PharmaCore](https://github.com/reacherwu/PharmaCore) — the first AI drug discovery platform that runs entirely on a MacBook. No cloud GPUs, no API keys, no data leaves your machine.
|
| 91 |
+
|
| 92 |
+
## Citation
|
| 93 |
+
|
| 94 |
+
```bibtex
|
| 95 |
+
@software{pharmacore2026,
|
| 96 |
+
title={PharmaCore: Apple Silicon-Native AI Drug Discovery},
|
| 97 |
+
author={Stephen Wu},
|
| 98 |
+
year={2026},
|
| 99 |
+
url={https://github.com/reacherwu/PharmaCore}
|
| 100 |
+
}
|
| 101 |
+
```
|