匠人学院 JR Academy
  • Position

    Where am I now, and where should I go?

    How your job is changing, where your experience can take you and what you still need for a target role, worked out from what you have actually done. Free, and the full result needs no sign-up.

    Analyse my career and skills

    Look up a career

    Will AI replace my job?AI impact and transition paths for common careersNew jobs in the AI eraWhat they do, what they need, how to move in

    Focused tools

    AI Engineer interview readiness30 timed questions on what you still need before interviewsCareer personality testDirections that suit how you workReturning to China checkJob prospects in China by school, major and graduation date

    AI coach

    Talk to your AI coachStill unsure after your result? Talk through what is holding you back
  • Core courses

    AI Engineer BootcampEngineering bootcamp from LLM apps to agentsAI Engineer Full-Stack Project Class16 weeks · RAG and full-stack AI projectsVibe Coding Masterclass8 weeks · direct agents to build and ship a productAI Essentials10 hours · use AI for email, reports, data and copyAI Office Automation Course8 weeks · help a whole company adopt AIOne-Person Company (OPC) Bootcamp15 weeks in person · build a one-person company with AIAll courses →

    AI engineering

    Machine Learning & Data Engineering Full-Stack ClassAI Agent & MCP Project BootcampAI Engineer Core TechniquesAI Engineer FoundationsAI Engineer Advanced: RAG to Agents and TuningClaude Code TasterAll AI engineering courses →

    AI at work

    AI Coding for everyoneClaude Code One-Day Masterclass (Non-Technical)Enterprise AI Automation BootcampAI Marketing BootcampAI Risk, Governance and Audit CourseOpenClaw 4-Week Personal AI Assistant BootcampAll AI-at-work courses →

    Career development

    AI Product Manager (BA) Bootcamp + InternshipAustralia IT Interview BootcampAustralia IT Technical Interview BootcampAustralia IT Resume BootcampAustralia Big Tech Job Search BootcampAustralia IT Career Planning BootcampAll career courses →

    Learn free first

    Vibe CodingAI for office workPrompt MasterAI EngineerAI data analysisResource centerInstructorsAll learning paths →
  • Evidence

    What will convince an employer?

    Certifications, projects, team work and competition entries, collected into one portfolio.

    See the portfolio

    Certifications

    Cert Master · all certificationsPrep and mock exams for AWS, Azure, GCP, Claude and moreAWS CLF-C02Entry-level AWS cloud certificationAWS SAA-C03Entry certification for cloud architectsClaude certificationsAnthropic Claude certification seriesAll certifications →

    Projects and team work

    P3 team projectsBuild a project with real teammates in a simulated team workflowP3 project experienceThe parts of a P3 project that go on your resumeDemo DayProject showcaseP3 certificatesProof once a project is completeAll of P3 →

    Competitions and work

    HackathonsBuild something against the clockSubmit your workAdd your project to the showcaseCareerOS portfolioDo tasks in the desktop app; your results become portfolio pieces
    Cert MasterBrowser extension, app and mini programScreenshot a question for analysis and practise anywhereAbout Cert Master
  • Connect

    How do I get myself in front of employers?

    Resume, interviews, referrals and mentors. See how far you are from the target role first, then decide what to fix.

    Start with Jobpin

    Resume and openings

    Graduate careersGraduate preparation across Australia, China, Malaysia, Singapore, the US and UKJobpinAI job search workspace: resume, roles, applicationsAI resumeRewrite your resume against a job descriptionReferralsRoles shared by students and mentorsOpportunitiesInternships, projects and collaborationsOffer boardOffers students have received

    Interviews

    AI Engineer interview guideSeven areas, with worked examplesFDE interview guideFive rounds, from scoping to the customer roundAI mock interviewPractise by text or voice and see the gapsInterview storiesReal interview experiencesSystem Design handbookPrepare for system design interviewsAll interview prep →

    Mentors

    1:1 mentorsBook AI, career and technical mentors by the hourGroup tutoringShare a tutor with a few others and pay less eachCareer coachingResume, interview and direction packages
    Jobpin desktopOne workspace for the whole job searchOrganise real experience and refine resume versions for target roles on macOS or Windows.About Jobpin
