Instructions to use davidleitw/fdem-4b-MLX-4bit with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use davidleitw/fdem-4b-MLX-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("davidleitw/fdem-4b-MLX-4bit") config = load_config("davidleitw/fdem-4b-MLX-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 davidleitw/fdem-4b-MLX-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 "davidleitw/fdem-4b-MLX-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": "davidleitw/fdem-4b-MLX-4bit" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Hermes Agent
How to use davidleitw/fdem-4b-MLX-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 "davidleitw/fdem-4b-MLX-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 davidleitw/fdem-4b-MLX-4bit
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use davidleitw/fdem-4b-MLX-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 "davidleitw/fdem-4b-MLX-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 "davidleitw/fdem-4b-MLX-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"
fdem-4b-MLX-4bit
fdem fills a list of fields from one document: text, a page image or one PDF page. It returns one typed value per field. The model is trained to return null for a field the document does not state, and the response gives the reason. Use it through the fdem Python package, which builds the prompt the model was trained on and checks and converts its answers.
A 4-bit MLX conversion of fdem-4b for Apple Silicon Macs, made with mlx-vlm 0.7.9 from the bf16 release weights. It keeps the vision part, so it reads page images.
Usage
Run fdem in front of mlx-vlm's server as the client: fdem builds the trained prompt and checks and converts the answer. fdem needs the tokenizer and fdem.json from the bf16 repository (no weights).
git clone https://github.com/davidleitw/fdem && cd fdem && pip install . mlx-vlm==0.7.9
hf download davidleitw/fdem-4b --exclude "*.safetensors" --local-dir fdem-4b
python -m mlx_vlm.server --model davidleitw/fdem-4b-MLX-4bit --port 8080
# in a second terminal, once the server is up:
fdem-serve --model fdem-4b --backend chat --server-kind mlx_vlm --server-url http://127.0.0.1:8080/v1 # fdem API on :8000
Leave mlx_vlm.server's --enable-thinking off. In Python: Extractor.chat("fdem-4b", server_url="http://127.0.0.1:8080/v1", server_kind="mlx_vlm"). Confidence is null when the server returns no per-token log-probabilities, and a min_confidence threshold then rejects every filled value.
Requests to port 8000 are the same as for fdem-4b.
API reference: docs/api.md. Recipes: docs/cookbook.md.
Scores
Measured on this variant itself, on the fdem benchmark, with fdem as the client. Do not assume the bf16 scores of fdem-4b. "Same answer as bf16" is the share of fields where this variant's answer equals the bf16 model's.
| Set | Right | Wrong | Blank | Filled empty fields | Same answer as bf16 |
|---|---|---|---|---|---|
| Held-back, English (2,957 stated / 218 empty) | 2,889 | 31 | 37 | 8 / 218 | 98.3% |
| Held-back, Chinese DRCD (948) | 885 | 43 | 20 | - | 90.2% |
| Held-back, Japanese JaWildText (1,077 / 156) | 1,043 | 31 | 3 | 2 / 156 | 96.0% |
| Real-usage (1,757 / 389) | 1,556 | 139 | 62 | 23 / 389 | 89.6% |
Speed and peak memory, measured on a Mac mini (Apple M4, 16 GB, macOS 15.6) with mlx-vlm 0.7.9, one request at a time over the 933 held-back documents (text and page images, as the benchmark gives them): 0.10 documents per second, a mean of 10.4 s per document (total time divided by documents; mlx-vlm logs no per-request times, so there is no median), and a peak memory footprint of 5.2 GiB of unified memory for the mlx-vlm server and the fdem client together. All tables: docs/results.md.
Intended use
Pulling typed fields (names, numbers, dates, times, durations, lists and tables) out of invoices, receipts, forms, contracts, statements, filings, notices and web pages, where an empty answer is better than a guessed one. Check the answers that matter: spans, null_reasons and confidence in each response point to the ones worth a second look.
Out of scope: decisions about people made without human review (credit, hiring, benefits), identifying people in documents, and multi-page reasoning across a whole PDF.
Limitations
- One page per request. Up to 20 fields, 200,000 characters of text and 16,384 tokens per request. Field names must be English.
- Measured on English, Chinese (mostly Traditional) and Japanese (receipts as text). Other languages are untested.
confidencecomes from token probabilities; use it to sort answers for review, not as the chance of being right.- Scores hold only with fdem building the prompt. Calling the weights with your own prompt, directly or through mlx-vlm's own API, is not measured. A request with no system message gets a default instruction prompt from the chat template instead, and that is not the trained fdem prompt either.
- A compressed variant can give a different answer from the bf16 model on some fields; the table above says how often.
Licence
The weights are released under Apache-2.0, the licence of the base model Qwen3.5-4B (also Apache-2.0). The training data and training code are not part of this release. The benchmark documents keep their sources' licences, listed in the benchmark README.
Citation
@software{lei2026fdem,
author = {Lei, David},
title = {{FDEM}: Field-level Data Extraction Model},
version = {0.1.0},
year = {2026},
url = {https://github.com/davidleitw/fdem}
}
- Downloads last month
- 14
4-bit