base
TextGenerationTask
dataclass
Bases: Task
A base Task
definition for text generation using LLMs.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
system_prompt |
str
|
the system prompt to be used. Defaults to |
"You are a helpful, respectful and honest assistant. Always answer as helpfully as possible, while being safe. Your answers should not include any harmful, unethical, racist, sexist, toxic, dangerous, or illegal content. Please ensure that your responses are socially unbiased and positive in nature.\nIf a question does not make any sense, or is not factually coherent, explain why instead of answering something not correct. If you don't know the answer to a question, please don't share false information."
|
principles |
Dict[str, List[str]]
|
the principles to be used for the system prompt.
Defaults to |
field(default_factory=lambda : {'harmlessness': harmlessness, 'helpfulness': helpfulness, 'truthfulness': truthfulness, 'honesty': honesty, 'verbalized_calibration': verbalized_calibration}, repr=False)
|
principles_distribution |
Union[Dict[str, float], Literal['balanced'], None]
|
the
distribution of principles to be used for the system prompt. Defaults to |
None
|
Examples:
Source code in src/distilabel/tasks/text_generation/base.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
|
input_args_names: list[str]
property
Returns the input args names for the task.
output_args_names: list[str]
property
Returns the output args names for the task.
__post_init__()
Validates the principles_distribution
if it is a dict.
Raises:
Type | Description |
---|---|
ValueError
|
if the |
ValueError
|
if the |
Source code in src/distilabel/tasks/text_generation/base.py
generate_prompt(input)
Generates the prompt to be used for generation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
input |
str
|
the input to be used for generation. |
required |
Returns:
Name | Type | Description |
---|---|---|
Prompt |
Prompt
|
the generated prompt. |
Examples:
>>> from distilabel.tasks.text_generation import TextGenerationTask
>>> task = TextGenerationTask(system_prompt="You are a helpful assistant.")
>>> task.generate_prompt("What are the first 5 Fibonacci numbers?")
Prompt(system_prompt='You are a helpful assistant.', formatted_prompt='What are the first 5 Fibonacci numbers?')