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
fix: improve caching and don't raise error for bad gather configs (#373)
* merge
* fix: improve caching and don't raise error for bad gather configs
* fix: improve caching and don't raise error for bad gather configs
* fix: improve caching and don't raise error for bad gather configs
Copy file name to clipboardExpand all lines: docs/concepts/operators.md
+8Lines changed: 8 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -155,7 +155,11 @@ To enable gleaning, specify:
155
155
156
156
- `validation_prompt`: Instructions for the LLM to evaluate and improve the output.
157
157
- `num_rounds`: The maximum number of refinement iterations.
158
+
<<<<<<< HEAD
158
159
- `model` (optional): The model to use for the LLM executing the validation prompt. Defaults to the model specified for this operation. **Note that if the validator LLM determines the output needs to be improved, the final output will be generated by the model specified for this operation.**
160
+
=======
161
+
- `model` (optional): The model to use for the LLM executing the validation prompt. Defaults to the model specified for that operation.
@@ -193,7 +197,11 @@ Example map operation (with a different model for the validation prompt):
193
197
194
198
!!! tip "Choosing a Different Model for Validation"
195
199
200
+
<<<<<<< HEAD
196
201
In the example above, the `gpt-4o` model is used to generate the main outputs, while the `gpt-4o-mini` model is used only for the validation and refinement steps. This means the more powerful (and expensive) model produces the final output, but a less expensive model handles the iterative validation, helping to reduce costs without sacrificing output quality.
202
+
=======
203
+
You may want to use a different model for the validation prompt. For example, you can use a more powerful (and expensive) model for generating outputs, but a cheaper model for validation—especially if the validation only checks a single aspect. This approach helps reduce costs while still ensuring quality, since the final output is always produced by the more capable model.
Copy file name to clipboardExpand all lines: docs/operators/parallel-map.md
+57Lines changed: 57 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -26,6 +26,7 @@ Each prompt configuration in the `prompts` list should contain:
26
26
-`prompt`: The prompt template to use for the transformation
27
27
-`output_keys`: List of keys that this prompt will generate
28
28
-`model` (optional): The language model to use for this specific prompt
29
+
-`gleaning` (optional): Advanced validation settings for this prompt (see Per-Prompt Gleaning section below)
29
30
30
31
### Optional Parameters
31
32
@@ -59,6 +60,10 @@ Here's an example of a parallel map operation that processes job applications by
59
60
prompt: "Given the following resume: '{{ input.resume }}', list the top 5 relevant skills for a software engineering position."
60
61
output_keys:
61
62
- skills
63
+
gleaning:
64
+
num_rounds: 1
65
+
validation_prompt: |
66
+
Confirm the skills list contains **exactly** 5 distinct skills and each skill is one or two words long.
62
67
model: gpt-4o-mini
63
68
- name: calculate_experience
64
69
prompt: "Based on the work history in this resume: '{{ input.resume }}', calculate the total years of relevant experience for a software engineering role."
@@ -79,6 +84,57 @@ Here's an example of a parallel map operation that processes job applications by
79
84
80
85
This Parallel Map operation processes job applications by concurrently extracting skills, calculating experience, and evaluating cultural fit.
81
86
87
+
## Advanced Validation: Per-Prompt Gleaning
88
+
89
+
Each prompt in a Parallel Map operation can include its own `gleaning` configuration. Gleaning works exactly as described in the [operators overview](../concepts/operators.md#advanced-validation-gleaning) but is **scoped to the individual LLM call** for that prompt. This allows you to tailor validation logic—and even the model used—to the specific transformation being performed.
90
+
91
+
The structure of the `gleaning` block is identical:
92
+
93
+
```yaml
94
+
gleaning:
95
+
num_rounds: 1 # maximum refinement iterations
96
+
validation_prompt: | # judge prompt appended to the chat thread
97
+
Ensure the extracted skills list contains at least 5 distinct items.
98
+
model: gpt-4o-mini # (optional) model for the validator LLM
99
+
```
100
+
101
+
### 📄 Example with Per-Prompt Gleaning
102
+
103
+
```yaml
104
+
- name: process_job_application
105
+
type: parallel_map
106
+
prompts:
107
+
- name: extract_skills
108
+
prompt: "Given the following resume: '{{ input.resume }}', list the top 5 relevant skills for a software engineering position."
109
+
output_keys:
110
+
- skills
111
+
gleaning:
112
+
num_rounds: 1
113
+
validation_prompt: |
114
+
Confirm the skills list contains **exactly** 5 distinct skills and each skill is one or two words long.
115
+
model: gpt-4o-mini
116
+
- name: calculate_experience
117
+
prompt: "Based on the work history in this resume: '{{ input.resume }}', calculate the total years of relevant experience for a software engineering role."
118
+
output_keys:
119
+
- years_experience
120
+
gleaning:
121
+
num_rounds: 2
122
+
validation_prompt: |
123
+
Verify that the years of experience is a non-negative number and round to one decimal place if necessary.
124
+
- name: evaluate_cultural_fit
125
+
prompt: "Analyze the following cover letter: '{{ input.cover_letter }}'. Rate the candidate's potential cultural fit on a scale of 1-10, where 10 is the highest."
126
+
output_keys:
127
+
- cultural_fit_score
128
+
model: gpt-4o-mini
129
+
output:
130
+
schema:
131
+
skills: list[string]
132
+
years_experience: float
133
+
cultural_fit_score: integer
134
+
```
135
+
136
+
In this configuration, only the `extract_skills` and `calculate_experience` prompts use gleaning. Each prompt's validator runs **immediately after** its own LLM call and before the overall outputs are merged.
@@ -91,3 +147,4 @@ This Parallel Map operation processes job applications by concurrently extractin
91
147
1. **Independent Transformations**: Ensure that the prompts in a Parallel Map operation are truly independent of each other to maximize the benefits of concurrent execution.
92
148
2. **Balanced Prompts**: Try to design prompts that have similar complexity and execution times to optimize overall performance.
93
149
3. **Output Schema Alignment**: Ensure that the output schema correctly captures all the fields generated by the individual prompts.
150
+
4. **Lightweight Validators**: When using per-prompt gleaning, keep validation prompts concise so that the cost and latency overhead stays manageable.
0 commit comments