Feature Extraction
Transformers
Safetensors
protenrich
proteins
bioinformatics
drug-discovery
custom_code
Instructions to use SaeedLab/ProtEnrich-ProtBERT with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use SaeedLab/ProtEnrich-ProtBERT with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("feature-extraction", model="SaeedLab/ProtEnrich-ProtBERT", trust_remote_code=True)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("SaeedLab/ProtEnrich-ProtBERT", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
| # ProtBERT | |
| ```python | |
| from transformers import AutoTokenizer, AutoModel | |
| import torch | |
| tokenizer = AutoTokenizer.from_pretrained("Rostlab/prot_bert") | |
| encoder = AutoModel.from_pretrained("Rostlab/prot_bert") | |
| protenrich = AutoModel.from_pretrained("SaeedLab/ProtEnrich-ProtBERT", trust_remote_code=True) | |
| seqs = ["MKTFFVLLL"] | |
| seqs = [" ".join(i) for i in seqs] | |
| inputs = tokenizer(seqs, return_tensors="pt", padding=True) | |
| with torch.no_grad(): | |
| outputs = encoder(**inputs) | |
| pooled = outputs.last_hidden_state[0, 1:-1].mean(axis=0) | |
| enriched = protenrich(pooled) | |
| print('H enrich:', enriched.h_enrich) | |
| print('H anchor:', enriched.h_anchor) | |
| print('H algn:', enriched.h_algn) | |
| print('Structure:', enriched.struct) | |
| print('Dynamics:', enriched.dyn) | |
| ``` |