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
Clarify base model and System One extraction usage
Browse files- README.md +3 -8
- clairic_model.py +4 -4
README.md
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
---
|
| 2 |
license: apache-2.0
|
| 3 |
library_name: transformers
|
|
|
|
| 4 |
pipeline_tag: image-text-to-text
|
| 5 |
tags:
|
| 6 |
- clairic
|
|
@@ -24,6 +25,7 @@ in the Clairic family.
|
|
| 24 |
|
| 25 |
## Model
|
| 26 |
|
|
|
|
| 27 |
- **Inputs:** a text or JSON state, optional images, and a mapping of field names to specifications.
|
| 28 |
- **Outputs:** typed values, lists, nulls, estimates, and forecast paths.
|
| 29 |
- **Scoring:** extraction confidence and null probabilities, plus optional quantiles for estimates.
|
|
@@ -35,15 +37,8 @@ Use Python 3.11 or later and install the packages listed in `requirements.txt`.
|
|
| 35 |
Transformers; `xgrammar` supplies schema constraints through a Transformers logits
|
| 36 |
processor.
|
| 37 |
|
| 38 |
-
The supported GPU setup is Linux x86_64 with an H100 or H200, PyTorch 2.13.0
|
| 39 |
-
with CUDA 13.0, and Transformers 5.10.2. The CUDA BF16 default uses FlashAttention 3
|
| 40 |
-
for text and vision, with batches of up to 32 sequences. The first load fetches
|
| 41 |
-
the pinned attention kernel through `kernels`; cache it before running offline.
|
| 42 |
-
Explicit `attn_implementation`, `batch_size`, and `text_batch_size` loader options
|
| 43 |
-
remain available.
|
| 44 |
-
|
| 45 |
Download the repository, load the model and processor, and call `systemone` with a
|
| 46 |
-
System One:
|
| 47 |
|
| 48 |
```python
|
| 49 |
import sys
|
|
|
|
| 1 |
---
|
| 2 |
license: apache-2.0
|
| 3 |
library_name: transformers
|
| 4 |
+
base_model: Qwen/Qwen3.8-27B
|
| 5 |
pipeline_tag: image-text-to-text
|
| 6 |
tags:
|
| 7 |
- clairic
|
|
|
|
| 25 |
|
| 26 |
## Model
|
| 27 |
|
| 28 |
+
- **Base model:** [Qwen3.8-27B](https://huggingface.co/Qwen/Qwen3.8-27B).
|
| 29 |
- **Inputs:** a text or JSON state, optional images, and a mapping of field names to specifications.
|
| 30 |
- **Outputs:** typed values, lists, nulls, estimates, and forecast paths.
|
| 31 |
- **Scoring:** extraction confidence and null probabilities, plus optional quantiles for estimates.
|
|
|
|
| 37 |
Transformers; `xgrammar` supplies schema constraints through a Transformers logits
|
| 38 |
processor.
|
| 39 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
Download the repository, load the model and processor, and call `systemone` with a
|
| 41 |
+
System One: Extract request.
|
| 42 |
|
| 43 |
```python
|
| 44 |
import sys
|
clairic_model.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
"""Clairic's Transformers loader and System One
|
| 2 |
|
| 3 |
from __future__ import annotations
|
| 4 |
|
|
@@ -41,7 +41,7 @@ def _request(value: Mapping[str, Any] | PredictRequest) -> PredictRequest:
|
|
| 41 |
|
| 42 |
|
| 43 |
class ClairicModel:
|
| 44 |
-
"""A model and its typed
|
| 45 |
|
| 46 |
def __init__(self, runtime: ClairicFlashModel, public_name: str) -> None:
|
| 47 |
self.runtime = runtime
|
|
@@ -65,7 +65,7 @@ class ClairicModel:
|
|
| 65 |
return serialize_response(validated, output, self.model_id)
|
| 66 |
|
| 67 |
def predict(self, request: Mapping[str, Any] | PredictRequest) -> dict[str, Any]:
|
| 68 |
-
"""Return structured values and scores for a
|
| 69 |
try:
|
| 70 |
asyncio.get_running_loop()
|
| 71 |
except RuntimeError:
|
|
@@ -121,7 +121,7 @@ def systemone(
|
|
| 121 |
request: Mapping[str, Any] | PredictRequest,
|
| 122 |
max_length: int | None = None,
|
| 123 |
) -> dict[str, Any]:
|
| 124 |
-
"""Answer a System One
|
| 125 |
if processor is not model.processor:
|
| 126 |
raise ValueError("Use the processor returned with this model")
|
| 127 |
if max_length is not None and max_length != model.runtime.settings.max_length:
|
|
|
|
| 1 |
+
"""Clairic's Transformers loader and System One extraction interface."""
|
| 2 |
|
| 3 |
from __future__ import annotations
|
| 4 |
|
|
|
|
| 41 |
|
| 42 |
|
| 43 |
class ClairicModel:
|
| 44 |
+
"""A model and its typed extraction head, with synchronous and async APIs."""
|
| 45 |
|
| 46 |
def __init__(self, runtime: ClairicFlashModel, public_name: str) -> None:
|
| 47 |
self.runtime = runtime
|
|
|
|
| 65 |
return serialize_response(validated, output, self.model_id)
|
| 66 |
|
| 67 |
def predict(self, request: Mapping[str, Any] | PredictRequest) -> dict[str, Any]:
|
| 68 |
+
"""Return structured values and scores for a System One: Extract request."""
|
| 69 |
try:
|
| 70 |
asyncio.get_running_loop()
|
| 71 |
except RuntimeError:
|
|
|
|
| 121 |
request: Mapping[str, Any] | PredictRequest,
|
| 122 |
max_length: int | None = None,
|
| 123 |
) -> dict[str, Any]:
|
| 124 |
+
"""Answer a System One: Extract request with typed fields and confidence."""
|
| 125 |
if processor is not model.processor:
|
| 126 |
raise ValueError("Use the processor returned with this model")
|
| 127 |
if max_length is not None and max_length != model.runtime.settings.max_length:
|