Image-Text-to-Text
Transformers
Safetensors
qwen3_5
clairic
cloudflare
systemone
multimodal
structured-output
information-extraction
custom-code
conversational
Instructions to use Cloudflare/clairic with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Cloudflare/clairic with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="Cloudflare/clairic") 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") model = AutoModelForMultimodalLM.from_pretrained("Cloudflare/clairic", 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 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Cloudflare/clairic" # 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", "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
- SGLang
How to use Cloudflare/clairic 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" \ --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", "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" \ --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", "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 with Docker Model Runner:
docker model run hf.co/Cloudflare/clairic
Download clairic_runtime/gdn/gating.py from Cloudflare/clairic: direct link, hf CLI and curl.
- Browser
- Download file 2.36 kB
-
https://huggingface.co/Cloudflare/clairic/resolve/main/clairic_runtime/gdn/gating.py
- Command line
-
hf download hf://Cloudflare/clairic/clairic_runtime/gdn/gating.py
-
curl -L -o gating.py https://huggingface.co/Cloudflare/clairic/resolve/main/clairic_runtime/gdn/gating.py
2.36 kB
| # Copyright (c) 2023-2025, Songlin Yang, Yu Zhang | |
| # Inference-only adaptation; see LICENSES and NOTICE. | |
| from typing import Tuple | |
| import torch | |
| import triton | |
| import triton.language as tl | |
| # g = -self.A_log.float().exp() * F.softplus(a.float() + self.dt_bias) | |
| # beta_output = b.sigmoid() | |
| def fused_gdn_gating_kernel( | |
| g: tl.tensor, | |
| beta_output: tl.tensor, | |
| A_log: tl.tensor, | |
| a: tl.tensor, | |
| b: tl.tensor, | |
| dt_bias: tl.tensor, | |
| seq_len: tl.int32, | |
| stride_a: tl.int32, | |
| stride_b: tl.int32, | |
| NUM_HEADS: tl.constexpr, | |
| beta: tl.constexpr, | |
| threshold: tl.constexpr, | |
| BLK_HEADS: tl.constexpr, | |
| ) -> None: | |
| i_b, i_s, i_d = tl.program_id(0), tl.program_id(1), tl.program_id(2) | |
| head_off = i_d * BLK_HEADS + tl.arange(0, BLK_HEADS) | |
| off = i_b * seq_len * NUM_HEADS + i_s * NUM_HEADS + head_off | |
| mask = head_off < NUM_HEADS | |
| blk_A_log = tl.load(A_log + head_off, mask=mask) | |
| blk_a = tl.load(a + i_b * stride_a + head_off, mask=mask) | |
| blk_b = tl.load(b + i_b * stride_b + head_off, mask=mask) | |
| blk_bias = tl.load(dt_bias + head_off, mask=mask) | |
| x = blk_a.to(tl.float32) + blk_bias.to(tl.float32) | |
| softplus_x = tl.where( | |
| beta * x <= threshold, (1 / beta) * tl.log(1 + tl.exp(beta * x)), x | |
| ) | |
| blk_g = -tl.exp(blk_A_log.to(tl.float32)) * softplus_x | |
| tl.store(g + off, blk_g.to(g.dtype.element_ty), mask=mask) | |
| blk_beta_output = tl.sigmoid(blk_b.to(tl.float32)) | |
| tl.store(beta_output + off, blk_beta_output.to(b.dtype.element_ty), mask=mask) | |
| def fused_gdn_gating( | |
| A_log: torch.Tensor, | |
| a: torch.Tensor, | |
| b: torch.Tensor, | |
| dt_bias: torch.Tensor, | |
| beta: float = 1.0, | |
| threshold: float = 20.0, | |
| ) -> Tuple[torch.Tensor, torch.Tensor]: | |
| batch, num_heads = a.shape | |
| seq_len = 1 | |
| stride_a = a.stride(0) | |
| stride_b = b.stride(0) | |
| grid = (batch, seq_len, triton.cdiv(num_heads, 8)) | |
| g = torch.empty(1, batch, num_heads, dtype=torch.float32, device=a.device) | |
| beta_output = torch.empty(1, batch, num_heads, dtype=torch.float32, device=b.device) | |
| fused_gdn_gating_kernel[grid]( | |
| g, | |
| beta_output, | |
| A_log, | |
| a, | |
| b, | |
| dt_bias, | |
| seq_len, | |
| stride_a, | |
| stride_b, | |
| num_heads, | |
| beta, | |
| threshold, | |
| 8, | |
| num_warps=1, | |
| ) | |
| return g, beta_output | |