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
File size: 4,070 Bytes
f65336d | 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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | from __future__ import annotations
import re
from typing import Any
TAX_INSTRUCTION = " A separately printed tax row is present even when its amount is zero or negative, including a tax refund. Copy every matching printed tax row. Do not return null or end the list while a matching printed tax row remains."
FEE_INSTRUCTION = " A separately printed fee or surcharge row is present even when its amount is zero or negative, including a fee refund. Copy every matching printed fee or surcharge row. Do not return null or end the list while a matching printed fee or surcharge row remains."
SERVICE_INSTRUCTION = " Use the row's own printed label. Include an ordinary billed product or service charge. Exclude a row whose own label identifies it as a separately printed tax, fee, surcharge, subtotal, total or payment. A neighboring fee or tax does not exclude an otherwise eligible service row."
def prepare(
fields: dict[str, dict[str, Any]],
*,
has_media: bool = False,
fee_guidance: bool = False,
service_guidance: bool = False,
) -> dict[str, dict[str, Any]]:
if has_media:
return fields
result = dict(fields)
for name, spec in fields.items():
item = spec.get("items")
instructions = spec.get("instructions", "")
if (
spec.get("type") != "list"
or not isinstance(item, dict)
or item.get("type") != "object"
or (not isinstance(instructions, str))
or (not isinstance(item.get("properties"), dict))
):
continue
properties = list(item["properties"].values())
if (
len(properties) != 2
or not all((isinstance(child, dict) for child in properties))
or sum((child.get("type") == "number" for child in properties)) != 1
or (sum((child.get("type") == "text" for child in properties)) != 1)
or spec.get("knowledge")
or any((child.get("knowledge") for child in properties))
):
continue
positive = re.split(
"[.\\n]|\\bExclude\\b", instructions, maxsplit=1, flags=re.IGNORECASE
)[0]
if re.match(
"\\s*Only\\b[^.\\n]*\\btax(?:es)?\\b[^.\\n]*\\brows\\b",
positive,
re.IGNORECASE,
) and (
not re.search(
"\\b(?:fees?|products?|services?|goods|summar\\w*|calculat\\w*|group\\w*)\\b",
positive,
re.IGNORECASE,
)
):
result[name] = {**spec, "instructions": instructions + TAX_INSTRUCTION}
elif (
fee_guidance
and re.match(
"\\s*Only\\b[^.\\n]*\\bfees?\\b[^.\\n]*\\brows\\b",
positive,
re.IGNORECASE,
)
and (
not re.search(
"\\b(?:tax(?:es)?|products?|services?|goods|summar\\w*|calculat\\w*|group\\w*|deduplicat\\w*|aggregat\\w*|combin\\w*|normaliz\\w*)\\b",
positive,
re.IGNORECASE,
)
)
):
result[name] = {**spec, "instructions": instructions + FEE_INSTRUCTION}
elif (
service_guidance
and re.match(
"\\s*Only\\s+billed\\b[^.\\n]*\\brows\\b", positive, re.IGNORECASE
)
and re.search(
"\\b(?:goods|products?|services?)\\b", positive, re.IGNORECASE
)
and (
not re.search(
"\\b(?:tax(?:es)?|fees?|surcharges?|summar\\w*|calculat\\w*|group\\w*|deduplicat\\w*|aggregat\\w*|combin\\w*|normaliz\\w*)\\b",
positive,
re.IGNORECASE,
)
)
and re.search(
"\\bExclude\\b[^.\\n]*\\b(?:fees?|surcharges?)\\b",
instructions,
re.IGNORECASE,
)
):
result[name] = {**spec, "instructions": instructions + SERVICE_INSTRUCTION}
return result
|