2
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?

Hugging Face形式をgguf形式にしてElixirでOllamaを使う

Posted at

Hugging Face形式をgguf形式にしてElixirで動かしたいと思いました

理由

  • Ollamaを動かす環境は安定して作れる
  • CUDA依存の環境構築は生物で再現性が難しい時もある
    • OSやドライバー等のバージョンアップの時に毎回苦労する
  • 上記の理由でUbuntu + ElixrのbackendがGPUは難易度がある
    • Macは簡単にGPU動くのでUbuntuの時限定です

結論

モデルをgguf形式にする

gguf形式に変換

$ git clone https://github.com/ggml-org/llama.cpp.git

細かいインストール方法は公式を見てください
python周りでインストールがいる(環境による、メモを忘れたのでツールが動く前提で)

モデル変換コマンド

$ python3 convert_hf_to_gguf.py HuggingFaceのフォルダ --outfile ./ファイル名.gguf

$ python3 convert_hf_to_gguf.py /home/user/model_tall-nautilus --outfile ./ymn.gguf

Ollamaに登録

Modelfileを作る

Modelfile
FROM ./ymn.gguf

例 ollamaに登録

$ ollama create my-ymn-model -f Modelfile

例 ollama実行(動作確認です)

ollama run my-ymn-model

ElixiでOllamaを動かす

下記を参考

差分例
modelの部分を変更する

    {:ok, ret} = Ollama.completion(client,
      model: "my-ymn-model",
      prompt: "Elixirについておしえて"
    )

以上です

実行例

H2O LLM Studioでファインチューニングした結果をgguf形式にしました

image.png

余談

Modelfileをいじると精度が変わります
image.png

2
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
2
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?