SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2305.05176 · 2023

FrugalGPT: How to Use Large Language Models While Reducing Cost and Improving Performance

arXiv · PDF · Open in the Atlas

Code that ran

We lifted 11 functions out of this paper's own repositories and ran 9 of them in a sandbox. "Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results.

RepositoryRoleRan
stanford-futuredata/frugalgpt pwc_unofficial 9 of 11
FunctionStatusWhere it lives
ans2opt Ran stanford-futuredata/frugalgpt/src/FrugalGPT/scoring.py
code served (permissive licence) · get_code("320a35b0624d3602")
compute_cost Ran stanford-futuredata/frugalgpt/src/service/utils.py
code served (permissive licence) · get_code("5141b572dad4bddf")
compute_dist Ran stanford-futuredata/frugalgpt/src/FrugalGPT/optimizer.py
code served (permissive licence) · get_code("afef112169d5fcf2")
form_keys Ran stanford-futuredata/frugalgpt/src/FrugalGPT/llmvanilla.py
code served (permissive licence) · get_code("97bed853c921dc6e")
formatdata Ran stanford-futuredata/frugalgpt/src/FrugalGPT/utils.py
code served (permissive licence) · get_code("894f647e885ebeb9")
getservicename Ran stanford-futuredata/frugalgpt/src/FrugalGPT/utils.py
code served (permissive licence) · get_code("0d52632aabe1e814")
loadcsvdata Ran stanford-futuredata/frugalgpt/src/FrugalGPT/utils.py
code served (permissive licence) · get_code("23ba7d3ad1de85d6")
scorer_text Ran stanford-futuredata/frugalgpt/src/FrugalGPT/llmcascade.py
code served (permissive licence) · get_code("50396a05d7ac8e73")
table2json Ran stanford-futuredata/frugalgpt/src/FrugalGPT/llmcascade.py
code served (permissive licence) · get_code("8d5abab8c54bed5a")
compute_distance_batch Not yet run stanford-futuredata/frugalgpt/src/FrugalGPT/optimizer.py
code served (permissive licence) · get_code("b9e4d8d1278fc2fb")
load_http_text Not yet run stanford-futuredata/frugalgpt/src/service/utils.py
code served (permissive licence) · get_code("d9d512988e76223b")

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

There is a rapidly growing number of large language models (LLMs) that users can query for a fee. We review the cost associated with querying popular LLM APIs, e.g. GPT-4, ChatGPT, J1-Jumbo, and find that these models have heterogeneous pricing structures, with fees that can differ by two orders of magnitude. In particular, using LLMs on large collections of queries and text can be expensive. Motivated by this, we outline and discuss three types of strategies that users can exploit to reduce the inference cost associated with using LLMs: 1) prompt adaptation, 2) LLM approximation, and 3) LLM cascade. As an example, we propose FrugalGPT, a simple yet flexible instantiation of LLM cascade which learns which combinations of LLMs to use for different queries in order to reduce cost and improve accuracy. Our experiments show that FrugalGPT can match the performance of the best individual LLM (e.g. GPT-4) with up to 98% cost reduction or improve the accuracy over GPT-4 by 4% with the same cost. The ideas and findings presented here lay a foundation for using LLMs sustainably and efficiently.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2305.05176")
get_code_for_paper("2305.05176")
have("2305.05176")

Connect an agent — have() is free.