You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are one mandatory and six optional parameters when using the `generate_goldens_from_docs` method:
64
+
There are one mandatory and seven optional parameters when using the `generate_goldens_from_docs` method:
63
65
64
66
-`document_paths`: a list strings, representing the path to the documents from which contexts will be extracted from. Supported documents types include: `.txt`, `.docx`, and `.pdf`.
65
67
-[Optional]`include_expected_output`: a boolean which when set to `True`, will additionally generate an `expected_output` for each synthetic `Golden`. Defaulted to `False`.
@@ -68,8 +70,9 @@ There are one mandatory and six optional parameters when using the `generate_gol
68
70
-[Optional]`chunk_overlap`: an int that determines the overlap size between consecutive text chunks during context extraction. Defaulted to 0.
69
71
-[Optional]`num_evolutions`: the number of evolution steps to apply to each generated input. This parameter controls the **complexity and diversity** of the generated dataset by iteratively refining and evolving the initial inputs. Defaulted to 1.
70
72
-[Optional]`enable_breadth_evolve`: a boolean which when set to `True`, introduces a **wider variety of context modifications**, enhancing the dataset's diversity. Defaulted to `False`.
73
+
-[Optional]`evolution_types`: a list of `Evolution`, specifying methods used during data evolution. Defaulted to all `Evolution`s.
71
74
72
-
### Generating From Provided Contexts
75
+
### 2. Generating From Provided Contexts
73
76
74
77
`deepeval` also allows you to generate synthetic `Goldens` from a manually provided a list of context instead of directly generating from your documents.
75
78
@@ -90,18 +93,85 @@ synthesizer.generate_goldens(
90
93
)
91
94
```
92
95
93
-
There are one mandatory and four optional parameters when using the `generate_goldens` method:
96
+
There are one mandatory and five optional parameters when using the `generate_goldens` method:
94
97
95
98
-`contexts`: a list of context, where each context is itself a list of strings, ideally sharing a common theme or subject area.
96
99
-[Optional]`include_expected_output`: a boolean which when set to `True`, will additionally generate an `expected_output` for each synthetic `Golden`. Defaulted to `False`.
97
100
-[Optional]`max_goldens_per_context`: the maximum number of golden data points to be generated from each context. Adjusting this parameter can influence the size of the resulting dataset. Defaulted to 2.
98
101
-[Optional]`num_evolutions`: the number of evolution steps to apply to each generated input. This parameter controls the **complexity and diversity** of the generated dataset by iteratively refining and evolving the initial inputs. Defaulted to 1.
99
102
-[Optional]`enable_breadth_evolve`: a boolean indicating whether to enable breadth evolution strategies during data generation. When set to True, it introduces a **wider variety of context modifications**, enhancing the dataset's diversity. Defaulted to `False`.
103
+
-[Optional]`evolution_types`: a list of `Evolution`, specifying methods used during data evolution. Defaulted to all `Evolution`s.
100
104
101
105
:::caution
102
-
You can also optionally generate `expected_output`s alongside each golden, but you should always aim to cross-check any generated expected output.
106
+
While the previous methods first use an LLM to generate a series of inputs based on the provided context before evolving them, `generate_goldens_from_inputs` simply evolves the provided list of inputs into more complex and diverse `Golden`s. It's also important to note that this method will only populate the input field of each generated `Golden`.
103
107
:::
104
108
109
+
### 3. Generating From Provided Prompts
110
+
111
+
If your LLM application **does not rely on a retrieval context**, or if you simply wish to generate a synthetic dataset based on information outside your application's information database, `deepeval` also supports generating synthetic `Golden`s from an initial list of prompts, which serve as examples from which additional prompts will be generated.
112
+
113
+
:::info
114
+
While the previous methods first use an LLM to generate a series of inputs based on the provided context before evolving them, `generate_goldens_from_prompts` simply **evolves the provided list of prompts** into more complex and diverse `Golden`s. It's also important to note that this method will only populate the input field of each generated `Golden`.
115
+
:::
116
+
117
+
```python
118
+
from deepeval.synthesizer import Synthesizer
119
+
120
+
synthesizer = Synthesizer()
121
+
synthesizer.generate_goldens_from_prompts(
122
+
prompts=[
123
+
"What is 2+2",
124
+
"Give me the solution to 12/5",
125
+
"5! = ?"
126
+
],
127
+
num_evolutions=20
128
+
)
129
+
```
130
+
131
+
There are one mandatory and three optional parameters when using the `generate_goldens_from_docs` method:
132
+
133
+
-`prompts`: a list of strings, representing your initial list of example prompts.
134
+
-[Optional]`num_evolutions`: the number of evolution steps to apply to each prompt. This parameter controls the **complexity and diversity** of the generated dataset by iteratively refining and evolving the initial prompts. Defaulted to 1.
135
+
-[Optional]`enable_breadth_evolve`: a boolean which when set to `True`, introduces a **wider variety of context modifications**, enhancing the dataset's diversity. Defaulted to `False`.
136
+
-[Optional]`evolution_types`: a list of `PromptEvolution`, specifying methods used during data evolution. Defaulted to all `PromptEvolution`s.
137
+
138
+
### 4. Generating From Scratch
139
+
140
+
If you do not have a list of example prompts, or wish to solely rely on an LLM generation for synthesis, you can also generate synthetic `Golden`s simply by specifying the subject, task, and output format you wish your prompts to follow.
141
+
142
+
:::tip
143
+
Generating goldens from scratch is especially helpful when you wish to **evaluate your LLM on a specific task**, such as red-teaming or text-to-SQL use cases!
144
+
:::
145
+
146
+
```python
147
+
from deepeval.synthesizer import Synthesizer
148
+
149
+
synthesizer = Synthesizer()
150
+
synthesizer.generate_goldens_from_scratch(
151
+
subject="Harmful and toxic prompts, with emphasis on dark humor",
152
+
task="Red-team LLMs",
153
+
output_format="string",
154
+
num_initial_goldens=25,
155
+
num_evolutions=20
156
+
)
157
+
```
158
+
159
+
This method is a **2-step function** that first generates a list of prompts about a given subject for a certain task and in a certain output format, before using the generated list of prompts to generate more prompts through data evolution.
160
+
161
+
:::info
162
+
The subject, task, and output format parameters are all strings that are inserted into a predefined prompt template, meaning these parameters are **flexible and will need to be iterated on** for optimal results.
163
+
:::
164
+
165
+
There are four mandatory and three optional parameters when using the `generate_goldens_from_docs` method:
166
+
167
+
-`subject`: a string, specifying the subject and nature of your generated `Golden`s
168
+
-`task`: a string, representing the purpose of these evaluation `Golden`s
169
+
-`output_format`: a string, representing the expected output format. This is not equivalent to python `type`s but simply gives you more control over the structure of your synthetic data.
170
+
-`num_initial_goldens`: the number of goldens generated before consequent evolutions
171
+
-[Optional]`num_evolutions`: the number of evolution steps to apply to each generated prompt. This parameter controls the **complexity and diversity** of the generated dataset by iteratively refining and evolving the initial inputs. Defaulted to 1.
172
+
-[Optional]`enable_breadth_evolve`: a boolean which when set to `True`, introduces a **wider variety of context modifications**, enhancing the dataset's diversity. Defaulted to `False`.
173
+
-[Optional]`evolution_types`: a list of `PromptEvolution`, specifying methods used during data evolution. Defaulted to all `PromptEvolution`s.
174
+
105
175
### Saving Generated Goldens
106
176
107
177
To not accidentally lose any generated synthetic `Golden`, you can use the `save_as()` method:
0 commit comments