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/lists.py from Cloudflare/clairic-flash: direct link, hf CLI and curl.
- Browser
- Download file 2.02 kB
-
https://huggingface.co/Cloudflare/clairic-flash/resolve/main/clairic_runtime/lists.py
- Command line
-
hf download hf://Cloudflare/clairic-flash/clairic_runtime/lists.py
-
curl -L -o lists.py https://huggingface.co/Cloudflare/clairic-flash/resolve/main/clairic_runtime/lists.py
2.02 kB
| from __future__ import annotations | |
| import re | |
| from typing import Any | |
| _CHAR_LIST_REQUEST = re.compile( | |
| "\\b(?:(?:extract|list|return|split|read)\\s+(?:(?:the|of)\\s+)?|(?:each|every|all|individual|separate)\\s+)(?:(?:single|individual)\\s+)?(?:characters?|letters?|digits?|symbols?)\\b", | |
| re.IGNORECASE, | |
| ) | |
| class RejectRecord(ValueError): | |
| def __init__(self, reason: str, field: str | None = None) -> None: | |
| (self.reason, self.field) = (reason, field) | |
| super().__init__(reason + (f": {field}" if field else "")) | |
| def list_query_budget(text: str, spec: dict[str, Any]) -> tuple[int, str]: | |
| maximum = spec.get("max_items") | |
| if maximum is not None: | |
| if isinstance(maximum, bool) or not isinstance(maximum, int) or maximum < 0: | |
| raise RejectRecord("invalid_explicit_list_budget") | |
| return (maximum + 1, "request_max_items") | |
| instructions = str(spec.get("instructions", "")) | |
| for match in _CHAR_LIST_REQUEST.finditer(instructions): | |
| if not re.search( | |
| "\\b(?:preserv\\w*|keep|retain\\w*|including|with)\\s*$", | |
| instructions[max(0, match.start() - 25) : match.start()], | |
| re.IGNORECASE, | |
| ): | |
| return (sum((not char.isspace() for char in text)) + 1, "source_characters") | |
| lines = [line for line in text.splitlines() if line.strip()] | |
| row_list = bool( | |
| re.search( | |
| "\\b(?:rows?|top to bottom|line items?|item lines?|receipt order|printed row order)\\b", | |
| instructions, | |
| re.IGNORECASE, | |
| ) | |
| or ( | |
| re.search("\\b(?:receipt|invoice|table)\\b", instructions, re.IGNORECASE) | |
| and re.search( | |
| "\\b(?:items?|products?|quantit\\w*|prices?|amounts?|names?)\\b", | |
| instructions, | |
| re.IGNORECASE, | |
| ) | |
| ) | |
| ) | |
| if row_list and len(lines) > 1: | |
| return (len(lines) + 1, "nonblank_source_lines") | |
| return (len(re.findall("\\w+|[^\\w\\s]", text)) + 1, "source_lexical_units") | |