Image-Text-to-Text
Transformers
Safetensors
qwen3_5
decision-model
typed-decisions
multimodal
conversational
Instructions to use inclusionAI/SingVL_S1_4B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use inclusionAI/SingVL_S1_4B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="inclusionAI/SingVL_S1_4B") 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)# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("inclusionAI/SingVL_S1_4B") model = AutoModelForMultimodalLM.from_pretrained("inclusionAI/SingVL_S1_4B", 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=256) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use inclusionAI/SingVL_S1_4B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "inclusionAI/SingVL_S1_4B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "inclusionAI/SingVL_S1_4B", "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/inclusionAI/SingVL_S1_4B
- SGLang
How to use inclusionAI/SingVL_S1_4B 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 "inclusionAI/SingVL_S1_4B" \ --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": "inclusionAI/SingVL_S1_4B", "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 "inclusionAI/SingVL_S1_4B" \ --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": "inclusionAI/SingVL_S1_4B", "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 inclusionAI/SingVL_S1_4B with Docker Model Runner:
docker model run hf.co/inclusionAI/SingVL_S1_4B
File size: 2,181 Bytes
82b505f | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | """Decision Index native-engine adapter using the released Transformers readout."""
from io import BytesIO
from pathlib import Path
from PIL import Image
from decision_index.engines.base import Engine, Unsupported as KitUnsupported
from decision_index.vision.images import load
from .model import SingVLS1, Unsupported, PUBLIC_IMAGE_MAX_PIXELS
class D3Engine(Engine):
name = "sing-vl-s1"
latency = "One native Transformers prediction including input preparation; model loading excluded."
def __init__(self, model, device="cuda:0", image_root=None,
image_max_pixels=PUBLIC_IMAGE_MAX_PIXELS, **options):
super().__init__(**options)
self.image_root = image_root
self.native = SingVLS1(model, device=device, image_max_pixels=image_max_pixels)
self.provenance = {
"kind": "native-transformers", "model": str(Path(model).resolve()),
"max_pixels": image_max_pixels,
"image_resize": "native Sing VL S1 processor: preserve aspect ratio, patch-grid rounding, RGB bicubic resize, 1.6 MP cap",
"attention": "prefix-bidirectional full attention, causal GDN, no KV cache",
"max_images": 4, "text_max_tokens": 65536, "vision_max_tokens": 10000,
}
def __call__(self, state, questions, images=(), prompt=None):
decoded = []
for ref in images:
with Image.open(BytesIO(load(ref, self.image_root))) as image:
decoded.append(image.copy())
try:
response, details = self.native.predict(state, questions, decoded)
except Unsupported as exc:
raise KitUnsupported(str(exc)) from exc
grids = next(iter(details.values())).get("image_grid_thw")
factor = self.native.image_factor
raw = {"details": details, "prompt_metadata": prompt,
"image_pixels": [int(t*h*w*factor*factor/self.native.merge_size**2) for t,h,w in grids or []],
"image_tokens": next(iter(details.values())).get("image_tokens", 0)}
return response, raw
def runtime(self):
return self.native.runtime()
def close(self):
del self.native
|