0% read

Gemma 4 的 10 個實用使用場景:你實際上能拿它做什麼

Apr 6, 2026
|Updated: Apr 7, 2026

Gemma 4 的 10 個實用使用場景

Gemma 4 是一個強大的開源 AI 模型,但你實際上能用它做什麼?本指南涵蓋 10 個實用的真實使用場景——每個都有建議的模型大小和你今天就能複製執行的範例提示詞。

這些全都能在你的電腦上透過 Ollama 或類似工具本機執行。不需要 API 金鑰、沒有雲端依賴、資料不離開你的裝置。


1. 本機程式設計助理

建議模型: Gemma 4 12B 或 27B

將 Gemma 4 變成你的個人程式設計助理,能理解你的程式碼庫、建議改善,並寫樣板程式碼讓你不必寫。

範例提示詞:

Write a Python function that reads a CSV file, filters rows where the
"status" column equals "active", and returns the results as a list of
dictionaries. Include error handling for missing files and malformed CSV data.

為什麼它很棒: 與基於雲端的助理不同,你的程式碼絕不離開你的機器。你可以透過 Ollama API 將整個檔案送給 Gemma 4,而不用擔心專有程式碼洩漏到第三方伺服器。

# 從終端機用 Gemma 4 作為程式設計助理
cat myfile.py | ollama run gemma4:12b "Review this code and suggest improvements:"

2. 文件分析

建議模型: Gemma 4 12B

把合約、報告、研究論文或任何長篇文字餵給 Gemma 4,取得結構化摘要、關鍵要點或針對具體問題的答案。

範例提示詞:

I'm going to paste a 10-page contract below. Please:
1. Summarize the key terms in 5 bullet points
2. Identify any unusual clauses that might be concerning
3. List all deadlines and dates mentioned
4. Flag any ambiguous language that should be clarified

[paste contract text here]

為什麼有效: Gemma 4 的 128K 上下文視窗可以在單個提示詞中處理大量文件。12B 模型提供足夠的推理能力來理解細微的法律和商業語言。


3. 語言翻譯

建議模型: Gemma 4 12B

Gemma 4 在主要語言之間提供驚人的翻譯品質,特別是當你提供關於語氣和受眾的上下文時。

範例提示詞:

Translate the following English marketing copy to natural, conversational
Japanese. The target audience is tech-savvy professionals in their 30s.
Avoid overly formal language — aim for a friendly but professional tone.

"Our new app helps you organize your work and life in one place.
No more switching between five different tools just to get through your day."

技巧: 為了最佳結果,一律指定目標受眾、期望的語氣和任何領域特定的術語。通用的「translate this」提示詞產生通用的翻譯。


4. 圖片理解

建議模型: Gemma 4 12B 或 27B(多模態)

Gemma 4 的視覺能力讓你分析圖片、從截圖提取文字、描述圖表和理解視覺內容——全部在本機。

範例提示詞(透過 API):

import ollama

response = ollama.chat(
    model="gemma4:12b",
    messages=[{
        "role": "user",
        "content": "Describe what's in this image and extract any visible text.",
        "images": ["./screenshot.png"]
    }]
)
print(response["message"]["content"])

這個使用場景內的細分用途:

  • 從文件的截圖或照片中提取文字
  • 為無障礙描述圖表和圖形
  • 分析 UI 設計稿並建議改善
  • 識別照片中的物件和場景

5. 內容寫作

建議模型: Gemma 4 12B

從部落格文章到產品描述到社群媒體文案,Gemma 4 可以起草內容,然後你用自己的聲音和專業知識精修。

範例提示詞:

Write a 300-word blog introduction about the benefits of running AI models
locally instead of using cloud APIs. The tone should be practical and
slightly opinionated — not corporate or generic. Target audience: developers
who are curious about local AI but haven't tried it yet.

Avoid clichés like "in today's rapidly evolving landscape" or
"game-changing". Start with a concrete scenario, not an abstract statement.

專業技巧: 你的指示越具體,輸出越好。告訴 Gemma 4 要避免什麼,就像告訴它要包含什麼一樣重要。


6. 從 PDF 提取資料

建議模型: Gemma 4 12B(掃描 PDF 需搭配視覺)

將非結構化的 PDF 內容轉為結構化資料。Gemma 4 可以從文件中提取表格、鍵值對和特定資料點。

範例提示詞:

Extract all line items from this invoice and format them as JSON:

[paste invoice text here]

Expected format:
{
  "invoice_number": "...",
  "date": "...",
  "items": [
    {"description": "...", "quantity": 0, "unit_price": 0.00, "total": 0.00}
  ],
  "subtotal": 0.00,
  "tax": 0.00,
  "total": 0.00
}

對於掃描 PDF: 先用視覺模型從頁面圖片提取文字,然後處理提取的文字取得結構化資料。這種兩步驟的方法處理大多數真實世界的 PDF 場景。


7. 客戶支援聊天機器人

建議模型: Gemma 4 2B (E2B) 求速度,12B 求品質

建構一個執行在你基礎設施上、絕不將客戶資料傳送到外部伺服器的私有、零成本客戶支援聊天機器人。

