Gemini 2.0 Flash Thinking

Gemini 2.0 Flash Thinking 是一种实验性模型,经过训练后,该模型会生成“思考过程”,并将其作为回答的一部分。因此,Gemini 2.0 Flash Thinking 的回答比 Gemini 2.0 Flash 基本模型具备更强的推理能力。

使用 Flash Thinking

闪电般的思考模型在 Vertex AI 中作为实验性模型提供。如需使用最新的 Flash Thinking 模型,请在模型下拉菜单中选择 gemini-2.0-flash-thinking-exp-01-21 模型。

Gen AI SDK for Python

了解如何安装或更新 Gen AI SDK for Python

如需了解详情,请参阅 SDK 参考文档

设置环境变量以将 Gen AI SDK 与 Vertex AI 搭配使用:

# Replace the `GOOGLE_CLOUD_PROJECT` and `GOOGLE_CLOUD_LOCATION` values
# with appropriate values for your project.
export GOOGLE_CLOUD_PROJECT=GOOGLE_CLOUD_PROJECT
export GOOGLE_CLOUD_LOCATION=us-central1
export GOOGLE_GENAI_USE_VERTEXAI=True

from google import genai
from google.genai.types import HttpOptions

client = genai.Client(http_options=HttpOptions(api_version="v1"))
response = client.models.generate_content(
    model="gemini-2.0-flash-thinking-exp-01-21",
    contents="solve x^2 + 4x + 4 = 0",
)
print(response.text)
# Example response:
#     To solve the equation x^2 + 4x + 4 = 0, we can use several methods.
#
#     **Method 1: Factoring**
#
#     We look for two numbers that multiply to 4 (the constant term) and add to 4 (the coefficient of the x term).
#     These two numbers are 2 and 2 because 2 * 2 = 4 and 2 + 2 = 4.
#     Therefore, we can factor the quadratic expression as:
#     (x + 2)(x + 2) = 0
#     This can also be written as:
#     (x + 2)^2 = 0
#
#     To solve for x, we set the factor (x + 2) equal to zero:
#     x + 2 = 0
#     Subtract 2 from both sides:
#     x = -2
#
#     **Method 2: Quadratic Formula**
#
#     The quadratic formula for an equation of the form ax^2 + bx + c = 0 is given by:
#     x = [-b ± sqrt(b^2 - 4ac)] / (2a)
#
#     ...
#
#
#     All three methods yield the same solution, x = -2.
#     This is a repeated root, which is expected since the discriminant (b^2 - 4ac) is 0.
#
#     To check our solution, we substitute x = -2 back into the original equation:
#     (-2)^2 + 4(-2) + 4 = 4 - 8 + 4 = 0
#     The equation holds true, so our solution is correct.

#     Final Answer: The final answer is $\boxed{-2}$

限制

Flash Thinking 是一种实验性模型,存在以下限制:

  • 100 万个 token 输入限制
  • 文本、图片、音频和视频输入
  • 64000 个 token 输出限制
  • 仅文本输出
  • 未使用搜索或代码执行等内置工具

后续步骤

您可以使用我们的 Colab 笔记本试用闪电思考功能,也可以打开 Vertex AI 控制台,尝试自行提示模型。