Skip to content
本地运行 ollama 和 qwen3 进行翻译
2025年12月4日 root

运行 ollama/webui

使用 docker run 运行

shell
docker network create llm-net
docker run -d --rm --name ollama-cpu --network llm-net -p 11434:11434 -v ollama-data:/root/.ollama --cpus=8 -e OLLAMA_GPU=off -e OLLAMA_NUM_PARALLEL=1 ollama/ollama
docker run -d --rm --name ollama-webui --network llm-net -p 8000:8080 -v open-webui:/app/backend/data -e OLLAMA_API_BASE_URL=http://ollama-cpu:11434 -e WEBUI_SECRET_KEY=ollama-webui -e ENABLE_GPU=false ghcr.io/open-webui/open-webui:main

或者使用 docker compose 运行

bash
cat cat docker-compose.yml
yml
version: "3.3"
services:
  ollama:
    image: ollama/ollama:latest
    container_name: ollama
    ports:
      - "11434:11434"
    volumes:
      - ollama:/root/.ollama
    networks:
      - ollama-net
    restart: unless-stopped

  open-webui:
    image: ghcr.io/open-webui/open-webui:latest  # 更新到最新版
    container_name: open-webui
    depends_on:
      - ollama
    ports:
      - "8000:8080"
    environment:
      - OLLAMA_BASE_URL=http://ollama:11434
      - ENABLE_MODEL_FILTER=false  # 禁用模型过滤
    volumes:
      - open-webui:/app/backend/data
    networks:
      - ollama-net
    restart: unless-stopped

volumes:
  ollama:
  open-webui:

networks:
  ollama-net:
    driver: bridge
bash
docker-compose up -d

安装 qwen2.5:7b

  1. 两种方式可以安装:
  • 或者,登陆 http://localhost:8080, 进入后左上角,选择模型,搜索框中输入 qwen3:4b-q4_K_M, 按照提示进行安装。
  • 或者,进入 ollama-cpu 安装运行
bash
docker exec -it ollama-cpu bash
ollama run ollama-cpu qwen3:4b-q4_K_M
  1. 登陆,http://localhost:8080,左上角模型选择 qwen3:4b-q4_K_M 即可

设置当前对话为翻译模式

  1. 进入会话后,输入
txt
/system You are a professional Chinese to English translator.  
Rules:  
1. Auto-detect the source language.  
2. translate input Chinese → output English  
3. Keep the original tone and style.  
4. After translating, scan the English text once more:  
   - Replace any occurrence of “Parameter Name”, “Param Name”, “参数名称” with “Name”.  
   - Do the same for their lowercase/plural forms.  
5. Do not add any explanations or notes outside the translation.
  1. 输入中文或者中英文文本,只会给出翻译后的英文文本

Last updated: