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/source_rows.py from mlx-community/clairic-flash-4bit: direct link, hf CLI and curl.
- Browser
- Download file 5.08 kB
-
https://huggingface.co/mlx-community/clairic-flash-4bit/resolve/main/clairic_runtime/source_rows.py
- Command line
-
hf download hf://mlx-community/clairic-flash-4bit/clairic_runtime/source_rows.py
-
curl -L -o source_rows.py https://huggingface.co/mlx-community/clairic-flash-4bit/resolve/main/clairic_runtime/source_rows.py
5.08 kB
| from __future__ import annotations | |
| import csv | |
| import io | |
| import re | |
| from collections.abc import Callable | |
| from html.parser import HTMLParser | |
| from typing import Any | |
| _ONE_PER_ROW = re.compile( | |
| "\\bone\\s+(?:[\\w-]+\\s+){0,5}per\\s+(?:[\\w-]+\\s+){0,5}row\\b", re.IGNORECASE | |
| ) | |
| class _Table(HTMLParser): | |
| def __init__(self) -> None: | |
| super().__init__(convert_charrefs=False) | |
| self.tables = self.depth = 0 | |
| self.rows: list[set[str]] = [] | |
| self.closed = False | |
| self.row_header = False | |
| self.in_cell = False | |
| self.ambiguous = False | |
| def handle_starttag(self, tag: str, attrs: list[tuple[str, str | None]]) -> None: | |
| if self.in_cell and tag in ("br", "div", "p", "ul", "ol", "li", "table"): | |
| self.ambiguous = True | |
| if tag == "table": | |
| self.tables += 1 | |
| self.depth += 1 | |
| if self.depth == 1: | |
| if tag == "tr": | |
| self.rows.append(set()) | |
| elif tag in ("td", "th") and self.rows: | |
| self.in_cell = True | |
| if any( | |
| ( | |
| key in ("rowspan", "colspan") and value != "1" | |
| for (key, value) in attrs | |
| ) | |
| ): | |
| self.ambiguous = True | |
| self.rows[-1].add(tag) | |
| if len(self.rows) == 1 and ( | |
| dict(attrs).get("scope") or "" | |
| ).casefold() in ("row", "rowgroup"): | |
| self.row_header = True | |
| def handle_endtag(self, tag: str) -> None: | |
| if tag in ("td", "th"): | |
| self.in_cell = False | |
| if tag == "table": | |
| self.depth -= 1 | |
| self.closed = self.depth == 0 | |
| def handle_data(self, data: str) -> None: | |
| if ( | |
| self.in_cell | |
| and len([line for line in data.splitlines() if line.strip()]) > 1 | |
| ): | |
| self.ambiguous = True | |
| def table_rows(source: str) -> int | None: | |
| if re.search("<table(?:\\s|>)", source, re.IGNORECASE): | |
| parser = _Table() | |
| try: | |
| parser.feed(source) | |
| parser.close() | |
| except (ValueError, AssertionError): | |
| return None | |
| if ( | |
| parser.tables != 1 | |
| or not parser.closed | |
| or parser.depth != 0 | |
| or (not parser.rows) | |
| or (parser.rows[0] != {"th"}) | |
| or parser.row_header | |
| or parser.ambiguous | |
| ): | |
| return None | |
| return len(parser.rows) - 1 | |
| lines = source.splitlines() | |
| if len(lines) < 2: | |
| return None | |
| for delimiter in (",", "\t", ";", "|"): | |
| if delimiter not in lines[0]: | |
| continue | |
| try: | |
| rows = list( | |
| csv.reader(io.StringIO(source), delimiter=delimiter, strict=True) | |
| ) | |
| except csv.Error: | |
| continue | |
| if ( | |
| not rows | |
| or len(rows[0]) < 2 | |
| or any((not row or len(row) != len(rows[0]) for row in rows)) | |
| or any((not cell.strip() or re.search("\\d", cell) for cell in rows[0])) | |
| or (not any((re.search("\\d", cell) for row in rows[1:] for cell in row))) | |
| ): | |
| continue | |
| return len(rows) - 1 | |
| return None | |
| def list_bounds( | |
| source: str, fields: dict[str, dict[str, Any]], *, has_images: bool = False | |
| ) -> dict[str, int]: | |
| if has_images: | |
| return {} | |
| parents = {} | |
| for name, spec in fields.items(): | |
| instructions = spec.get("instructions", "") | |
| if ( | |
| spec.get("type") == "list" | |
| and spec.get("items") in ("text", "number") | |
| and (not spec.get("knowledge")) | |
| and _ONE_PER_ROW.search(instructions) | |
| and ( | |
| not re.search( | |
| "\\b(?:not|never|multiple|two|three)\\b|don't", | |
| instructions, | |
| re.IGNORECASE, | |
| ) | |
| ) | |
| ): | |
| parents[name] = spec | |
| count = table_rows(source) if parents else None | |
| return {name: count for name in parents} if count is not None else {} | |
| def bounded_predictions( | |
| predictions: dict[str, dict[str, Any]], | |
| fields: dict[str, dict[str, Any]], | |
| bounds: dict[str, int], | |
| item_name: Callable[[str, int], str], | |
| ) -> dict[str, dict[str, Any]]: | |
| if not bounds: | |
| return predictions | |
| result = dict(predictions) | |
| for parent, count in bounds.items(): | |
| name = item_name(parent, count + 1) | |
| if name not in fields or name not in result: | |
| continue | |
| previous = result[name] | |
| if previous.get("value") is None and previous.get("valid", True): | |
| continue | |
| result[name] = { | |
| **previous, | |
| "value": None, | |
| "valid": True, | |
| "complete": True, | |
| "span": None, | |
| "confidence": 1.0, | |
| "log_probability": 0.0, | |
| "confidence_method": "source_structure", | |
| "grounding_method": "source_row_bound", | |
| } | |
| return result | |