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/l2norm.py from Cloudflare/clairic-flash: direct link, hf CLI and curl.
- Browser
- Download file 2.78 kB
-
https://huggingface.co/Cloudflare/clairic-flash/resolve/main/clairic_runtime/gdn/l2norm.py
- Command line
-
hf download hf://Cloudflare/clairic-flash/clairic_runtime/gdn/l2norm.py
-
curl -L -o l2norm.py https://huggingface.co/Cloudflare/clairic-flash/resolve/main/clairic_runtime/gdn/l2norm.py
2.78 kB
| # Adapt from https://github.com/fla-org/flash-linear-attention/blob/main/fla/modules/l2norm.py | |
| # -*- coding: utf-8 -*- | |
| # Copyright (c) 2023-2025, Songlin Yang, Yu Zhang | |
| # Standalone import layout; see LICENSES and NOTICE for retained notices. | |
| from typing import Optional | |
| import torch | |
| import triton | |
| import triton.language as tl | |
| def l2norm_fwd_kernel1( | |
| x: tl.tensor, | |
| y: tl.tensor, | |
| D: tl.int32, | |
| BD: tl.constexpr, | |
| eps: tl.float32, | |
| ) -> None: | |
| i_t = tl.program_id(0) | |
| x += i_t * D | |
| y += i_t * D | |
| # Compute mean and variance | |
| cols = tl.arange(0, BD) | |
| mask = cols < D | |
| b_x = tl.load(x + cols, mask=mask, other=0.0).to(tl.float32) | |
| b_var = tl.sum(b_x * b_x, axis=0) | |
| b_rstd = 1 / tl.sqrt(b_var + eps) | |
| # tl.store(Rstd + i_t, rstd) | |
| # Normalize and apply linear transformation | |
| b_y = b_x * b_rstd | |
| tl.store(y + cols, b_y, mask=mask) | |
| def l2norm_fwd_kernel( | |
| x: tl.tensor, | |
| y: tl.tensor, | |
| eps: tl.float32, | |
| T: tl.int32, | |
| D: tl.constexpr, | |
| BT: tl.constexpr, | |
| BD: tl.constexpr, | |
| ) -> None: | |
| i_t = tl.program_id(0) | |
| p_x = tl.make_block_ptr(x, (T, D), (D, 1), (i_t * BT, 0), (BT, BD), (1, 0)) | |
| b_x = tl.load(p_x, boundary_check=(0, 1)).to(tl.float32) | |
| b_var = tl.sum(b_x * b_x, axis=1) | |
| b_y = b_x / tl.sqrt(b_var + eps)[:, None] | |
| p_y = tl.make_block_ptr(y, (T, D), (D, 1), (i_t * BT, 0), (BT, BD), (1, 0)) | |
| tl.store(p_y, b_y.to(p_y.dtype.element_ty), boundary_check=(0, 1)) | |
| def l2norm_fwd( | |
| x: torch.Tensor, eps: float = 1e-6, output_dtype: Optional[torch.dtype] = None | |
| ) -> torch.Tensor: | |
| x_shape_og = x.shape | |
| x = x.view(-1, x.shape[-1]) | |
| # allocate output | |
| if output_dtype is None: | |
| y = torch.empty_like(x) | |
| else: | |
| y = torch.empty_like(x, dtype=output_dtype) | |
| assert y.stride(-1) == 1 | |
| T, D = x.shape[0], x.shape[-1] | |
| # rstd = torch.empty((T,), dtype=torch.float32, device=x.device) | |
| # Less than 64KB per feature: enqueue fused kernel | |
| MAX_FUSED_SIZE = 65536 // x.element_size() | |
| BD = min(MAX_FUSED_SIZE, triton.next_power_of_2(D)) | |
| if D > BD: | |
| raise RuntimeError("This layer doesn't support feature dim >= 64KB.") | |
| if D <= 512: | |
| def grid(meta: dict[str, int]) -> tuple[int]: | |
| return (triton.cdiv(T, meta["BT"]),) | |
| l2norm_fwd_kernel[grid]( | |
| x, | |
| y, | |
| eps, | |
| T=T, | |
| D=D, | |
| BD=BD, | |
| BT=16, | |
| num_warps=8, | |
| num_stages=3, | |
| ) | |
| else: | |
| l2norm_fwd_kernel1[(T,)]( | |
| x, | |
| y, | |
| eps=eps, | |
| D=D, | |
| BD=BD, | |
| num_warps=8, | |
| num_stages=3, | |
| ) | |
| return y.view(x_shape_og) | |