BusinessMembershipDownload CareerOS
0
匠人学院 JR Academy

Follow Us

linkedinfacebooktwitterinstagramyoutube

We Accept

/image/layout/pay-paypal.png/image/layout/pay-visa.png/image/layout/pay-master-card.png/image/layout/pay-airwallex.png/image/layout/pay-alipay.png
Airbotix · AI learning & creation for kids Another Life · AI story game
Products46

CareerOS and tools

  • CareerOS
  • Cert Master
  • Jobpin
  • Jobpin web
  • Jobpin report
  • Jobpin desktop download
  • My job search reports
  • Buy report credits
  • Jobpin billing
  • AI Toolbox
  • AI Skill Marketplace

Membership

  • Membership
  • AI membership

Courses

  • Bootcamps
  • Training Camp
  • Kanban learning
  • AI Builder course
  • MCP course
  • NotebookLM workshop
  • Business Analyst course
  • Web Full-Stack Bootcamp
  • DevOps Bootcamp
  • Data Engineering Bootcamp
  • Data Analysis Bootcamp
  • Coding for Beginners
  • Algorithm Bootcamp

Career services

  • Graduate careers
  • Graduate careers in Australia
  • Graduate careers in China
  • Graduate careers in Malaysia
  • Graduate careers in Singapore
  • Graduate careers in the US
  • Graduate careers in the UK
  • 1:1 coaching
  • Career coaching
  • AI Engineer VIP
  • BA & PM Internship
  • Data Science Internship
  • Data Analysis Internship
  • Marketing Internship
  • Resume Review
  • Interview Coaching
  • Job Application Service
  • Job Monitoring
  • LinkedIn Management
  • LinkedIn Networking
Library57

Learning paths

  • All Learning Paths
  • AI Engineer
  • Context Engineering
  • Vibe Coding
  • Prompt Master
  • AI Builder
  • AI Product Manager
  • Python Basics
  • AI Productivity
  • AI Data Analysis
  • AI Finance
  • AI Content Creation
  • AI Image Creation
  • Frontend Development
  • Hermes Agent
  • OpenClaw Local Agent

Interactive labs

  • Prompt Lab
  • Frontend Lab
  • JavaScript Lab
  • Python Lab
  • AWS Lab
  • Azure Lab
  • LLM Lab
  • Git Lab

Reference and guides

  • Resources
  • Wiki
  • Cheat sheets
  • Roadmaps
  • AI roadmaps
  • Videos
  • Ebooks
  • Blog
  • Interview handbook
  • Mock exams
  • Free resources

Cities

  • Sydney
  • Melbourne
  • Brisbane
  • Adelaide
  • Singapore
  • Kuala Lumpur
  • London
  • New York
  • San Francisco
  • Los Angeles
  • Seattle
  • Toronto
  • Vancouver

Immigration

  • Australia Immigration
  • Skilled Visa 189/190/491
  • Employer Sponsored 482/186/494
  • Business Visa 188/888
  • UK Immigration
  • US Immigration
  • Canada Immigration
  • Singapore immigration
  • Malaysia immigration
Business20

For business

  • AI for Business
  • Business portal sign-in
  • Corporate Training
  • Internship Partnership
  • Recruitment Partnership
  • Enterprise (EN)

Metatree AI Lab

  • Metatree AI Lab (Chinese)
  • AI solutions (Chinese)
  • Digital employees (Chinese)
  • Case studies (Chinese)
  • Metatree AI Lab
  • AI services
  • Digital employees
  • Case studies

AI education for kids

  • Airbotix — AI Learning & Creation for Kids
  • AU Family Resource Hub
  • NAPLAN Report Guide
  • My School Data Guide
  • Sydney Private School Fees 2026
  • Kids Coding Programs
About15

Company

  • About Us
  • Our Mentors
  • Become a Mentor
  • Metaverse Classroom
  • JR Careers
  • Another Life — AI Story Game
  • Contact Us

Help and policies

  • FAQs
  • Terms & Conditions
  • Privacy Policy
  • Cancellation & Refund Policy
  • Site map

Friend links

  • CS Browser

Contact

  • hello@jiangren.com.au
  • 0421-672-555

Offices

Level 10b, 144 Edward Street, Brisbane CBD (Headquarter)
Level 2, 171 La Trobe St, Melbourne VIC 3000
45A13, Block B, Oriental Hope Tianxiang Plaza, 500 Tianfu Avenue Middle Section, Wuhou District, Chengdu, Sichuan, China
Business Hub, 155 Waymouth St, Adelaide SA 5000
Disclaimer
footer-disclaimerfooter-disclaimer

JR Academy acknowledges Traditional Owners of Country throughout Australia and recognises the continuing connection to lands, waters and communities. We pay our respect to Aboriginal and Torres Strait Islander cultures; and to Elders past and present. Aboriginal and Torres Strait Islander peoples should be aware that this website may contain images or names of people who have since passed away.

All content on the JR Academy website, including course materials, logos, and information provided, is protected under Australian intellectual property laws. Unauthorized use, sale, distribution, reproduction, or modification is strictly prohibited. Violations may result in legal action. By accessing our website, you agree to respect our intellectual property. JR Academy Pty Ltd reserves all rights, including patents, trademarks, and copyrights. Any infringement will be subject to legal prosecution. View Terms of Service

© 2017-2026 JR Academy Pty Ltd. All rights reserved.

ABN 26621887572

HomeLearnCoursesCerts
  1. Home
  2. Learn
  3. Blog
  4. Gemma 4 上手指南:Apache 2.0 开源,31B 编程能力超越大多数闭源模型
JR Academy · BlogCareer insights

Gemma 4 上手指南:Apache 2.0 开源,31B 编程能力超越大多数闭源模型

Google Gemma 4 刚发布,Apache 2.0 授权,四个尺寸可选,31B 在全球开源模型中排第三。这篇文章告诉你怎么选尺寸、怎么本地部署、怎么接入实际项目。

Published2026-04-05
Reading time2 min
Author

Contents

  • 先把尺寸选对
  • 三种接入方式
  • 方式一:Google AI Studio(零成本上手)
  • 方式二:Ollama 本地部署
  • 方式三:Hugging Face Transformers(Fine-tuning 场景)
  • Gemma 4 实际适合哪些任务
  • 跟竞争对手的真实对比
  • 快速上手清单
  • 相关 JR Academy 资源

Google DeepMind 在 4 月 2 日发布了 Gemma 4。这不是"又一个开源模型"——31B 版本目前在 Lmsys Chatbot Arena 文本榜排全球第三,比它强的开源模型只有 DeepSeek V3 和 Qwen 3.5-Plus。Apache 2.0 授权,可以直接商用。

这篇文章是给想用起来的开发者写的,不是给想了解 AI 趋势的人写的。


先把尺寸选对

Gemma 4 有四个版本,选错了要么浪费资源要么效果不够用:

模型 参数量 推荐场景
Gemma 4 E2B 2B(高效版) 手机端/边缘设备,低延迟场景
Gemma 4 E4B 4B(高效版) 消费级 GPU 本地跑,日常辅助
Gemma 4 26B MoE 26B 混合专家 编程、分析,推理成本接近 4B
Gemma 4 31B Dense 31B 稠密 最强能力,需要高端 GPU

大多数开发者应该先试 26B MoE。MoE 架构的特点是总参数大但激活参数少——推理时只有一部分参数被激活,速度和显存消耗接近 10B 级模型,但实际效果接近 30B。它在 Arena 榜排第六,编程和数学表现扎实。

31B Dense 是旗舰,但需要至少 24GB 显存(A100/RTX 4090 级别)。如果你没有这个硬件,别死磕,先用 26B MoE。


