Skip to content

SwiftSage: A Generative Agent with Fast and Slow Thinking for Complex Interactive Tasks

Notifications You must be signed in to change notification settings

duk42111/SwiftSage

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

73 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🤖 SwiftSage: A General Reasoning Framework with Fast and Slow Thinking

Important

This is the beta version of SwiftSage V2, which is still under development. The current version may not be stable and is subject to change. Any comments and suggestions are welcome! The code of SwiftSage V1 (for the experiments in NeurIPS 2023) is archived in the science_world branch.

🔗 Links:

Installation

git clone https://github.com/SwiftSage/SwiftSage.git
pip install -e .
# pip install git+https://github.com/SwiftSage/SwiftSage.git # for the latest version

Usage

export TOGETHER_API_KEY="your-api-key" # get your key from https://www.together.ai
swiftsage --problem "How many letter r are there in 'My strawberry is red.'?"

Design of SwiftSage V2

The key motivation of SwiftSage is to provide a general reasoning framework that can mimic the fast and slow thinking processes in human cognition. The fast thinking process is based on the intuition and heuristic reasoning, while the slow thinking process is based on more analytical, critical thinking. Unlike SwiftSage V1, which relies on feedbacks from the well-designed environment such as ScienceWorld, SwiftSage v2 is designed to be more general and can be applied to various reasoning tasks.

General reasoning. In order to support more general reasoning, we also use Agent Lumos's idea to unify the task formats with a plan-ground-execute paradigm. We define actions as generating a python code snippet.

In-context reinforcement. Instead of behavior cloning SFT and trajectory optimization, we focus on prompting-based strategies to achieve the same goal such that it is easier to adapt to newer models and API-based LLM access. The feedbacks are generated by LLMs and are used as reflections and rewards for SwiftSage to update reasoning strategies.

SwiftSage Components

The main components in SwiftSage v2:

  • Swift Agent: A smaller LM that generates python code snippets based on the prompt.
  • Feedback Agent: A larger LM that generates feedbacks based on the prompt and the generated code snippet.
  • Sage Agent: A reasoning agent that uses the feedbacks to update the reasoning strategies.
  • Retriever (soon to be added): A retrieval module that retrieves the most relevant feedbacks for the current prompt.
  • Executor: A python executor that executes the generated code snippets.

SwiftSage Workflow

  • Step 1. Given a reasoning problem that a user inputs, Swift Agent firsts generates a plan and a code-based solution.
  • Step 2. The executor executes the code snippet and generates the final answer.
  • Step 3. We then use the feedback agent to analyze the generated answer and provide feedbacks including a short paragraph and a score. Depending on the score and the threshold, we can decide if the current solution is good enough to show to the user.
    • Case 3.1. If yes, we then stop the process and show the answer to the user.
    • Case 3.2. If not, we use the critical feedbacks to prompt the Swift Agent again to generate a new solution based on the feedbacks. Go to Step 1 with the feedbacks as the new prompt.
    • Case 3.3 If the new solution is still not good enough after a few iterations, go to Step 4.
  • Step 4. If smaller models cannot solve the task, we can then use the Sage Agent to solve the problem in a more analytical way, and then provide the final answer to the user.

TODO: Soon, we'll add retrieval augmentation step to further improve the reasoning process of Swift Agent.

Misc.

Contact

Please email Bill Yuchen Lin at the gmail address.

License

We use the MIT license for SwiftSage.

Citation

The technical report of SwiftSage V2 is under preparation. Please cite the following paper for the previous version of SwiftSage:

@inproceedings{
  lin2023swiftsage,
  title={SwiftSage: A Generative Agent with Fast and Slow Thinking for Complex Interactive Tasks},
  author={Bill Yuchen Lin and Yicheng Fu and Karina Yang and Faeze Brahman and Shiyu Huang and Chandra Bhagavatula and Prithviraj Ammanabrolu and Yejin Choi and Xiang Ren},
  booktitle={Thirty-seventh Conference on Neural Information Processing Systems},
  year={2023}
}

About

SwiftSage: A Generative Agent with Fast and Slow Thinking for Complex Interactive Tasks

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 99.7%
  • Shell 0.3%