Skip to content

Commit 4908e35

Browse files
Update CLI Docs for Optimizer (#902)
Update CLI documentation with Optimize command ## By Submitting this PR I confirm: - I am familiar with the [Contributing Guidelines](https://github.com/NVIDIA/NeMo-Agent-Toolkit/blob/develop/docs/source/resources/contributing.md). - We require that all contributors "sign-off" on their commits. This certifies that the contribution is your original work, or you have rights to submit it under the same license, or a compatible license. - Any contribution which contains commits that are not Signed-Off will not be accepted. - When the PR is ready for review, new or existing tests cover these changes. - When the PR is ready for review, the documentation is up to date with these changes. ## Summary by CodeRabbit * **Documentation** * Added an “Optimize” section to the CLI reference covering the nat optimize command for hyperparameter and prompt optimization. * Documented key options: --config_file, --dataset, --result_json_path, --endpoint, and --endpoint_timeout. * Included usage examples, including a local configuration invocation. * Clarifies underlying approach and links to the reference guide, improving discoverability for tuning workflows. Authors: - Dhruv Nandakumar (https://github.com/dnandakumar-nv) - Will Killian (https://github.com/willkill07) Approvers: - Will Killian (https://github.com/willkill07) URL: #902
1 parent 1910117 commit 4908e35

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

docs/source/reference/cli.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,57 @@ Options:
473473
--help Show this message and exit.
474474
```
475475

476+
## Optimize
477+
478+
The `nat optimize` command provides automated hyperparameter tuning and prompt engineering for NeMo Agent toolkit workflows. It intelligently searches for the best combination of parameters based on the evaluation metrics you specify. The optimizer uses [Optuna](https://optuna.org/) for numerical hyperparameter optimization and a genetic algorithm (GA) for prompt optimization. Please reference the [NeMo Agent toolkit Optimizer Guide](../reference/optimizer.md) for a comprehensive overview of the optimizer capabilities and configuration.
479+
480+
The `nat optimize --help` utility provides a brief overview of the command and its available options:
481+
482+
```console
483+
$ nat optimize --help
484+
Usage: nat optimize [OPTIONS] COMMAND [ARGS]...
485+
486+
Optimize a workflow with the specified dataset.
487+
488+
Options:
489+
--config_file FILE A JSON/YAML file that sets the parameters for
490+
the workflow and evaluation. [required]
491+
--dataset FILE A json file with questions and ground truth
492+
answers. This will override the dataset path in
493+
the config file.
494+
--result_json_path TEXT A JSON path to extract the result from the
495+
workflow. Use this when the workflow returns
496+
multiple objects or a dictionary. For example,
497+
'$.output' will extract the 'output' field from
498+
the result. [default: $]
499+
--endpoint TEXT Use endpoint for running the workflow. Example:
500+
http://localhost:8000/generate
501+
--endpoint_timeout INTEGER HTTP response timeout in seconds. Only relevant
502+
if endpoint is specified. [default: 300]
503+
--help Show this message and exit.
504+
```
505+
506+
### Options Description
507+
508+
- **`--config_file`**: This is the main configuration file that contains both the workflow configuration and the optimizer settings. The file must include an `optimizer` section that defines the optimization parameters, search spaces, and evaluation metrics.
509+
510+
- **`--dataset`**: Path to a JSON file containing the evaluation dataset with questions and ground truth answers. If provided, this will override the dataset path specified in the configuration file. The dataset is used to evaluate different parameter combinations during optimization.
511+
512+
- **`--result_json_path`**: A JSON path expression to extract the relevant result from the workflow output. This is useful when your workflow returns complex objects or dictionaries and you need to specify which field contains the actual result to evaluate. The default value `$` uses the entire output.
513+
514+
- **`--endpoint`**: Instead of running the workflow locally, you can specify an HTTP endpoint where the workflow is deployed. This is useful for optimizing workflows that are already running as services.
515+
516+
- **`--endpoint_timeout`**: When using the `--endpoint` option, this sets the maximum time (in seconds) to wait for a response from the remote service.
517+
518+
519+
To optimize a workflow with a local configuration, run:
520+
521+
<!-- path-check-skip-begin -->
522+
```bash
523+
nat optimize --config_file configs/my_workflow_optimizer.yml
524+
```
525+
<!-- path-check-skip-end -->
526+
476527
## Uninstall
477528

478529
When a package and its corresponding components are no longer needed, they can be removed from the local environment.

0 commit comments

Comments
 (0)