分類彙整: Ollama

OLlama 安裝 Google MedGemma 模型(失敗)

以下步驟示範如何把 MedGemma(Google 針對醫療領域釋出的 Gemma 3 變體)裝進 Ollama,並分別說明「文字版 27 B」和「多模態 4 B(看圖)」兩種情境。

建議放在專用資料夾

mkdir -p ~/ollama-models/medgemma && cd ~/ollama-models/medgemma

27 B(文字版,Q4_K_M 量化)

wget -c https://huggingface.co/unsloth/medgemma-27b-text-it-GGUF/resolve/main/medgemma-27b-text-it-Q4_K_M.gguf

4 B(多模態版,Q4_K_M 量化 + mmproj 投影層)

wget -c https://huggingface.co/unsloth/medgemma-4b-it-GGUF/resolve/main/medgemma-4b-it-Q4_K_M.gguf
wget -c https://huggingface.co/unsloth/medgemma-4b-it-GGUF/resolve/main/mmproj-F16.gguf

若想用 原生 pre-train (-pt) 版,檔名一樣要注意大小寫:
wget -c https://huggingface.co/mradermacher/medgemma-4b-pt-GGUF/resolve/main/medgemma-4b-pt-F16.gguf

2. 撰寫 Modelfile

2.1 文字版 27 B

Modelfile 內容(放在同一目錄):
Modelfile27B

FROM ./medgemma-27b-text-it-Q4_K_M.gguf

TEMPLATE """
{{- if .System }}<|im_start|>system
{{.System}}<|im_end|>{{ end -}}
{{- if .Prompt }}<|im_start|>user
{{.Prompt}}<|im_end|>{{ end -}}
<|im_start|>assistant
{{.Response}}<|im_end|>
"""

PARAMETER num_ctx 8192

2.2 多模態 4 B

多模態必須同時載入 主 GGUFmmproj 投影層檔案;Ollama 允許用兩行 FROMOllama
Modelfile4B

FROM ./mmproj-F16.gguf              # 第 1 行:視覺投影層
FROM ./medgemma-4b-it-Q4_K_M.gguf # 第 2 行:4B 主模型

TEMPLATE """
{{- if .System }}<|im_start|>system
{{.System}}<|im_end|>{{ end -}}
{{- if .Prompt }}<|im_start|>user
{{.Prompt}}<|im_end|>{{ end -}}
<|im_start|>assistant
{{.Response}}<|im_end|>
"""

PARAMETER num_ctx 4096

3. 建立並測試模型

# 建立 27B
ollama create medgemma-27b -f ./Modelfile27B
# 建立 4B
ollama create medgemma-4b-vision -f ./Modelfile4B

文字測試
ollama run medgemma-27b

你是誰?

圖像/多模態測試(Ollama CLI)

ollama run medgemma-4b-vision \
--image chest_xray.png \
-p "請描述這張影像的主要異常位置"

或透過 HTTP API:

curl http://localhost:11434/api/generate \
-d '{
"model": "medgemma-4b-vision",
"prompt": "Read this fundus photo and report findings in Chinese",
"images": ["data:image/png;base64,...."]
}'

Open WebUI 安裝

https://docs.openwebui.com

Manual Installation
手動安裝

Installation with pip (Beta)
安裝 (Beta)

For users who prefer to use Python’s package manager pip, Open WebUI offers a installation method. Python 3.11 is required for this method.
對於喜歡使用 Python 包管理員的使用者,Open WebUI 提供了一種安裝方法。此方法需要 Python 3.11。

  1. Install Open WebUI: Open your terminal and run the following command:
    :
    開啟終端並執行以下命令:pip install open-webui
  2. Start Open WebUI: Once installed, start the server using:
    :
    安裝後,使用以下命令啟動伺服器:open-webui serve

This method installs all necessary dependencies and starts Open WebUI, allowing for a simple and efficient setup. After installation, you can access Open WebUI at http://localhost:8080. Enjoy! 😄
此方法會安裝所有必要的依賴項並啟動Open WebUI,從而實現簡單高效的設置。安裝后,您可以在 http://localhost:8080 訪問 Open WebUI。享受!😄

实现本地知识库和大模型检索增强生成(RAG)

https://mp.weixin.qq.com/s?__biz=MzkyNzMyNTkwMg==&mid=2247484289&idx=1&sn=d4f08858bd23ef1fefcbbf994dedbfd2&chksm=c2288820f55f0136b28d8b72740c610dfc542e7685e085fc5c07db653086bbf40d3d74237555&scene=21#wechat_redirect

https://mp.weixin.qq.com/s?__biz=MzkyNzMyNTkwMg==&mid=2247484522&idx=1&sn=dd771358b3491211de305dbe07f34008&chksm=c2288fcbf55f06dd147ce7319a3c3935e87dcb96470b71dcc526b6432b42be7f2ba781def892&scene=21#wechat_redirect

https://mp.weixin.qq.com/s?__biz=MzkyNzMyNTkwMg==&mid=2247484522&idx=1&sn=dd771358b3491211de305dbe07f34008&chksm=c2288fcbf55f06dd147ce7319a3c3935e87dcb96470b71dcc526b6432b42be7f2ba781def892&scene=21#wechat_redirect

https://www.53ai.com/news/qianyanjishu/1234.html