Incentivizing Quality Text Generation via Statistical Contracts

Authors: eden  saig
ohad  einav
inbal  talgam-cohen
Venue: NeurIPS_cc_2024_Conference
Published: 2024-05-15 20:52:59

Abstract: While the success of large language models (LLMs) increases demand for machine-generated text, current pay-per-token pricing schemes create a misalignment of incentives known in economics as moral hazard: Text-generating agents have strong incentive to cut costs by preferring a cheaper model over the cutting-edge one, and this can be done “behind the scenes” since the agent performs inference internally. In this work, we approach this issue from an economic perspective, by proposing a pay-for-performance, contract-based framework for incentivizing quality. We study a principal-agent game where the agent generates text using costly inference, and the contract determines the principal’s payment for the text according to an automated quality evaluation. Since standard contract theory is inapplicable when internal inference costs are unknown, we introduce cost-robust contracts. As our main theoretical contribution, we characterize optimal cost-robust contracts through a direct correspondence to optimal composite hypothesis tests from statistics, generalizing a result of Saig et al. (NeurIPS’23). We evaluate our framework empirically by deriving contracts for a range of objectives and LLM evaluation benchmarks, and find that cost-robust contracts sacrifice only a marginal increase in objective value compared to their cost-aware counterparts.

Main paper: 
 introduction: 
 Modern-day LLMs are showing increasingly impressive capabilities, and simultaneously becoming increasingly costly. With rising success at handling complex tasks, conversational AI systems are seeing ubiquitous usage across critical domains such as healthcare [19, 34] , financial risk assessment [27] , and law [24, 35] . To achieve such levels of performance, contemporary LLM architectures contain billions and even trillions of parameters, leading to a computational pipeline that requires dedicated facilities and substantial energy to operate [33] .Due to the high computational requirements of modern LLMs, language generation tasks are typically outsourced to commercial firms which generate text for a fee. These firms either maintain dedicated infrastructure optimized for inference workloads, or act as intermediaries that facilitate access to such resources. To address the tension between performance and computational costs, such firms typically have multiple service options, each offering a different trade-off between model quality and cost [1, 7, 36, 37] . Currently, the most common pricing scheme for such services is pay-per-token, in which users agree in advance to pay a fixed rate for each token of text generated by the system [10] .While simple and intuitive, the pay-per-token pricing scheme creates a misalignment of economic incentives between the firms and their consumers, known in the economic literature as moral hazard: As inference is performed internally and a fixed price is agreed upon in advance, firms can strategically increase their profit margin by generating text using a cheaper, lower-quality model. Due to the stochastic nature of language generation, consumers may not be able to reliably determine the quality of the model being used, exposing them to this kind of hazard.Moral hazard is especially prevalent in cases where the text generation task is complex, and so evaluation is hard: Consider a scenario where a healthcare provider hires a firm to use conversational AI for summarizing medical notes. As medical diagnosis is an intricate and critical task, the healthcare provider wishes the medical summaries to be generated using the most advanced language model. Under the pay-per-token pricing scheme, the healthcare provider agrees in advance to pay the firm a fixed amount for each token generated. However, it is not hard to imagine that the firm may attempt to increase profit margins by routing some of the summarization requests to cheaper language models, instead of the most advanced one, without taking into account their purpose, and knowing that any lower-quality results would be attributed to the stochastic nature of LLM inference.From pay-per-token to pay-for-performance. In the economic literature, the canonical solution to moral hazard problems is pay-for-performance, or P4P [17] . Instead of paying a fixed price for any outcome, the parties agree in advance on a contract that specifies a differential payment scheme -for example, agreeing in advance that the firm will receive higher pay when the generated text is considered to be of higher quality. When designed correctly, contracts incentivize rational agents to invest more effort, thus providing a way to align incentives. Interaction around contracts is modeled as a principal-agent game, where the principal commits to a payment scheme, and the agent responds by rationally selecting a utility-maximizing action. Within this framework, the principal seeks to design a contract which satisfies some notion of optimality, such as requiring the least amount of expected pay ("min-pay contract"), or the lowest budget ("min-budget contract").In this work, we extend the theory of contract design, and use it to design optimal pay-for-performance pricing schemes for delegated text generation. Applying contract design to this setting requires us to overcome the challenges of automated evaluation and cost uncertainty. The former stems from the need for a scalable measure of performance to support pay-for-performance pricing, while the latter arises from the principal's uncertainty about the agent's true internal cost structure, as commercial firms often regard operational costs and implementation details as proprietary information.Our results. To tackle automated evaluation, we draw upon recent advances in the LLM evaluation literature [9] , and propose a modular contract design framework which uses LLM evaluators as subroutines. More specifically, upon receiving generated text, our pricing scheme is implemented by evaluating the prompt-response pair using an automated evaluator and paying accordingly. The choice of evaluator can be tailored to the task: optimal pricing schemes in code generation tasks, for example, would rely on a pass/fail code evaluator [11, 4] , whereas evaluation of linguistic tasks can be achieved using an "LLM-as-a-judge" approach [41, 28, 25] . In our theoretical analysis, we show that our framework is applicable even to intricate tasks where current evaluation methods are noisy and undecisive, as the principal can compensate for the noise by paying more (Proposition 1).To address the challenge of cost uncertainty, we propose a new notion of cost-robust contracts, which are pay-for-performance schemes guaranteed to incentivize effort even when the internal cost structure is uncertain. Our main theoretical contribution is a statistical characterization of optimal cost-robust contracts (Theorem 1): We prove a direct correspondence between optimal cost-robust contracts and statistical hypothesis tests by showing that the min-budget and min-pay contract objectives correspond to minimax risk functions of composite hypothesis tests (Type-1+Type-2 errors and FP/TP, respectively). This significantly generalizes a recent result by Saig et al. [31] to arbitrary action spaces and multiple optimality objectives. The statistical connection provides intuition and interpretation for numerical results, and the applicability to multiple objectives allows system designers to accommodate different business requirements. Intriguingly, the relation between the optimal contract and the optimal statistical risk have the same functional form in both objectives (min-budget and min-pay). Moreover, multiplying optimal hypothesis tests by a constant whose value depends only on the statistical risk yields approximately-optimal contracts (Theorem 2).Finally, we evaluate the empirical performance of cost-robust contracts by analyzing LLM evaluation benchmarks for two families of tasks. In the first experiment, we compare the performance of two-outcome contracts across code generation tasks with varying difficulty; results show that what determines the pricing scheme is the relative success rates of the models, not the task difficulty. In the second experiment, we compute multi-outcome contracts for an intricate conversational task evaluated via LLM-as-a-judge. Numerical results show that the optimal monotone cost-robust pricing scheme has an intuitive 3-level structure: pay nothing if the quality is poor, pay extra if it is exceptional, and pay a fixed baseline otherwise. We show our framework's flexibility by providing a comprehensive comparison across various contract objectives and simplicity constraints. Receive 𝑡 𝑞 monetary units Figure 1 : Interaction protocol. Principal commits to pay t(q) monetary units according to response quality, and sends prompt ω 0 ; Agent selects text generator g ∼ σ(t), and generates response ω R = g(ω 0 ) at cost α g |ω R |; Principal evaluates response quality q(ω 0 , ω R ), and pays accordingly.Our main technical tool is algorithmic contract design (see [5, 20, 14] and subsequent works). Many works in this area address distributional robustness, e.g. [8] , [14] which also studies approximation guarantees of simple contracts, and the recent [3] which presents a distributionally-robust contract design approach for delegation of learning. However, to our knowledge, none address cost-robustness. Connections between contract design and statistics have long been known to exist at a high level (see, e.g., [32] ), and were recently explored by [6] in the context of adverse selection, and [31] for two-action min-budget contract. From a technical standpoint, our work is closest to [31] , which only proves the statistical connection for the special case of two-action min-budget contracts. Finally, we note that our cost-robustness framework is general, and our characterization results may be of independent interest. Additional related work appears in Appendix A. 
