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提供可操作的洞察:
一个充满示例的教程,涵盖我们文档中的提示词工程概念。