LLM MLX VLM - eiichiromomma/CVMLAB GitHub Wiki

(LLM) MLX-VLM

MLX-LMのVLM版.ただしserver機能はない.

pip install -U mlx-vlm

generateが基本.chat_uiも用意はされているが最低限のやりとり表示とTemperatureとMax new tokensの設定しかできない(mlx-lmのserver同様にパラメータのオプションは存在しない.埋め込めるだろうけど).

コマンドラインで--imageで画像を指定すればBase64エンコード不要で動くのが便利.

M4 32GB Macで動いたモデル

  • image-text-to-text
    • mlx-community/deepseek-vl2-4bit: ギリ動く
      • Generation: 181 tokens, 30.629 tokens-per-sec
      • Peak memory: 17.245 GB
    • mlx-community/Qwen3-VL-30B-A3B-Thinking-4bit: ギリ
      • Generation: 759 tokens, 45.988 tokens-per-sec
      • Peak memory: 19.050 GB
      • 要torch-vision
  • image-to-text
    • mlx-community/Llama-3.2-11B-Vision-Instruct-4bit: トロい
      • Generation: 145 tokens, 2.681 tokens-per-sec
      • Peak memory: 9.839 GB
    • Llavaは古くて動かなかった

python -m mlx_vlm.generate --model mlx-community/Qwen3-VL-30B-A3B-Thinking-4bit --max-tokens 1000 --temp 0.0 --kv-bits 4 --prompt "Describe this image in Japanese." --image path_to_img

Fetching 17 files: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 17/17 [00:00<00:00, 200289.80it/s]

========== Files: ['']

Prompt: <|im_start|>user <|vision_start|><|image_pad|><|vision_end|>Describe this image in Japanese.<|im_end|> <|im_start|>assistant <think>

Got it, let's describe the image in Japanese. First, I need to observe all elements. There's a man in a black tuxedo with a bow tie, a red flower on his lapel, holding a white sewing machine. Behind him, there's a brown truck that's tilted, maybe on a grassy slope near a river. There are police officers standing on a pathway. The background has trees, a river, and a stone structure. Let's break it down.

Start with the main subject: a young man in a formal black suit (tuxedo) with a bow tie, a red boutonnière. He's holding a white sewing machine. Then the background: a brown truck is tilted, seems like it's on a grassy area near a river. There are several police officers standing on a paved path. The setting is outdoors, maybe a park or a riverside area with trees and greenery.

Now, structure the Japanese description. Make sure to mention each element clearly.

First, the man: 男性が黒いタキシードを着て、蝶ネクタイと赤い花のブートニエールを身につけ、白いミシンを持っています。次に背景:茶色のトラックが斜めに傾いており、川沿いの草むらに停まっているようです。その周囲には、制服を着た警察官たちが数人立っています。道は舗装されており、周囲には木々や緑が広がり、川や石造りの構造物も見えます。全体的に屋外の公園や川沿いの場所で、何らかの出来事の様子が描かれています。

Check if all elements are covered: tuxedo, bow tie, boutonnière, sewing machine, tilted truck, police officers, pathway, greenery, river, stone structure. Yes.

Make sure the Japanese is natural. Let's adjust:

黒いタキシードに蝶ネクタイと赤いブートニエールを身につけた男性が、白いミシンを手にしています。背景には、川沿いの草むらに斜めに傾いた茶色のトラックが見え、その周囲には制服姿の警察官たちが数人立っています。男性の後ろには舗装された道があり、周囲には木々や緑が広がり、川や石造りの構造物も確認できます。屋外の公園や川沿いの場所で、何らかの出来事の様子が描かれています。

That should cover it. Let's check for accuracy. The truck is tilted, so "斜めに傾いた". The police officers are standing. The setting is outdoors with greenery, river. The man is holding a sewing machine. Yes. </think>

黒いタキシードに蝶ネクタイと赤いブートニエールを身につけた男性が、白いミシンを手にしています。背景には、川沿いの草むらに斜めに傾いた茶色のトラックが見え、その周囲には制服姿の警察官たちが数人立っています。男性の後ろには舗装された道があり、周囲には木々や緑が広がり、川や石造りの構造物も確認できます。屋外の公園や川沿いの場所で、何らかの出来事の様子が描かれています。

==========

Prompt: 450 tokens, 117.012 tokens-per-sec

Generation: 759 tokens, 45.954 tokens-per-sec

Peak memory: 19.050 GB

⚠️ **GitHub.com Fallback** ⚠️