Gemini 2.0 Flash Thinking 模型是一种实验性模型,经过训练后,该模型会生成“思考过程”,并将其作为回答的一部分。因此,Flash Thinking 模型的回答比 Gemini 2.0 Flash Experimental 模型具备更强的推理能力。
使用思维模型
闪电思考模型可在 Google AI Studio 中使用,也可通过 Gemini API 使用。Gemini API 不会在响应中返回想法。
发送基本请求
此示例使用新的 Google Genai SDK 和 v1alpha
版 API。
from google import genai
client = genai.Client(api_key='GEMINI_API_KEY', http_options={'api_version':'v1alpha'})
response = client.models.generate_content(
model='gemini-2.0-flash-thinking-exp',
contents='Explain how RLHF works in simple terms.',
)
print(response.text)
多轮思考对话
在多轮对话期间,模型的输入中会移除之前几轮对话中的想法。
新的 Google Genai SDK 提供了创建多轮聊天会话的功能,这有助于管理对话状态。
from google import genai
client = genai.Client(api_key='GEMINI_API_KEY', http_options={'api_version':'v1alpha'})
chat = client.aio.chats.create(
model='gemini-2.0-flash-thinking-exp',
)
response = await chat.send_message('What is your name?')
print(response.text)
response = await chat.send_message('What did you just say before this?')
print(response.text)
限制
Flash Thinking 模型是一种实验性模型,具有以下限制:
- 无 JSON 模式或搜索着陆页
- 思考内容仅在 Google AI Studio 中显示
后续操作
- 在 Google AI Studio 中试用“闪电思考”模型。
- 试用 Flash Thinking Colab。