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-flash-4bit with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use mlx-community/clairic-flash-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-flash-4bit") config = load_config("mlx-community/clairic-flash-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-flash-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-flash-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-flash-4bit" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Hermes Agent
How to use mlx-community/clairic-flash-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-flash-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-flash-4bit
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use mlx-community/clairic-flash-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-flash-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-flash-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/media_state_prompt.py from mlx-community/clairic-flash-4bit: direct link, hf CLI and curl.
- Browser
- Download file 4.47 kB
-
https://huggingface.co/mlx-community/clairic-flash-4bit/resolve/main/clairic_runtime/media_state_prompt.py
- Command line
-
hf download hf://mlx-community/clairic-flash-4bit/clairic_runtime/media_state_prompt.py
-
curl -L -o media_state_prompt.py https://huggingface.co/mlx-community/clairic-flash-4bit/resolve/main/clairic_runtime/media_state_prompt.py
4.47 kB
| from __future__ import annotations | |
| from typing import TYPE_CHECKING | |
| if TYPE_CHECKING: | |
| from collections.abc import Callable | |
| from typing import Any | |
| from .api import PredictRequest | |
| from .backend import ARTask, EncodedRequest | |
| from transformers import PreTrainedTokenizerBase | |
| def eligible(request: PredictRequest) -> bool: | |
| if not request.state or not (request.images or request.documents): | |
| return False | |
| if len(request.images) > 1: | |
| return True | |
| from . import grounding | |
| return any( | |
| ( | |
| spec.get("type") == "boolean" | |
| and (not spec.get("knowledge")) | |
| and (not grounding.state_only(spec)) | |
| for spec in request.fields.values() | |
| ) | |
| ) | |
| def rewrite_media_evidence( | |
| task: ARTask, | |
| *, | |
| record: dict[str, Any], | |
| tokenizer: PreTrainedTokenizerBase, | |
| max_length: int, | |
| ) -> ARTask: | |
| from . import ar | |
| (name, ids, media) = task | |
| if media is None: | |
| raise ValueError("Media evidence guidance requires actual task media") | |
| source_ids = list(ids) | |
| text = tokenizer.decode( | |
| ids, skip_special_tokens=False, clean_up_tokenization_spaces=False | |
| ) | |
| if tokenizer.encode(text, add_special_tokens=False) != source_ids: | |
| raise ValueError( | |
| "Media evidence prompt must make a lossless tokenizer roundtrip" | |
| ) | |
| instruction = ar.instruction(record, name, compact_lists=False).rstrip() | |
| boundary = instruction + "\n\nDocument:\n" | |
| existing = ( | |
| ar.MEDIA_EVIDENCE_INSTRUCTION | |
| + "\n\n" | |
| + instruction | |
| + "\n\nAccompanying text:\n" | |
| ) | |
| if text.count(existing) == 1: | |
| return task | |
| if text.count(boundary) != 1 or ar.MEDIA_EVIDENCE_INSTRUCTION in text: | |
| raise ValueError( | |
| "Expected exactly one original instruction and accompanying-state boundary" | |
| ) | |
| revised = text.replace(boundary, existing) | |
| revised_ids = tokenizer.encode(revised, add_special_tokens=False) | |
| if ( | |
| tokenizer.decode( | |
| revised_ids, skip_special_tokens=False, clean_up_tokenization_spaces=False | |
| ) | |
| != revised | |
| ): | |
| raise ValueError( | |
| "Media evidence revised prompt must make a lossless tokenizer roundtrip" | |
| ) | |
| if len(revised_ids) > max_length: | |
| raise ValueError("Media evidence prompt exceeds the complete model context") | |
| return (name, revised_ids, media) | |
| def prepare( | |
| request: PredictRequest, | |
| encoded: EncodedRequest, | |
| *, | |
| tokenizer: PreTrainedTokenizerBase, | |
| max_length: int, | |
| media_groups: Callable[..., list[dict[str, Any]]], | |
| ) -> EncodedRequest: | |
| if not eligible(request): | |
| return encoded | |
| from . import grounding | |
| (record, forecasts, tasks, typed, eos) = encoded | |
| annotations = ( | |
| record.get("_meta", {}).get("extraction_contract", {}).get("fields", {}) | |
| ) | |
| meta = record.get("_meta", {}) | |
| protected = set(meta.get("identifier_spelling", {})) | set( | |
| meta.get("model_po_supplement", {}).get("fields", ()) | |
| ) | |
| multi_image = len(request.images) > 1 | |
| updated: list[ARTask] = [] | |
| changed = False | |
| for task in tasks: | |
| (name, _, media) = task | |
| parent = annotations.get(name, {}).get("parent", name) | |
| spec = request.fields.get(parent) | |
| selected = ( | |
| media is not None | |
| and name not in protected | |
| and (parent not in protected) | |
| and (spec is not None) | |
| and (not spec.get("knowledge")) | |
| and (not grounding.state_only(spec)) | |
| and (multi_image or (name == parent and spec.get("type") == "boolean")) | |
| ) | |
| revised = task | |
| if selected: | |
| try: | |
| revised = rewrite_media_evidence( | |
| task, record=record, tokenizer=tokenizer, max_length=max_length | |
| ) | |
| except ValueError: | |
| return encoded | |
| updated.append(revised) | |
| changed |= revised is not task | |
| if not changed: | |
| return encoded | |
| revised_record = { | |
| **record, | |
| "_ar_tasks": updated, | |
| "_ar_prefix": [], | |
| "_ar_group_prefixes": [], | |
| } | |
| revised_record["_ar_media_groups"] = media_groups( | |
| updated, | |
| default_salt=record["_cache_salt"], | |
| task_salts=record.get("_ar_task_salts", {}), | |
| annotations=annotations, | |
| ) | |
| return (revised_record, forecasts, updated, typed, eos) | |