Text Generation
Transformers
PyTorch
English
prot2text
feature-extraction
Causal Language Modeling
GPT2
ESM2
Proteins
GNN
custom_code
Instructions to use habdine/Prot2Text-Large-v1-0 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use habdine/Prot2Text-Large-v1-0 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="habdine/Prot2Text-Large-v1-0", trust_remote_code=True)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("habdine/Prot2Text-Large-v1-0", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use habdine/Prot2Text-Large-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-Large-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-Large-v1-0", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/habdine/Prot2Text-Large-v1-0
- SGLang
How to use habdine/Prot2Text-Large-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-Large-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-Large-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-Large-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-Large-v1-0", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use habdine/Prot2Text-Large-v1-0 with Docker Model Runner:
docker model run hf.co/habdine/Prot2Text-Large-v1-0
| """ Prot2Text configuration""" | |
| from transformers.configuration_utils import PretrainedConfig | |
| from transformers import AutoConfig | |
| from transformers.utils import logging | |
| logger = logging.get_logger(__name__) | |
| class Prot2TextConfig(PretrainedConfig): | |
| model_type = "prot2text" | |
| keys_to_ignore_at_inference = ["past_key_values"] | |
| _keys_to_ignore_on_load_missing = [r"transformer"] | |
| def __init__( | |
| self, | |
| cross_esm_graph=True, | |
| decoder_start_token_id=50257, | |
| early_stopping=True, | |
| eos_token_id=50258, | |
| bos_token_id=50257, | |
| esm=True, | |
| esm_model_name="facebook/esm2_t6_8M_UR50D", | |
| gpt_model_name="gpt2", | |
| length_penalty=2.0, | |
| max_new_tokens=256, | |
| no_repeat_ngram_size=3, | |
| pad_token_id=50256, | |
| prot2text_version="1.1", | |
| rgcn=True, | |
| rgc_input_dim=67, | |
| rgcn_n_layers=6, | |
| gpt_config=None, | |
| esm_config=None, | |
| **kwargs, | |
| ): | |
| self.cross_esm_graph = cross_esm_graph | |
| self.decoder_start_token_id = decoder_start_token_id | |
| self.early_stopping = early_stopping | |
| self.eos_token_id = eos_token_id | |
| self.esm = esm | |
| self.esm_model_name = esm_model_name | |
| self.gpt_model_name = gpt_model_name | |
| self.length_penalty = length_penalty | |
| self.max_new_tokens = max_new_tokens | |
| self.no_repeat_ngram_size = no_repeat_ngram_size | |
| self.pad_token_id = pad_token_id | |
| self.prot2text_version = prot2text_version | |
| self.rgcn = rgcn | |
| self.rgc_input_dim = rgc_input_dim | |
| self.rgcn_n_layers = rgcn_n_layers | |
| if gpt_config is None: | |
| self.gpt_config = AutoConfig.from_pretrained(gpt_model_name, | |
| _name_or_path= gpt_model_name, | |
| is_encoder_decoder=True, | |
| use_cache=False, | |
| add_cross_attention=True, | |
| bos_token_id=bos_token_id, | |
| decoder_start_token_id=decoder_start_token_id, | |
| eos_token_id=eos_token_id, | |
| max_new_tokens=max_new_tokens, | |
| pad_token_id=50256, | |
| vocab_size=50259, | |
| num_beams=1, | |
| max_length=256, | |
| min_length=1).to_dict() | |
| else: | |
| self.gpt_config = gpt_config | |
| if esm_config is None: | |
| self.esm_config = AutoConfig.from_pretrained(esm_model_name).to_dict() | |
| self.esm_config = esm_config | |
| super().__init__(bos_token_id=bos_token_id, eos_token_id=eos_token_id, **kwargs) |