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: 7,501 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 | """Recover unresolved image rows backed by a completed row inventory."""
from copy import deepcopy
import json
from typing import Any
from . import ar, image_rows
from .schema import MAX_LIST_ITEMS
def prepare(
record: dict[str, Any], predictions: dict[str, dict[str, Any]]
) -> tuple[dict[str, Any], list[dict[str, Any]]] | None:
if record.get("_null_recovery") or record.get("_row_omission_recovery"):
return None
annotations = (
record.get("_meta", {}).get("extraction_contract", {}).get("fields", {})
)
tasks = {name: (name, ids, media) for name, ids, media in record["_ar_tasks"]}
if len(tasks) != len(record["_ar_tasks"]):
return None
contexts, retry_tasks = [], []
constraints = dict(record.get("_ar_constraints", {}))
for parent, annotation in annotations.items():
queries = annotation.get("image_row_fields")
spec, inventory = record["fields"].get(parent, {}), predictions.get(parent, {})
value = inventory.get("value")
if (
set(annotation) != {"image_row_fields"}
or not isinstance(queries, list)
or len(queries) != len(set(queries))
or not queries
or not image_rows.is_inventory(spec)
or spec.get("knowledge")
or not inventory.get("valid")
or not inventory.get("complete")
or not isinstance(value, list)
or not value
or len(value) > min(spec.get("max_items", MAX_LIST_ITEMS), len(queries))
or any(
not isinstance(row, dict)
or set(row) != {"label"}
or not isinstance(row["label"], str)
or not row["label"].strip()
for row in value
)
or any(child not in predictions for child in queries)
):
continue
properties = spec.get("items", {}).get("properties", {})
text_keys = [
key
for key, child in properties.items()
if child.get("type") == "text" and not child.get("knowledge")
]
if not text_keys:
continue
labels = [row["label"] for row in value]
proposals = [predictions[child] for child in queries]
selected, conflicts = image_rows._select(labels, proposals, text_keys)
if not conflicts or any(
row is not None and (not row.get("valid") or not row.get("complete"))
for row in selected
):
continue
children, local_constraints = [], {}
for index in conflicts:
child = queries[index]
row, child_spec = predictions[child], record["fields"].get(child, {})
row_value = row.get("value")
task = tasks.get(child)
native = constraints.get(child, {})
if (
annotations.get(child) != {"parent": parent, "index": index + 1}
or child_spec.get("type") != "object"
or not child_spec.get("_image_row_proposal")
or child_spec.get("knowledge")
or not row.get("valid")
or not row.get("complete")
or not isinstance(row_value, dict)
or not row_value
or any(cell is not None for cell in row_value.values())
or any(row is previous for previous in selected if previous is not None)
or task is None
or task[2] is None
or set(native) != {"json_schema"}
):
break
schema = json.loads(native["json_schema"])
if schema != ar.schema(child_spec) or not set(text_keys) <= set(
schema.get("properties", {})
):
break
# A completed inventory requires a matching textual cell; the
# original selector remains the acceptance test for that label.
# Full branches retain required fields with the native grammar compiler.
branches = []
for key in text_keys:
branch = deepcopy(schema)
branch["properties"][key]["type"] = "string"
branches.append(branch)
local_constraints[child] = {"json_schema": json.dumps({"anyOf": branches})}
children.append(child)
else:
constraints.update(local_constraints)
retry_tasks.extend(tasks[child] for child in children)
contexts.append(
{
"parent": parent,
"queries": queries,
"labels": labels,
"text_keys": text_keys,
"selected": selected,
"conflicts": conflicts,
"children": children,
}
)
if not retry_tasks:
return None
repair = {
**record,
"_ar_tasks": retry_tasks,
"_ar_constraints": constraints,
"_ar_prefix": None,
"_ar_group_prefixes": [],
"_ar_media_groups": [],
"_null_recovery": True,
"_row_omission_recovery": True,
}
return repair, contexts
def merge(
record: dict[str, Any],
predictions: dict[str, dict[str, Any]],
alternatives: dict[str, dict[str, Any]],
plan: tuple[dict[str, Any], list[dict[str, Any]]],
) -> tuple[dict[str, dict[str, Any]], list[dict[str, Any]]]:
repair, contexts = plan
lengths = {name: len(ids) for name, ids, _ in repair["_ar_tasks"]}
result = dict(predictions)
evidence = []
for context in contexts:
candidates = {}
for child in context["children"]:
original, alternative = predictions[child], alternatives.get(child, {})
account = {
"tokens": original["tokens"] + alternative.get("tokens", 0),
"retry_input_tokens": original.get("retry_input_tokens", 0)
+ lengths[child],
}
result[child] = {**original, **account}
value = alternative.get("value")
if (
alternative.get("valid")
and alternative.get("complete")
and isinstance(value, dict)
and any(cell is not None for cell in value.values())
):
candidates[child] = {
**alternative,
**account,
"image_row_omission_recovered": True,
}
trial = {**result, **candidates}
selected, conflicts = image_rows._select(
context["labels"],
[trial[name] for name in context["queries"]],
context["text_keys"],
)
unchanged = all(
previous is None or selected[index] is previous
for index, previous in enumerate(context["selected"])
)
accepted = (
not conflicts and unchanged and len(candidates) == len(context["children"])
)
if accepted:
result.update(candidates)
evidence.append(
{
"parent": context["parent"],
"original_conflicts": context["conflicts"],
"retry_children": context["children"],
"conflicts_after_retry": conflicts,
"previously_matched_proposals_preserved_exactly": unchanged,
"accepted": accepted,
}
)
return result, evidence
|