Text Generation
Transformers
PyTorch
English
prot2text
feature-extraction
Causal Language Modeling
GPT2
ESM2
Proteins
GNN
custom_code
Instructions to use habdine/Prot2Text-Base-v1-0 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use habdine/Prot2Text-Base-v1-0 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="habdine/Prot2Text-Base-v1-0", trust_remote_code=True)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("habdine/Prot2Text-Base-v1-0", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use habdine/Prot2Text-Base-v1-0 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "habdine/Prot2Text-Base-v1-0" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "habdine/Prot2Text-Base-v1-0", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/habdine/Prot2Text-Base-v1-0
- SGLang
How to use habdine/Prot2Text-Base-v1-0 with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "habdine/Prot2Text-Base-v1-0" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "habdine/Prot2Text-Base-v1-0", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "habdine/Prot2Text-Base-v1-0" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "habdine/Prot2Text-Base-v1-0", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use habdine/Prot2Text-Base-v1-0 with Docker Model Runner:
docker model run hf.co/habdine/Prot2Text-Base-v1-0
| import numpy as np | |
| from biopandas.pdb import PandasPdb | |
| pdb_order = [ | |
| "record_name", | |
| "atom_number", | |
| "blank_1", | |
| "atom_name", | |
| "alt_loc", | |
| "residue_name", | |
| "blank_2", | |
| "chain_id", | |
| "residue_number", | |
| "insertion", | |
| "blank_3", | |
| "x_coord", | |
| "y_coord", | |
| "z_coord", | |
| "occupancy", | |
| "b_factor", | |
| "blank_4", | |
| "segment_id", | |
| "element_symbol", | |
| "charge", | |
| "line_idx", | |
| ] | |
| mmcif_read = { | |
| "group_PDB": "record_name", | |
| "id": "atom_number", | |
| "auth_atom_id": "atom_name", | |
| "auth_comp_id": "residue_name", | |
| "auth_asym_id": "chain_id", | |
| "auth_seq_id": "residue_number", | |
| "Cartn_x": "x_coord", | |
| "Cartn_y": "y_coord", | |
| "Cartn_z": "z_coord", | |
| "occupancy": "occupancy", | |
| "B_iso_or_equiv": "b_factor", | |
| "type_symbol": "element_symbol", | |
| } | |
| nonefields = [ | |
| "blank_1", | |
| "alt_loc", | |
| "blank_2", | |
| "insertion", | |
| "blank_3", | |
| "blank_4", | |
| "segment_id", | |
| "charge", | |
| "line_idx", | |
| ] | |
| def biopandas_mmcif2pdb(pandasmmcif, model_index = 1): | |
| """ | |
| Converts the ATOM and HETATM dataframes of PandasMmcif() to PandasPdb() format. | |
| """ | |
| pandaspdb = PandasPdb() | |
| for a in ["ATOM", "HETATM"]: | |
| dfa = pandasmmcif.df[a] | |
| dfa = dfa.loc[dfa.pdbx_PDB_model_num == model_index] | |
| if a =='ATOM': | |
| if len(dfa) == 0: | |
| raise ValueError(f"No model found for index: {model_index}") | |
| # keep only those fields found in pdb | |
| dfa = dfa[mmcif_read.keys()] | |
| # rename fields | |
| dfa = dfa.rename(columns=mmcif_read) | |
| # add empty fields | |
| for i in nonefields: | |
| dfa[i] = "" | |
| dfa["charge"] = np.nan | |
| # reorder columns to PandasPdb order | |
| dfa = dfa[pdb_order] | |
| pandaspdb.df[a] = dfa | |
| # update line_idx | |
| pandaspdb.df["ATOM"]["line_idx"] = pandaspdb.df["ATOM"].index.values | |
| pandaspdb.df["HETATM"]["line_idx"] = pandaspdb.df["HETATM"].index | |
| return pandaspdb |