LoginSignup
2
0

LLaMa-3をAPIサーバーのように使う方法

Posted at

結論

ollamaというツールを使ってLLaMa-3を立ち上げると、REST APIサーバーお自動的に立ち上がる。

REST APIサーバーの立ち上げ方

環境 : linux (インストール方法は環境に依存。詳しくは参考サイト)

ollamaをインストール

curl -fsSL https://ollama.com/install.sh | sh

LlaMa-3を動かす

ollama run llama3

実は、これでREST APIサーバーが自動的に立ち上がります。
LLaMa-3以外にも色々なモデルを動かすことができるみたいです。

Model Parameters Size Download
Llama 3 8B 4.7GB ollama run llama3
Llama 3 70B 40GB ollama run llama3:70b
Phi-3 3.8B 2.3GB ollama run phi3
Mistral 7B 4.1GB ollama run mistral
Neural Chat 7B 4.1GB ollama run neural-chat
Starling 7B 4.1GB ollama run starling-lm
Code Llama 7B 3.8GB ollama run codellama
Llama 2 Uncensored 7B 3.8GB ollama run llama2-uncensored
LLaVA 7B 4.5GB ollama run llava
Gemma 2B 1.4GB ollama run gemma:2b
Gemma 7B 4.8GB ollama run gemma:7b
Solar 10.7B 6.1GB ollama run solar

サーバーにアクセス

Generate Mode

curl http://localhost:11434/api/generate -d '{
  "model": "llama3",
  "prompt":"Why is the sky blue?"
}'

Chat Mode

curl http://localhost:11434/api/chat -d '{
  "model": "llama3",
  "messages": [
    { "role": "user", "content": "why is the sky blue?" }
  ]
}'

参考

  1. ollama
  2. ollama-API
2
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
2
0