Run this model with HF Jobs

Run VisualInference/Soma-1X-lite-MLX-4bit on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.

Paste one of these prompts into your coding agent:

Fine-tune on my dataset

Use HF Jobs to fine-tune https://huggingface.co/VisualInference/Soma-1X-lite-MLX-4bit. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.

Run batch inference

Use HF Jobs to run batch inference with https://huggingface.co/VisualInference/Soma-1X-lite-MLX-4bit on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.

Evaluate on a benchmark

Use HF Jobs to evaluate https://huggingface.co/VisualInference/Soma-1X-lite-MLX-4bit. Ask me which benchmark to run, then save the scores and the per-example results to a new dataset repo. Run `hf jobs --help` first to learn the CLI.
VisualInference's picture
Card: add measured 6bit row
0b1b4b5 verified
|
Raw History Blame Contribute Delete
6.48 kB
metadata
license: apache-2.0
license_link: https://www.apache.org/licenses/LICENSE-2.0
base_model: AminiTech/Soma-1X-lite
base_model_relation: quantized
library_name: mlx
pipeline_tag: image-text-to-text
language:
  - en
  - fr
  - es
  - sw
  - yo
  - ha
  - wo
  - ln
  - xh
  - af
  - rw
  - ny
  - sg
tags:
  - mlx
  - mlx-vlm
  - apple-silicon
  - quantized
  - qwen3_5
  - document-parsing
  - ocr
  - layout-analysis
  - table-recognition
  - handwriting
  - african-languages

Soma-1X Lite for MLX, 4bit

Soma-1X Lite is Amini's 2B vision-language model for document parsing (a fine-tune of Qwen3.5-2B, Apache 2.0). It turns a page image into layout blocks in reading order, with labels, boxes, tables in HTML and equations in LaTeX. This repository is a 4bit build for Apple silicon in mlx-vlm format: 1.60 GiB of weights, for any Mac with 8 GB of memory or more.

The language model is quantized to 4-bit affine, groups of 64. The vision tower is kept in bf16, as in the original, because reading small print depends on it. On nine test pages 0.34% of the characters differ from bf16 and eight of nine pages keep the same blocks. On the ninth it splits a paragraph into one block per printed line and marks the first cell of each table row as a header cell. Use the 8bit build when exact structure matters more than 0.9 GiB.

Build Weights Bits per weight (language model) Decode Prompt Peak memory, one A4 page Loss vs bf16, nats per token Text vs bf16
original, bf16 in MLX 4.12 GiB 16 99 tok/s 3,366 tok/s 5.24 GiB reference (0.0364) reference
4bit (this repo) 1.60 GiB 4.5 249 tok/s 4,822 tok/s 3.04 GiB +0.021 ± 0.008 0.34% of characters differ
6bit 2.04 GiB 6.5 197 tok/s 5,099 tok/s 3.39 GiB +0.0009 ± 0.0014 identical
8bit 2.48 GiB 8.5 161 tok/s 5,124 tok/s 3.82 GiB +0.0002 ± 0.0008 identical

Measured on a MacBook Pro (M5 Max, 36 GB), mlx 0.32.5, mlx-vlm commit bb224121, greedy decoding. Speed and memory: one synthetic A4 page rendered at 1240 x 1754 (3,297 prompt tokens, about 320 output tokens). Loss and text: nine pages, below. Sizes are in GiB, the unit Mac memory comes in. Bits per weight include the group scales.

Use

pip install -U mlx-vlm
hf download VisualInference/Soma-1X-lite-MLX-4bit system_prompt.txt user_prompt.txt --local-dir .
mlx_vlm.generate --model VisualInference/Soma-1X-lite-MLX-4bit \
  --system "$(cat system_prompt.txt)" --prompt "$(cat user_prompt.txt)" \
  --image page.png --max-tokens 16384 --temperature 0

In Python:

from mlx_vlm import load, generate
from mlx_vlm.prompt_utils import apply_chat_template
from huggingface_hub import hf_hub_download

repo = "VisualInference/Soma-1X-lite-MLX-4bit"
model, processor = load(repo)
system = open(hf_hub_download(repo, "system_prompt.txt")).read()
user = open(hf_hub_download(repo, "user_prompt.txt")).read()
messages = [{"role": "system", "content": system}, {"role": "user", "content": user}]
prompt = apply_chat_template(processor, model.config, messages, num_images=1, enable_thinking=False)
out = generate(model, processor, prompt, image=["page.png"], max_tokens=16384, temperature=0.0)
print(out.text)

Output is one <block label="..." box="x0 y0 x1 y1">text</block> per page element, boxes on a 0-1000 grid over the image. See the original card for the label set, PDF rendering and its benchmark settings.

Settings that matter

  • Prompts. The model was trained with the system prompt and instruction in system_prompt.txt and user_prompt.txt, copied here unchanged from the original. Without them it still transcribes, but the block format is not guaranteed.
  • Thinking. The chat template only adds a thinking block when enable_thinking is true; leave it off, as the original does.
  • Resolution. The original's benchmarks render pages with a 1,792-pixel long edge (olmOCR-Bench: 400 DPI, 5 MP cap). Prompt length and memory grow with the page's pixel count.
  • Only documents. Asked for code or general chat, the model declines and asks for a page. That is the original's behaviour.

The chat template, tokenizer and prompt files are the original files, byte for byte.

What was checked

  • Loss against bf16. Nine synthetic A4 pages (English, French, Swahili, Afrikaans and Yoruba prose, an invoice, lab results, tables, five typefaces). The bf16 build's greedy output for each page, 2,759 tokens in all, is scored teacher-forced under every build with the trained prompts. Differences are mean nats per token against bf16, with a 95% bootstrap interval over pages. bf16 gives its own output 0.0364 nats per token.

  • Text against bf16. Each build's greedy output, tags stripped, compared with bf16's by edit distance.

  • Document page. One more A4 page with a running header, a heading, English prose, a Yoruba sentence with tone marks and dots below, a Hausa line, a 3 x 4 table and a page number. All four builds return the header, heading, prose, Yoruba and table values correctly. All of them, bf16 included, drop the Hausa hooked letters ɓ and ƙ on this page (ɗ survives), so that is the model on this font, not the quantization.

  • Image read. A picture of the text MLX 42 with a red circle and a blue square: read and described correctly.

  • Not measured yet: comparison with the Transformers reference, olmOCR-Bench, OmniParse-Bench and the African-language CER set on these builds. Coming.

Limitations

  • Tested on one machine (M5 Max, 36 GB). The 8 GB guidance follows from the measured peak and was not run on an 8 GB Mac.
  • The original ships no multi-token-prediction weights, so there is no drafter for speculative decoding.
  • The original's benchmark numbers were measured with Transformers in bf16 and are not claims about this build.

Credits and licence

Model and weights: Amini, Apache 2.0, see the original card. Base model: Qwen3.5-2B by the Qwen team. MLX runtime: the mlx-vlm authors. Quantization, checks and this card: VisualInference. Built from upstream revision 47f839de4ea6.