problem setting: contract design for text generation: 
 We study the delegation of a text generation task from a strategic principal to agent, with a payment scheme designed to incentivize quality. Here we formulate the problem as a contract design instance.The core of our setting is a standard language generation task. Let V be a vocabulary of tokens, and denote the set of all token sequences by V * . A text generator g : V * → V * is a mapping from a textual prompt ω 0 to a response ω R . We assume that prompts are sampled from a distribution ω 0 ∼ D ∈ ∆ (V * ), and denote by D g the distribution of prompt-response pairs, where the prompt is sampled from D and the response is generated by generator g. Given a prompt and generated response, a quality evaluator is a function q : V * × V * → [m] which scores the response on a scale of 1, . . . , m. We use F g to denote the distribution over scores [m] induced by applying the quality evaluator to a random pair (ω 0 , ω R ) ∼ D g , and F gj to denote the probability of score j ∈ [m].The agent has access to a collection of possible text generators G = {g 1 , . . . , g n }, which we also refer to for convenience by their indices [n] . Each model g i ∈ G is associated with a model-dependent cost α i ≥ 0, which is the average cost (borne by the agent) of generating a single token from g i . For convenience we write D i = D gi andF i = F gi . Denote by c i = α i E (ω0,ω R )∼Di [|ω R |]the expected cost of using the ith generator. We assume w.l.o.g. that the costs are non-decreasing, i.e., c 1 ≤ • • • ≤ c n , and that they reflect the inherent quality of the models. In contract design terminology, the generators are the agent's possible actions. The agent can choose a single (pure) action, or a distribution over text generators σ ∈ ∆ (G) known in game theory as a mixed action. 1 The cost c 1 of the lowest-cost action is the agent's "opportunity cost", and unless stated otherwise c 1 = 0.2 As an abstract contract design problem. The above setting is precisely a contract design setting with n actions and m outcomes [21] . Such a setting is defined by the pair (F, c), where F is an n × m matrix with distribution F i as its ith row for every i (known as the distribution matrix), and where c is a vector of costs. For every action i, F i and c i are the outcome distribution and cost, respectively.Pay-for-performance and agent's utility. To incentivize high quality text generation, the principal commits in advance to a pay-for-performance contract, which specifies the amount of payment to the agent for generating a response with a certain quality. More formally, given a quality evaluator q with an output scale 1, . . . , m, a contract t : [m] → R ≥0 is a mapping from the estimated quality to the size of monetary transfer. Note that transfers are non-negative; this standard restriction is known as limited liability, and it mirrors the fact that when a principal hires an agent to perform a task, money flows in one way only (from principal to agent, and not vice versa). If transfers are increasing with score, we say t is a monotone contract. Monotonicity is not without loss of generality, but is a desirable property as monotone contracts are generally simpler and easier to explain [14] .Given a contract t ∈ R m ≥0 and an action σ ∈ ∆ (G), the agent's expected utility u A (t; σ) (a.k.a. the agent's profit) is the difference between the expected reward and the expected cost of text generation:u A (t; σ) = E gi∼σ;(ω0,ω R )∼Di [t(q(ω 0 , ω R )) -α i |ω R |] = E gi∼σ;j∼Fi [t(j) -c i ],where (ω 0 , ω R ) ∼ D i are the prompt and generated response, t(q(ω 0 , ω R )) is the payment transferred to the agent based on the quality of response, and α i |ω R | is the agent's cost of generating the response.We assume the agent is rational and therefore selects, when facing contract t, an action σ(t) which maximizes their expected profit (also known as the agent's best response):σ(t) ∈ arg max σ∈∆(G) u A (t; σ).As is standard in contract theory, we assume the agent breaks ties consistently and in a way that agrees with the principal's preferences. 3 The interaction model is summarized in Figure 1 .We assume that the principal seeks to obtain text generated by the model g n ∈ G, the most advanced model with the (strictly) highest associated cost c n > c n-1 . We refer to g n as the target action, i.e. the action which the principal wishes to incentivize. Taking the role of the principal, our goal is to design the "best" contract t * that incentivizes the agent to generate responses using the target model g n . This is formalized by the following optimization problem:EQUATIONwhere ∥t∥ is a norm of t representing the principal's economic objective (see below), and δ gn is a point-mass distribution over text generators, supported by the target generator g n . We denote the set of contracts incentivizing action g n by T (g n ) = t ∈ R m ≥0 | σ(t) = δ gn , and further note that the assumption of a single target action serves as a foundational step towards more complex contract design scenarios (see Appendix B.1).[m] are known to both players. As the quality distributions F i can be learned from past data, we assume they are known to both principal and agent. As the costs of inference {α i } depend on internal implementation details, we assume the costs are known to the agent but uncertain to the principal. We thus aim for a contract optimization framework which maximizes different types of objectives, and allows for optimization of t even when the costs incurred by the agent are uncertain to the principal.Objectives: min-budget, min-pay and min-variance contracts. In eq. ( 1), different norms ∥t∥ correspond to different possible optimization goals of the principal: For example, a contract is min-pay if it incentivizes the target action using minimum total expected payment E j∼Fn [t(j)] among all contracts in T (g n ) [14] ; In eq. ( 1), this corresponds to the ℓ 1 norm weighted by the quality distribution of the target action. Similarly, a contract is min-budget if it incentivizes the target action using minimum budget B t = max j t(j) [31] ; In eq. ( 1), this corresponds to the ℓ ∞ norm. Additionally, we also consider a natural min-variance objective, which was not previously studied to our knowledge. A min-variance contract minimizes the objective Var(t), corresponding to a weighted ℓ 2 norm. Optimal contracts for these objectives can be computed in polynomial time by solving a corresponding linear or convex-quadratic program (see Appendix D.1). We also consider approximately-optimal contracts: Definition 1 (η-optimal contract). Let η ≥ 1. For contract setting (F, c), let t * ∈ T (g n ) be the optimal contract with respect to objective ∥t∥. A contract t ∈ T (g n ) is η-optimal if ∥t∥ ≤ η ∥t * ∥. 
hypothesis testing and contracts: 
 This section sets the stage for connecting cost-robust contracts to statistical tests in Section 4.Consider two distributions F 0 , F 1 ∈ ∆ ([m]). Given j ∈ [m] which is sampled from either F 0 or F 1 , a hypothesis test is a function ψ : [m] → [0, 1]which outputs 1 if j is likely to have been sampled from F 1 , and 0 otherwise4 . In the hypothesis testing literature, F 0 is a simple null hypothesis, and F 1 is a simple alternative hypothesis. Performance measures of hypothesis tests are derived from the probabilities of making different types of errors: For a test ψ, the probability of false positives FP = m j=1 F 0,j ψ j measures the rate of type-1 errors; This is when the test rejects the null hypothesis despite the sample being drawn from F 0 . Similarly, the probability of false negatives FN = m j=1 F 1,j (1 -ψ j ) measures the rate of type-2 errors, i.e. when the test does not reject the null hypothesis despite the sample being drawn from F 1 . We also denote the true positives by TP = m j=1 F 1,j ψ j ; TP is also known as the test's power, and equal to 1 -FN.k } n-1 k=1 , {F n }, where F i ∈ ∆ ([m]) for all i ∈ [n]. In hypothesis testing terms, {F k } n-1k=1 is a composite null hypothesis. {F n } is a simple alternative hypothesis as before, and a composite hypothesis test ψ outputs 1 if a given j ∈ [m] is likely to have been sampled from F n . To define performance in the composite case, we denote by FP k = m j=1 F k,j ψ j the standard type-1 error between distributions F k and F n . As the alternative hypothesis is still simple, definitions of FN and TP remain as before, using F n as the reference distribution. To measure the performance of hypothesis tests, it is common to take a worst-case approach, and define the composite FP as the standard type-1 error FP k against the worst-case distribution F k in the null hypothesis set.To formalize the notion of worst-case error, let ψ be a composite hypothesis test for{F k } n-1 k=1 , {F n }. For any k ∈ [n -1], define a risk function r k : [0, 1] m → R ≥0to be a mapping from ψ to a risk score, treating ψ as a simple hypothesis test between distributions F k and F n . A natural way of measuring risk is by combining the test's two error types. One measure is the sum of errors, denoted by R k (ψ) := FP k + FN. A classic result by Neyman and Pearson shows that R k (ψ) is minimized by the likelihood-ratio test for any fixed k [29] . Another measure is the ratio of false positives to true positives, denoted by ρ k (ψ) := FP k / TP. To generalize a risk measure r k to a composite hypothesis test, we adopt the worst-case approach and define r(ψ):= max k∈[n-1] {r k (ψ)}. Thus, R(ψ) = max k∈[n-1] {R k } = FP + FN, and ρ(ψ) = max k∈[n-1] {ρ k } = FP / TP. Definition 2 (Minimax hypothesis test). Let ψ * F be a composite hypothesis test for {F k } n-1k=1 , {F n }, and fix a risk function r k . The test ψ * F is minimax optimal w.r.t. r if it minimizes the worst-case risk:ψ * F = arg min ψ∈[0,1] m max k∈[n-1] {r k (ψ)} = arg min ψ∈[0,1] m {r(ψ)}.The minimax sum-optimal test and minimax ratio-optimal test are the minimax optimal tests with respect to the sum R and the ratio ρ, respectively.Observe that the optimal risk of both types of tests is bounded by r(ψ) ≤ 1, as the constant testψ j = 0.5 satisfies R(ψ) = ρ(ψ) = 1.We assume at least a small difference between the hypotheses, such that r(ψ) < 1. This allows us to define contracts based on these tests. • Test-to-contract: Let ψ be a test for sets{F k } n-1 k=1 , {F n } with budget B r (ψ, b) ∈ [0, ∞). The corresponding statistical contract t (r,ψ) is B r (ψ, b) • ψ.• Contract-to-test: Let t be a contract. The corresponding contractual test ψ t is t/ ∥t∥ ∞ .-budget max j∈[m] t j FP + FN Pr F k (ψ = 1) + Pr Fn (ψ = 0) Min-pay E j∼Fn [t j ] FP / TP Pr F k (ψ=1) Pr Fn (ψ=1)Table 1 : Correspondence between cost-robust contracts and hypothesis tests, arising from Theorem 1.We are interested in the following statistical contracts corresponding to the tests from Definition 2:Definition 3. Consider a contract setting (F, c), with either known costs and b:= c n -c 1 , or a cost upper bound b ≥ c n -c 1 . The sum-optimal statistical contract B * R (b) • ψ * R is obtained from the minimax sum-optimal test ψ * R multiplied by B * R (b) := b 1-R(ψ * R ) . The ratio-optimal statistical contract B * ρ (b)•ψ * ρ is obtained from the minimax ratio-optimal test ψ * ρ multiplied by B * ρ (b) := b TP(ψ * ρ )-FP(ψ * ρ ) . 
cost-robust contracts: 
 In this section we state and prove our main result -a direct connection between composite hypothesis testing and cost-robust contracts. Consider a contract design setting (F, c) with increasing costsc 1 ≤ • • • ≤ c n-1 < c n ,where n is the target action. In real-world settings, the principal may not have full knowledge of the agent's internal cost structure. We model this by assuming the principal is oblivious to the precise costs, but knows an upper bound b ≥ c n -c 1 . We are interested in robust contracts that incentivize the target action for any cost vector compatible with the upper bound:Definition 4 (Cost-robust contracts). Consider a distribution matrix F and a bound b > 0 on the costs. Let C b be an ambiguity set of all increasing cost vectors c such thatc n -c 1 ≤ b. A contract is b-cost-robust if it implements action n for any cost vector c ∈ C b .Informally, our main theoretical result shows that optimal cost-robust contracts are optimal hypothesis tests up to scaling, where the scaler depends on the risk measure which the test optimizes. Our approach can be applied to several notions of optimality, and each optimality criterion for contracts corresponds to a different optimality criterion for hypothesis tests. Specifically, we derive the correspondence for min-budget and min-pay optimality of contracts. Formally (recall Definition 3):Theorem 1 (Optimal cost-robust contracts). For every contract setting with distribution matrix F and an upper bound b on the (unknown) costs, let ψ * R (resp., ψ * ρ ) be the minimax sum-optimal (ratio-optimal) test with risk R * (ρ * ) among all composite hypothesis tests for{F k } n-1 k=1 , {F n }. Then: • The sum-optimal statistical contract B * R (b) • ψ * R is b-cost-robust with budget b/(1 -R * ), and has the lowest budget among all b-cost-robust contracts.• The ratio-optimal statistical contract B * ρ (b) • ψ * ρ is b-cost-robust with expected total payment b/(1 -ρ * ), and has the lowest expected total payment among all b-cost-robust contracts.Table 1 summarizes the contract vs. test equivalences arising from Theorem 1. In the special case of contract design settings combining (i) a binary action space (n = 2), (ii) a zero-cost action (c 1 = 0), and (iii) a tight upper bound (b = c 2 ), the first half of Theorem 1 recovers a recentlydiscovered correspondence between hypothesis testing and (non-cost-robust) two-action min-budget contracts [31, Theorem 2] . Theorem 1 is more general since it applies to any number of actions as well as to the standard min-pay objective. Thus, Theorem 1 can also be seen as extending the interpretable format of optimal contracts for binary-action settings beyond two actions.In Appendix D.2, we derive our main lemmas, which are used in Appendix D.4 to prove Theorem 1. Our proofs rely on two main assumptions. The first assumption is that the cost uncertainty bounds are known; as these bounds become looser, the required budget and expected payout increase linearly. The second assumption is that the contract design problem is implementable -i.e., that there exists some contract incentivizing the target action. In particular, implementability holds when text generated by the target model has the highest quality in expectation (see Appendix C.1). Generally, a contract design problem is implementable when the observed quality distribution of the target model can't be emulated by a combination alternative models at a lower cost (see, e.g., [14] ).In this section, we focus for concreteness on min-budget cost-robust contracts, and establish their approximation guarantees as well as their functional form under structural assumptions. First, in analogy to [14] , it is natural to examine the approximation guarantees of cost-robust contracts. We show (recall Definition 1):Theorem 2 (Approximation guarantees). For every contract setting (F, c), let 0 < a ≤ b be a lower and upper bound on the difference between the target cost and any other cost, i.e., (c n -c i ) ∈ [a, b] for all i ∈ [n -1]. Then the min-budget b-cost-robust contract for (F, c) is ba -optimal with respect to the budget objective ∥t∥ ∞ , and the approximation ratio b a is tight. Proof in Appendix D.5. As a corollary, combining this result with Theorem 1 shows that statistical contracts are approximately optimal in the global sense: For any contract setting (F, c) with corresponding minimax sum-optimal hypothesis test ψ * R , the contract t = cn-c1 1-R * ψ * R is η-optimal with respect to the budget metric and η = cn-c1 cn-cn-1 . We also note that similar results hold for min-pay cost-robust contracts.We next turn to consider the functional form of optimal cost-robust contracts (i.e., why their payments are as they are). One of the criticisms of optimal (non-robust) contracts is that the payments seem arbitrary and opaque. Compared to this, cost-robust contracts are more transparent and explainable. We show two additional results regarding their format, leveraging the connection to minimax hypothesis testing.The first result explains the budget: By the minimax principle, there is a "least favorable distribution" (to use terminology from statistics) or, equivalently, a mixed strategy over the rows of F (to use terminology from game theory) such that no test can achieve for it better risk than the minimax risk R * . We show that the budget of the optimal cost-robust contract can be interpreted using this distribution. Formally, let ∥F 1 -F 2 ∥ TV be the total variation distance between distributions F 1 , F 2 , then the budget is as follows (see Appendix D.5 for a proof):Proposition 1 (Distribution distance determines budget). For every contract setting with distribution matrix F and spread of costsc n -c 1 ≤ b, the minimum budget of a b-cost-robust contract is max λ∈∆([n-1]) b/ F n -i<n λ i F i TV .The distribution i<n λ i F i that maximizes the above expression is the least favorable one. Intuitively, the closer it is to the target distribution F n , the larger the budget needed for the agent to distinguish among them and prefer the target action. We also note that the required budget approaches infinity when the worst-case distribution distance approaches zero, coinciding with the implementability characterization known from the literature (see Appendix C.1). The second set of results adds standard structure to the distribution matrix F to obtain even simpler contract formats:Definition 5 (Monotone Likelihood Ratio (MLR)). A distribution matrix F satisfies MLR if F i,j /F i ′ ,j is monotonically increasing in j ∈ [m] for all i > i ′ .Intuitively, if F satisfies MLR, then the higher the outcome j, the more likely it is to origin from a more costly distribution F i than from F i ′ (recall that costs c i are increasing in i). Consider minimax composite hypothesis tests for {F k } n-1 k=1 , {F n }; if F does not satisfy MLR, optimal such tests may require randomization (i.e., ψ j ∈ (0, 1) for some outcome j) and/or non-monotonicity (i.e. ψ j > ψ j ′ for some pair of outcomes j < j ′ ). However, if MLR holds for F , then nice properties (determinism, monotonicity) hold for minimax tests (e.g., by the Karlin-Rubin theorem [29] ), and consequently also for cost-robust contracts (see Appendix D.6 for a proof):Proposition 2 (MLR induces threshold simplicity). For every contract setting with distribution matrix F that satisfies MLR, and with spread of costs c n -c 1 ≤ b, the min-budget b-cost-robust contract for F is a monotone threshold contract, which pays full budget to the agent for every outcome j above some threshold j * .For min-pay rather than min-budget, under MLR we get a monotone contract with a single positive payment, which is optimal (see [14, Lemma 7] ). Finally, we note that finding cost-robust min-budget contracts with two levels of pay ("all-or-nothing" [31] ) is computationally hard in the general case, as the reduction by [31, Theorem 3 ] also applies in the cost-robust case (see Appendix D.8).  
empirical evaluation: 
 We evaluate the empirical performance of our cost-robust contracts using LLM evaluation benchmarks.We compute binary and multi-outcome contracts for two distinct families of tasks based on evaluation scores from known benchmark datasets, optimizing the contract objectives set forth in Section 2.2.Our action space consists of the 7B, 13B, and 70B parameter model versions of the open-source Llama2 and CodeLlama LLMs [37, 30] , which share the same architecture and hence similar inference costs. The benchmark data is used to create an empirical outcome distribution for each LLM in the action space. In both cases, contract optimization targets of the largest model variant (70B), which is the most performant and costly. Implementation details are provided in Appendix E.3, and code is available at: https://github.com/edensaig/llm-contracts.Cost estimation. To estimate the inference costs of the language models, we leverage their open-source availability. We use energy consumption data from the popular Hugging Face LLM-Performance Leaderboard [22, 23] , which we then convert to dollar values using conservative cost estimates (see Appendix E.1). As a first-order assumption of cost uncertainty, we assume that inference costs of alternative generators are bounded from below by the cost of the most energy-efficient alternative model (c 1 ), and bounded from above by the cost of the alternative model with the highest energy consumption (c n-1 ).We begin by analyzing a simple contract design setting across benchmarks of varying difficulties. We use the LLM task of code-generation which has m = 2 outcomes: pass or fail. The analysis of a binary outcome space is motivated by the following theoretical property: Proposition 3. For any contract design problem with m = 2 where the most-costly (target) action has the highest pass rate, the optimal contract is identical for all optimality objectives (min-pay, min-budget, and min-variance). Moreover, the optimal contract satisfies t pass > 0, t fail = 0.Proof in Appendix D.7. Proposition 3 allows us to compare performance across different evaluation tasks without being sensitive to the choice of contract objective and constraints such as monotonicity.Datasets. We use evaluation data from two distinct benchmarks, which represent differing degrees of task difficulty. The Mostly Basic Programming Problems (MBPP) benchmark [4] contains 974 entry-level programming problems with 3 unit tests per problem. The HumanEval benchmark [11] consists of 164 hand-written functional programming problems. Included in each programming problem is a function signature, a doc-string prompt, and unit tests. There is an average of 7.7 unit tests per problem, and the overall score is based on a pass/fail evaluation of the responses. For each of these benchmarks, we create a binary-outcome (m = 2) contract from the pass rates of the CodeLlama model family (CodeLlama-{7B,13B,70B}). We use the pass@1 values from the CodeLlama paper [30] (success rates for a single response), as they capture a setting where the agent gets paid for each response.Cost-robust ). The numbers in bold denote the relative increase from the optimal monotone contract that the costrobustness sacrifices in each setting. The percentages denote the price of cost-robustness: how much the objective values increase relative to the cost-aware setting.E[t]Task difficulty and optimal pay. Figure 2 (Left-Center) presents optimal cost-aware and costrobust contracts for code-generation. We observe that cost uncertainty entails a consistent increase in payment across tasks: For MBPP, we observe a 14.9% increase, and for HumanEval we observe a similar 14.7% increase. Additionally, while the MBPP task is easier than HumanEval (i.e. characterized by higher pass rates), the resulting contracts for MBPP are more expensive. This demonstrates the fundamental connection between contracts and statistics: In MBPP, there is smaller gap between the performance of the target model (70B) and the performance of the alternatives. This makes the highest-performing model harder to detect, increasing the cost of the contract. The required payments in this case thus depend on the absolute differences between pass rates, rather than absolute values.To understand the relation between different optimality objectives and constraints, we analyze optimal contracts in an expressive multi-outcome (m = 10) environment based on MT-Bench.Dataset. The MT-Bench benchmark [41] is designed to evaluate the conversational and instructionfollowing abilities of LLMs in multi-turn (MT) conversational settings. The benchmark consists of 80 prompts in the format of multi-turn questions, and the evaluation dataset includes LLM-as-a-judge evaluations on (prompt,response) pairs from various models, using GPT-4 as the judge. In the dataset, each (prompt,response) pair is given discrete response quality scores in the range 1, . . . , 10. These scores define our contract outcome space. In consistence with the analysis in section 5.1, we use the outcome distributions of (Llama-2-{7B,13B,70B}-chat), and target the 70B model. Outcome distributions for the MT-Bench dataset are presented in Figure 2 .Simple optimal contracts. In practical applications, contracts with a simple functional form are often preferred since they are easier to comprehend. We compute optimal contracts with two types of simplicity constraints: monotone contracts (weakly increasing payout), and threshold contracts (full budget for all scores above a threshold, and zero otherwise). Results are presented in Figure 2 (Right), and Table 2 . For the min-budget and min-variance criteria, monotone cost-robust contracts have an intuitive three-level structure: Zero pay for outputs with the lowest quality score, base pay for intermediate scores, and extra pay for outputs with the highest quality score. While threshold contracts may resemble current pricing schemes more closely (see Appendix E.1), monotone contracts enable a lower overall budget while still maintaining a simple functional form. For min-pay, monotone cost-robust contracts are in themselves threshold contracts, however they may deter risk-averse agents as they only pay for highest-quality outputs. In Appendix E.2, we additionally analyze non-monotone contracts, and show that further economic efficiency can be achieved by sacrificing simplicity.Price of cost-robustness. Table 2 compares cost-robust and cost-aware monotone contracts across different performance metrics. We observe that cost-robust contracts setting sacrifice a marginal increase in objective values: a 15% increase in the min-pay objective, an 1.7% increase if optimizing for budget, and 6.7% increase when optimizing for minimum variance. We refer to Appendix E.2 for further analysis of cost-robustness in the non-monotone setting. 
discussion: 
 In this paper, we introduce cost-robust contracts as a means to address the emerging problem of moral hazards in LLM inference. Our aim is to offer flexible payment schemes that ensure integrity in current LLM markets, even when facing challenges of incomplete information. One of the key insights from our study is that cost-robust contracts can be relevant and effective in practical settings. Moreover, we generalize the work paved by Saig et al. [31] by uncovering stronger connections between the fields of contract design and statistical hypothesis testing. These connections underscore the statistical intuition that is prevalent in contract design.Despite the promising results, our work still has several limitations that would do well to be addressed in future research. For one, the data we capture through the evaluation benchmarks does not accurately reflect real-world distributions, where the prompt space is much richer. A natural direction for future work is to explore approximation guarantees when learning contracts from data. Additionally, our analysis relies on a set of assumptions regarding the cost uncertainty and estimations, which should be carefully considered when designing contracts for Generative AI. Lastly, it would also be interesting to see our contract design framework applied to markets with a more elaborate action space.Detection. As a possible alternative to a contract-design approach, the LLM content detection literature develops tools which attempt to detect machine-generated text, and distinguish between different text generators [38, 26, 40, 39] . Using such tools, a principal could deploy an LLM content detector and penalize firms who are not labeled as using target text generator. From this perspective, contract design is a complementary approach which provides guidelines for positive incentives in case a generated text gets accepted, an approach considered more effective at encouraging participation. Additionally, our pay-for-performance framework supports richer outcomes spaces beyond binary pass/fail, enabling more granular, and thus more efficient, control of incentives.AGT and LLMs. On a broader perspective, our work further promotes the role of Algorithmic Game Theory in the economics of Generative AI. Previous works include: Duetting et al. [13] who design auctions that merge outputs from multiple LLMs; Harris et al. [18] who offer a Bayesian Persuasion setting where the sender can use Generative AI to simulate the receiver's behavior; and Fish et al. [15] who leverage the creative nature of LLMs to enhance social choice settings.For high-stake tasks such as summarizing medical information, it makes sense to target the most advanced model. In other scenarios, specifying a single target action can act as an intermediate step toward the final contract design.For instance, a principal might aim to incentivize the use of any model that meets a certain quality threshold, e.g., requiring text generation from any LLM with more than 70B parameters. Formally, given a set of models G = {g 1 , . . . , g n } with associated costs c 1 < c 2 < • • • < c n , we assume that higher-cost models offer higher quality. Let k ∈ [n] represent the index of the minimum quality model that the principal seeks to target, such that the goal is to incentivize any model g i ∈ {g k , . . . , g n }.To compute the optimal contract in this setting, the principal enumerates over the different target models g i ∈ {g k , . . . , g n }, designs an optimal single-target contract for each, and selects the "best" contract among the resulting designs -formally, the contract minimizing ∥t∥ for the appropriate norm (see Section 2.2). Since all enumerated contracts are designed to satisfy incentive compatibility and potentially cost-robustness, the optimal contract among them also satisfies these properties.The implementatbility of min-pay contracts is discussed in [ i ′ ̸ =i λ i ′ F i ′ = F i but lower cost i ′ ̸ =i λ i ′ c i ′ < c i .We note that Proposition 4 holds for all objectives ∥t∥ described in eq. ( 1), as feasibility only depends on the incentive compatibility constraints. Adding to the result above, we show that implementability holds in the the intuitive case where the target model has the highest expected quality: Proposition 5 (Highest expected quality implies implementability). For a contract design problem (F, c), denote the expected quality of action i by q i = E j∈Fi [j]. If q i < q n for all i < n, then the contract is implementable.Proof. By contradiction. Assume that q i < q n for all i < n but the contract design problem is not implementable. By Proposition 4, there exists a convex combination of actions such that i<n λ i F i = F n and i c i < c n . Denote the convex combination of distributions by F λ . By definition, it holds that:E j∼F λ [j] = i<n λ i E j∼Fi [j] = i<n λ i q iBut from the infeasibility assumption i<n λ i F i = F n , and therefore it also holds that:E j∼F λ [j] = E j∼Fn [j] = q nand therefore i<n λ i q i < q n , which contradicts the initial assumption that q i < q n for all i.Our main analysis technique for cost-robust contracts requires a separation between the interval covering the costs of target actions, and the interval covering the costs of alternative actions (see proofs of Lemma 2 and Lemma 3). This assumption does not hold when the principal targets a strictly intermediate model, formally g i ∈ G such that i < n and c i < c n . This captures scenarios where the principal seeks to incentivize text generation from a medium-sized model, but not from larger, costlier models that are available. In such instances, guaranteeing the implementability of cost-robust contracts requires additional assumptions.To illustrate this, consider the following design setting, with n = 3 actions and m = 2 outcomes:F 1 = (1, 0) c 1 = 0 F 2 = (0, 1) c 2 = 1 F 3 = (0.5, 0.5) c 3 = 10Assume that the principal targets action i * = 2. In this setting, the cost difference is upper-bounded by c i * -c i ≤ c 2 -c 1 = 1, and the cost-robust min-budget contract corresponding to the bound b = 1 is given by Theorem 1:t = 0, b ∥F 3 -F 2 ∥ TV = 0, 1 0.5 = (0, 2)This contract is incentive compatible with respect to the target action, yielding expected utilities u A (t, 1) = 0 for action 1, u A (t, 2) = 1 for action 2, and u A (t, 3) = -9 for action 3.However, consider the following setting, with identical target and different outcome distributions:F 1 = (1, 0) c 1 = 0 F 2 = (0.5, 0.5) c 2 = 1 F 3 = (0, 1) c 3 = 10In this setting, an incentive-compatible contract exists (e.g., t = (0, 4)), and the same cost upper bound b = 1 holds, however the cost-robust contract design problems are unfeasible by Proposition 4, as in the truncated contract design setting (F = (F 1 , F 2 , F 3 ), c const = (0, 1, 0)) there exists a convex combination of alternative actions λ 1 = 0.5, λ 3 = 0.5 which satisfies i∈{1,3}λ i F i = F 2 and i∈{1,3} λ i c const i = 0 < c 2 = 1.In this section, we include linear programs (LPs) for optimizing contracts and hypothesis tests. Non-negativity constraints on the variables are ommitted where clear from context.By definition (see Section 2.2), a contract t is min-budget with respect to target action i if and only if it is an optimal solution to the following MIN-BUDGET LP, where IC stands for incentive compatibility (i.e., the constraints that ensure the agent's best response to t is choosing action i):EQUATIONProposition 6 (Equivalent form to the MIN-BUDGET LP; [31, B.2] ). When eq. ( 2) is feasible, the variable transformation (t, B) → (ψ/β, 1/β) yields an equivalent LP which we refer to as the statistical LP:EQUATIONSimilarly to the MIN-BUDGET LP, we have the MIN-PAY LP:EQUATIONThere are also natural LP formulations for hypothesis testing. A hypothesis test ψ is the minimax sum-optimal test w.r.t. risk (see Definition 2) if and only if it is an optimal solution to the following LP:min ψ∈[0,1] m ,r∈R ≥0 r s.t. j F ij ψ j + j F nj (1 -ψ j ) ≤ r ∀i < n (5)Proposition 7 (Dual of statistical LP). The dual of eq. ( 3) is given by:EQUATIONProof. Denote:x = (ψ 1 , . . . , ψ m , β) ∈ R m+1 . A =                  F 1,1 -F n,1 • • • F 1,m -F n,m c n -c 1 . . . . . . . . . F i,j -F n,j . . . c n -c i . . . . . . F (n-1),1 -F n,1 • • • F (n-1),m -F n,m c n -c n-1 0 I m×m . . . 0                  b = ( 0, . . . , 0 n -1 times , 1, . . . , 1 m times ) ∈ R n-1+m . c = (0, . . . , 0 m times , 1) ∈ R m+1 .Using these notations, eq. ( 3) can be written as:max x≥0 c T x s.t. Ax ≤ b (7)The symmetric dual LP of eq. ( 7) is given by:EQUATIONDenote: y = (λ 1 , . . . , λ n-1 , µ 1 , . . . , µ m ).Unpacking the matrix notations in eq. ( 8) yields the following:min λ∈R n-1 ≥0 ,µ∈R m ≥0 j∈[m] µ j s.t. i<n (F i,j -F n,j ) λ i + µ j ≥ 0 ∀j ∈ [m] i<n (c n -c i ) λ i ≥ 1which is equivalent to eq. ( 6).Proposition 8. A min-variance contract is an optimal solution for the following quadratic program:EQUATIONWhere V is a positive semi-definite matrix depending on the target action distribution F i .Proof. Denote the contract by t ∈ R m ≥0 and the probability distribution of the target action by p ∈ ∆ ([m]). We use the following matrix notations:p =    p 1 . . . p m    ; t =    t 1 . . . t m    ; 1 =    1 . . . 1    ; diag (p) =    p 1 . . . p m   The variance of t is given by:Var (t) = E j∼p (t j -E[t]) 2 = j p j t j - k p k t k 2 = diag (p) It -1p T t 2 = diag ( √ p) I -1p T t 2 Denote R = diag √ p I -1pT , and V = R T R. Then:Var (t) = ∥Rt∥ = t T R T Rt = t T V t Note that V = R T R is a Gram matrix.It is therefore positive semi-definite, and the quadratic program is convex.The next lemmas are the workhorses of our theoretical results. We use T (F,c) to denote the set of contracts incentivizing the target action n in a contract design setting (F, c); the contracts in T (F,c) are also known as the feasible solutions of the setting. For simplicity we focus on settings for which the set of feasible solutions is nonempty (i.e., the target action is implementable). Given either a non-decreasing cost vector c= (c 1 , . . . , c n-1 , c n ) ∈ R n ≥0 and an index k ∈ [n -1], or a cost c n and a constant c ′ < c n , define c (k) := (c k , . . . , c k , c n ) ∈ R n ≥0 ; c const := (c ′ , . . . , c ′ , c n ).These are vectors with uniform costs (up to c n ). Note that the costs in c (1) are (weakly) lower than those in c, and vice versa for c (n-1) :c (1) ≤ c ≤ c (n-1)Where the relation ≤ is defined element-wise. Intuitively, since the agent gravitates towards lower costs, it is harder to incentivize the target action against lower costs. We formalize this as follows:Lemma 1 (Incentivizing against lower costs is harder). Consider a distribution matrix F , and two cost vectors c ≤ c ∈ R n ≥0 satisfying c n = c n (i.e., c is dominated by c, and the cost of the target action coincides). Then the sets of feasible solutions for contract design settings (F, c) and (F, c) satisfy T (F,c) ⊆ T (F,c) .Corollary 1. For every contract design setting (F, c), the set T (F,c) of feasible solutions satisfiesT (F,c (1) ) ⊆ T (F,c) ⊆ T (F,c (n-1) ) .Consider now a contract setting (F, c const ), where the action costs are uniformly equal to c ′ except for the target action (which is more costly). We show that for such a setting, the optimal contract for incentivizing the target action has an interpretable format closely related to hypothesis testing. Recall the notions of sum-optimal and ratio-optimal statistical contracts from Definition 3; then: Lemma 2 (Min-budget optimality in uniform-cost settings). For every contract design setting (F, c const ), the min-budget contract coincides with the sum-optimal statistical contract B* R (c n -c ′ ) • ψ *R , and the optimal budget is (c n -c ′ )/(1 -R * ). Lemma 3 (Min-pay optimality in uniform-cost settings). For every contract design setting (F, c const ), the min-pay contract coincides with the ratio-optimal statistical contract B * ρ (c n -c ′ ) • ψ * ρ , and the optimal expected total payment is (c n -c ′ )/(1 -ρ * ).Proofs appear in Appendix D.3, establishing also the other direction: Observation 1. Let (F, c const ) be a contract design setting. Then the minimax sum-optimal test among the composite hypothesis tests for {F k } n-1 k=1 , {F n } is obtained by normalizing the min-budget contract, and the minimax ratio-optimal test is obtained by normalizing the min-pay contract.Proof of Lemma 1. For target action n and any alternative action i < n, the (IC) constraint of the MIN-BUDGET LP (eq. ( 2)) is given by: jF ij t j -c i ≤ j F nj t j -c n .Rearranging the terms yields:EQUATIONLet c be a cost vector satisfying c ≤ c and c n = c n . The costs c k are assumed to be increasing in k, and therefore c i -c n = c i -c n < 0 for all i. Moreover, as c i ≤ c i for all i < n, the RHS of eq. ( 10) satisfies:c i -c n RHS of (F, c) LP ≤ c i -c n RHS of (F, c) LP < 0.Hence, the (IC) constraints of the (F, c) contract design problem are more restrictive than the (IC) constraints of the (F, c) design problem. Since the design problems (F, c) , (F, c) , only differ in the RHS of the (IC) constraints, the sets of feasible solutions satisfy the desired inclusion relation.Proof of Lemma 2. Under the "statistical" variable transformation (t, B) → (ψ/β, 1/β), the MIN-BUDGET LP for (F, c const ) is given by eq. ( 3):max ψ∈[0,1] m ,β∈R ≥0 β s.t. j F ij ψ j + j F nj (1 -ψ j ) ≤ 1 -(c n -c ′ )β ∀i < nApplying the variable transformation r = 1 -(c n -c ′ )β yields the following equivalent LP:min ψ∈[0,1] m ,r∈R ≥0 r s.t. j F ij ψ j + j F nj (1 -ψ j ) ≤ r ∀i < nThis LP is equivalent to the minimax sum-optimal test ψ * R in eq. ( 5), and therefore the optimal solution ψ * is precisely this test. By the same equivalence, the optimal value of the optimization parameter r satisfies r * = R * , where R * is the minimax risk of the testing problem (i.e., the risk of ψ * R ). By construction, the optimal β satisfies β * = 1-r * cn-c ′ = 1-R * cn-c ′ , and therefore the minimal budget isB * = 1 β * = cn-c ′ 1-R * which in the notation of Definition 3 is B * R (c n -c ′ ).Reversing the variable transformation we get t * = ψ * /β * = B * • ψ * , which is equal to the sum-optimal statistical contractB * R (c n -c ′ ) • ψ * R , as required.Proof of Lemma 3. For the min-pay contract design problem, introduce an auxiliary variable β > 0, and define a "statistical" variable transformation t → cn-c ′ β ψ, where ψ ∈ [0, 1] m . The MIN-PAY LP (eq. ( 4)) transforms into:EQUATIONFor any given ψ, the optimal value of β is:β * = min k∈[n-1]   j F nj ψ j - j F kj ψ j   = j F nj ψ j -max k∈[n-1] j F kj ψ j .Therefore, eq. ( 11) is equivalent to:EQUATION)Divide the numerator and the denominator by j F nj ψ j to obtain the transformed objective:j F nj ψ j j F nj ψ j -max k∈[n-1] j F kj ψ j = 1 1 -max k∈[n-1] j F kj ψj j Fnj ψj = 1 1 -max k∈[n-1] ρ k (ψ).And hence eq. ( 12) can be written compactly as:EQUATION)The optimal solution for eq. ( 13) is the minimizer of max k∈[n-1] ρ k (ψ), which is equivalent to the minimax ratio-optimal test ψ * ρ by Definition 2. The optimal expected pay is cn-c ′ 1-ρ * , and the optimal contract is given by:t * = c n -c ′ β * ψ * = c n -c ′ TP(ψ * ρ ) -FP(ψ * ρ ) ψ * ρ . = B * ρ (c n -c ′ ) • ψ * ρ ,where B * ρ (•) is as in Definition 3. We conclude that t * is the ratio-optimal statistical contract, as required.We are now ready to prove our main theorem:Proof of Theorem 1. We prove the first half of the theorem, i.e., that the sum-optimal statistical contract is b-cost-robust and has the lowest budget b/(1 -R * ) among all b-cost-robust contracts. The second half of the theorem follows by swapping Lemma 2 with Lemma 3.We first show that the sum-optimal statistical contract is b-cost-robust, i.e., incentivizes the target action for every cost vector in the ambiguity set C: Define c 0 := (0, . . . , 0, b). By Lemma 2, the minbudget contract for the setting (F, c 0 ) is the sum-optimal statistical contract t * R , i.e., B * R (c n -c ′ ) • ψ * R , where ψ * R is the minimax sum-optimal composite test for distribution sets{F i } i∈[n-1] , {F n }. Its budget is (b -0)/(1 -R * ) = b/(1 -R * ).In particular, t * R incentivizes the target action and so belongs to T (F,c 0 ) . Observe that any increasing cost vector c with c n = b dominates the cost vector c 0 , and therefore by Lemma 1, contract t * R also belongs to T (F,c) for any such cost vector c that dominates c 0 . Furthermore, any cost vector c in the ambiguity set C has a corresponding cost vector c in which all costs are identical except for c n ≤ c n = b. Lowering the target action's cost from c n to c n can only help incentivize it, thus we conclude that t * R ∈ T (F,c) , as required. We now show optimality of the budget: Since t * R is the min-budget contract for the setting (F, c 0 ), and since c 0 is within the ambiguity region C, it holds that any b-cost-robust contract t must satisfy B t ≥ b/(1 -R * ). As t * R satisfies this bound exactly, it has the lowest budget among all b-cost-robust contracts.Proof of Theorem 2. Let c cn-a = (c n -a, . . . , c n -a, c n ) and c cn-b = (c n -b, . . . , c n -b, c n ) be two uniform-cost profiles; for brevity we refer to these as c -a , c -b . Since in contract setting (F, c)EQUATIONthat is, any contract that incentivizes the target action in setting (F, c) will incentivize it also in setting (F, c -a ).Consider the min-budget contracts for settings (F, c -a ), (F, c), (F, c -b ). Denote their budgets byB * (F,c -a ) , B * (F,c) , B * (F,c -b ), respectively. We deduce from Equation ( 14) thatEQUATIONsince the min-budget contract for (F, c) is feasible for (F, c -a ). Now recall that Lemma 2 gives us an expression for the optimal budgets of the two uniform-cost settings. This expression depends on the risk R * of the minimax sum-optimal hypothesis test for {F k } n-1 k=1 , {F n }, which is static across the two settings. It also depends on the difference between the highest and lowest cost in each setting. Thus:EQUATIONCombining Equation (15) and Equation ( 16) we get b a B * (F,c) ≥ B * (F,c -b ) . We conclude that the min-budget contract for setting (F, c -b ) is a b a -min-budget contract for (F, c). By Lemma 2 the min-budget contract is the sum-optimal statistical contract b 1-R * ψ * R , which by Theorem 1 is the b-cost-robust contract with the lowest budget, as required.We now turn to the claim of tightness. Consider the following contract design setting:F 1 = (1, 0) F 2 = (ε, 1 -ε) F 3 = (0, 1)Where costs are increasing c 1 < c 2 < c 3 , and ε is a parameter satisfying:EQUATIONThe target distribution F 3 is only supported on j = 3, and therefore the minimax sum-optimal test for this setting is: ψ * = (0, 1).As F 1 , F 3 do not overlap, the minimax risk is given with respect to F 2 by the Neyman-Pearson Lemma [29] :R = 1 -∥F 2 -F 3 ∥ TV = 1 -ε,and therefore the approximate contract given by Theorem 2 is:t = c n -c 1 1 -R ψ * = 0, c 3 -c 1 ε .As for the optimal contract, it satisfies t * = (0, B * ) because the target distribution is only supported on j = 2, and it has a threshold form due to [31, Lemma 4] . The optimal budget is:B * = max c 3 -c 1 , c 3 -c 2 εWhen ε satisfies Equation (17) , the optimal budget is B * = c3-c2 ε , and therefore:∥t∥ ∞ = c 3 -c 1 ε = c 3 -c 1 c 3 -c 2 • c 3 -c 2 ε =B * = c n -c 1 c n -c n-1 ∥t * ∥ ∞ as required.Remark 1 (Extending the proof of Theorem 2 to cost-robust min-pay contracts). By Lemma 3, the min-pay contracts for the design settings (F, c -a ), (F, c -b ) defined in the proof depend linearly on a, b, respectively, and thus their expected pay is also linear in the bounds. The inclusion argument in eq. ( 14) holds for min-pay contracts as well, and thus an argument analogous to eq. ( 16) can be constructed for the ratio of expected payments. The rest of the proof follows similarly.Proof of Proposition 1. By Theorem 1 and Lemma 2, the b-cost-robust contract with minimum budget is the min-budget contract for setting (F, c const ) where c const = (0, . . . , 0, b). For this setting, plugging variables λ, μ into the dual in eq. ( 6), we get:min λ∈R n-1 ≥0 ,μ∈R m ≥0 j∈[m] μj s.t. i<n (F n,j -F i,j ) λi ≤ μj ∀j ∈ [m] i<n b λi ≥ 1Define the following variable transformation:λ = b λ; µ = bμ.Under this transformation, the dual LP is equivalent to:min λ∈R n-1 ≥0 ,µ∈R m ≥0 j∈[m] µ j s.t. i<n (F n,j -F i,j ) λ i ≤ µ j ∀j ∈ [m] i<n λ i ≥ 1When the contract is implementable, the optimal solution to the primal statistical LP (eq. ( 3)) satisfies β * > 0, corresponding to the last constraint in the dual LP. Therefore, the last constraint of the dual is tight due to complementary slackness:i<n λ i = 1,and the LP is equivalent to:min λ∈∆([n-1]),µ∈R m ≥0 j∈[m] µ j s.t. F n,j - i<n λ i F i,j ≤ µ j ∀j ∈ [m]As µ ≥ 0 we can write:min λ∈∆([n-1]) j∈[m] F n,j - i<n λ i F i,j + ,and by the definition of total variation distance (e.g by [31, Claim 4] ), the optimization objective satisfies:j∈[m] F n,j - i<n λ i F i,j + = F n - i λ i F iApplying the inverse transformation yields:j∈[m] μ * j = 1 b j∈[m] µ * j = min λ∈∆([n-1]) F n -i<n λ i F i TV b .Then, by strong LP duality β * = j μ * j , and the final result is obtain by applying the nonlinear variable transformation B * = 1 β * . This gives the desired expression for the minimum budget B * of a b-cost-robust contract: max λ∈∆([n-1]) b/ F n -i<n λ i F i TV .In this section, we prove that cost-robust min-budget contracts for distributions satisfying the Monotone Likelihood Ratio (MLR) property have a threshold functional form.Proof of Proposition 2. Let (F, c) be a contract design setting with c n -c a ≤ b, such that F satisfies monotone likelihood ratio. By the Karlin-Rubin theorem, the hypothesis test for the composite hypotheses {F k } n-1 k=1 , {F n } minimizing FP + FN is a threshold function, and therefore there exists j 0 ∈ [m] such that ψ * (j) = 1 [j ≥ j 0 ]. By Theorem 1, the optimal contract in this case is of the form t * = Bψ * for some scalar B > 0, and therefore t * is a threshold contract. D.7 Two-outcome settings Proposition 9. Let (F, c) be a two-outcome contract design setting (m = 2). A contract t = (t 0 , t 1 ) with t 1 ≥ t 0 implements the target action if and only if the contract t ′ = (0, t 1 -t 0 ) implements the target action. Proof. For any action i ∈ [n -1], the corresponding (IC) constraint is:EQUATIONAs f i , f n are probability distributions, the following holds for any t 0 :EQUATIONSubtracting eq. ( 19) from eq. ( 18) does not change the (IC) constraint, as both sides of eq. ( 19) are equal. Performing the subtraction and rearranging the terms gives:j∈{0,1} f i,j (t j -t 0 ) -c i ≤ j∈{0,1} f n,j (t j -t 0 ) -c n which is equivalent to: f i,1 (t 1 -t 0 ) -c i ≤ f n,1 (t 1 -t 0 ) -c nand this is the (IC) constraint for the contract t ′ = (0, t 1 -t 0 ). Therefore, the contract t is feasible if and only if the contract t ′ is feasible.Proposition 10. Let (F, c) be a two-outcome contract design setting (m = 2), and let t = (t 0 , t 1 ).Then the contract t ′ = (0, t 1 -t 0 ) has weakly-better expected pay, weakly-better budget requirements, and the same variance as t.Proof. For the min-pay objective, we obtain from linearity of expectation:E j∈fn [t j -t 0 ] ≤ E j∈fn [t j ]and therefore t ′ has weakly-better expected pay. For the min-budget objective, it holds that :max {0, t 1 -t 0 } ≤ max {t 0 , t 1 }and therefore t ′ has weakly-better budget requirement. for the min-variance objective, adding a constant to a random variable does not affect its variance:Var(t) = Var(t ′ )and therefore t ′ has the same variance as t.Proof of Proposition 3. For all i ∈ [n], let F i = Bernoulli(p i ). As m = 2, any contract t is a two-dimensional vector. By proposition 9, proposition 10, it holds that the optimal contract is of the form t * = (0, t * 1 ) for any of the three objectives. To prove that the optimal payment t * 1 is the same for all objectives, observe that all objective functions are monotonically-increasing in t * 1 :max t * = t * 1 (Required budget) E j∼fn [t * ] = f n,1 t * 1 (Expected pay) Var(t * ) = f n,1 (1 -f n,1 ) (t * 1 ) 2 (Variance)Since all the optimization problems are of a single variable with identical (IC) constraints, their optimal solutions are all identical. In [31, Theorem 3] , it is shown that computing a min-budget all-or-nothing contract is NP-hard. We show that the same reduction is applicable for min-budget cost-robust contracts:Proposition 11 (Hardness). Computing a min-budget all-or-nothing contract is NP-hard.Proof. By reduction from 3SAT. Given a 3-CNF formula, we show that there exists a cost-robust contract design problem such that the required budget of an all-or-nothing cost-robust min-budget contract is below a certain threshold if and only if the formula is satisfyiable.First, given a 3-CNF formula, apply the polynomial-time reduction described in [31, Appendix B.5.3] to construct a min-budget contract design problem (F, c). Denote the target action of the design problem by n ∈ [n]. By the construction described in [31, Equation (27) ], it holds that c n = 1 and c i = 0 for all i < n. Thus, the contract design problem tightly satisfies the cost difference upper bound c n -c i ≤ 1. Moreover, since all alternative actions have the same cost c i = 0, the cost vector c it is also the worst-case cost vector in the cost uncertainty set induced by the bound b (by Lemma 1). Therefore, (F, c) is also a cost-robust contract design setting for the bound c n -c i ≤ 1.By the proof of [31, Theorem 3] , there exists a threshold B 0 such that the required budget of an all-or-nothing min-budget contract in the design setting (F, c) is below a certain threshold if and only if the 3-CNF formula is satisfiable.To calculate the costs for each model, we use energy data from the Hugging Face LLM Performance Leaderboard 5 . The energy efficiency for each model is expressed in the leaderboard in units of output tokens per kWH. To convert to actionable costs we assume a rate of .105 $/kWH, aligning with conservative energy costs in the United States and giving us order-of-magnitude approximations of the actual inference costs. The inference costs are presented in units of $/1M tokens. The leaderboard data was taken from the experiments on the A100 GPUs. For each model, we took the GPTQ-4bit+exllama-v2 quantization benchmark. Table 3 shows the energy costs on the leaderboard for Llama2 and CodeLlama. We note that energy data was missing for CodeLlama-70B, so we extrapolated from Llama2-70B-chat.Model verbosity. Calculation of the per-token inference costs are not complete without an analysis of the response length produced by the various models. Table 4 shows the average verbosity (output length) of the 3 Llama models on the single-turn prompts in the MT-bench evaluation set. Since the values are of the same order of magnitude, we simplify and assume that the choice of model does not influence the verbosity, and therefore we do not include this in our cost calculations. Table 5 : Cost-aware vs Cost-robust contracts in the non-monotone setting. The numbers in bold denote the optimal values achieved for the 3 objectives. The percentages denote the relative increase from the optimal that the cost-robustness sacrifices in each setting.Current pricing schemes As described in Section 1, current market pricing schemes for LLM generation involve pay-per-token rates for which the user pays regardless of the response quality.For open-source models such as Llama2, there exist API services to run model inference, such as AWS and Microsoft Azure. In other scenarios, some pricing schemes behave as threshold contracts: an unsatisfied user may request from the API to regenerate a response free of charge, and hence will only pay if the response quality is above some threshold. For this reason threshold contracts can offer a "satisfaction guarantee" while retaining a simple form.Non-Monotone Contracts Table 5 shows the statistics of the various contract objectives in contracts when optimized without a monotonicity constraint, and displays how they match up to each other in cost-aware and cost-robust settings. We observe that the min-pay contract minimizes expected pay at the expense of high budget and variance. The min-budget contract, on the other hand, is not the worst in any of the objectives. Additionally, the cost-robust setting sacrifices only a marginal increase in objective values: a 6.9% increase in the Min-pay objective, an 8.7% increase if optimizing for budget, and 6.5% increase when optimizing for minimum variance.Price of monotonicity It is of interest to analyze the relative difference in resulting contracts that occurs due to removing the monotonicity constraint. Table 6 shows the discrepancy in contract objectives for cost-robust contracts. We can observe that while the monotone contracts as a whole are simpler, more intuitive, and closely resemble threshold contracts, it is not without cost as they suffer a sizeable increase in contract objectives, most notably an increase of 388% when trying to minimize expected pay. For example, the agent can generate responses using a larger model for 95% of requests, and apply the smaller model for the remaining 5%, corresponding to the mixed action σ = (0.05, 0.95).Choosing the first action can be thought of as opting out of the task at cost c1. If c1 = 0 then the agent participates in the contract only if the expected utility is non-negative -a property known as individual rationality.In our context, this means that if action gn is a best response for the agent, then the agent will choose σ(t) that plays gn with probability 1 (see Section 2.2).When ψ(j) is fractional, we consider the output of the test to be 1 with probability ψ(j), and 0 otherwise.https://huggingface.co/spaces/optimum/llm-perf-leaderboard. 
 
 Appendix:  