三种接入方式

方式一:Google AI Studio(零成本上手)

Google 在 AI Studio 提供 Gemma 4 免费访问,不需要部署,不需要 GPU:

# 安装 Google GenAI SDK
pip install google-generativeai
import google.generativeai as genai

genai.configure(api_key="YOUR_API_KEY")  # 从 aistudio.google.com 获取

model = genai.GenerativeModel("gemma-4-31b-it")  # 或 gemma-4-26b-moe-it

response = model.generate_content(
    "用 Python 写一个异步任务队列,支持优先级和重试机制"
)
print(response.text)

适合:快速原型验证、个人项目、不需要私有化的场景。

方式二:Ollama 本地部署

Ollama 是最简单的本地 LLM 运行方式,Gemma 4 发布后几小时内就有了官方支持:

# 安装 Ollama(macOS/Linux)
curl -fsSL https://ollama.ai/install.sh | sh

# 拉取模型(26B MoE 约 16GB)
ollama pull gemma4:26b-moe

# 运行
ollama run gemma4:26b-moe

通过 API 调用(兼容 OpenAI 格式):

from openai import OpenAI

client = OpenAI(
    base_url="http://localhost:11434/v1",
    api_key="ollama",  # 任意值
)

response = client.chat.completions.create(
    model="gemma4:26b-moe",
    messages=[
        {"role": "user", "content": "帮我 review 这段代码,找出潜在的并发问题"}
    ]
)
print(response.choices[0].message.content)

适合:需要数据隐私、离线场景、二次开发。

方式三:Hugging Face Transformers(Fine-tuning 场景)

如果你需要微调,直接用 HF Transformers:

from transformers import AutoTokenizer, AutoModelForCausalLM
import torch

model_id = "google/gemma-4-27b-it"  # HF 上的模型 ID

tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
    model_id,
    torch_dtype=torch.bfloat16,
    device_map="auto",
)

inputs = tokenizer("帮我写一个 React hook,用于管理复杂表单状态", return_tensors="pt")
outputs = model.generate(**inputs, max_new_tokens=512)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))

Fine-tuning 推荐用 QLoRA,在单张 A100 上可以微调 31B 模型:

pip install trl peft bitsandbytes
from trl import SFTTrainer
from peft import LoraConfig
from transformers import TrainingArguments

lora_config = LoraConfig(
    r=16,
    lora_alpha=32,
    target_modules=["q_proj", "v_proj"],
    lora_dropout=0.05,
    bias="none",
    task_type="CAUSAL_LM",
)

# 用你自己的数据集替换 dataset
trainer = SFTTrainer(
    model=model,
    train_dataset=dataset,
    peft_config=lora_config,
    args=TrainingArguments(
        output_dir="./gemma4-finetuned",
        num_train_epochs=3,
        per_device_train_batch_size=2,
        gradient_accumulation_steps=4,
        warmup_steps=100,
        learning_rate=2e-4,
        bf16=True,
    ),
)
trainer.train()

Gemma 4 实际适合哪些任务

根据发布的基准数据,有几个场景 Gemma 4 明显够用:

编程:Codeforces ELO 从前代的 110 跳到 2150,LiveCodeBench v6 达到 80%。日常代码补全、debug、代码 review 完全没问题。31B 在复杂算法题上的表现已经超过大多数程序员。

数学推理:AIME 2026 达到 89.2%。如果你的产品需要处理数学公式、量化计算、数据分析,Gemma 4 是可靠的选择。

多语言:Gemma 4 对中文的支持比前代强了很多(Google 在训练数据上增加了多语言比重)。中英混合的技术文档场景表现不错。

不太适合的场景:实时语音对话(用 MAI-Voice-1 或 Whisper 更合适)、图像生成(这不是 Gemma 4 的方向)、需要 100 万 Token 超长上下文的场景(等 DeepSeek V4)。


跟竞争对手的真实对比

