PairRM¶
使用 LLM
模型根据输入对候选进行排序。
注意¶
此步骤与其他任务不同,因为目前此模型只有一个实现,我们将使用特定的 LLM
。
属性¶
-
model: 用于排序的模型。默认为
"llm-blender/PairRM"
。 -
instructions: 用于模型的指令。默认为
None
。
输入 & 输出列¶
graph TD
subgraph Dataset
subgraph Columns
ICOL0[inputs]
ICOL1[candidates]
end
subgraph New columns
OCOL0[ranks]
OCOL1[ranked_candidates]
OCOL2[model_name]
end
end
subgraph PairRM
StepInput[Input Columns: inputs, candidates]
StepOutput[Output Columns: ranks, ranked_candidates, model_name]
end
ICOL0 --> StepInput
ICOL1 --> StepInput
StepOutput --> OCOL0
StepOutput --> OCOL1
StepOutput --> OCOL2
StepInput --> StepOutput
输入¶
-
inputs (
List[Dict[str, Any]]
): 用于对候选进行排序的输入文本或对话。 -
candidates (
List[Dict[str, Any]]
): 要排序的候选。
输出¶
-
ranks (
List[int]
): 基于输入的候选排名。 -
ranked_candidates (
List[Dict[str, Any]]
): 基于输入排序的候选。 -
model_name (
str
): 用于对候选响应进行排序的模型名称。默认为"llm-blender/PairRM"
。
示例¶
对 LLM 候选进行排序¶
from distilabel.steps.tasks import PairRM
# Consider this as a placeholder for your actual LLM.
pair_rm = PairRM()
pair_rm.load()
result = next(
scorer.process(
[
{"input": "Hello, how are you?", "candidates": ["fine", "good", "bad"]},
]
)
)
# result
# [
# {
# 'input': 'Hello, how are you?',
# 'candidates': ['fine', 'good', 'bad'],
# 'ranks': [2, 1, 3],
# 'ranked_candidates': ['good', 'fine', 'bad'],
# 'model_name': 'llm-blender/PairRM',
# }
# ]