Decision: The paper takes a contract design approach for LLMs, proposing a pay-for-performance, contract-based framework for incentivizing quality.

The review team (including the AC) agrees that the paper makes a solid theoretical contribution to the literature, by offering an interesting statistical characterization of optimal cost-robust contracts by connecting them to statistical hypothesis tests. This contribution is perhaps of independent interest (thus applicable beyond the LLMs setting). 

On the other hand, the review team pointed out that there is little to no evidence on the misalignment of incentives in quality text generation. More generally, the application of cost-robust contract design to LLMs might seem somewhat superficial / not particularly suitable. Overall, the practical motivation of the problem and its applications can be significantly improved.

Despite these concerns, the review team weighted more positively the theoretical and conceptual contribution of the paper.

Reviews: review: paper_summary: paper_summary: * The paper concerns the problem of incentivizing LLMs to use the most costly model, which is assumed to be the model with the best performance. Without proper incentive, the LLM company has the incentive to charge customers for the highest payment, but deliver the service using a lower-cost model, because the performance of the model is usually not verified. Therefore, the paper proposes to use contract design to solve this problem. In particular, an automatic detector first gives an integer score for the performance of an LLM. Then, the task is to design a payment for the company for each of the integer scores. The goal is to minimize the total payment conditioned on incentivizing the best-performed model. 
* The main contribution is the discussion of the cost-robust contract, meaning how to design the optimal contract while the costs of LLMs are unknown. Empirical evaluations have shown how to use the theory in practical settings given LLM performance data.
strength_weakness: strength_weakness: Although I believe contract design can speak with the production of LLMs, I’m not fully convinced that the proposed model is a good idea to solve the considered problem. 

