Skip to content

Commit

Permalink
Update todos
Browse files Browse the repository at this point in the history
  • Loading branch information
shreyashankar committed Aug 22, 2024
1 parent 3c37997 commit b01901f
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 8 deletions.
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,29 @@ parallel_map_operation:
word_count: integer
```

```yaml
extract_info:
type: map
model: gpt-4o-mini
output:
schema:
officer_name: string
suspect_name: string
prompts:
- name: officer
prompt: |
Infer the officer's name from this police interrogation transcript:
{ { input.transcript } }
output_keys:
- officer_name
- name: suspect
prompt: |
Infer the suspect's name from this police interrogation transcript:
{ { input.transcript } }
output_keys:
- suspect_name
```

### Filter

The Filter operation selects items from the input data based on a condition.
Expand Down
4 changes: 2 additions & 2 deletions motion/operations/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ def __init__(
self.default_model = default_model
self.max_threads = max_threads
self.console = console or Console()
self.num_retries_on_validation_failure = self.config.get(
"num_retries_on_validation_failure", 0
self.num_retries_on_validate_failure = self.config.get(
"num_retries_on_validate_failure", 0
)
self.syntax_check()

Expand Down
2 changes: 1 addition & 1 deletion motion/operations/filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def validation_fn(response: Dict[str, Any]):
),
validation_fn=validation_fn,
val_rule=self.config.get("validate", []),
num_retries=self.num_retries_on_validation_failure,
num_retries=self.num_retries_on_validate_failure,
console=self.console,
)

Expand Down
6 changes: 3 additions & 3 deletions motion/operations/map.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def validation_fn(response: Dict[str, Any]):
),
validation_fn=validation_fn,
val_rule=self.config.get("validate", []),
num_retries=self.num_retries_on_validation_failure,
num_retries=self.num_retries_on_validate_failure,
console=self.console,
)
else:
Expand All @@ -119,7 +119,7 @@ def validation_fn(response: Dict[str, Any]):
),
validation_fn=validation_fn,
val_rule=self.config.get("validate", []),
num_retries=self.num_retries_on_validation_failure,
num_retries=self.num_retries_on_validate_failure,
console=self.console,
)

Expand Down Expand Up @@ -287,7 +287,7 @@ def validation_fn(response: Dict[str, Any]):
llm_call_fn,
validation_fn,
prompt_config.get("validate", []),
self.num_retries_on_validation_failure,
self.num_retries_on_validate_failure,
self.console,
)

Expand Down
5 changes: 4 additions & 1 deletion todos.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,12 @@ TODO:
- [x] In map optimizer: optimize the reduce operator for each chunk size plan
- [x] In reduce optimizer: synthesize resolver if need be
- [x] In resolve optimizer, support list-type reduce keys
- [ ] Operator reordering (Aug 21 & 22)
- [ ] Operator reordering (Aug 23)
- [ ] support equivalence: map -> unnest -> reduce might be same as split -> gather -> map -> unnest -> reduce (no need to have a reduce right after map)
- [x] Run tests in CI
- [x] Support retry on validation failure
- [ ] Break down split into split + gather (Aug 21 & 22)
- [ ] Support prompts exceeding context windows; figure out how to throw out data / prioritize elements
- [ ] Support retries in the optimizers
- [ ] Write tests for optimizers
- [ ] Filter optimizer
Expand Down Expand Up @@ -84,3 +86,4 @@ Things to think about
- Try various combine prompts in the reduce optimizer
- Filter optimizer: we should recursively optimize reduces if the reduce isn't good on its own
- Support retry on val failure for operations beyond map/filter
- If reduce input is too big to fit in the prompt, prompt for a map operation
2 changes: 1 addition & 1 deletion workloads/medical/map.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ operations:
If a piece of information is not found, return an empty string.
validate:
- "output['medication_info'].startswith('Medication Info: ')"
num_retries_on_validation_failure: 1
num_retries_on_validate_failure: 1

# gleaning:
# num_rounds: 1
Expand Down

0 comments on commit b01901f

Please sign in to comment.