使用 Google Colab + VS Code 開發 TranslateGemma 翻譯模型,並部署到 Cloud Run
本專案實驗 Google 最新開源的 TranslateGemma 翻譯模型(4B 參數版本),採用 Colab-First 開發策略:
TranslateGemma 是 gated repository,使用前需要:
詳細步驟請參考:Hugging Face 存取設定指南
我們提供兩個 Colab notebooks,依據使用場景選擇:
專注於學術論文雙語閱讀:
適合:深入研讀論文、學習專業術語、準備寫作/審稿
支援多種檔案類型:
適合:一般翻譯需求、多種檔案格式
使用步驟(兩個 notebook 都適用):
HF_TOKEN(或手動輸入)document-translator-colab.ipynbuv)⚡最簡單的方式(推薦):
# 1. 安裝 uv(如果尚未安裝)
curl -LsSf https://astral.sh/uv/install.sh | sh
# 2. 建立 .env 檔案
cp .env.example .env
# 編輯 .env 並填入你的 HF_TOKEN
# 3. 運行範例(一行指令搞定!)
./run-examples.sh verify-hf-token # 驗證 HF Token(不需要 GPU)
./run-examples.sh local-test # 完整測試(需要 GPU,可選)
# 4. 清理快取(可選)
./run-examples.sh cleanup # 清理 HF/uv 快取,釋放空間
優點:
詳細說明請參考:QUICKSTART.md
trans-gemma/
├── document-translator-colab.ipynb # 文件翻譯 Colab notebook(核心檔案)
├── README.md # 本檔案
├── .gitignore # Git 忽略規則
│
├── cloudrun/ # Cloud Run 部署配置
│ ├── Dockerfile # 容器定義
│ ├── requirements.txt # Python 依賴
│ ├── main.py # FastAPI 應用
│ └── deploy.sh # 部署腳本
│
├── docs/ # 文檔
│ ├── colab-vscode-setup.md # VS Code Colab 整合教學
│ └── deployment-guide.md # 部署指南
│
├── examples/ # 使用範例
│ └── simple-translation.py # 簡單翻譯範例
│
└── tests/ # 測試檔案
└── test_translation.py # 單元測試
| 平台 | GPU | 記憶體 | 推理速度 | 成本 |
|---|---|---|---|---|
| Google Colab | T4 | 12GB | ~40 tok/s | 免費 |
| Cloud Run | L4 | 24GB | ~80 tok/s | $0.67/hr |
詳細效能測試結果請參考 performance-benchmarks.md
cd cloudrun
./deploy.sh
詳細步驟請參考 deployment-guide.md
歡迎提交 Issue 或 Pull Request!
本專案採用 MIT 授權條款 - 詳見 LICENSE 檔案
Jimmy Liao (@jimmyliao)
⭐ 如果這個專案對你有幫助,請給個 Star!
88 commits
Jupyter Notebook
64.1%
Shell
17.8%
Python
17.3%
使用 Google Colab + VS Code 開發 TranslateGemma 翻譯模型,並部署到 Cloud Run
本專案實驗 Google 最新開源的 TranslateGemma 翻譯模型(4B 參數版本),採用 Colab-First 開發策略:
TranslateGemma 是 gated repository,使用前需要:
詳細步驟請參考:Hugging Face 存取設定指南
我們提供兩個 Colab notebooks,依據使用場景選擇:
專注於學術論文雙語閱讀:
適合:深入研讀論文、學習專業術語、準備寫作/審稿
支援多種檔案類型:
適合:一般翻譯需求、多種檔案格式
使用步驟(兩個 notebook 都適用):
HF_TOKEN(或手動輸入)document-translator-colab.ipynbuv)⚡最簡單的方式(推薦):
# 1. 安裝 uv(如果尚未安裝)
curl -LsSf https://astral.sh/uv/install.sh | sh
# 2. 建立 .env 檔案
cp .env.example .env
# 編輯 .env 並填入你的 HF_TOKEN
# 3. 運行範例(一行指令搞定!)
./run-examples.sh verify-hf-token # 驗證 HF Token(不需要 GPU)
./run-examples.sh local-test # 完整測試(需要 GPU,可選)
# 4. 清理快取(可選)
./run-examples.sh cleanup # 清理 HF/uv 快取,釋放空間
優點:
詳細說明請參考:QUICKSTART.md
trans-gemma/
├── document-translator-colab.ipynb # 文件翻譯 Colab notebook(核心檔案)
├── README.md # 本檔案
├── .gitignore # Git 忽略規則
│
├── cloudrun/ # Cloud Run 部署配置
│ ├── Dockerfile # 容器定義
│ ├── requirements.txt # Python 依賴
│ ├── main.py # FastAPI 應用
│ └── deploy.sh # 部署腳本
│
├── docs/ # 文檔
│ ├── colab-vscode-setup.md # VS Code Colab 整合教學
│ └── deployment-guide.md # 部署指南
│
├── examples/ # 使用範例
│ └── simple-translation.py # 簡單翻譯範例
│
└── tests/ # 測試檔案
└── test_translation.py # 單元測試
| 平台 | GPU | 記憶體 | 推理速度 | 成本 |
|---|---|---|---|---|
| Google Colab | T4 | 12GB | ~40 tok/s | 免費 |
| Cloud Run | L4 | 24GB | ~80 tok/s | $0.67/hr |
詳細效能測試結果請參考 performance-benchmarks.md
cd cloudrun
./deploy.sh
詳細步驟請參考 deployment-guide.md
歡迎提交 Issue 或 Pull Request!
本專案採用 MIT 授權條款 - 詳見 LICENSE 檔案
Jimmy Liao (@jimmyliao)
⭐ 如果這個專案對你有幫助,請給個 Star!
88 commits
Jupyter Notebook
64.1%
Shell
17.8%
Python
17.3%