範例 system prompt:

You are a helpful customer support agent for TechCo, a software company.

Rules:
- Always be polite and professional
- If you don't know the answer, say so honestly and suggest contacting
  support@techco.com
- Never make up product features or pricing
- Keep responses concise (2-3 sentences for simple questions)
- For billing issues, always recommend contacting the billing team directly

Product info:
- TechCo Pro: $29/month, includes 5 users, 100GB storage
- TechCo Enterprise: $99/month, unlimited users, 1TB storage
- Free trial: 14 days, no credit card required

為什麼本機在這裡很重要: 客戶對話通常包含敏感資訊——姓名、帳戶細節、投訴。在本機執行聊天機器人意味著對第三方 AI 供應商零資料暴露。


8. 程式碼審查

建議模型: Gemma 4 12B 或 27B

為你的程式碼找第二雙眼睛。Gemma 4 可以找出 bug、建議改善、識別安全問題並推薦更好的模式。

範例提示詞:

Review the following Python code for:
1. Potential bugs or edge cases
2. Security vulnerabilities
3. Performance issues
4. Code style improvements
5. Missing error handling

Be specific — point to exact lines and explain why each issue matters.

```python
def get_user_data(user_id):
    conn = sqlite3.connect("users.db")
    cursor = conn.cursor()
    result = cursor.execute(f"SELECT * FROM users WHERE id = {user_id}")
    data = result.fetchone()
    return {"id": data[0], "name": data[1], "email": data[2]}

Gemma 4 會正確識別 SQL injection 漏洞、缺少的連線清理、對 null 結果缺少錯誤處理,並建議使用參數化查詢和 context manager。

---

## 9. 研究摘要

**建議模型:** Gemma 4 12B 或 27B

將長篇研究論文、技術文件或文章集合濃縮為可行動的摘要。

**範例提示詞:**

Summarize the following research paper in three sections:

  1. Key Finding (2-3 sentences): What did they discover?
  2. Methodology (2-3 sentences): How did they test it?
  3. Practical Implications (2-3 sentences): Why should I care?

Also note any limitations the authors acknowledge.

[paste paper text here]


**批次處理技巧:** 使用 Ollama API 以程式方式處理多篇論文:

```python
import ollama

papers = ["paper1.txt", "paper2.txt", "paper3.txt"]

for paper_path in papers:
    with open(paper_path) as f:
        content = f.read()

    response = ollama.chat(
        model="gemma4:12b",
        messages=[{
            "role": "user",
            "content": f"Summarize this paper in 3 bullet points:\n\n{content}"
        }]
    )
    print(f"\n--- {paper_path} ---")
    print(response["message"]["content"])

10. 隱私敏感應用

建議模型: Gemma 4 12B(任何大小,視任務而定)

這與其說是單一的使用場景,不如說是一個類別——任何資料隱私不可妥協的任務。

範例:

  • 醫療筆記處理 — 摘要病人筆記而不將健康資料傳送到雲端
  • 法律文件審查 — 分析包含機密商業條款的合約
  • 財務分析 — 處理內部財務報告和預測
  • HR 工作流程 — 篩選履歷、起草職務說明、摘要員工回饋
  • 日記和個人反思 — 用 AI 幫助整理思緒,沒有任何公司會讀到

醫療筆記範例提示詞:

Summarize the following patient visit notes into a structured format:
- Chief complaint
- Key findings
- Diagnosis
- Treatment plan
- Follow-up needed (yes/no, when)

Keep the summary under 100 words. Use medical terminology where appropriate.

[paste notes here]

隱私優勢是絕對的: 當你在本機執行 Gemma 4 時,你的資料實體上無法到達外部伺服器。沒有服務條款要擔心、沒有資料保留政策要讀、沒有來自第三方處理器的合規風險。資料從你的磁碟到你的 GPU 再回來——就這樣。


該用哪個模型大小?

以下是快速參考:

使用場景2B (E2B)12B27B
程式設計助理基本建議最佳
文件分析-建議最佳
翻譯基本建議最佳
圖片理解-建議最佳
內容寫作基本建議最佳
PDF 資料提取-建議良好
客戶支援建議(速度)最佳(品質)過剩
程式碼審查-良好建議
研究摘要-良好建議
隱私應用視任務而定建議最佳

一般規則: 從 12B 模型開始。它能處理 90% 的使用場景。對需要更深推理的任務(複雜程式碼、細微分析)升級到 27B,或對速度和低資源使用最重要時降到 2B。

開始使用

以上所有使用場景今天就能透過 Ollama 實現:

ollama pull gemma4:12b
ollama run gemma4:12b

挑一個使用場景,試試範例提示詞,並改編到你的工作流程。了解 Gemma 4 能做什麼的最好方式就是開始使用它。


延伸閱讀

gemma4 — interact

Stop reading. Start building.

~/gemma4 $ Get hands-on with the models discussed in this guide. No deployment, no friction, 100% free playground.

Launch Playground />
Gemma 4 AI

Gemma 4 AI

Related Guides

Gemma 4 的 10 個實用使用場景:你實際上能拿它做什麼 | 部落格