Instructions to use yoni-log/gpt2-HPO with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use yoni-log/gpt2-HPO with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="yoni-log/gpt2-HPO")# Load model directly from transformers import AutoTokenizer, AutoModelForMultimodalLM tokenizer = AutoTokenizer.from_pretrained("yoni-log/gpt2-HPO") model = AutoModelForMultimodalLM.from_pretrained("yoni-log/gpt2-HPO") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use yoni-log/gpt2-HPO with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "yoni-log/gpt2-HPO" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "yoni-log/gpt2-HPO", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/yoni-log/gpt2-HPO
- SGLang
How to use yoni-log/gpt2-HPO 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 "yoni-log/gpt2-HPO" \ --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": "yoni-log/gpt2-HPO", "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 "yoni-log/gpt2-HPO" \ --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": "yoni-log/gpt2-HPO", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use yoni-log/gpt2-HPO with Docker Model Runner:
docker model run hf.co/yoni-log/gpt2-HPO
Model Details
This model is a fine-tuned language model designed to identify and extract Human Phenotype Ontology (HPO) terms from clinical text. It is trained using an Alpaca-style instruction format, allowing it to map medical descriptions to their corresponding HPO terms, IDs, and definitions.
Function to generate responses
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained(model_path)
model = AutoModelForCausalLM.from_pretrained(model_path)
def generate_response(instruction, input_text=""):
# Create the Alpaca-style prompt
if input_text.strip():
prompt = (
"You are an expert at identifying HPO ids. "
"Provide the most accurate HPO id for the given input.\n\n"
f"### Instruction:\n{instruction}\n\n"
f"### Input:\n{input_text}\n\n"
"### Response:\n"
)
else:
prompt = (
"You are an expert at identifying HPO ids. "
"Provide the most accurate HPO id for the given input.\n\n"
f"### Instruction:\n{instruction}\n\n"
"### Response:\n"
)
# Tokenize input prompt
inputs = tokenizer(prompt, return_tensors="pt")
# Generate response
with torch.no_grad():
output = model.generate(
**inputs,
max_length=512, # Adjust based on your expected output size
temperature=0.7, # Controls randomness
top_p=0.9, # Nucleus sampling
do_sample=True # Enables sampling
)
# Decode output tokens to text
response = tokenizer.decode(output[0], skip_special_tokens=True)
# Remove the input prompt from the output
return response[len(prompt):].strip()
# Test the model with an example instruction
instruction = "Extract the Human Phenotype Ontology (HPO) details from the following clinical context. Provide the HPO Term, HPO ID, and HPO Definition."
input_text = "An anomaly of the intracellular membrane complexes known as the dense tubular system."
response = generate_response(instruction, input_text)
print("\nGenerated Response:\n", response)
- Downloads last month
- 2