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"
Download clairic_runtime/image_party_names.py from mlx-community/clairic-4bit: direct link, hf CLI and curl.
- Browser
- Download file 2.68 kB
-
https://huggingface.co/mlx-community/clairic-4bit/resolve/main/clairic_runtime/image_party_names.py
- Command line
-
hf download hf://mlx-community/clairic-4bit/clairic_runtime/image_party_names.py
-
curl -L -o image_party_names.py https://huggingface.co/mlx-community/clairic-4bit/resolve/main/clairic_runtime/image_party_names.py
2.68 kB
| from __future__ import annotations | |
| import math | |
| import re | |
| from typing import Any | |
| import numpy as np | |
| from PIL import Image, ImageChops | |
| VIEW_ID = "party-name-header-lines-v1" | |
| VIEW_INSTRUCTION = " The first image is the complete document. The second image enlarges its first printed lines. Use both views of the same source to read the complete requested name; preserve every digit in the name." | |
| _ROLE = re.compile( | |
| "\\b(?:seller|merchant|vendor|customer|bill[- ]?to|recipient|payee|payer|guest|organization|business|company|legal)\\b", | |
| re.IGNORECASE, | |
| ) | |
| _OTHER_VALUE = re.compile( | |
| "\\b(?:address|number|identifier|code|date|row|label|amount)\\b", re.IGNORECASE | |
| ) | |
| def fields(schema: dict[str, dict[str, Any]]) -> list[str]: | |
| selected = [] | |
| for name, spec in schema.items(): | |
| instructions = spec.get("instructions", "") | |
| if ( | |
| spec.get("type") != "text" | |
| or spec.get("knowledge") | |
| or (not isinstance(instructions, str)) | |
| ): | |
| continue | |
| requested = re.split("[.\\n]", instructions, maxsplit=1)[0] | |
| if ( | |
| re.search("\\bname\\b", requested, re.IGNORECASE) | |
| and _ROLE.search(requested) | |
| and (not _OTHER_VALUE.search(requested)) | |
| ): | |
| selected.append(name) | |
| return selected | |
| def header_detail( | |
| image: Image.Image, *, max_pixels: int = 1600000 | |
| ) -> Image.Image | None: | |
| if image.mode != "RGB" or image.getpixel((0, 0)) != (255, 255, 255): | |
| return None | |
| ink = np.asarray(image.convert("L")) < 200 | |
| if np.mean(ink) > 0.22: | |
| return None | |
| edges = np.flatnonzero(np.diff(np.pad(ink.any(axis=1).astype(np.int8), (1, 1)))) | |
| bands = edges.reshape(-1, 2).tolist()[:6] | |
| if not bands or any((not 8 <= bottom - top <= 32 for (top, bottom) in bands)): | |
| return None | |
| top = max(0, bands[0][0] - 24) | |
| bottom = min(image.height, bands[-1][1] + 24) | |
| block = image.crop((0, top, image.width, bottom)) | |
| bounds = ImageChops.difference( | |
| block, Image.new("RGB", block.size, "white") | |
| ).getbbox() | |
| if bounds is None: | |
| return None | |
| (left, right) = (max(0, bounds[0] - 24), min(block.width, bounds[2] + 24)) | |
| block = block.crop((left, 0, right, block.height)) | |
| scale = min(3.0, math.sqrt(max_pixels / (block.width * block.height))) | |
| size = (max(1, int(block.width * scale)), max(1, int(block.height * scale))) | |
| return block.resize(size, Image.Resampling.BICUBIC) | |
| def views(image: Image.Image, *, max_pixels: int = 1600000) -> tuple[Image.Image, ...]: | |
| detail = header_detail(image, max_pixels=max_pixels) | |
| return (image, detail) if detail is not None else (image,) | |