Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
While these tips apply broadly to all Claude models, you can find prompting tips specific to extended thinking models here.
使用Claude时,您可以通过使用system参数为其分配角色来显著提高其性能。这种技术称为角色提示,是使用系统提示与Claude配合的最强大方式。
正确的角色可以将Claude从通用助手转变为您的虚拟领域专家!
system参数设置Claude的角色。将其他所有内容(如特定任务的说明)放在user轮次中。在Messages API中使用system参数来设置Claude的角色:
import anthropic
client = anthropic.Anthropic()
response = client.messages.create(
model="claude-sonnet-4-5-20250929",
max_tokens=2048,
system="You are a seasoned data scientist at a Fortune 500 company.", # <-- role prompt
messages=[
{"role": "user", "content": "Analyze this dataset for anomalies: <dataset>{{DATASET}}</dataset>"}
]
)
print(response.content)数据科学家可能会对相同的数据看到不同的见解,而营销策略师也会如此。专门从事财富500强公司客户洞察分析的数据科学家可能会产生完全不同的结果!没有角色的情况下,Claude可能会遗漏关键问题:
通过角色提示,Claude能够发现可能造成数百万美元损失的关键问题:
没有角色的情况下,Claude的分析缺乏深度:
通过角色提示,Claude提供可行的洞察: