pair_preference_mapper¶
Mapper to construct paired preference samples by generating a rejected response and its reason.
This operator uses an API model to generate a new response that is opposite in style, factuality, or stance to the original response. The generated response and the reason for its generation are stored in the sample. The default system prompt and input template are provided, but can be customized. The output is parsed using a regular expression to extract the new response and the reason. If parsing fails, the operator retries up to a specified number of times. The generated response and reason are stored in the sample under the keys ‘rejected_response’ and ‘reason’, respectively.
构造配对偏好样本的映射器,通过生成一个被拒绝的回答及其原因。
该算子使用API模型生成与原始回答在风格、事实性或立场上相反的新回答。生成的回答及其生成原因会被存储在样本中。提供了默认的系统提示和输入模板,但可以自定义。输出使用正则表达式解析以提取新回答和原因。如果解析失败,算子将重试指定次数。生成的回答和原因分别存储在样本的’rejected_response’和’reason’键下。
Type 算子类型: mapper
Tags 标签: cpu, api, text
🔧 Parameter Configuration 参数配置¶
name 参数名 |
type 类型 |
default 默认值 |
desc 说明 |
---|---|---|---|
|
<class ‘str’> |
|
API model name. |
|
typing.Optional[str] |
|
URL endpoint for the API. |
|
typing.Optional[str] |
|
Path to extract content from the API response. |
|
typing.Optional[str] |
|
System prompt for guiding the generation task. |
|
typing.Optional[str] |
|
Template for building the model input. It must |
|
typing.Optional[str] |
|
Regular expression for parsing model output. |
|
<class ‘str’> |
|
The field name in the sample to store the |
|
<class ‘str’> |
|
The field name in the sample to store the reason for |
|
typing.Annotated[int, Gt(gt=0)] |
|
The number of retries for the API call in case of |
|
typing.Dict |
|
Parameters for initializing the API model. |
|
typing.Dict |
|
Extra parameters passed to the API call. |
|
|
Extra keyword arguments. |
📊 Effect demonstration 效果演示¶
not available 暂无