Skip to content

Commit

Permalink
Improve doc in tutorial/conversation-patterns and customized_speaker_…
Browse files Browse the repository at this point in the history
…selection (#3006)

* update

* update

---------

Co-authored-by: Yiran Wu <32823396+kevin666aa@users.noreply.github.com>
  • Loading branch information
yiranwu0 and yiranwu0 committed Jun 23, 2024
1 parent 03259b2 commit 1582927
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 28 deletions.
2 changes: 1 addition & 1 deletion website/blog/2023-06-28-MathChat/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ We found that compared to basic prompting, which demonstrates the innate capabil

For categories like Algebra and Prealgebra, PoT and PS showed little improvement, and in some instances, even led to a decrease in accuracy. However, MathChat was able to enhance total accuracy by around 6% compared to PoT and PS, showing competitive performance across all categories. Remarkably, MathChat improved accuracy in the Algebra category by about 15% over other methods. Note that categories like Intermediate Algebra and Precalculus remained challenging for all methods, with only about 20% of problems solved accurately.

The code for experiments can be found at this [repository](https://github.com/kevin666aa/FLAML/tree/gpt_math_solver/flaml/autogen/math).
The code for experiments can be found at this [repository](https://github.com/yiranwu0/FLAML/tree/gpt_math_solver/flaml/autogen/math).
We now provide an implementation of MathChat using the interactive agents in AutoGen. See this [notebook](https://github.com/microsoft/autogen/blob/main/notebook/agentchat_MathChat.ipynb) for example usage.

## Future Directions
Expand Down
2 changes: 1 addition & 1 deletion website/blog/2023-11-13-OAI-assistants/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,6 @@ Checkout more examples [here](https://github.com/microsoft/autogen/tree/main/not
`GPTAssistantAgent` was made possible through collaboration with
[@IANTHEREAL](https://github.com/IANTHEREAL),
[Jiale Liu](https://leoljl.github.io),
[Yiran Wu](https://github.com/kevin666aa),
[Yiran Wu](https://github.com/yiranwu0),
[Qingyun Wu](https://qingyun-wu.github.io/),
[Chi Wang](https://www.microsoft.com/en-us/research/people/chiw/), and many other AutoGen maintainers.
4 changes: 2 additions & 2 deletions website/blog/authors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ qingyunwu:
yiranwu:
name: Yiran Wu
title: PhD student at Pennsylvania State University
url: https://github.com/kevin666aa
image_url: https://github.com/kevin666aa.png
url: https://github.com/yiranwu0
image_url: https://github.com/yiranwu0.png

jialeliu:
name: Jiale Liu
Expand Down
52 changes: 29 additions & 23 deletions website/docs/topics/groupchat/customized_speaker_selection.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,34 @@
"source": [
"# Customize Speaker Selection\n",
"\n",
"In GroupChat, we can also customize the speaker selection by passing in a function to `speaker_selection_method`:\n",
"```{=mdx}\n",
"![group_chat](../../../blog/2024-02-29-StateFlow/img/sf_example_1.png)\n",
"```\n",
"\n",
"In GroupChat, we can customize the speaker selection by passing a function to the `GroupChat` object. With this function, you can build a more **deterministic** agent workflow. We recommend following a **StateFlow** pattern when crafting this function. Please refer to the [StateFlow blog](/blog/2024/02/29/StateFlow) for more details.\n",
"\n",
"\n",
"## An example research workflow\n",
"We provide a simple example to build a StateFlow model for research with customized speaker selection.\n",
"\n",
"We first define the following agents:\n",
"\n",
"- Initializer: Start the workflow by sending a task.\n",
"- Coder: Retrieve papers from the internet by writing code.\n",
"- Executor: Execute the code.\n",
"- Scientist: Read the papers and write a summary.\n",
"\n",
"In the figure above, we define a simple workflow for research with 4 states: *Init*, *Retrieve*, *Research*, and *End*. Within each state, we will call different agents to perform the tasks.\n",
"\n",
"- *Init*: We use the initializer to start the workflow.\n",
"- *Retrieve*: We will first call the coder to write code and then call the executor to execute the code.\n",
"- *Research*: We will call the scientist to read the papers and write a summary.\n",
"- *End*: We will end the workflow.\n",
"\n",
"## Create your speaker selection function\n",
"\n",
"Below is a skeleton of the speaker selection function. Fill in the function to define the speaker selection logic.\n",
"\n",
"```python\n",
"def custom_speaker_selection_func(\n",
" last_speaker: Agent, \n",
Expand Down Expand Up @@ -35,28 +62,7 @@
")\n",
"```\n",
"The last speaker and the groupchat object are passed to the function. \n",
"Commonly used variables from groupchat are `groupchat.messages` and `groupchat.agents`, which is the message history and the agents in the group chat respectively. You can access other attributes of the groupchat, such as `groupchat.allowed_speaker_transitions_dict` for pre-defined `allowed_speaker_transitions_dict`.\n",
"\n",
"Heres is a simple example to build workflow for research with customized speaker selection.\n",
"\n",
"\n",
"```{=mdx}\n",
"![group_chat](../../../blog/2024-02-29-StateFlow/img/sf_example_1.png)\n",
"```\n",
"\n",
"We define the following agents:\n",
"\n",
"- Initializer: Start the workflow by sending a task.\n",
"- Coder: Retrieve papers from the internet by writing code.\n",
"- Executor: Execute the code.\n",
"- Scientist: Read the papers and write a summary.\n",
"\n",
"In the Figure, we define a simple workflow for research with 4 states: Init, Retrieve, Research and End. Within each state, we will call different agents to perform the tasks.\n",
"\n",
"Init: We use the initializer to start the workflow.\n",
"Retrieve: We will first call the coder to write code and then call the executor to execute the code.\n",
"Research: We will call the scientist to read the papers and write a summary.\n",
"End: We will end the workflow."
"Commonly used variables from groupchat are `groupchat.messages` and `groupchat.agents`, which is the message history and the agents in the group chat respectively. You can access other attributes of the groupchat, such as `groupchat.allowed_speaker_transitions_dict` for pre-defined `allowed_speaker_transitions_dict`."
]
},
{
Expand Down
13 changes: 12 additions & 1 deletion website/docs/tutorial/conversation-patterns.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,18 @@
"In this chapter, we will first dig a little bit more into the two-agent \n",
"chat pattern and chat result, \n",
"then we will show you several conversation patterns that involve \n",
"more than two agents.\n"
"more than two agents.\n",
"\n",
"### An Overview\n",
"\n",
"1. **Two-agent chat**: the simplest form of conversation pattern where two agents chat with each other.\n",
"2. **Sequential chat**: a sequence of chats between two agents, chained together by a carryover mechanism, which brings the summary of the previous chat to the context of the next chat.\n",
"3. **Group Chat**: a single chat involving more than two agents. An important question in group chat is: What agent should be next to speak? To support different scenarios, we provide different ways to organize agents in a group chat:\n",
" - We support several strategies to select the next agent: `round_robin`, `random`, `manual` (human selection), and `auto` (Default, using an LLM to decide).\n",
" - We provide a way to constrain the selection of the next speaker (See examples below).\n",
" - We allow you to pass in a function to customize the selection of the next speaker. With this feature, you can build a **StateFlow** model which allows a deterministic workflow among your agents.\n",
" Please refer to this [guide](/docs/topics/groupchat/customized_speaker_selection) and this [blog post](/blog/2024/02/29/StateFlow) on StateFlow for more details.\n",
"4. **Nested Chat**: package a workflow into a single agent for reuse in a larger workflow."
]
},
{
Expand Down

0 comments on commit 1582927

Please sign in to comment.