Image-Text-to-Text
Transformers
Safetensors
multilingual
GOT
feature-extraction
got
vision-language
ocr2.0
custom_code
Instructions to use velier/GOT_MPS with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use velier/GOT_MPS with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="velier/GOT_MPS", trust_remote_code=True)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("velier/GOT_MPS", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use velier/GOT_MPS with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "velier/GOT_MPS" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "velier/GOT_MPS", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/velier/GOT_MPS
- SGLang
How to use velier/GOT_MPS 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 "velier/GOT_MPS" \ --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": "velier/GOT_MPS", "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 "velier/GOT_MPS" \ --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": "velier/GOT_MPS", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use velier/GOT_MPS with Docker Model Runner:
docker model run hf.co/velier/GOT_MPS
Revert "remove default "cuda" parameters and refactor torch.bfloat16 to torch.float16"
Browse filesThis reverts commit 7f908b9564b5f8bfc3048f502c5bc043bf32846f.
- modeling_GOT.py +6 -6
modeling_GOT.py
CHANGED
|
@@ -164,7 +164,7 @@ class GOTQwenModel(Qwen2Model):
|
|
| 164 |
use_im_start_end=False,
|
| 165 |
vision_select_layer=-1,
|
| 166 |
dtype=torch.float16,
|
| 167 |
-
device="
|
| 168 |
):
|
| 169 |
|
| 170 |
|
|
@@ -453,7 +453,7 @@ class GOTQwenForCausalLM(Qwen2ForCausalLM):
|
|
| 453 |
tokenizer,
|
| 454 |
freeze_lm_model=False,
|
| 455 |
pretrained_stage1_model=None,
|
| 456 |
-
device="
|
| 457 |
):
|
| 458 |
config = self.get_model().config
|
| 459 |
|
|
@@ -566,7 +566,7 @@ class GOTQwenForCausalLM(Qwen2ForCausalLM):
|
|
| 566 |
streamer = TextStreamer(tokenizer, skip_prompt=True, skip_special_tokens=True)
|
| 567 |
|
| 568 |
if stream_flag:
|
| 569 |
-
with torch.autocast("
|
| 570 |
output_ids = self.generate(
|
| 571 |
input_ids,
|
| 572 |
images=[image_tensor_1.unsqueeze(0).half()],
|
|
@@ -578,7 +578,7 @@ class GOTQwenForCausalLM(Qwen2ForCausalLM):
|
|
| 578 |
stopping_criteria=[stopping_criteria]
|
| 579 |
)
|
| 580 |
else:
|
| 581 |
-
with torch.autocast("
|
| 582 |
output_ids = self.generate(
|
| 583 |
input_ids,
|
| 584 |
images=[image_tensor_1.unsqueeze(0).half()],
|
|
@@ -820,7 +820,7 @@ class GOTQwenForCausalLM(Qwen2ForCausalLM):
|
|
| 820 |
streamer = TextStreamer(tokenizer, skip_prompt=True, skip_special_tokens=True)
|
| 821 |
|
| 822 |
if stream_flag:
|
| 823 |
-
with torch.autocast("
|
| 824 |
output_ids = self.generate(
|
| 825 |
input_ids,
|
| 826 |
images=[image_list.half()],
|
|
@@ -832,7 +832,7 @@ class GOTQwenForCausalLM(Qwen2ForCausalLM):
|
|
| 832 |
stopping_criteria=[stopping_criteria]
|
| 833 |
)
|
| 834 |
else:
|
| 835 |
-
with torch.autocast("
|
| 836 |
output_ids = self.generate(
|
| 837 |
input_ids,
|
| 838 |
images=[image_list.half()],
|
|
|
|
| 164 |
use_im_start_end=False,
|
| 165 |
vision_select_layer=-1,
|
| 166 |
dtype=torch.float16,
|
| 167 |
+
device="cuda"
|
| 168 |
):
|
| 169 |
|
| 170 |
|
|
|
|
| 453 |
tokenizer,
|
| 454 |
freeze_lm_model=False,
|
| 455 |
pretrained_stage1_model=None,
|
| 456 |
+
device="cuda"
|
| 457 |
):
|
| 458 |
config = self.get_model().config
|
| 459 |
|
|
|
|
| 566 |
streamer = TextStreamer(tokenizer, skip_prompt=True, skip_special_tokens=True)
|
| 567 |
|
| 568 |
if stream_flag:
|
| 569 |
+
with torch.autocast("cuda", dtype=torch.bfloat16):
|
| 570 |
output_ids = self.generate(
|
| 571 |
input_ids,
|
| 572 |
images=[image_tensor_1.unsqueeze(0).half()],
|
|
|
|
| 578 |
stopping_criteria=[stopping_criteria]
|
| 579 |
)
|
| 580 |
else:
|
| 581 |
+
with torch.autocast("cuda", dtype=torch.bfloat16):
|
| 582 |
output_ids = self.generate(
|
| 583 |
input_ids,
|
| 584 |
images=[image_tensor_1.unsqueeze(0).half()],
|
|
|
|
| 820 |
streamer = TextStreamer(tokenizer, skip_prompt=True, skip_special_tokens=True)
|
| 821 |
|
| 822 |
if stream_flag:
|
| 823 |
+
with torch.autocast("cuda", dtype=torch.bfloat16):
|
| 824 |
output_ids = self.generate(
|
| 825 |
input_ids,
|
| 826 |
images=[image_list.half()],
|
|
|
|
| 832 |
stopping_criteria=[stopping_criteria]
|
| 833 |
)
|
| 834 |
else:
|
| 835 |
+
with torch.autocast("cuda", dtype=torch.bfloat16):
|
| 836 |
output_ids = self.generate(
|
| 837 |
input_ids,
|
| 838 |
images=[image_list.half()],
|