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/printed_temporal.py from mlx-community/clairic-4bit: direct link, hf CLI and curl.
- Browser
- Download file 6.45 kB
-
https://huggingface.co/mlx-community/clairic-4bit/resolve/main/clairic_runtime/printed_temporal.py
- Command line
-
hf download hf://mlx-community/clairic-4bit/clairic_runtime/printed_temporal.py
-
curl -L -o printed_temporal.py https://huggingface.co/mlx-community/clairic-4bit/resolve/main/clairic_runtime/printed_temporal.py
6.45 kB
| from __future__ import annotations | |
| import re | |
| from datetime import datetime | |
| from typing import Any | |
| TYPES = ("date", "time", "datetime") | |
| COPY_INSTRUCTION = " Copy only a date or time explicitly printed for this exact requested role. Return null if this role has no printed date or time. Do not use invoice or due dates for service or billing period boundaries. Do not infer a period from its duration. Copy the requested date or time exactly as printed, including AM or PM when present. Preserve every digit. Do not normalize or convert the value. Return null only if the requested value is absent." | |
| _LITERAL = re.compile("\\b(?:print\\w*|explicit\\w*|verbatim|shown)\\b", re.IGNORECASE) | |
| _DERIVED = re.compile( | |
| "\\b(?:calculat\\w*|comput\\w*|deriv\\w*|infer\\w*|after|before|ago|next|previous|following|prior|add|subtract|plus|minus|earlier|later|offset|duration|terms)\\b|\\bnet\\s*\\d+\\b|\\b(?:first|last)\\s+day\\s+of\\b", | |
| re.IGNORECASE, | |
| ) | |
| _DOCUMENT_DATE = re.compile( | |
| "\\b(?:invoice|billing|service|subscription|document|receipt)\\b", re.IGNORECASE | |
| ) | |
| _DATE_ROLES = { | |
| "invoice_date", | |
| "due_date", | |
| "period_start", | |
| "period_end", | |
| "start_date", | |
| "end_date", | |
| } | |
| def explicit_fields(fields: dict[str, dict[str, Any]]) -> dict[str, dict[str, Any]]: | |
| result = dict(fields) | |
| for name, spec in fields.items(): | |
| date_list = spec.get("type") == "list" and spec.get("items") == "date" | |
| if ( | |
| spec.get("type") not in TYPES | |
| and (not date_list) | |
| or "source_only" in spec | |
| or "null_threshold" in spec | |
| or spec.get("knowledge") | |
| ): | |
| continue | |
| instructions = spec.get("instructions", "") | |
| if not isinstance(instructions, str): | |
| continue | |
| role = name.casefold() in _DATE_ROLES and _DOCUMENT_DATE.search(instructions) | |
| if (_LITERAL.search(instructions) or role) and ( | |
| not _DERIVED.search(instructions) | |
| ): | |
| result[name] = {**spec, "source_only": True} | |
| return result | |
| def clock(value: str) -> str: | |
| match = re.fullmatch( | |
| "\\s*(\\d{1,2}):(\\d{2})(?::(\\d{2}))?\\s*([AP]\\.?M\\.?)?\\s*", | |
| value, | |
| re.IGNORECASE, | |
| ) | |
| if match is None: | |
| raise ValueError("Unsupported printed time") | |
| (hour, minute, second) = map(int, (match[1], match[2], match[3] or "0")) | |
| meridiem = match[4] | |
| if meridiem: | |
| if not 1 <= hour <= 12: | |
| raise ValueError("Invalid 12-hour clock") | |
| hour = hour % 12 + (12 if meridiem.replace(".", "").upper() == "PM" else 0) | |
| if not 0 <= hour < 24 or not 0 <= minute < 60 or (not 0 <= second < 60): | |
| raise ValueError("Invalid printed time") | |
| return f"{hour:02}:{minute:02}:{second:02}" | |
| def day(value: str) -> str: | |
| value = value.strip() | |
| for fmt in ( | |
| "%Y-%m-%d", | |
| "%Y/%m/%d", | |
| "%Y.%m.%d", | |
| "%B %d, %Y", | |
| "%b %d, %Y", | |
| "%B %d %Y", | |
| "%b %d %Y", | |
| "%d %B %Y", | |
| "%d %b %Y", | |
| ): | |
| try: | |
| return datetime.strptime(value, fmt).date().isoformat() | |
| except ValueError: | |
| pass | |
| numeric = re.fullmatch("(\\d{1,2})([-/.])(\\d{1,2})\\2(\\d{4})", value) | |
| if numeric: | |
| (first, second, year) = (int(numeric[1]), int(numeric[3]), int(numeric[4])) | |
| readings = set() | |
| for month, date in ((first, second), (second, first)): | |
| try: | |
| readings.add(datetime(year, month, date).date().isoformat()) | |
| except ValueError: | |
| pass | |
| if len(readings) == 1: | |
| return readings.pop() | |
| raise ValueError("Unsupported or ambiguous printed date") | |
| def normalize(value: object, kind: str) -> str | None: | |
| if value is None: | |
| return None | |
| if not isinstance(value, str): | |
| raise TypeError("A printed temporal answer must be a string") | |
| if kind == "time": | |
| return clock(value) | |
| if kind == "date": | |
| return day(value) | |
| if kind == "datetime": | |
| match = re.fullmatch( | |
| "(.+?)(?:T|\\s+(?:at\\s+)?)(\\d{1,2}:\\d{2}(?::\\d{2})?\\s*(?:[AP]\\.?M\\.?)?)", | |
| value.strip(), | |
| re.IGNORECASE, | |
| ) | |
| if match is None: | |
| raise ValueError("Unsupported printed datetime") | |
| return day(match[1]) + "T" + clock(match[2]) | |
| raise ValueError("Unsupported temporal type") | |
| def prepare( | |
| fields: dict[str, dict[str, Any]], | |
| ) -> tuple[dict[str, dict[str, Any]], dict[str, str]]: | |
| fields = {name: dict(spec) for (name, spec) in fields.items()} | |
| kinds = {} | |
| for name, spec in fields.items(): | |
| if not spec.get("source_only"): | |
| continue | |
| if spec["type"] == "list" and spec["items"] == "date": | |
| spec["items"] = "text" | |
| spec["instructions"] = spec.get("instructions", "") + COPY_INSTRUCTION | |
| continue | |
| kind = spec["type"] | |
| if kind not in TYPES: | |
| continue | |
| kinds[name] = kind | |
| fields[name] = { | |
| "type": "text", | |
| "nullable": spec.get("nullable", True), | |
| "instructions": spec.get("instructions", "") + COPY_INSTRUCTION, | |
| } | |
| return (fields, kinds) | |
| def normalize_predictions( | |
| record: dict[str, Any], predictions: dict[str, dict[str, Any]] | |
| ) -> dict[str, dict[str, Any]]: | |
| result = dict(predictions) | |
| for name, kind in record.get("_meta", {}).get("printed_temporal", {}).items(): | |
| answer = dict(result[name]) | |
| result[name] = answer | |
| if not answer.get("valid"): | |
| continue | |
| printed = answer["value"] | |
| answer["printed_value"] = printed | |
| if ( | |
| printed is not None | |
| and (not record.get("_media_payload")) | |
| and (not isinstance(printed, str) or printed not in record["input"]) | |
| ): | |
| answer.update( | |
| value=None, | |
| valid=False, | |
| confidence=0.0, | |
| span=None, | |
| failure_reason="not_in_source", | |
| ) | |
| continue | |
| try: | |
| answer["value"] = normalize(printed, kind) | |
| answer["normalization_method"] = "printed_temporal_v1" | |
| except (TypeError, ValueError): | |
| answer.update( | |
| value=None, | |
| valid=False, | |
| confidence=0.0, | |
| failure_reason="invalid_printed_temporal", | |
| ) | |
| return result | |