Giter Club home page Giter Club logo

ecoassistant's Introduction

EcoAssistant

EcoAssistant: using LLM assistant more affordably and accurately

Check out our blog in AutoGen website!

A simplified version with latest AutoGen is in simplified_demo.py

Introduction

What is EcoAssistant?

EcoAssistant is a framework that can make the LLM assistant more affordable and accurate for code-driven question answering. It is based on the idea of assistant hierarchy and solution demonstration. It is built upon AutoGen.

What is LLM assistant?

LLM assistant is an assistant agent backed by conversational LLM such as ChatGPT and GPT-4 and is able to address user query in a conversation.

What is code-driven question answering?

Code-driven question answering is a task that requires the LLM assistant to write code to call external APIs to answer the question. For example, given the question "What is the average temperature of the city X in the next 5 days?", the assistant needs to write code to get the weather information via certain APIS and calculate the average temperature of the city X in the next 5 days.

Code-driven question answering requires iterative coding, because, just like human, LLM can hardly write the correct code at the first attempt. Therefore, the assistant needs to interact with the user to get feedback and revise the code iteratively until the code is correct. We built our system on a two-agent conversation framework, where the LLM assistant is coupled with a code executor agent that can automatically execute the code and return the output to the LLM assistant.

What is assistant hierarchy?

Assistant hierarchy is a hierarchy of assistants, where the LLM assistants are ranked by their cost (e.g., GPT-3.5-turbo -> GPT-4). When addressing a user query, the EcoAssistant first asks the cheapest assistant to answer the query. Only when it fails, we invoke the more expensive assistant. It is designed to save the cost by reducing the usage of expensive assistants.

What is solution demonstration?

Solution demonstration is a technique that leverage the past successful query-code pair to help future queries. Everytime when a query is successfully addressed, we save the query-code pair to a database. When a new query comes, we retrieve the most similar query from the database, and then use the query and its associated code as in-context demonstration. It is designed to improve the accuracy by leveraging the past successful query-code pairs.

The combination of assistant hierarchy and solution demonstration amplifies the individual benefits because the solution from high-performing model would be naturally leveraged to guide weaker model without specific designs.

Why use EcoAssistant?

For queries about weather, stock, and places, EcoAssistant surpass individual GPT-4 assistant by 10 points of success rate with less than 50% of GPT-4's cost. More details can be found in our paper.

Preparation

All the data are included in this repository.

You only need to set your API keys in keys.json

Install required libraries (we recommend Python3.10):

pip3 install -r requirements.txt

Instructions

We use the Mixed-100 dataset as an example. For other dataset, just change the dataset name to google_places/stock/weather/mixed_1/mixed_2/mixed_3 in the following commands.

The outputting results can be found in the results folder.

The following commands are for the autonomous systems without human feedback described in the Section 4.5.

Run the GPT-3.5-turbo assistant

python3 run.py --data mixed_100 --seed 0 --api --model gpt-3.5-turbo 

Run the GPT-3.5-turbo assistant + Chain-of-Thought

turn on cot

python3 run.py --data mixed_100 --seed 0 --api --cot --model gpt-3.5-turbo 

Run the GPT-3.5-turbo assistant + solution demonstration

turn on solution_demonstration

python3 run.py --data mixed_100 --seed 0 --api --solution_demonstration --model gpt-3.5-turbo 

Run the assistant hierarchy (GPT-3.5-turbo + GPT-4)

set model to gpt-3.5-turbo,gpt-4

python3 run.py --data mixed_100 --seed 0 --api --model gpt-3.5-turbo,gpt-4

Run the EcoAssistant: assistant hierarchy (GPT-3.5-turbo + GPT-4) + solution demonstration

python3 run.py --data mixed_100 --seed 0 --api --solution_demonstration --model gpt-3.5-turbo,gpt-4

Enable human feedback

For systems with human judgement, please set eval to human (which is by default llm) like the following example command.

python3 run.py --data mixed_100 --seed 0 --api --solution_demonstration --model gpt-3.5-turbo,gpt-4 --eval human

Run the gold code for Mixed-100 we collect as described in Section 4.4

This script would print the code outputs.

python3 run_gold_code_for_mix_100.py

๐Ÿ“Ž Cite

If you find this repository useful, please consider citing:

@article{zhang2023ecoassistant,
  title={EcoAssistant: Using LLM Assistant More Affordably and Accurately},
  author={Zhang, Jieyu and Krishna, Ranjay and Awadallah, Ahmed H and Wang, Chi},
  journal={arXiv preprint arXiv:2310.03046},
  year={2023}
}

ecoassistant's People

Contributors

jieyuz2 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

ecoassistant's Issues

Open source LLMs?

Thanks for this awesome project! Now setup isn't fully clear to me yet, but have you also tried open source integration? If you did, can you give a working example (with f.e. LMStudio and model Llama Code)? If not I see this as most valuable feature as you just want the EcoAssistant to run like 24/7 and do whatever for you but only reach out to gpt 3.5 or 4 if it can't figure out more complex things.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.