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/prefill.py from Cloudflare/clairic-flash: direct link, hf CLI and curl.
- Browser
- Download file 1.65 kB
-
https://huggingface.co/Cloudflare/clairic-flash/resolve/main/clairic_runtime/gdn/prefill.py
- Command line
-
hf download hf://Cloudflare/clairic-flash/clairic_runtime/gdn/prefill.py
-
curl -L -o prefill.py https://huggingface.co/Cloudflare/clairic-flash/resolve/main/clairic_runtime/gdn/prefill.py
1.65 kB
| from typing import Any | |
| # Copyright (c) 2023-2025, Songlin Yang, Yu Zhang | |
| # Inference-only adaptation; see LICENSES and NOTICE. | |
| from typing import Optional | |
| import torch | |
| from .chunk_delta_h import chunk_gated_delta_rule_fwd_h | |
| from .chunk_fwd import chunk_gated_delta_rule_fwd_intra | |
| from .chunk_o import chunk_fwd_o | |
| from .cumsum import chunk_local_cumsum_scalar as chunk_local_cumsum | |
| CHUNK_SIZE = 64 | |
| SUPPRESS_LEVEL = 0 | |
| def chunk_gated_delta_rule_fwd( | |
| q: torch.Tensor, | |
| k: torch.Tensor, | |
| v: torch.Tensor, | |
| g: torch.Tensor, | |
| beta: torch.Tensor, | |
| scale: float, | |
| initial_state: torch.Tensor, | |
| initial_state_indices: torch.Tensor, | |
| cu_seqlens: Optional[torch.LongTensor] = None, | |
| chunk_indices: torch.LongTensor | None = None, | |
| ) -> Any: | |
| g = chunk_local_cumsum( | |
| g, chunk_size=CHUNK_SIZE, cu_seqlens=cu_seqlens, chunk_indices=chunk_indices | |
| ) | |
| # fused kkt + solve_tril + recompute_w_u | |
| w, u, A = chunk_gated_delta_rule_fwd_intra( | |
| k=k, | |
| v=v, | |
| g=g, | |
| beta=beta, | |
| cu_seqlens=cu_seqlens, | |
| chunk_indices=chunk_indices, | |
| ) | |
| h, v_new = chunk_gated_delta_rule_fwd_h( | |
| k=k, | |
| w=w, | |
| u=u, | |
| g=g, | |
| initial_state=initial_state, | |
| initial_state_indices=initial_state_indices, | |
| cu_seqlens=cu_seqlens, | |
| chunk_indices=chunk_indices, | |
| ) | |
| o = chunk_fwd_o( | |
| q=q, | |
| k=k, | |
| v=v_new, | |
| h=h, | |
| g=g, | |
| scale=scale, | |
| cu_seqlens=cu_seqlens, | |
| ) | |
| if SUPPRESS_LEVEL < 3: | |
| return g, o, A, None, h, None | |
| elif SUPPRESS_LEVEL >= 3: | |
| return g, o, A, w, h, v_new | |