Home

Awesome

🤖 SwiftSage V2: An Agent System for Reasoning with LLMs via In-context Reinforcement Learning

<!-- add a banner img for s2_banner.png --> <!-- add a banner img for s2_banner.png with a black border --> <img src="s2_banner_v2.png" alt="SwiftSage Banner" style="border: 2px solid black;" />

[!IMPORTANT]

<!-- Github Readme Important Callout box note -->

🔗 Links:

Installation

pip install git+https://github.com/SwiftSage/SwiftSage.git  
# alternatively, you can clone the repo and install it locally
# git clone https://github.com/SwiftSage/SwiftSage.git
# pip install -e .

Usage

# export TOGETHER_API_KEY="your-api-key" # get your key from https://www.together.ai
export ENGINE="Together"
export SWIFT_MODEL_ID="meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo" # can be 70B for more complex reasoning
export FEEDBACK_MODEL_ID="meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo" 
export SAGE_MODEL_ID="meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo" # can be 405B for more complex reasoning
QUERY="How many letter r are there in 'My strawberry is red.'?"
# QUERY="9.9 or 9.11 --  which is bigger?"
# QUERY="How can you solve the quadratic equation 3x^2 + 7.15x + 4 = 0 using the quadratic formula?"
# QUERY="What is the capital of Australia?"
swiftsage --problem $QUERY \
          --api_provider ${ENGINE} \
          --swift_model_id ${SWIFT_MODEL_ID} \
          --feedback_model_id ${FEEDBACK_MODEL_ID} \
          --sage_model_id ${SAGE_MODEL_ID}
<!-- ```bash pip install git+https://github.com/SwiftSage/SwiftSage.git # 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.'?" \ --api_provider "Together" \ --swift_model_id "meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo" \ --feedback_model_id "meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo" \ --sage_model_id "meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo" ``` --> <!-- export SWIFT_MODEL_ID="meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo" export FEEDBACK_MODEL_ID="meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo" export SAGE_MODEL_ID="meta-llama/Meta-Llama-3.1-405B-Instruct-Turbo" swiftsage --problem "9.9 or 9.11 -- which is bigger?" \ --api_provider ${ENGINE} \ --swift_model_id ${SWIFT_MODEL_ID} \ --feedback_model_id ${FEEDBACK_MODEL_ID} \ --sage_model_id ${SAGE_MODEL_ID} -->

[!Tip] Check more configurations in the code: swiftsage/cli.py.

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.

[!Note]

SwiftSage Components

The main components in SwiftSage v2:

SwiftSage Workflow

[!WARNING]
The Retriever is not yet implemented yet. Soon, we'll add retrieval augmentation step to further improve the reasoning process of Swift Agent in Step 1.

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}
}

Star History

Star History Chart