组合评分
机器翻译译自英文(docs.typesafe.ai)本页 11 段已全部译完
文档索引
在以下地址获取完整的文档索引:https://docs.typesafe.ai/llms.txt 使用此文件可以在进一步探索之前发现所有可用页面。
组合评分
将复杂的判断分解为原子分数,在代码中通过你控制的权重进行组合。
通常我们希望根据多个标准同时对一组项目进行排名。组合评分是一种简单的方法:将判断分解为独立的维度,分别对每个维度进行评分,并在代码中使用你控制的权重将它们组合起来。
示例:简历筛选
想象一下,你正在处理工程职位的简历。你希望根据几个标准对候选人进行排名,并最终选出前 X 名候选人进行进一步审查。
%%{init: {"fontFamily": "Inter, sans-serif", "flowchart": {"rankSpacing": 35, "wrappingWidth": 300, "subGraphTitleMargin": {"top": 12, "bottom": 36}}}}%%
flowchart LR
resume["candidate resume"]
subgraph req["TypeSafe evaluates questions<br/>in parallel"]
direction TB
py["<b>Score:</b> Python depth"]
lead["<b>Score:</b> team leadership"]
arch["<b>Score:</b> system design"]
general["<b>Score:</b> generalist"]
%% Invisible links stack the questions; they are answered in parallel.
py ~~~ lead ~~~ arch ~~~ general
end
resume -- "one request<br/>resume + 4 questions" --> req
req -- "one response<br/>4 score answers" --> normalize["<b>normalize scores to 0–1</b><br/>divide each by 4 in your code"]
normalize --> ic["<b>senior IC weights</b><br/>40% Python + 10% leadership<br/>40% design + 10% generalist"]
normalize --> em["<b>engineering manager weights</b><br/>15% Python + 40% leadership<br/>20% design + 25% generalist"]
ic --> rank["rank candidates<br/>for each role"]
em --> rank步骤 1:独立对每个维度进行评分
{
"python_depth": {
"type": "score",
"instructions": "根据提供的简历,该候选人有多少 Python 经验深度?",
"criteria": [
"未提及 Python 经验",
"提及但无细节",
"在项目中使用,有一些具体细节",
"主要编程语言,多个项目",
"深度专业知识:架构、性能、库"
]
},
"team_leadership": {
"type": "score",
"instructions": "该候选人在管理或领导工程团队方面有多少经验?",
"criteria": [
"未提及管理经验",
"非正式指导或技术领导角色",
"领导过一个小团队或项目",
"管理过有直接下属的团队",
"管理过多个团队或整个工程部门"
]
},
"system_design": {
"type": "score",
"instructions": "该候选人在设计大型或分布式系统方面有多少经验?",
"criteria": [
"未提及架构工作",
"参与过设计讨论",
"设计了较大系统的组件",
"拥有对重要系统的架构所有权",
"在多个领域设计了大规模系统"
]
},
"generalist": {
"type": "score",
"instructions": "有什么证据表明该候选人能够掌握核心专业技能之外的不熟悉工具、角色或领域?",
"criteria": [
"仅提及一个领域或角色",
"有一定多样性但局限于狭窄领域",
"跨几个不同领域或技术栈工作",
"经常在领域之间切换,身兼数职",
"有在不熟悉领域快速上手并交付成果的记录"
]
}
}步骤 2:使用权重进行组合
每个维度都标准化为 0–1 并加权。权重提供了一种简单的方法来调整每个维度的相对重要性,而不会丧失各个分数中的任何细微差别。
scoring.py
py = response.answers["python_depth"].score / 4
lead = response.answers["team_leadership"].score / 4
arch = response.answers["system_design"].score / 4
general = response.answers["generalist"].score / 4
# Senior IC
ic_score = (0.40 * py) + (0.10 * lead) + (0.40 * arch) + (0.10 * general)
# Engineering Manager
em_score = (0.15 * py) + (0.40 * lead) + (0.20 * arch) + (0.25 * general)这使你能够根据组合分数对候选人进行排名。但更重要的是,它让你清楚地看到最终分数是如何计算出来的。如果排名最高的候选人不符合你的期望,你可以调整权重以找到正确的平衡。
AI 翻译查看英文原文