* In practice, each company pricing its own AIs, so who should be the principal? In other words, the paper assumes there is a trust-worthy third party who can run the quality-detector and commits to a contract with the LLM companies. I’m not sure this is feasible in practice. I hope the authors can explain more carefully the application scenarios of their theory.
* Furthermore, there is no evidence in the paper (and, I guess, on the Internet) that can prove LLM companies are cheating about their service quality. I also don’t think this is very likely because LLM companies have other incentives to provide high-quality services, e.g. their reputation. So, how do we know we are not solving a problem that does not exist?
* Even though we go with the assumption that there is a contract that the company (agent) agrees on, I doubt cost-robustness is the first-order concern. The cost data is usually publicly obtainable from energy reports, as the authors did in their experiments. Even though this data is not public, the energy cost is usually easy to estimate. Therefore, I don’t think incentivizing LLM production is a suitable application for cost-robust contracts.
questions: questions: See weakness
limitations: limitations: Limitations are reasonably stated.
paper_summary: paper_summary: This paper addresses the issue of moral hazard in pay-per-token pricing for large language model (LLM) services. Firms may use cheaper, lower-quality models to cut costs, compromising text quality. Moreover, the firms's costs may be unknown to the clients. To counter this, the authors propose a pay-for-performance framework using cost-robust contracts that incentivize high-quality text generation under the uncertainty about the firms's costs. These contracts are designed based on and have a one-to-one correspondence to optimal composite hypothesis tests. Approximation guarantees are provided with respect to the optimal contracts. Empirical evaluations show that these contracts provide robust incentives with small cost increases.
strength_weakness: strength_weakness: 1. The model's complexity is unnecessary. The problem could actually be studied in the most basic contract setting. 
2. The authors do not discuss the computational complexity of finding the optimal cost-robust contract. 
3. The authors do not discuss the cases where the action with the highest cost may not be the best action to incentivize.
questions: questions: 1. what is the computational complexity of finding the optimal cost-robust contract that incentivizes $c_n$ (equivalently, the complexity of finding the optimal test)?
2. Can the characterization results and computational efficiencies be directly applied to the cases where actions with lower costs may be the best action to incentivize?
limitations: limitations: Yes.
paper_summary: paper_summary: The authors formulate a theoretical setup for a LLM text generation service to incentivize the service to output high quality text the consumer. The authors formulate this setup as having the service having a set of models that has quality (as rated by a evaluator on the end of the consumer) that increases with the cost of running the LLM. The goal is to derive a framework for paying the LLM service based on that quality of the text generated that incentivizes the LLM service to always use its best model. The authors go about this by formulating the definition of a contract in this setting, and defining various metric (max payment, avg. payment, etc.) that consumer aims optimize. They show that the set of contracts that will incentivize the LLM service to output text with the best model can be derived from the set of optimal hypothesis tests that distinguish which model is being used from the evaluator outputs. They derive how the optimal contract can be formulated from these hypothesis tests, when only bounds are known on the costs of running each model for the LLM service.
strength_weakness: strength_weakness: The main issue is the theoretical setup does require an assumption that the bounds on cost are known, which seems somewhat impractical. It might be useful to explicitly comment on how the different metrics degrade with increased looseness of the cost bounds (linearly, it seems like), since one can always pick extremely conservative cost bounds.

