View a markdown version of this page

适应性思维 - Amazon Bedrock

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

适应性思维

建议在 Claude Opus 4.6 中延伸思考使用自适应思维。自适应思维不是手动设置思维代币预算,而是可以根据每个请求的复杂性Claude动态决定何时考虑以及考虑多少。与固定思维相比,适应性思维可以可靠地推动更好的表现budget_tokens,我们建议转向适应性思维,以便从 Claude Opus 4.6 中获得最聪明的回应。不需要测试版标题。

支持的模型如下所示:

模型 模型 ID

Claude Opus 5

anthropic.claude-opus-5

Claude Mythos 5

anthropic.claude-mythos-5

Claude Fable 5

anthropic.claude-fable-5

Claude Opus4.7

anthropic.claude-opus-4-7

Claude Mythos 预览

anthropic.claude-mythos-preview

Claude Opus4.6

anthropic.claude-opus-4-6-v1

克劳德十四行诗 4.6

anthropic.claude-sonnet-4-6

注意

Claude Mythos 5、Claude Fable 5、Claude Opus 4.7 和 Claude Mythos Preview 仅支持适应性思维。 这些模型不支持手动扩展思考(thinking.type: "enabled"使用 budget_tokensthinking.type: "disabled")和禁用思维(),将返回 400 错误。thinking.type: "adaptive"与一起使用output_config.effort可控制思维行为。

thinking.type: "enabled"budget_tokens在 Claude Opus 4.6 和 Claude Sonnet 4.6 中已弃用,并将在未来的模型版本中删除。改为thinking.type: "adaptive"与 effort 参数一起使用。

较旧的模型(Claude Sonnet 4.5、Claude Opus 4.5 等)不支持自适应思维,需要thinking.type: "enabled"使用budget_tokens

适应性思维是如何运作的

在自适应模式下,Claude评估每个请求的复杂性并决定是否要考虑以及考虑多少。在默认努力级别 (high) 下,几乎总是Claude会思考。在较低的努力水平下,Claude可能会跳过思考更简单的问题。

适应性思维也可以自动启用交替思考(测试版)。这意味着Claude可以在工具调用之间进行思考,使其对代理工作流程特别有效。

"adaptive"在您的 API 请求中设置thinking.type为:

CLI
aws bedrock-runtime invoke-model \ --model-id "us.anthropic.claude-opus-4-6-v1" \ --body '{ "anthropic_version": "bedrock-2023-05-31", "max_tokens": 16000, "thinking": { "type": "adaptive" }, "messages": [ { "role": "user", "content": "Three players A, B, C play a game. Each has a jar with 100 balls numbered 1-100. Simultaneously, each draws one ball. A beats B if As number > Bs number (mod 100, treating 100 as 0 for comparison). Similarly for B vs C and C vs A. The overall winner is determined by majority of pairwise wins (ties broken randomly). Is there a mixed strategy Nash equilibrium where each player draws uniformly? If not, characterize the equilibrium." } ] }' \ --cli-binary-format raw-in-base64-out \ output.json && cat output.json | jq '.content[] | {type, thinking: .thinking[0:200], text}'
Python
import boto3 import json bedrock_runtime = boto3.client( service_name='bedrock-runtime', region_name='us-east-2' ) response = bedrock_runtime.invoke_model( modelId="us.anthropic.claude-opus-4-6-v1", body=json.dumps({ "anthropic_version": "bedrock-2023-05-31", "max_tokens": 16000, "thinking": { "type": "adaptive" }, "messages": [{ "role": "user", "content": "Explain why the sum of two even numbers is always even." }] }) ) response_body = json.loads(response["body"].read()) for block in response_body["content"]: if block["type"] == "thinking": print(f"\nThinking: {block['thinking']}") elif block["type"] == "text": print(f"\nResponse: {block['text']}")
TypeScript
import { BedrockRuntimeClient, InvokeModelCommand } from "@aws-sdk/client-bedrock-runtime"; async function main() { const client = new BedrockRuntimeClient({}); const command = new InvokeModelCommand({ modelId: "us.anthropic.claude-opus-4-6-v1", body: JSON.stringify({ anthropic_version: "bedrock-2023-05-31", max_tokens: 16000, thinking: { type: "adaptive" }, messages: [{ role: "user", content: "Explain why the sum of two even numbers is always even." }] }) }); const response = await client.send(command); const responseBody = JSON.parse(new TextDecoder().decode(response.body)); for (const block of responseBody.content) { if (block.type === "thinking") { console.log(`\nThinking: ${block.thinking}`); } else if (block.type === "text") { console.log(`\nResponse: ${block.text}`); } } } main().catch(console.error);

