0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

M4 の Mac mini で ローカルLLM: LLM-jp-3.1(MLX版 13B instruct4 8bit)を MLX LM で試す

Last updated at Posted at 2025-06-17

はじめに

以前から色々と試してみている、M4 の Mac mini を使ったローカルLLM の話です。

自分がローカルLLM を試す時には、主に MLX版のモデルと「MLX LM」/「MLX-VLM」との組み合わせや、Ollama を使っているのですが、今回はその中の「MLX LM」を使ったものです。

そしてモデルは、以下(の MLX版)を試します。

●LLM-jp-3.1 シリーズ instruct4 の公開 | LLM 勉強会
 https://app007.xsrv.jp/llmjp/ja/blog/blog-887/

image.png

元のモデルは 2025年5月30日に公開されたようです。

実際に試していく

利用するモデル

今回使うモデルは、LLM 勉強会の LLM-jp-3.1 シリーズ instruct4 の MLX版と書きましたが、自分の Mac mini で使えそうなサイズになっているものを選んで使います。

自分の環境で使えるモデルで、できるだけ大きなものを選ぼうとして、パラメータ数・量子化が以下になっているものにしました。

●mlx-community/llm-jp-3.1-13b-instruct4-8bit · Hugging Face
 https://huggingface.co/mlx-community/llm-jp-3.1-13b-instruct4-8bit

image.png

モデルサイズは 14.5GB くらいのようです。

image.png

あと、モデルサイズをもう少し抑えたい場合は、以下にしてみても良いかもしれません。

●mlx-community/llm-jp-3.1-13b-instruct4-4bit · Hugging Face
 https://huggingface.co/mlx-community/llm-jp-3.1-13b-instruct4-4bit

試す際の環境

今回のお試し用の環境について、少しここで紹介しておきます。

  • PC
    • M4 の Mac mini(メモリ 24GB、うち 16GB をローカルLLM用で利用可能)
  • 実行環境
    • Python の仮想環境を利用
    • Python のコードで MLX LM を使った処理

コードと実行結果

以下が今回用いたコードです。基本的にサンプルのコードを使っていて、プロンプトの部分だけ変えて使っています。

from mlx_lm import load, generate

model, tokenizer = load("mlx-community/llm-jp-3.1-13b-instruct4-8bit")

prompt = "生成AIを8歳に分かるように短い言葉で日本語で説明して"

if tokenizer.chat_template is not None:
    messages = [{"role": "user", "content": prompt}]
    prompt = tokenizer.apply_chat_template(
        messages, add_generation_prompt=True
    )

response = generate(model, tokenizer, prompt=prompt, verbose=True)

上記を pythonコマンドで実行した結果は、以下のとおりです。

image.png

プロンプトは「生成AIを8歳に分かるように短い言葉で日本語で説明して」という内容にしていましたが、それに対して問題なくレスポンスを得られました。

おわりに

今回、M4 の Mac mini での ローカルLLM を試しました。そのモデルや環境として、LLM-jp-3.1(MLX版 13B instruct4 8bit)と MLX LM などを用いました。

今回はとりあえずの動作確認でしたが、またプロンプトを変えて性能を確かめてみたりなどできればと思います。

その他: 過去に試して記事に書いた内容のリスト

これまで、色々とローカルLLM を試して、その中の多くを記事に書いていました。ざっと検索して出てきた記事を、以下にリストで記載してみます。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?