Minor issue:

- In Definition 3, it would be helpful to illustrate why $B_R^*$ and $B^*_\rho$ are defined as they are, correctly. Further, the definition with $b \geq c_n$ is a bit strange, since the definition of minmax hypothesis test does not involve worst case over cost vectors, so it doesn't seem correct to use $b$ to derive the minimax contract (and instead it should remain a function of $c_n - c_1$) --- maybe dropping that $b \geq c_n$ case would be more accurate, since it is used in the definition of cost-robust later.
questions: questions: Should the principal know the outcome distribution for each generator? This seems slightly unrealistic since consumers only ever have black box access to the API, and never know precisely which model they're responses are from. They do know that previous agent actions could only be mixed over the old (worse) models though.
limitations: limitations: I think the limitations are sufficiently addressed.

Comments: title: post rebuttal
comment: Thank you so much for the improved assessment! We appreciate your feedback, and will certainly expand on this discussion in the paper to further facilitate the applicability of our model. We are also more than happy to continue the discussion if additional questions arise.
I appreciate the author's rebuttal. Although I'm still not fully convinced by the rebuttal of the second point which concerns the applicability of the theory, I can see some value in the model and theoretical analysis. I'm raising my score to 5.
Thank you for the thoughtful response! We address your remarks below:

> **Do you make any assumption on the outcome distributions related to actions with different costs? Or do you just refer the action with the highest quality to the action with the highest cost? If this is the case, why do your results only rely on incentivizing actions with the highest costs without any assumptions made on the distributions? Could you provide more intuitions and explanations for it?**

