EvolComplexity¶
使用 LLM
进化指令,使其更复杂。
EvolComplexity
是一个进化指令使其更复杂的任务,它基于 EvolInstruct 任务,使用略微不同的提示,但采用完全相同的进化方法。
属性¶
-
num_instructions: 要生成的指令数量。
-
generate_answers: 是否为指令生成答案。默认为
False
。 -
mutation_templates: 用于生成指令的突变模板。
-
min_length: 定义生成的指令需要高于的长度(以字节为单位),才被认为是有效的。默认为
512
。 -
max_length: 定义生成的指令需要低于的长度(以字节为单位),才被认为是有效的。默认为
1024
。 -
seed: 为
numpy
设置的种子,以便随机选择突变方法。默认为42
。
运行时参数¶
-
min_length: 定义生成的指令需要高于的长度(以字节为单位),才被认为是有效的。
-
max_length: 定义生成的指令需要低于的长度(以字节为单位),才被认为是有效的。
-
seed: 要运行的进化次数。
输入和输出列¶
graph TD
subgraph Dataset
subgraph Columns
ICOL0[instruction]
end
subgraph New columns
OCOL0[evolved_instruction]
OCOL1[answer]
OCOL2[model_name]
end
end
subgraph EvolComplexity
StepInput[Input Columns: instruction]
StepOutput[Output Columns: evolved_instruction, answer, model_name]
end
ICOL0 --> StepInput
StepOutput --> OCOL0
StepOutput --> OCOL1
StepOutput --> OCOL2
StepInput --> StepOutput
输入¶
- instruction (
str
): 要进化的指令。
输出¶
-
evolved_instruction (
str
): 进化后的指令。 -
answer (
str
, 可选): 如果generate_answers=True
,则为指令的答案。 -
model_name (
str
): 用于进化指令的 LLM 的名称。
示例¶
使用 LLM 进化指令¶
from distilabel.steps.tasks import EvolComplexity
from distilabel.models import InferenceEndpointsLLM
# Consider this as a placeholder for your actual LLM.
evol_complexity = EvolComplexity(
llm=InferenceEndpointsLLM(
model_id="mistralai/Mistral-7B-Instruct-v0.2",
),
num_evolutions=2,
)
evol_complexity.load()
result = next(evol_complexity.process([{"instruction": "common instruction"}]))
# result
# [{'instruction': 'common instruction', 'evolved_instruction': 'evolved instruction', 'model_name': 'model_name'}]