Overview
The paper introduces Coke, a cost-efficient strategy for Knowledge-Based Question Answering (KBQA) that intelligently routes questions to either expensive Large Language Models (LLMs) or lightweight Knowledge Graph Models (KGMs). By modeling model selection as a multi-armed bandit problem, Coke achieves up to 2.74% higher accuracy than GPT-4 while slashing API costs by over 20%.
The Challenge: Balancing Cost and Accuracy
Knowledge-Based Question Answering (KBQA) requires a model to reason using specific domain facts. Currently, researchers face a difficult "pick your poison" scenario:
- LLMs (like GPT-4): These models are incredibly capable but come with prohibitive API costs. Furthermore, they can hallucinate when domain-specific data was missing from their pre-training corpus.
- KGMs (Knowledge Graph Models): These are small, specialized models that reason over structured data (triples like head-relation-tail). They are cheap to run but generally lag behind LLMs in raw reasoning power.
The core challenge is that accuracy and cost are distinct metrics that do not easily combine in a single optimization formula. Furthermore, different models excel at different types of questions—one might be great at medical jargon, while another excels at common-sense logic. Manually deciding which model to use for every single query is impossible at scale.
Methods: Coke as a Multi-Armed Bandit
The authors propose Coke (Cost-efficient Knowledge-based question answering), which treats model selection as a Multi-Armed Bandit (MAB) problem. The goal is to maximize cumulative rewards (correct answers) while staying under a strict budget.
The framework consists of three main components:
- Cluster-level Thompson Sampling: Instead of evaluating every model individually at first, Coke groups them into clusters (LLMs vs. KGMs). It uses historical success and failure rates (modeled via a Beta distribution) to estimate which type of model is likely to succeed for a given budget.
- Context-Aware Expert Distinguishing: To pick the specific "expert" model within a cluster, Coke uses a lightweight RoBERTa model to create an embedding of the question. It then learns a linear correlation between these semantic features and the likelihood of a specific model answering correctly.
- Cost Regret Constraint: This penalty term "punishes" the system for wasting money on incorrect answers. It ensures that the selection policy respects the budget constraints and prioritizes exploration only when it is likely to lead to a more cost-effective outcome.
Key Insights
- Moving the Pareto Frontier: Most systems trade accuracy for cost. Coke is notable because it moves the "Pareto frontier"—it manages to be both more accurate and cheaper than using a top-tier LLM alone.
- Semantic Routing: The "aha moment" of the paper is that question semantics (the "context") are a strong predictor of which model will succeed. By embedding the question, Coke realizes that a small KGM might actually be more reliable for a specific structural query than a general-purpose LLM.
- Exploration vs. Exploitation: The bandit framework allows the system to "gamble" on cheaper models early on. If a small model proves it can handle a certain class of questions, the system "exploits" that knowledge to save money later.
Key Results
The authors evaluated Coke on three diverse domain-specific benchmarks: CommonsenseQA (CSQA), OpenBookQA (OBQA), and MedQA-USMLE. Coke demonstrated significant improvements across the board when compared to a baseline of calling GPT-4 for every question.
- CommonsenseQA: Achieved a 2.74% accuracy boost while saving 20.89% in GPT-4 fees.
- OpenBookQA: Achieved a 0.67% accuracy boost with an 11.02% cost saving.
- MedQA: Even in the difficult medical domain, it saw a 1.03% accuracy increase and a 4.32% cost reduction.
- Efficiency: The framework is lightweight enough to run on a single CPU, making the overhead of the selection process negligible compared to the savings generated.
Limitations and Future Work
The primary limitation identified is the performance gap between models. In specialized fields like medicine (MedQA), the gap between the best KGM and GPT-4 is massive (roughly 36%). In these cases, Coke is forced to rely heavily on the LLM to maintain accuracy, which inherently limits the potential for cost savings.
The authors suggest that as more robust "middle-tier" models (like Llama 3 70B or specialized medical LLMs) emerge, Coke can easily plug them in as new arms in the bandit framework to further optimize the cost-accuracy balance.
Summary updated