Text Generation
Transformers
PyTorch
Safetensors
English
prot2text
feature-extraction
Causal Language Modeling
GPT2
ESM2
Proteins
GNN
custom_code
Instructions to use habdine/Prot2Text-Large-v1-1 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use habdine/Prot2Text-Large-v1-1 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="habdine/Prot2Text-Large-v1-1", trust_remote_code=True)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("habdine/Prot2Text-Large-v1-1", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use habdine/Prot2Text-Large-v1-1 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "habdine/Prot2Text-Large-v1-1" # 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-Large-v1-1", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/habdine/Prot2Text-Large-v1-1
- SGLang
How to use habdine/Prot2Text-Large-v1-1 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-Large-v1-1" \ --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-Large-v1-1", "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-Large-v1-1" \ --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-Large-v1-1", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use habdine/Prot2Text-Large-v1-1 with Docker Model Runner:
docker model run hf.co/habdine/Prot2Text-Large-v1-1
| import numpy as np | |
| import csv | |
| def load_GO_annot(filename): | |
| # Load GO annotations | |
| onts = ['mf', 'bp', 'cc'] | |
| prot2annot = {} | |
| goterms = {ont: [] for ont in onts} | |
| gonames = {ont: [] for ont in onts} | |
| with open(filename, mode='r') as tsvfile: | |
| reader = csv.reader(tsvfile, delimiter='\t') | |
| # molecular function | |
| next(reader, None) # skip the headers | |
| goterms[onts[0]] = next(reader) | |
| next(reader, None) # skip the headers | |
| gonames[onts[0]] = next(reader) | |
| # biological process | |
| next(reader, None) # skip the headers | |
| goterms[onts[1]] = next(reader) | |
| next(reader, None) # skip the headers | |
| gonames[onts[1]] = next(reader) | |
| # cellular component | |
| next(reader, None) # skip the headers | |
| goterms[onts[2]] = next(reader) | |
| next(reader, None) # skip the headers | |
| gonames[onts[2]] = next(reader) | |
| next(reader, None) # skip the headers | |
| counts = {ont: np.zeros(len(goterms[ont]), dtype=float) for ont in onts} | |
| for row in reader: | |
| prot, prot_goterms = row[0], row[1:] | |
| prot2annot[prot] = {ont: [] for ont in onts} | |
| for i in range(3): | |
| goterm_indices = [goterms[onts[i]].index(goterm) for goterm in prot_goterms[i].split(',') if goterm != ''] | |
| prot2annot[prot][onts[i]] = np.zeros(len(goterms[onts[i]])) | |
| prot2annot[prot][onts[i]][goterm_indices] = 1.0 | |
| counts[onts[i]][goterm_indices] += 1.0 | |
| return prot2annot, goterms, gonames, counts | |
| def load_EC_annot(filename): | |
| # Load EC annotations """ | |
| prot2annot = {} | |
| with open(filename, mode='r') as tsvfile: | |
| reader = csv.reader(tsvfile, delimiter='\t') | |
| # molecular function | |
| next(reader, None) # skip the headers | |
| ec_numbers = {'ec': next(reader)} | |
| next(reader, None) # skip the headers | |
| counts = {'ec': np.zeros(len(ec_numbers['ec']), dtype=float)} | |
| for row in reader: | |
| prot, prot_ec_numbers = row[0], row[1] | |
| ec_indices = [ec_numbers['ec'].index(ec_num) for ec_num in prot_ec_numbers.split(',')] | |
| prot2annot[prot] = {'ec': np.zeros(len(ec_numbers['ec']), dtype=np.int64)} | |
| prot2annot[prot]['ec'][ec_indices] = 1.0 | |
| counts['ec'][ec_indices] += 1 | |