Image-Text-to-Text
Transformers
Safetensors
qwen3_5
clairic
cloudflare
systemone
multimodal
structured-output
information-extraction
custom-code
conversational
Instructions to use Cloudflare/clairic-flash with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Cloudflare/clairic-flash with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="Cloudflare/clairic-flash") 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("Cloudflare/clairic-flash") model = AutoModelForMultimodalLM.from_pretrained("Cloudflare/clairic-flash", 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 Cloudflare/clairic-flash with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Cloudflare/clairic-flash" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Cloudflare/clairic-flash", "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/Cloudflare/clairic-flash
- SGLang
How to use Cloudflare/clairic-flash 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 "Cloudflare/clairic-flash" \ --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": "Cloudflare/clairic-flash", "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 "Cloudflare/clairic-flash" \ --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": "Cloudflare/clairic-flash", "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 Cloudflare/clairic-flash with Docker Model Runner:
docker model run hf.co/Cloudflare/clairic-flash
Download clairic_runtime/gdn/utils.py from Cloudflare/clairic-flash: direct link, hf CLI and curl.
- Browser
- Download file 3.75 kB
-
https://huggingface.co/Cloudflare/clairic-flash/resolve/main/clairic_runtime/gdn/utils.py
- Command line
-
hf download hf://Cloudflare/clairic-flash/clairic_runtime/gdn/utils.py
-
curl -L -o utils.py https://huggingface.co/Cloudflare/clairic-flash/resolve/main/clairic_runtime/gdn/utils.py
3.75 kB
| # Copyright (c) 2023-2025, Songlin Yang, Yu Zhang | |
| # Standalone helper plumbing; see LICENSES and NOTICE for retained notices. | |
| """Device, cache, and launch helpers for the standalone inference kernels.""" | |
| import contextlib | |
| import functools | |
| import inspect | |
| import os | |
| from collections.abc import Callable | |
| from typing import Any | |
| import torch | |
| import triton | |
| FLA_CACHE_RESULTS = os.getenv("FLA_CACHE_RESULTS", "1") == "1" | |
| SUPPORTS_AUTOTUNE_CACHE = "cache_results" in inspect.signature(triton.autotune).parameters | |
| autotune_cache_kwargs = ( | |
| {"cache_results": FLA_CACHE_RESULTS} if SUPPORTS_AUTOTUNE_CACHE else {} | |
| ) | |
| def _backend() -> str: | |
| try: | |
| return triton.runtime.driver.active.get_current_target().backend | |
| except RuntimeError: | |
| return "cpu" | |
| is_nvidia = _backend() == "cuda" | |
| is_nvidia_hopper = is_nvidia and ( | |
| "NVIDIA H" in torch.cuda.get_device_name(0) | |
| or torch.cuda.get_device_capability()[0] >= 9 | |
| ) | |
| is_tf32_supported = is_nvidia and torch.cuda.get_device_capability(0)[0] >= 8 | |
| def check_shared_mem(arch: str = "none", tensor_idx: int = 0) -> bool: | |
| required = { | |
| "ADA": 101376, | |
| "AMPERE": 166912, | |
| "HOPPER": 232448, | |
| }.get(arch.upper(), 102400) | |
| try: | |
| properties = triton.runtime.driver.active.utils.get_device_properties(tensor_idx) | |
| return properties["max_shared_mem"] >= required | |
| except Exception: | |
| return False | |
| def tensor_cache(fn: Callable[..., Any]) -> Callable[..., Any]: | |
| """Retain the source's four-entry cache keyed by input object identity.""" | |
| cache_entries: list[tuple[tuple[Any, ...], dict[str, Any], Any]] = [] | |
| cache_size = 4 | |
| def wrapper(*args: Any, **kwargs: Any) -> Any: | |
| nonlocal cache_entries, cache_size | |
| for i, entry in enumerate(cache_entries): | |
| last_args, last_kwargs, last_result = entry | |
| if len(args) == len(last_args) and len(kwargs) == len(last_kwargs): | |
| if all(a is b for a, b in zip(args, last_args)) and all( | |
| k in last_kwargs and v is last_kwargs[k] for k, v in kwargs.items() | |
| ): | |
| cache_entries = ( | |
| cache_entries[:i] | |
| + cache_entries[i + 1 :] | |
| + [(args, kwargs, last_result)] | |
| ) | |
| return last_result | |
| result = fn(*args, **kwargs) | |
| if len(cache_entries) >= cache_size: | |
| cache_entries = cache_entries[1:] | |
| cache_entries.append((args, kwargs, result)) | |
| return result | |
| return wrapper | |
| def input_guard(fn: Callable[..., Any]) -> Callable[..., Any]: | |
| """Make tensor inputs contiguous and retain their CUDA device context.""" | |
| def wrapper(*args: Any, **kwargs: Any) -> Any: | |
| contiguous_args = ( | |
| value.contiguous() if isinstance(value, torch.Tensor) else value | |
| for value in args | |
| ) | |
| contiguous_kwargs = { | |
| key: value.contiguous() if isinstance(value, torch.Tensor) else value | |
| for key, value in kwargs.items() | |
| } | |
| tensor = next((value for value in args if isinstance(value, torch.Tensor)), None) | |
| if tensor is None: | |
| tensor = next( | |
| (value for value in kwargs.values() if isinstance(value, torch.Tensor)), | |
| None, | |
| ) | |
| context = ( | |
| torch.cuda.device(tensor.device.index) | |
| if tensor is not None and tensor.is_cuda | |
| else contextlib.nullcontext() | |
| ) | |
| with context: | |
| return fn(*contiguous_args, **contiguous_kwargs) | |
| return wrapper | |