今天我们宣布推出 Google Colab 命令行界面(CLI),它弥合了本地终端与远程 Colab 运行时之间的鸿沟,为开发者和 AI 智能体提供了一个零摩擦的执行平台。Colab CLI 提供以下功能:
- 零摩擦加速器配置:即时申请高性能 GPU 或 TPU(例如 `colab --gpu A100` 或 `colab --gpu T4`)。
- 简单远程执行:使用 `colab exec` 在 Colab 运行时上直接运行本地 Python 脚本和复杂的机器学习流水线。
- 无缝工件恢复:通过 `colab download` 和 `colab log` 轻松检索模型、数据集以及可复现的 `.ipynb` 日志。
- 交互式访问:通过 `colab repl` 或 `colab console` 进入远程 Colab 运行时的交互式环境。
智能体驱动的工作流实战
由于 Colab CLI 能够无缝集成到标准终端环境中,任何具备终端访问权限的智能体都可以使用它。为了确保你的 AI 助手能够快速上手,该 CLI 包含一个预打包的 Colab 技能文件,为智能体提供关于如何利用 CLI 的即时内置上下文。让我们来看一个用户或智能体可能使用 Colab CLI 的真实示例。
*请注意,虽然下面的示例重点展示了 Antigravity 智能体将 Colab CLI 作为工具使用,但 Colab CLI 同样可以轻松被 Claude Code、Codex 以及其他智能体使用。
以下是智能体如何使用 Colab CLI 执行真实机器学习工作流的示例:
微调 Gemma 3-1B
该 CLI 可用于运行一个真实的 QLoRA 流水线,仅需少量命令即可端到端执行。通过指示 Antigravity(或你选择的智能体)构建一个远程微调任务,无需输入任何云配置命令,即可将繁重的计算负载卸载到 GPU 上。在此场景中,我们要求智能体使用 Colab CLI 在 Text-to-SQL 数据集上微调 `google/gemma-3-1b-it`,以使模型在编写 SQL 查询方面表现更佳。
反重力提示词:使用 Colab CLI(https://github.com/googlecolab/google-colab-cli)通过 QLoRA 微调 Gemma 3 1B。配置一个 Colab T4 GPU 实例,安装必要的机器学习包(transformers、datasets、peft、trl 等),远程运行本地的 ~finetune_run.py 脚本,下载生成的 safetensors 适配器,保存笔记本日志,并进行清理。
反重力执行:
$ colab new --gpu T4
$ colab install transformers datasets peft trl bitsandbytes accelerate
$ colab exec -f finetune_run.py
$ colab log --output gemma_finetune_log.ipynb
$ colab stop 反重力还使用“colab download”命令下载适配器模型、适配器配置、分词器配置和分词器,这些文件可用于在本地加载并运行你微调后的模型。现在,你拥有了一个远程微调好的模型,可以随时从本地设备提供服务!
立即尝试
Colab CLI 使强大的 Colab 算力变得可访问、可编程且适配智能体。它轻量级且易于任何基于终端的 AI 智能体使用。要开始自行使用 Colab CLI,请前往 Google Colab CLI GitHub 仓库查看设置说明。
我们很期待看到这将如何加速你的开发流程,并期待你和你的智能体所构建的成果!
- AI
- 云
- 公告
- 学习
Today we are announcing the Google Colab Command-Line Interface (CLI), which bridges the gap between your local terminal and remote Colab runtimes, providing a zero-friction execution platform for both developers and AI agents. The Colab CLI offers:
- Zero-Friction Accelerator Provisioning: Request high-powered GPUs or TPUs instantly (e.g.,
colab --gpu A100orcolab --gpu T4). - Simple Remote Execution: Run your local Python scripts and complex ML pipelines directly on Colab runtimes using
colab exec. - Seamless Artifact Recovery: Easily retrieve models, datasets, and replayable
.ipynblogs viacolab downloadandcolab log. - Interactive Access: Drop into an interactive environment on your remote Colab runtime with
colab replorcolab console.
Agent-driven workflows in action
Because the Colab CLI integrates seamlessly into standard terminal environments, it can be used by any agent with terminal access. To ensure your AI assistants can hit the ground running, the CLI includes a prepackaged Colab skill file that provides agents with instant, built-in context on exactly how to leverage the CLI. Let's look at a real life example of something a user or agent might try with the Colab CLI.
*Note that while the example below highlights Antigravity agent using Colab CLI as a tool, Colab CLI can easily be used by Claude Code, Codex, and other agents.
Here is how an Agent can use the Colab CLI for a real-world ML workflow:
Fine-tuning Gemma 3-1B
The CLI can be used to run a real QLoRA pipeline that runs end-to-end with just a handful of commands. Offload heavy computational lifting to a GPU without typing a single cloud provisioning command by Instructing Antigravity (or your agent of choice) to build a remote fine-tuning job. In this scenario, we ask our agent to use the Colab CLI to fine-tune google/gemma-3-1b-it on a Text-to-SQL dataset to make the model better at writing SQL queries.
The Antigravity prompt:
Use the Colab CLI (https://github.com/googlecolab/google-colab-cli) to fine-tune Gemma 3 1B using QLoRA. Provision a Colab T4 GPU instance, install the necessary ML packages (transformers, datasets, peft, trl, etc.), run my local ~finetune_run.py script remotely, download the resulting safetensors adapter, save the notebook log, and cleanup.
Antigravity executes:
$ colab new --gpu T4
$ colab install transformers datasets peft trl bitsandbytes accelerate
$ colab exec -f finetune_run.py
$ colab log --output gemma_finetune_log.ipynb
$ colab stop Antigravity also uses the "colab download" command to download the adapter model, adapter config, tokenizer config, and tokenizer, which can be used to load and run your fine-tuned model locally. Now you have a remotely fine-tuned model ready to serve from your local device!
Try it out now
The Colab CLI makes powerful Colab compute accessible, programmable, and agent-ready. It is lightweight and easily accessible to any terminal-based AI agent. To start using the Colab CLI yourself, head over to the Google Colab CLI GitHub repository for setup instructions.
We are excited to see how this accelerates your development process and look forward to seeing what you and your agents build!