LoginSignup
0
0

MLX で OpenELM を試してみる

Last updated at Posted at 2024-04-28

目的

mlx を用いて OpenELM で text generation を動作させてみる

node

  • mac
    • m1
    • mem: 16GB

mlx とは

apple シリコン上での機械学習研究のためのフレームワーク

所管

  • m1 macbook air, nvidia gpu 無しでの速度としては十分
    • 1B model も memory 16GB で動作した
  • text 内容は判断を見送る
    • 使い方の問題もありそう
    • 素の1Bの状態では微妙に思えた
  • mac studio 64G~128G などで, 高容量モデルを試してみたい所
    • 会社でも小規模なら耐えうるかもしれない

1B 8bit model の参考動作

2024-04-28_1607.gif

使用できるモデルと how to use

install


環境が汚れているので, 以下だけでは setup が完成しない可能性もあります

pip install mlx-lm

sample code

test.py
from mlx_lm import load, generate

model, tokenizer = load("mlx-community/OpenELM-1_1B-8bit")

response = generate(
    model,
    tokenizer,
    prompt='please tell me about programming language ruby',
    verbose=True,
    max_tokens=512,
    temp=0.0,
    repetition_penalty=3.2,
)

run. 以下で上述の gif のように動作するはず

python test.py

余談: 3b model の壊れた出力

unk

スクリーンショット 2024-04-28 16.32.21.png

0
0
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
0