使用努力参数进行适应性思考

你可以将适应性思维与努力参数相结合,以指导思考的Claude效果。努力水平可作为思维分配Claude的软指导:

工作量级别 思维行为
max Claude始终不受思维深度限制地思考。Claude Opus仅限 4.6 和 Claude Opus 5 — max 在其他模型上使用的请求将返回错误。
xhigh Claude始终以更深的深度思考。仅限 Claude Opus 5 和 Claude Opus 4.6。
high(默认值) Claude总是在想。为复杂任务提供深度推理。
medium Claude使用适度的思维。对于非常简单的查询,可能会跳过思考。
low Claude最大限度地减少思考。无需思考速度最重要的简单任务。
重要

effort参数必须放置在请求正文中的单独output_config对象内,而不是放置在thinking对象内。放置在effort里面thinking会导致ValidationException.

重要

思维被禁用时的努力上限(Claude Opus 5):Claude Opus 5 支持"thinking": {"type": "disabled"},但当思维被禁用时,output_config.effort上限为。high如果请求xhighmax努力与思维障碍相结合,将返回invalid_request_error. 此上限还适用于通过对话中间系统消息设定的每回合努力量。要使用xhighmax努力,请启用自适应思维(默认)或完全省略该thinking参数。

以下示例显示了在使用 InvokeModel API 时如何设置工作量级别:

{ "anthropic_version": "bedrock-2023-05-31", "max_tokens": 16000, "thinking": { "type": "adaptive" }, "output_config": { "effort": "high" }, "messages": [{ "role": "user", "content": "Your prompt here" }] }

在 Converse API 中使用自适应思维

使用 Converse API 时,将thinkingeffort参数传递到里面additionalModelRequestFields。以下示例显示了默认努力水平下的适应性思维:

import boto3, json bedrock_runtime = boto3.client(service_name='bedrock-runtime', region_name='us-east-2') response = bedrock_runtime.converse( modelId="us.anthropic.claude-opus-4-6-v1", messages=[{ "role": "user", "content": [{"text": "Explain why the sum of two even numbers is always even."}] }], additionalModelRequestFields={ "thinking": { "type": "adaptive" } } ) print(json.dumps(response["output"], indent=2, default=str))

要指定努力级别,请在以下单独的output_config对象中添加该effort字段additionalModelRequestFields

response = bedrock_runtime.converse( modelId="us.anthropic.claude-opus-4-6-v1", messages=[{ "role": "user", "content": [{"text": "What is 2 + 2?"}] }], additionalModelRequestFields={ "thinking": { "type": "adaptive" }, "output_config": { "effort": "low" } } )

提示缓存

使用 adaptive thinking 的连续请求会保留提示的缓存断点。但是,在adaptiveenabled/disabled思维模式之间切换会破坏消息的缓存断点。无论模式如何更改,系统提示和工具定义都将保持缓存状态。

调整思维行为

Claude如果思考的频率比你想要的多或少,你可以在系统提示符中添加指导:

Extended thinking adds latency and should only be used when it will meaningfully improve answer quality — typically for problems that require multi-step reasoning. When in doubt, respond directly.
警告

Claude转而减少思考频率可能会降低受益于推理的任务的质量。在将基于提示的调整部署到生产环境之前,先衡量对特定工作负载的影响。考虑先用较低的工作量进行测试。

连接器文本摘要(测试版)

在 Claude Fable 5 中,模型在工具调用之间发出的文本(有时称为 “连接器文本” ——例如,“接下来让我检查那个文件...”)在服务器端汇总并作为思维方块而不是纯文本内容块返回。思维方块使用与任何其他思维方块相同的形状(默认omitted显示屏下带有签名的空文本)。

客户影响:

  • 响应形状: Tool-use 来自 Claude Fable 5 的响应可能包含额外的思维方块,其中先前的模型在方块之间发出纯文本。tool_use没有新的内容块类型。最终的助手答案(在所有工具使用完毕后)不受影响,仍为纯文本。

  • Multi-turn 处理:在多回合对话中将这些思维方块原封不动地传回去,处理方式与受保护思维相同(传回时签名已验证;如果发送到其他模型,则静默删除)。

  • 范围:连接器摘要仅在对话中tool_result存在 a 后才适用。新对话中第一次工具调用之前的旁白仍然是纯文本。短文本段可以作为纯文本传递,无需摘要。

此功能已在 Claude Fable 5 的服务器端启用。没有客户选择加入或选择退出。