Image-Text-to-Text
Transformers
Safetensors
qwen2_5_vl
agent
computer-use
gui-grounding
vision-language
conversational
text-generation-inference
Instructions to use ServiceNow/GroundNext-7B-V0 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ServiceNow/GroundNext-7B-V0 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="ServiceNow/GroundNext-7B-V0") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("ServiceNow/GroundNext-7B-V0") model = AutoModelForMultimodalLM.from_pretrained("ServiceNow/GroundNext-7B-V0", device_map="auto") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.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=40) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use ServiceNow/GroundNext-7B-V0 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "ServiceNow/GroundNext-7B-V0" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ServiceNow/GroundNext-7B-V0", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker
docker model run hf.co/ServiceNow/GroundNext-7B-V0
- SGLang
How to use ServiceNow/GroundNext-7B-V0 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 "ServiceNow/GroundNext-7B-V0" \ --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": "ServiceNow/GroundNext-7B-V0", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'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 "ServiceNow/GroundNext-7B-V0" \ --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": "ServiceNow/GroundNext-7B-V0", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }' - Docker Model Runner
How to use ServiceNow/GroundNext-7B-V0 with Docker Model Runner:
docker model run hf.co/ServiceNow/GroundNext-7B-V0
Update README.md
Browse files
README.md
CHANGED
|
@@ -85,7 +85,7 @@ full_prompt = f'{instruction}'
|
|
| 85 |
messages = [
|
| 86 |
{
|
| 87 |
"role": "system",
|
| 88 |
-
"content":
|
| 89 |
},
|
| 90 |
{
|
| 91 |
"role": "user",
|
|
@@ -102,20 +102,20 @@ messages = [
|
|
| 102 |
input_text = tokenizer.apply_chat_template(messages,
|
| 103 |
add_generation_prompt=True,
|
| 104 |
tokenize=False)
|
| 105 |
-
inputs =
|
| 106 |
text=[input_text],
|
| 107 |
images=[image],
|
| 108 |
videos=None,
|
| 109 |
padding=True,
|
| 110 |
return_tensors="pt",
|
| 111 |
-
).to(
|
| 112 |
|
| 113 |
-
|
| 114 |
|
| 115 |
generated_ids_trimmed = [
|
| 116 |
out_ids[len(in_ids) :] for in_ids, out_ids in zip(inputs.input_ids, generated_ids)
|
| 117 |
]
|
| 118 |
-
response =
|
| 119 |
generated_ids_trimmed, skip_special_tokens=True, clean_up_tokenization_spaces=False
|
| 120 |
)[0]
|
| 121 |
|
|
|
|
| 85 |
messages = [
|
| 86 |
{
|
| 87 |
"role": "system",
|
| 88 |
+
"content": GroundNext_GROUNDER_SYS_PROMPT.format(img_width=img_width, img_height=img_height)
|
| 89 |
},
|
| 90 |
{
|
| 91 |
"role": "user",
|
|
|
|
| 102 |
input_text = tokenizer.apply_chat_template(messages,
|
| 103 |
add_generation_prompt=True,
|
| 104 |
tokenize=False)
|
| 105 |
+
inputs = processor(
|
| 106 |
text=[input_text],
|
| 107 |
images=[image],
|
| 108 |
videos=None,
|
| 109 |
padding=True,
|
| 110 |
return_tensors="pt",
|
| 111 |
+
).to(model.device)
|
| 112 |
|
| 113 |
+
generated_ids = model.generate(**inputs, max_new_tokens=64)
|
| 114 |
|
| 115 |
generated_ids_trimmed = [
|
| 116 |
out_ids[len(in_ids) :] for in_ids, out_ids in zip(inputs.input_ids, generated_ids)
|
| 117 |
]
|
| 118 |
+
response = processor.batch_decode(
|
| 119 |
generated_ids_trimmed, skip_special_tokens=True, clean_up_tokenization_spaces=False
|
| 120 |
)[0]
|
| 121 |
|