This is a great question. Our main theoretical results only assume that the target action is implementable - i.e., that there exists some contract incentivizing it (see, e.g., Appendix B.2). Intuitively, implementability is equivalent to the assumption that the observed quality of the target LLM is different (in distribution) from the observed quality of smaller, cheaper models [1]. One intuition for the fact that no further distributional assumptions are required is the equivalence to optimal composite hypothesis testing (by Theorem 1), which doesn't require further assumptions as well.

We also note that the implementability assumption can be verified in polynomial time given outcome distributions, by checking the feasibility of the corresponding linear programs (i.e. equations (1,3)). Additionally, the assumption was verified to hold in the empirical datasets we analyze. In scenarios where the highest-cost action cannot be implemented by any contract (i.e., when the observed quality of the costly LLM is identical to the quality of cheaper ones), this action can be ignored, and the next highest-cost action effectively becomes the highest-cost one and can be targeted instead. We will further emphasize these points in the paper.

Further extending on this remark, we also note that another common theme in the literature is providing stronger guarantees on the resulting contracts by making stronger assumptions about the structure of outcome distributions (see, e.g., [1,2]). Connecting to this theme, in Proposition 2 we show that the MLR structural assumption (Monotone Likelihood Ratio, Def. 5) implies a threshold functional form for the optimal cost-robust contracts. However, from the empirical perspective, it is also worth noting that the outcome distributions we observe in our empirical study don’t seem to satisfy the theoretical assumptions currently available in the literature (for example, see Figure 2 middle right, which shows the non-trivial outcome distributions of the MT-Bench dataset). In this context, we hope that our empirical observations will motivate future theoretical research with refined structural assumptions. We will emphasize this point in the paper as well.

