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

ローカルLLMエージェント

1
Posted at

CPUで動く軽量LLM

最近CPUで動くローカルLLMをインストールしてみました!!
lfm3-vl:2b というモデルで、1G程度のメモリで動作しCPUで十分動作するモデルです。

Linuxへのインストールはollamaが入っていれば ollama run lfm3-vl:2b で動作します。
https://youtu.be/4HxPLteHnhE

ここからはOllamaの話

OllamaはバックグランドでAPIが動作しているのでこれを呼び出すことで簡単にエージェントプログラムが作れます。
エージェントを作るにはpython環境に ollama モジュールをいんすっトールします。

pip install ollama

簡単なプログラムを作ってみる

import ollama

# LFM3-VL-2Bに画像と質問を渡して推論させる
response = ollama.chat(
    model='lfm3-vl:2b',
    messages=[
        {
            'role': 'user',
            'content': 'この画像に何が写っているか日本語で詳しく説明して。',
            'images': ['path/to/image.jpg']  # 実際の画像ファイルのパスを指定
        }
    ]
)

print(response['message']['content'])

このプログラムを使って予め、content で Use 'ファイル名'
を読んでおくとファイルの内容についての特化した会話ができるようになるはずです。

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