Image-Text-to-Text
MLX
Safetensors
qwen3_5
clairic
cloudflare
systemone
structured-output
information-extraction
multimodal
custom-code
conversational
4-bit precision
Instructions to use mlx-community/clairic-4bit with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use mlx-community/clairic-4bit with MLX:
# Make sure mlx-vlm is installed # pip install --upgrade mlx-vlm from mlx_vlm import load, generate from mlx_vlm.prompt_utils import apply_chat_template from mlx_vlm.utils import load_config # Load the model model, processor = load("mlx-community/clairic-4bit") config = load_config("mlx-community/clairic-4bit") # Prepare input image = ["http://images.cocodataset.org/val2017/000000039769.jpg"] prompt = "Describe this image." # Apply chat template formatted_prompt = apply_chat_template( processor, config, prompt, num_images=1 ) # Generate output output = generate(model, processor, formatted_prompt, image) print(output) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- LM Studio
- Pi
How to use mlx-community/clairic-4bit with Pi:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "mlx-community/clairic-4bit"
Configure the model in Pi
# Install Pi: npm install -g @earendil-works/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "mlx-lm": { "baseUrl": "http://localhost:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "mlx-community/clairic-4bit" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Hermes Agent
How to use mlx-community/clairic-4bit with Hermes Agent:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "mlx-community/clairic-4bit"
Configure Hermes
# Install Hermes: curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash hermes setup # Point Hermes at the local server: hermes config set model.provider custom hermes config set model.base_url http://127.0.0.1:8080/v1 hermes config set model.default mlx-community/clairic-4bit
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use mlx-community/clairic-4bit with OpenClaw:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "mlx-community/clairic-4bit"
Configure OpenClaw
# Install OpenClaw: npm install -g openclaw@latest # Register the local server and set it as the default model: openclaw onboard --non-interactive --mode local \ --auth-choice custom-api-key \ --custom-base-url http://127.0.0.1:8080/v1 \ --custom-model-id "mlx-community/clairic-4bit" \ --custom-provider-id mlx-lm \ --custom-compatibility openai \ --custom-text-input \ --accept-risk \ --skip-health
Run OpenClaw
openclaw agent --local --agent main --message "Hello from Hugging Face"
File size: 8,114 Bytes
1a48d6b | 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 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 | from __future__ import annotations
from typing import TYPE_CHECKING
from . import media_state_prompt, po_image_supplement, text_ar, text_list_completion
from . import grounding, identifier_spelling
from .backend import ClairicFlashModel
from .media import media_warmup_groups
if TYPE_CHECKING:
from typing import Any
from .api import PredictRequest
from .backend import EncodedRequest
class Clairic27BModel(ClairicFlashModel):
RELEASE_MODEL_ID = "clairic-27b"
COMPACT_LIST_PROMPTS = False
DATE_ROLE_GUIDANCE = False
SOURCE_ROW_ELIGIBILITY = True
FINANCIAL_SERVICE_GUIDANCE = False
FINANCIAL_FEE_GUIDANCE = True
SPELL_VISUAL_PO_REFERENCES = True
FOCUS_SPARSE_IMAGES = False
PRESERVE_IMAGE_ENTITY_NAMES = True
FOCUS_IMAGE_PARTY_NAMES = False
LITERAL_IMAGE_PAYMENT_ROWS = True
BIND_IMAGE_FINANCIAL_LINES = False
IMAGE_TABLE_ROW_SCALE = 4
BIND_IMAGE_RAGGED_ROWS = False
def encode(self, request: PredictRequest, **options: Any) -> EncodedRequest:
supplement_disabled = options.pop("po_supplement_disabled", False)
encoded = self._encode_without_po_supplement(request, **options)
detail = any(
(
options.get(name)
for name in (
"identifier_view",
"party_name_view",
"physical_row_view",
"identifier_spelling_disabled",
"pdf_spelling_view",
"po_detail_view",
)
)
)
if (
type(self) is not Clairic27BModel
or supplement_disabled
or detail
or (not po_image_supplement.selected_fields(request, encoded))
):
return encoded
if (
self.settings.model_id != "clairic-27b"
or self.max_concurrency != self.settings.max_concurrency
or self.max_concurrency != 1
):
return encoded
return po_image_supplement.prepare(
request,
encoded,
encode_child=lambda child: self.encode(child, po_supplement_disabled=True),
tokenizer=self.tokenizer,
max_length=self.settings.max_length,
media_groups=media_warmup_groups,
)
def _encode_without_po_supplement(
self, request: PredictRequest, **options: Any
) -> EncodedRequest:
detail = any(
(
options.get(name)
for name in (
"identifier_view",
"party_name_view",
"physical_row_view",
"identifier_spelling_disabled",
"pdf_spelling_view",
"po_detail_view",
)
)
)
if type(self) is Clairic27BModel and options.get("po_detail_view"):
options = {**options, "pdf_spelling_view": True}
encoded = super().encode(request, **options)
if type(self) is not Clairic27BModel or detail:
return encoded
(record, forecasts, tasks, typed, eos) = encoded
active = {name for (name, _, _) in tasks}
contracts = record.get("_meta", {}).get("identifier_spelling", {})
po_fields = {
name: request.fields[name]
for (name, contract) in contracts.items()
if name in active
and contract.get("wire") == identifier_spelling.VERSION
and (len(request.images) in (1, 2))
and (not request.documents)
}
number_fields = {
name: spec
for (name, spec) in request.fields.items()
if name in active
and spec.get("type") == "number"
and (spec.get("source_only") is True)
and (not spec.get("knowledge"))
and (not grounding.state_only(spec))
and (len(request.images) > 1 or request.documents)
}
selected = {**po_fields, **number_fields}
if not selected:
return encoded
originals = record.get("_original_images", ())
if len(originals) < len(request.images) or (
not request.documents and len(originals) != len(request.images)
):
raise ValueError(
"27B scalar detail must retain every original image in order"
)
(child, _, replacements, child_typed, child_eos) = super().encode(
request.model_copy(update={"fields": selected}),
identifier_view=True,
pdf_spelling_view=True,
image_views=lambda: originals,
image_view_key="27b-literal-scalars-all-content2-v1",
)
if child_typed is not None or child_eos != eos:
raise ValueError(
"27B scalar detail must retain the original scalar AR contract"
)
by_name = {task[0]: task for task in replacements}
if set(by_name) != set(selected) or len(replacements) != len(selected):
raise ValueError(
"27B scalar detail tasks differ from selected public fields"
)
updated = [by_name.get(task[0], task) for task in tasks]
salts = dict(record.get("_ar_task_salts", {}))
for name in selected:
record["fields"][name] = child["fields"][name]
record["_ar_constraints"][name] = child["_ar_constraints"][name]
salts[name] = child["_cache_salt"]
record["_meta"]["model_document_scalar_view"] = {
"version": "27b-literal-scalars-all-content2-v1",
"fields": list(selected),
"po_fields": list(po_fields),
"number_fields": list(number_fields),
"image_count": len(originals),
}
record.update(
_ar_tasks=updated,
_ar_task_salts=salts,
_ar_prefix=[],
_ar_group_prefixes=[],
)
record["_ar_media_groups"] = media_warmup_groups(
updated,
default_salt=record["_cache_salt"],
task_salts=salts,
annotations=record["_meta"]["extraction_contract"]["fields"],
)
return (record, forecasts, updated, typed, eos)
def _encode_request(self, request: PredictRequest) -> EncodedRequest:
encoded = super()._encode_request(request)
if (
type(self) is Clairic27BModel
and self.settings.model_id == "clairic-27b"
and (self.max_concurrency == self.settings.max_concurrency == 1)
and bool(
getattr(request, "images", ()) or getattr(request, "documents", ())
)
):
encoded[0]["_first_item_list_gating"] = True
fallback = encoded[0].get("_identifier_spelling_fallback")
if fallback is not None:
fallback["_first_item_list_gating"] = True
encoded = media_state_prompt.prepare(
request,
encoded,
tokenizer=self.tokenizer,
max_length=self.settings.max_length,
media_groups=media_warmup_groups,
)
return encoded
async def _ar_all(
self, record: dict[str, Any], eos: int
) -> dict[str, dict[str, Any]]:
caller_record = record
if len(record["_ar_tasks"]) < 64 and (not record.get("_media_payload")):
record = {**record, "_ar_prefix": None, "_ar_group_prefixes": []}
if (
type(self) is Clairic27BModel
and self.settings.model_id == "clairic-27b"
and (self.max_concurrency == self.settings.max_concurrency == 1)
and text_list_completion.eligible(record, record["_ar_tasks"])
):
predictions = await text_ar.text_ar_all(self, record, eos)
if record is not caller_record:
caller_record["_unexecuted_list_items"] = record[
"_unexecuted_list_items"
]
return predictions
return await super()._ar_all(record, eos)
|