Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamically generate agent systems in AutoGen #4226

Open
wants to merge 24 commits into
base: main
Choose a base branch
from

Conversation

yeandy
Copy link

@yeandy yeandy commented Nov 15, 2024

Why are these changes needed?

Version 1 of the ADAS implementation in AutoGen. Please read the README.md in this PR for details.

Related issue number

This is the PR for the feature initially discussed here #4569 and #4486

Checks

@yeandy yeandy changed the title [WIP] Dynamically generate agent systems in AutoGen Dynamically generate agent systems in AutoGen Dec 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 9 out of 9 changed files in this pull request and generated no suggestions.

@yeandy yeandy marked this pull request as ready for review December 18, 2024 23:36
Copy link

@cseifert1 cseifert1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some initial comments

TLDR:
This is a feature to use a meta-agent to generate new agent systems. For example, this agent system was discovered and written entirely by an agent using o1-preview:
```
def forward(self, task, model_client_kwargs):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would love to get rid of this as I feel like its still rooted in the ADAS implementation.

python/packages/autogen-core/samples/adas/README.md Outdated Show resolved Hide resolved
python/packages/autogen-core/samples/adas/README.md Outdated Show resolved Hide resolved
python/packages/autogen-core/samples/adas/README.md Outdated Show resolved Hide resolved
return documentation


def get_autogen_documentation() -> List[str]:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i love you dynamically pulling this. Do we need to think about matching versions of what it pulls to the version of code you have?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are pulling documentation under https://github.com/microsoft/autogen/tree/main/python/packages/autogen-core/docs/src/user-guide/core-user-guide, and using the default main branch, which has the most up-to-date API. I assume anyone who changes the API behavior will also change the documentation, as well as all example code (including this one) that would be affected.

Note: If you add a new agent system after you’ve started generating new Agent Systems (next [section](#generate-new-agent-systems)), the meta-agent will not pick up this new seed agent system. This is because it will try to first detect the results file defined by the expr_name flag, and reference that file for the agent archive, instead of the `adas_prompt.py` file.

### Generate new Agent Systems
#### Prepare your dataset

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about including an example already that works out of the box?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current instructions say to clone the https://github.com/ShengranHu/ADAS repo and use the https://github.com/ShengranHu/ADAS/blob/main/dataset/drop_v0_dev.jsonl.gz dataset that is present in that repo. Did you mean that we should add a dataset file directly to the autogen repo? i.e. copy drop_v0_dev.jsonl.gz to the autogen repo, or maybe create a different toy dataset?

# Install autogen-core and autogen-ext in editable mode
pip install -e packages/autogen-core
pip install -e packages/autogen-ext
pip install -r packages/autogen-core/samples/adas/requirements.txt

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

id also include pandas and numpy as you are using them in the example code

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have numpy in the requirements.txt. Did you find yourself to have to separately install pandas?

python/packages/autogen-core/samples/adas/README.md Outdated Show resolved Hide resolved
python/packages/autogen-core/samples/adas/README.md Outdated Show resolved Hide resolved

This should be passed as a JSON string to the `meta_agent_model_config` flag.
```bash
--meta_agent_model_config='{"api_version": "2024-08-01-preview", "azure_endpoint": "https://<user>-aoai1.openai.azure.com/openai/deployments/o1-preview/chat/completions?api-version=2024-08-01-preview", "model_capabilities": {"function_calling": false, "json_output": false, "vision": false}, "azure_ad_token_provider": "DEFAULT", "model": "o1-preview-2024-09-12"}'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this also support API keys?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not right now

- `base_agent_model_config`: JSON string of the `AzureOpenAIChatCompletionClient` settings for the Base Agent.
- `n_generation`: number of generations of new agents that the meta-agent tries to discover
- `expr_name`: name of the output file containing both the original/seed and newly generated agent systems, as well as their fitness scores.
- `max_workers`: the number of threads to spin up in a `ThreadPoolExecutor`, to parallelize the execution of the particular Agent System that is currently being evaluated.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whats the default value and what is the recommended value as per CPUs? Can we dynamically set that based on CPUs? Is it only influenced by CPUs or also model capacity?

Copy link
Author

@yeandy yeandy Dec 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Default is 48, but that actually gets adjusted based on the number of examples and the multiprocessing flag as well https://github.com/yeandy/autogen/blob/yeandy_adas/python/packages/autogen-core/samples/adas/adas.py#L138.

It currently does do any smart detection based on # of CPUs. If you know that number (i.e. 32 cores), then of course you can set the value of max_workers. Though the "optimal" value also depends on the tokens/sec limit on your particular model deployment, where you may still need to cap the number of max_workers to say 10 if the number of parallel LLM calls made be the Agent System being evaluated is high.

However, in practice, I've found for some Agent Systems that running with max_workers > 1 causes some hanging issues with the AutoGen messaging. i.e. the E2E process doesn't terminate. For these, I had to manually set max_workers=1. See the "Troubleshooting" section in the README for the details. Unfortunately, the reason for this is unknown. Will need insight from other devs on what is going on.

```bash
--base_agent_model_config='{"api_version": "2023-03-15-preview", "azure_endpoint": "https://<user>-aoai1.openai.azure.com/openai/deployments/gpt-4o/chat/completions?api-version=2023-03-15-preview", "model_capabilities": {"function_calling": true, "json_output": true, "vision": true}, "azure_ad_token_provider": "DEFAULT", "model": "gpt-4o-2024-08-06"}'
```
### Run ADAS

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Running adas.py does seem to generate standard output and standard error output. Strangely it seems like the output in the error stream is of type info. I recommend to consolidate and also give users the option to adjust the logging threshold. I feel like we want to aim at INFO including all relevant output that allows a user to understand what ADAS is doing. Put everything else into DEBUG. Id recommend to ensure lengthy prompts are in DEBUG, where as the that the LLM was queried and gist of the prompt should be in INFO.

Copy link
Collaborator

@ekzhu ekzhu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will dig into it a bit more. For now let's move this to autogen/python/samples/

@yeandy
Copy link
Author

yeandy commented Dec 20, 2024

Will dig into it a bit more. For now let's move this to autogen/python/samples/

Moved. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants