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/identifier_scope.py from mlx-community/clairic-flash-4bit: direct link, hf CLI and curl.
- Browser
- Download file 3.52 kB
-
https://huggingface.co/mlx-community/clairic-flash-4bit/resolve/main/clairic_runtime/identifier_scope.py
- Command line
-
hf download hf://mlx-community/clairic-flash-4bit/clairic_runtime/identifier_scope.py
-
curl -L -o identifier_scope.py https://huggingface.co/mlx-community/clairic-flash-4bit/resolve/main/clairic_runtime/identifier_scope.py
3.52 kB
| from __future__ import annotations | |
| import re | |
| from typing import Any | |
| ROLE_NOTE = " Select the value by its printed label and requested role. Do not infer the role from the spelling or prefix of an identifier. A similar-looking value under another label is not the requested value. Return null if that role is absent." | |
| _GENERIC_NAMES = {"reference", "value"} | |
| _PURCHASE_ORDER = re.compile("\\bpurchase[\\s-]+order\\s+reference\\b", re.IGNORECASE) | |
| _LITERAL = re.compile( | |
| "\\b(?:exact|printed|verbatim|copy|extract|read)\\b", re.IGNORECASE | |
| ) | |
| _EXCLUDED = re.compile( | |
| "\\b(?:not|exclude|excluding|ignore|rather than)\\b[^.;:\\n]*$", re.IGNORECASE | |
| ) | |
| _OTHER_ROLE = re.compile( | |
| "\\b(?:invoice|receipt|payment|tracking|sales[\\s-]+order|account)\\s+(?:reference|number|identifier|id|code)\\b", | |
| re.IGNORECASE, | |
| ) | |
| _TRANSFORM = re.compile( | |
| "\\b(?:compare|combine|join|concatenate|compute|calculate|sum|count|hash|mask|normalize|convert|format|summarize|(?:first|last)\\s+\\d+)\\b", | |
| re.IGNORECASE, | |
| ) | |
| _STATE_TEXT = re.compile( | |
| "\\b(?:state|accompanying)\\s+(?:state\\s+)?text\\b", re.IGNORECASE | |
| ) | |
| _QUOTED_LITERAL_TARGET = re.compile( | |
| "\\b(?:copy|extract|read|return)\\s+(?:the\\s+)?(?:(?:exact|printed|literal|verbatim)\\s+)*(?:phrase|words?|sentence|string)\\s*:?\\s*(?:\"([^\"\\n]+)\"|'([^'\\n]+)'|“([^”\\n]+)”|‘([^’\\n]+)’|`([^`\\n]+)`)", | |
| re.IGNORECASE, | |
| ) | |
| _LITERAL_COMMAND_NEGATION = re.compile( | |
| "\\b(?:never|don['’]t)\\b[^.;:\\n]*$", re.IGNORECASE | |
| ) | |
| def _positive(pattern: re.Pattern[str], instructions: str) -> bool: | |
| return any( | |
| ( | |
| not _EXCLUDED.search(instructions[: match.start()]) | |
| for match in pattern.finditer(instructions) | |
| ) | |
| ) | |
| def _literal_target(instructions: str) -> bool: | |
| for match in _QUOTED_LITERAL_TARGET.finditer(instructions): | |
| prefix = instructions[: match.start()] | |
| if not (_EXCLUDED.search(prefix) or _LITERAL_COMMAND_NEGATION.search(prefix)): | |
| if any( | |
| ( | |
| _PURCHASE_ORDER.search(text) | |
| for text in match.groups() | |
| if text is not None | |
| ) | |
| ): | |
| return True | |
| return False | |
| def prepare_fields( | |
| fields: dict[str, dict[str, Any]], *, has_media: bool | |
| ) -> tuple[dict[str, dict[str, Any]], dict[str, str]]: | |
| if not has_media: | |
| return (fields, {}) | |
| (changed, labels) = ({}, {}) | |
| for name, spec in fields.items(): | |
| if ( | |
| not isinstance(name, str) | |
| or name.casefold() not in _GENERIC_NAMES | |
| or (not isinstance(spec, dict)) | |
| or (spec.get("type") != "text") | |
| or spec.get("knowledge") | |
| or (spec.get("nullable", True) is False) | |
| or ("enum" in spec) | |
| ): | |
| continue | |
| instructions = spec.get("instructions", "") | |
| if ( | |
| not isinstance(instructions, str) | |
| or not _LITERAL.search(instructions) | |
| or _TRANSFORM.search(instructions) | |
| or _STATE_TEXT.search(instructions) | |
| or _literal_target(instructions) | |
| or (not _positive(_PURCHASE_ORDER, instructions)) | |
| or _positive(_OTHER_ROLE, instructions) | |
| ): | |
| continue | |
| if not instructions.endswith(ROLE_NOTE): | |
| changed[name] = {**spec, "instructions": instructions + ROLE_NOTE} | |
| labels[name] = "purchase_order_reference" | |
| return ({**fields, **changed} if changed else fields, labels) | |