Instructions to use MLGResearch/cleaver_t5g_ss with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use MLGResearch/cleaver_t5g_ss with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="MLGResearch/cleaver_t5g_ss") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForSeq2SeqLM tokenizer = AutoTokenizer.from_pretrained("MLGResearch/cleaver_t5g_ss") model = AutoModelForSeq2SeqLM.from_pretrained("MLGResearch/cleaver_t5g_ss", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use MLGResearch/cleaver_t5g_ss with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "MLGResearch/cleaver_t5g_ss" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "MLGResearch/cleaver_t5g_ss", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/MLGResearch/cleaver_t5g_ss
- SGLang
How to use MLGResearch/cleaver_t5g_ss 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 "MLGResearch/cleaver_t5g_ss" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "MLGResearch/cleaver_t5g_ss", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'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 "MLGResearch/cleaver_t5g_ss" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "MLGResearch/cleaver_t5g_ss", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use MLGResearch/cleaver_t5g_ss with Docker Model Runner:
docker model run hf.co/MLGResearch/cleaver_t5g_ss
Download handler.py from MLGResearch/cleaver_t5g_ss: direct link, hf CLI and curl.
- Browser
- Download file 1.33 kB
-
https://huggingface.co/MLGResearch/cleaver_t5g_ss/resolve/main/handler.py
- Command line
-
hf download hf://MLGResearch/cleaver_t5g_ss/handler.py
-
curl -L -o handler.py https://huggingface.co/MLGResearch/cleaver_t5g_ss/resolve/main/handler.py
1.33 kB
| from transformers import AutoTokenizer, AutoModelForSeq2SeqLM | |
| import torch | |
| import os | |
| class EndpointHandler: | |
| def __init__(self, path=""): | |
| # Explicitly prevent sentence-transformers auto-detection | |
| os.environ["TRANSFORMERS_OFFLINE"] = "1" | |
| print(f"Loading T5Gemma model from: {path}") | |
| self.tokenizer = AutoTokenizer.from_pretrained( | |
| path, | |
| trust_remote_code=True | |
| ) | |
| self.model = AutoModelForSeq2SeqLM.from_pretrained( | |
| path, | |
| torch_dtype=torch.bfloat16, | |
| trust_remote_code=True, | |
| device_map="auto" | |
| ) | |
| print("T5Gemma model loaded successfully") | |
| def __call__(self, data): | |
| inputs = data.pop("inputs", data) | |
| messages = [{"role": "user", "content": inputs}] | |
| input_ids = self.tokenizer.apply_chat_template( | |
| messages, | |
| add_generation_prompt=True, | |
| return_tensors="pt" | |
| ) | |
| outputs = self.model.generate( | |
| input_ids, | |
| max_new_tokens=1024, | |
| temperature=0.1, | |
| do_sample=True | |
| ) | |
| return { | |
| "generated_text": self.tokenizer.decode(outputs[0], skip_special_tokens=True) | |
| } | |