Skip to content

Instantly share code, notes, and snippets.

@clairefro
Last active March 21, 2026 08:10
Show Gist options
  • Select an option

  • Save clairefro/4373d4c3a97310a63b40d520d9f518d6 to your computer and use it in GitHub Desktop.

Select an option

Save clairefro/4373d4c3a97310a63b40d520d9f518d6 to your computer and use it in GitHub Desktop.
# Hugging FaceからのモデルをOllamaで実行する方法
## 参照:https://www.markhneedham.com/blog/2023/10/18/ollama-hugging-face-gguf-models
## Ollamaをゲット:https://ollama.com/download
# 1. hugging faceのCLIを取得
## pipの場合
pip install -U "huggingface_hub[cli]"
## pip3の場合は:pip3 install -U "huggingface_hub[cli]" 
## どこかにモデルファイルのためのフォルダを作成
mkdir ~/ollama-models
cd ~/ollama-models
# 2. hugging faceからローカルにモデルをダウンロード
## ダウンロードが完了すると、./downloadsというフォルダーにモデルが保存されます
## 各モデルは約4G、、、ダウンロードは5〜10分ほどかかります
## チャットモデルの場合
huggingface-cli download mmnga/RakutenAI-7B-chat-gguf RakutenAI-7B-chat-q4_0.gguf --local-dir downloads --local-dir-use-symlinks False
## 指示モデルの場合
huggingface-cli download mmnga/RakutenAI-7B-instruct-gguf RakutenAI-7B-instruct-q4_0.gguf --local-dir downloads --local-dir-use-symlinks False
## ベースモデルの場合
huggingface-cli download mmnga/RakutenAI-7B-gguf RakutenAI-7B-q4_0.gguf --local-dir downloads --local-dir-use-symlinks False
# 3. Ollama用のモデルファイルを作成
## チャットモデルのモデルファイルを例に
touch ./Rakuten-chat
echo "FROM ./downloads/RakutenAI-7B-chat-q4_0.gguf" > ./Rakuten-chat
# 4. OllamaでモデルをBuild
ollama create rakuten-chat -f ./Rakuten-chat
# 5. Ollamaでモデルを実行
ollama run rakuten-chat
## 実行した上、そのままターミナル上でチャットするか、OllamaのREST APIを使用できます
## Ollama REST APIの使用方法:https://www.postman.com/postman-student-programs/workspace/ollama-api/collection/21521806-f48dc31a-a9f1-4dad-9082-fd07f5cd2fda
## モデルをアンインストールには
ollama rm <モデル名>
@clairefro
Copy link
Author

clairefro commented Mar 25, 2024

PostmanでAPIを試してまる

このコレクションをフォークし、generate(指示モデルの場合)またはchat(チャットモデルの場合)のリクエストを使用できます。

ロカルで使用する場合、ベースURLをhttp://localhost:11434に設定します

例)mistral(指示モデル)のロカルでの使用
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment