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/html_rows.py from Cloudflare/clairic-flash: direct link, hf CLI and curl.
- Browser
- Download file 4.92 kB
-
https://huggingface.co/Cloudflare/clairic-flash/resolve/main/clairic_runtime/html_rows.py
- Command line
-
hf download hf://Cloudflare/clairic-flash/clairic_runtime/html_rows.py
-
curl -L -o html_rows.py https://huggingface.co/Cloudflare/clairic-flash/resolve/main/clairic_runtime/html_rows.py
4.92 kB
| from __future__ import annotations | |
| import re | |
| from html.parser import HTMLParser | |
| from typing import Any | |
| class _Tables(HTMLParser): | |
| def __init__(self, source: str) -> None: | |
| super().__init__(convert_charrefs=True) | |
| self.source = source | |
| self.offsets = [0] | |
| self.offsets.extend((match.end() for match in re.finditer("\n", source))) | |
| self.tables: list[list[dict[str, Any]]] = [] | |
| self.table: list[dict[str, Any]] | None | |
| self.row: list[str] | None | |
| self.cell: list[str] | None | |
| self.cell_tag: str | None | |
| self.cell_parts: list[tuple[str, int]] | None | |
| self.row_spans: list[list[int] | None] | None | |
| self.table = self.row = self.cell = None | |
| self.cell_tag = self.cell_parts = self.row_spans = None | |
| self.row_start: int | None = None | |
| self.depth = 0 | |
| self.invalid = False | |
| def position(self) -> int: | |
| (line, column) = self.getpos() | |
| return self.offsets[line - 1] + column | |
| def handle_starttag( | |
| self, tag: str, attrs: list[tuple[str, str | None]] | dict[str, str | None] | |
| ) -> None: | |
| if tag == "table": | |
| self.depth += 1 | |
| if self.depth != 1: | |
| self.invalid = True | |
| else: | |
| self.table = [] | |
| if not self.depth: | |
| return | |
| attrs = dict(attrs) | |
| if ( | |
| "hidden" in attrs | |
| or (attrs.get("aria-hidden") or "").lower() == "true" | |
| or re.search( | |
| "(?:display\\s*:\\s*none|visibility\\s*:\\s*hidden)", | |
| attrs.get("style") or "", | |
| re.IGNORECASE, | |
| ) | |
| or (tag in ("script", "style")) | |
| ): | |
| self.invalid = True | |
| if tag == "tr": | |
| if self.row is not None or self.cell is not None: | |
| self.invalid = True | |
| (self.row, self.row_start, self.row_spans) = ([], self.position(), []) | |
| elif tag in ("td", "th"): | |
| if self.row is None or self.cell is not None: | |
| self.invalid = True | |
| if attrs.get("rowspan", "1") != "1" or attrs.get("colspan", "1") != "1": | |
| self.invalid = True | |
| (self.cell, self.cell_tag, self.cell_parts) = ([], tag, []) | |
| elif tag in ("br", "p", "div", "ul", "ol", "li") and self.cell is not None: | |
| self.cell.append(" ") | |
| def handle_data(self, data: str) -> None: | |
| if self.cell is not None: | |
| self.cell.append(data) | |
| self.cell_parts.append((data, self.position())) | |
| elif self.row is not None and data.strip(): | |
| self.invalid = True | |
| def handle_endtag(self, tag: str) -> None: | |
| if not self.depth: | |
| return | |
| if tag in ("td", "th"): | |
| if self.cell is None or self.row is None or tag != self.cell_tag: | |
| self.invalid = True | |
| else: | |
| value = re.sub("\\s+", " ", "".join(self.cell)).strip() | |
| self.row.append(value) | |
| matches = [ | |
| position + data.find(value) | |
| for (data, position) in self.cell_parts | |
| if value | |
| and data.count(value) == 1 | |
| and self.source.startswith(value, position + data.find(value)) | |
| ] | |
| self.row_spans.append( | |
| [matches[0], matches[0] + len(value)] if len(matches) == 1 else None | |
| ) | |
| self.cell = self.cell_tag = self.cell_parts = None | |
| elif tag == "tr": | |
| if self.row is None or self.cell is not None or self.table is None: | |
| self.invalid = True | |
| else: | |
| end = self.source.find(">", self.position()) + 1 | |
| self.table.append( | |
| { | |
| "cells": self.row, | |
| "line": self.source[self.row_start : end], | |
| "offset": self.row_start, | |
| "spans": self.row_spans, | |
| } | |
| ) | |
| self.row = self.row_start = self.row_spans = None | |
| elif tag == "table": | |
| if self.depth == 1: | |
| if self.row is not None or self.cell is not None: | |
| self.invalid = True | |
| self.tables.append(self.table) | |
| self.table = None | |
| self.depth -= 1 | |
| elif tag in ("p", "div", "ul", "ol", "li") and self.cell is not None: | |
| self.cell.append(" ") | |
| def tables(source: str) -> list[list[dict[str, Any]]] | None: | |
| parser = _Tables(source) | |
| try: | |
| parser.feed(source) | |
| parser.close() | |
| except (ValueError, TypeError): | |
| return None | |
| if ( | |
| parser.invalid | |
| or parser.depth | |
| or parser.row is not None | |
| or (parser.cell is not None) | |
| ): | |
| return None | |
| return parser.tables | |