> **By saying basic contract problem, I mean that the problem can be studied in the basic contract setting without the modeling of LLM and Text Generation. The problem is actually a robust contract design setting where the action costs are uncertain, and LLM is just an application. Using the language of contract design with moral hazard would significantly simplify the notations.**

Thanks for the clarification, this is also a very good point. The cost-robustness model and our theoretical results indeed apply more broadly, and extend beyond the context of LLMs and text generation - We view it as one of the paper’s main strengths. Through the use of "application specific" language (i.e. focusing on LLMs), our hope is to promote discussion between different scientific communities, which will eventually increase the applicability of contracts in this setting. The LLM market is nascent and evolving - for example, more players are joining, and different pricing (contract) schemes are emerging. The current naïve pricing schemes, which do not yet tie payments to performance, are likely to be reshaped and improved. Experience from the sponsored search market shows that economic theory informs better pricing [3], and we expect that through contractual payments this will be the case for LLM pricing too. In any case, we will also update the paper to further clarify the significance of our results to general contract design theory.

> **One minor: It seems that the references are not updated. the reference of Saig et al'23 is still the Arxiv one.**

Thank you for this remark! We will gladly fix this.

–

Please let us know if our response has addressed your questions regarding distributional assumptions, and the relation to general contract design theory. Also, if the discussion so far increases the favorability of your assessment, we would greatly appreciate it if you would consider increasing your score. In any case, your remarks are very helpful, and we are more than happy to discuss any additional questions or thoughts that come up.

References:
* [1] Dutting et al., Simple vs Optimal Contracts, EC 2019.
* [2] Saig et al., Delegated Classification, NeurIPS 2023.
* [3] Ostrovsky and Schwarz, Reserve Prices in Internet Advertising Auctions: A Field Experiment, JPE 2023.
Thanks for the responses. The computational efficiency is indeed helpful. Here are my further responses and questions:

1. Just to clarify. Do you make any assumption on the outcome distributions related to actions with different costs? Or do you just refer the action with the highest quality to the action with the highest cost? If this is the case, why do your results only rely on incentivizing actions with the highest costs without any assumptions made on the distributions? Could you provide more intuitions and explanations for it?
2. By saying basic contract problem, I mean that the problem can be studied in the basic contract setting without the modeling of LLM and Text Generation. The problem is actually a robust contract design setting where the action costs are uncertain, and LLM is just an application. Using the language of contract design with moral hazard would significantly simplify the notations. 

One minor:
1. It seems that the references are not updated. the reference of Saig et al'23 is still the Arxiv one.