Gemma 4 31B 在 Arena 文本榜排第三,但这个榜单是综合人类偏好投票,不等于每个任务都第三。

具体来看:

  • vs Llama 4:Gemma 4 Apache 2.0 许可更宽松,编程基准更强,但 Llama 4 有更大的社区生态
  • vs Qwen 3.5:Qwen 在中文任务上有优势,Gemma 4 在推理和数学上更强
  • vs DeepSeek V3:V3 目前仍然是开源最强,但 Gemma 4 的 Google 背书意味着更稳定的长期维护

实际选型建议:如果你在做 coding agent 或数学密集的应用,先用 Gemma 4 26B MoE 跑基准测试,再决定要不要花钱买 API 或部署 31B。


快速上手清单

  1. 今天就能试:去 Google AI Studio 免费体验,不需要信用卡
  2. 本地跑起来:安装 Ollama,ollama pull gemma4:26b-moe,5 分钟搞定
  3. 评估编程能力:把你项目里最复杂的一段代码丢给它 review,看输出质量
  4. 考虑微调:如果你有领域数据,Gemma 4 + QLoRA 是现在性价比最高的私有模型方案之一

Apache 2.0 意味着你用 Gemma 4 做的商业产品不需要向 Google 付授权费,也不需要开源你的代码。这是真正可以放心押注的开源模型。


相关 JR Academy 资源

  • Claude Code 工作流指南 - 把 AI 编程助手用起来
  • Cursor IDE 实用技巧 - 编辑器级别的 AI 集成
Author
Share or copy the link
← Previous article推荐一个老板和高管会喜欢的OpenClaw私享会Next article →AI 日报 2026-04-06:Claude Mythos 万亿参数模型曝光,GPT-5.4 首次超越人类基准

Related articles

🇦🇺测一下:袋鼠国码农能当FDE吗?

2026-12-01

Monash 研究:肠道酸度是膳食纤维降血压的关键;AI 搬运新闻冲击维州选举信息;MPAC 公布 2027 演出季

2026-12-01

Adelaide 物理学家获 $250,000 总理科学奖;全球葡萄酒消费六十年降四分之一;残障师范生实习障碍研究

2026-12-01

DVA-C03今日上线首发 · Google Cloud AI Agent认证完整解析 · AZ-401本月GA替代AZ-400

2026-12-01

Anthropic推迟下一代模型并调百人做安全,AWS推出AI办公三件套,Google让用户单独关掉AI训练

2026-12-01

GitHub Copilot 实战指南 — Copilot AI Code Review:30 秒让 AI 帮你审 PR,三档深度随需切换

2026-11-30
View all articles →

Done reading? Next steps

Not sure what to learn next? Tell us where you are

Tell us what you do now and where you want to go. See your gaps in skills, evidence, experience, expression and positioning, and what to work on first. No sign-in needed.

Compare with my situation
  • SkillLearn AI for free by pathVibe Coding, AI at work, prompting, AI engineering and more, chapter by chapter from the basics.All learning paths →
  • PositioningLearning roadmaps by roleFrontend, backend, data, AI and more, laid out stage by stage in the order to learn them.All roadmaps →
  • ExpressionTry an AI mock interviewPick a role and run a mock interview to practise explaining your experience and projects.Practise now →

Not sure what to do next?

Take this page's topic with you and see where your gaps are.

Compare with my situation
JR Academy
AI learning for the global Chinese community
BootcampsFree resourcesLearn AICareer coaching
精选推荐
AI Career Impact Map
Assess career exposure and explore transition paths and learning options
Popular tool
AI & Data Bootcamps
Build your skills through structured courses and hands-on projects
Popular courses
1:1 Career Coaching
Work with an experienced mentor on your resume and interview preparation
Career coaching
Custom Corporate Training
AI training tailored to your team
Business services
Popular tags
Vibe CodingAI codingCursorClaudeJob searchPromptFrontend developmentBackend development
Subscribe to updates

Receive AI learning resources, technical tutorials and career advice by email.

We respect your privacy and do not send spam.