https://chatgpt.com/share/684e364e-dd08-8002-b363-a3582babee48
https://chatgpt.com/share/684e630f-998c-8002-849b-fcb31d1eec86
以下步驟示範如何把 MedGemma(Google 針對醫療領域釋出的 Gemma 3 變體)裝進 Ollama,並分別說明「文字版 27 B」和「多模態 4 B(看圖)」兩種情境。
mkdir -p ~/ollama-models/medgemma && cd ~/ollama-models/medgemma
wget -c https://huggingface.co/unsloth/medgemma-27b-text-it-GGUF/resolve/main/medgemma-27b-text-it-Q4_K_M.gguf
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
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
多模態必須同時載入 主 GGUF 與 mmproj 投影層檔案;Ollama 允許用兩行 FROM
:Ollama
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
# 建立 27B
ollama create medgemma-27b -f ./Modelfile27B
# 建立 4B
ollama create medgemma-4b-vision -f ./Modelfile4B
你是誰?
圖像/多模態測試(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,...."]
}'
你可以直接 git clone 筆者的 GitHub 專案,或者建立一個 n8n
的資料夾,新增 docker-compose.yml
檔案。
volumes: n8n_storage: services: n8n: image: n8nio/n8n:latest restart: always ports: - "127.0.0.1:5678:5678" # 根據實際需求設定 volumes: - n8n_storage:/home/node/.n8n
貼上內容後,在終端機(Terminal)
輸入 docker compose
n8n --project-name
up
-d
即可啟動
加上
environment:
- N8N_SECURE_COOKIE=false # 或改成 true 並上 HTTPS
- N8N_PROTOCOL=http
sudo apt install certbot python3-certbot-apache
sudo certbot certonly --standalone -d yourdomain.com
成功後,憑證位置會是:
/etc/letsencrypt/live/yourdomain.com/
🛠 2. 設定 Apache SSL(以 8443 為例)
建立檔案:
sudo nano /etc/apache2/sites-available/n8n-ssl.conf
內容如下:
<VirtualHost *:8443>
ServerName yourdomain.com
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/yourdomain.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/yourdomain.com/privkey.pem
ProxyPreserveHost On
ProxyPass / http://localhost:5678/
ProxyPassReverse / http://localhost:5678/
ErrorLog ${APACHE_LOG_DIR}/n8n_error.log
CustomLog ${APACHE_LOG_DIR}/n8n_access.log combined
</VirtualHost>
啟用必要模組與設定:
sudo a2enmod ssl
sudo a2enmod proxy
sudo a2enmod proxy_http
sudo a2ensite n8n-ssl.conf
sudo systemctl reload apache2
🐳 3. Docker Compose 設定 (n8n 走 http 5678)
services:
n8n:
image: n8nio/n8n
restart: always
ports:
– “5678:5678”
environment:
– N8N_HOST=yourdomain.com
– N8N_PORT=5678
– N8N_PROTOCOL=http
– N8N_SECURE_COOKIE=true
🔎 存取方式:
https://ithelp.ithome.com.tw/articles/10360064
git clone https://github.com/langgenius/dify.git
先到 Docker 的官網裝好 docker,將 Dify 複製到你的裝置中
將 dify 複製到你的任何目錄底下git clone https://github.com/langgenius/dify.git
進到 dify/docker
中,這邊放了所有和 docker 有關的設定cd dify/docker
創建環境檔案 (.env
) 這邊直接複製他的範例即可cp .env.example .env
這邊 Dify 有 nginx 的 container,會將服務開在我們電腦的 80 port 和 443 port (如果有啟動 https),如果你不想開在這些 port 或者電腦這些 port 已經被使用了可以自行修改 .env
# HTTP port NGINX_PORT=80
# 這邊改成你想要的 port
# ------------------------------
# Docker Compose Service Expose Host Port Configurations
# ------------------------------
EXPOSE_NGINX_PORT=80
# 這邊也要改
啟動 docker composedocker compose --project-name dify up -d # 這邊的 -d 是背景執行的意思
-p 命名 DockerName
注意 新增多個 Dify 需要設定 DockerName
docker composedocker compose
--project-name
dockername up -d
5003 port 也需要修改
PLUGIN_DEBUGGING_PORT=5003
EXPOSE_PLUGIN_DEBUGGING_PORT=5003