SVIP: Towards Verifiable Inference of Open-source Large Language Models

## Abstract

Abstract Open-source Large Language Models (LLMs) have recently demonstrated remarkable capabilities in natural language understanding and generation, leading to widespread adoption across various domains. However, their increasing model sizes render local deployment impractical for individual users, pushing many to rely on computing service providers for inference through a blackbox API. This reliance introduces a new risk: a computing provider may stealthily substitute the requested LLM with a smaller, less capable model without consent from users, thereby delivering inferior outputs while benefiting from cost savings. In this paper, we formalize the problem of verifiable inference for LLMs. Existing verifiable computing solutions based on cryptographic or game-theoretic techniques are either computationally uneconomical or rest on strong assumptions. We introduce SVIP , a secret-based verifiable LLM inference protocol that leverages intermediate outputs from LLM as unique model identifiers. By training a proxy task on these outputs and requiring the computing provider to return both the generated text and the processed intermediate outputs, users can reliably verify whether the computing provider is acting honestly. In addition, the integration of a secret mechanism further enhances the security of our protocol. We thoroughly analyze our protocol under multiple strong and adaptive adversarial scenarios. Our extensive experiments demonstrate that SVIP is accurate, generalizable, computationally efficient, and resistant to various attacks. Notably, SVIP achieves false negative rates below 5 % percent 5 5\% 5 % and false positive rates below 3 % percent 3 3\% 3 % , while requiring less than 0.01 0.01 0.01 0.01 seconds per query for verification.

## 1 Introduction

In recent years, Large Language Models (LLMs) have achieved unprecedented success across a broad array of tasks and domains (Achiam et al., ; Dubey et al., ; Yang et al., ). Alongside this progress, open-source LLMs have proliferated, offering increasingly sophisticated and capable models to the broader research community (Touvron et al., ; Black et al., ; Le Scao et al., ; Jiang et al., ; Almazrouei et al., ; Zhang et al., ). Many of these open-source LLMs now rival, or even surpass, their closed-source counterparts in performance (Chiang et al., ; Almazrouei et al., ; Dubey et al., ), while remaining freely accessible. However, as model capacity grows, it typically comes with a corresponding increase in the number of model parameters, which directly drives up the computational demands, particularly in terms of memory and processing power (Kukreja et al., ). For example, the Llama-3.1-70B model
requires $140$ GB of GPU memory for inference under FP16 (Hugging Face, ). These escalating computational costs have made local deployment increasingly impractical, pushing many users to turn to computing service providers for inference.

To ease the deployment of LLM inference, computing providers may provide API-only access to users, hiding implementation details. A new risk arises in this setting: *how to ensure that the outputs from a computing provider are indeed generated by the requested LLM*? For instance, a user might request the Llama-3.1-70B model for complex tasks, but a dishonest computing provider could substitute the smaller Llama-2-7B model for cost savings, while still charging for the larger model. The smaller model demands significantly less memory and processing power, giving the computing provider a strong incentive to cheat.
Restricted by the black-box API access, it is difficult for the user to detect model substitution. Particularly, future computing service may be provided by decentralized individuals (Uriarte & DeNicola, ) who sell their computation power at a competitive price, but the computation outputs may not be trustworthy. This highlights the need for verifiable inference, a mechanism designed to ensure that the model specified by the user is the one actually used during inference. Implementing verifiable inference for LLMs is essential not only for safeguarding users’ interests but also for fostering trust in the open-source LLM ecosystem, driving low-cost and wider adoption and continued development of more advanced LLMs.

Figure: Figure 1: The problem setting of verifiable inference for LLMs. (a) A user requests the computing provider (referred to as provider in the figure) to run inference on their prompt using the Llama-3.1-70B model. Without verification, they have no way to confirm if the specified model is used. (b) Our proposed protocol solves this by requiring the provider to return processed intermediate outputs from the LLM, enabling the user to verify through a verification function whether the correct model was used for inference. Specifically, the intermediate outputs are compressed to reduce the computational overhead.
Refer to caption: extracted/5904422/pics/protocol_explain_2.png

An effective verifiable inference solution for LLMs must accurately confirm that the specified model is being used during inference, while maintaining computational efficiency. Simple solutions, such as probing the model with established benchmark datasets, may be easily detected and bypassed. On the other hand, cryptographic verifiable computing methods, which rely on generating mathematical proofs (Yu et al., ; Setty et al., ) or secure computation techniques (Gennaro et al., ; Laud & Pankova, ), are often too computationally expensive for real-time LLM inference.
For instance, zkLLM, a recent Zero Knowledge Proof-based technique, requires over $803$ seconds for a single prompt query (Sun et al., ).
Game-theoretic protocols such as Zhang et al. () involve the interaction of multiple computing providers with carefully designed penalties and rewards, assuming all providers are rational, flawless, and non-cooperative, which might be unrealistic in practice. Meanwhile, watermarking and fingerprinting techniques (Kirchenbauer et al., ; Xu et al., ) are mostly implemented by model publishers, making them unsuitable for verifiable inference, where the verification primarily occurs between the user and the computing provider.

In this paper, we propose SVIP, a Secret-based Verifiable LLM Inference Protocol using intermediate outputs. The core idea of our method is to require the computing provider to return not only the generated text but also the processed intermediate outputs (hidden state representations) from the LLM. We carefully design and train a proxy task exclusively on the hidden representations produced by the specified model, effectively transforming these representations into a distinct identifier for that model. During deployment, users can verify whether the processed hidden states returned by the computing provider come from the specified model by assessing their performance on the proxy task. If the returned outputs perform well on this task, it provides strong evidence that the correct model was used for inference. We further strengthen the security of our protocol with a secret-based mechanism, making it difficult for a malicious computing provider to fake or bypass the verification process. We also conduct a thorough security analysis, addressing potential attacks such as direct vector optimization attack, adapter attack, and secret recovery attack. Our key contributions are:

- •
We take the first step toward systematically formalizing the problem of verifiable LLM inference and propose an innovative protocol that leverages processed intermediate outputs. Notably, our protocol does not require retraining or fine-tuning the LLM. The security of our protocol is further enhanced by a novel secret-based mechanism.
- •
Our comprehensive experiments with $5$ specified open-source LLMs (ranging from $13$B to $70$B) demonstrate the effectiveness of SVIP: it achieves an average false negative rate of $3.49\%$, while maintaining the false positive rate below $3\%$ across $6$ smaller alternative models. SVIP introduces negligible overhead (less than $0.01$ seconds per query) for both the user and the computing provider.
- •
We provide a thorough discussion and analysis of various strong and adaptive attack scenarios in verifiable LLM inference. Our results show that SVIP can effectively and securely handle approximately $80$ to $120$ million prompt queries in total after a single round of protocol training, with the update mechanism further bolstering security.

## 2 Problem Statement

We begin by formalizing the verifiable inference problem in the context of LLMs. We consider three parties: the user, the computing provider, and a trusted third party. The user intends to use a specified LLM, $\mathcal{M}_{spec}$, to perform inference on a prompt $x\in\mathcal{V}^{*}$, where $\mathcal{V}^{*}$ represents the set of all possible string sequences for a vocabulary set $\mathcal{V}$. Lacking sufficient computational resources to run $\mathcal{M}_{spec}$ locally, the user relies on the computing provider to execute the model and accordingly pays for the service. Ideally, the computing provider would run $\mathcal{M}_{spec}$ as requested and return the completion. However, a dishonest provider might stealthily substitute an alternative LLM, $\mathcal{M}_{alt}$, which could be significantly smaller than $\mathcal{M}_{spec}$ in terms of model size, and return an inferior result.

The goal of a trusted third party, is to design and implement a verification protocol that verifies whether the computing provider uses $\mathcal{M}_{spec}$ for inference.
Based on this protocol, the user can determine with high confidence whether the computing provider used $\mathcal{M}_{spec}$ (True) or not (False) for any query $x$. A satisfactory protocol should meet the following criteria:

- 1.
Low False Negative Rate (FNR): The protocol should minimize instances where the computing provider did use $\mathcal{M}_{spec}$ but is wrongly flagged as not using it.
- 2.
Low False Positive Rate (FPR): The protocol should minimize cases where it incorrectly confirms that the computing provider used $\mathcal{M}_{spec}$ when, in fact, it used an alternative model, $\mathcal{M}_{alt}$.
- 3.
Efficiency: The verification protocol should be computationally efficient and introduce minimal overhead for both the computing provider and the user.
- 4.
Preservation of Completion Quality: The protocol should not compromise the quality of the prompt completion returned by the computing provider.

## 3 Related work

##### Verifiable Computing

Verifiable Computing (VC) allows users to verify that an untrusted computing provider has executed computations correctly, without having to perform the computation themselves (Walfish & Blumberg, ; Yu et al., ; Costello et al., ; Kosba et al., ). VC approaches can be broadly categorized into cryptographic methods and game-theoretic methods.

Cryptographic VC techniques either require the provider to return a mathematical proof that confirms the correctness of the results (Ghodsi et al., ; Setty et al., ; Parno et al., ), or rely on secure computation techniques (Gennaro et al., ; Madi et al., ; Laud & Pankova, ). These techniques cryptographically guarantee correctness and have been applied to machine learning models and shallow neural networks (Niu et al., ; Zhao et al., ; Hu et al., ; Lee et al., ; Ghodsi et al., ; Lee et al., ). However, they typically require the computation task to be expressed as arithmetic circuits. Representing open-source LLMs in circuit form is particularly challenging due to their complex architectures and intricate operations. Moreover, the sheer size of these models, with billions of parameters, introduces substantial computational overhead. A recent work, zkLLM (Sun et al., ), attempts to verify LLM inference using Zero Knowledge Proofs. For the Llama-2-13B (Touvron et al., ) model, generating a proof for a single prompt takes $803$ seconds, and repeating this process for large batches of prompt queries becomes computationally prohibitive.

In contrast, game-theoretic VC techniques ensure the correctness of outsourced computations by leveraging economic incentives to enforce honest behavior (Nabi et al., ; Liu & Zhang, ). For instance, a sampling-based verification mechanism Proof of Sampling (Zhang et al., ) requires multiple computing service providers to independently compute and compare results, ensuring integrity through penalties and rewards. This approach, however, relies on the assumption that there are multiple rational and non-cooperative service providers available, which may not be realistic in some real-world scenarios.

##### LLM Watermarking and Fingerprinting

LLM watermarking involves embedding algorithmically detectable signals into the text generated by LLMs, with the goal of identifying AI-generated texts
(Kirchenbauer et al., ; Hu et al., ; Christ et al., ; Gu et al., ).
Meanwhile, LLM fingerprinting implants specific backdoor triggers into LLMs, causing the model to generate particular text whenever a confidential private key is used (Xu et al., ). Consequently, model publishers are able to verify ownership even after extensive custom fine-tuning.

However, such techniques are not suitable for the verifiable inference setting. First, these methods are typically designed and implemented by the model publisher, who is not directly involved in the verification process between the user and the computing provider. Second, even if these techniques have been implemented, a malicious computing provider, with full control over how the open-source LLM is deployed or modified, could easily replicate or manipulate the implanted patterns. Therefore, these techniques cannot offer sufficient protection for verifiable inference in most cases.

## 4 Methodology

Figure: (a) Simple Protocol
Refer to caption: extracted/5904422/pics/method_no_secret.png

##### Motivation

Despite the fact that larger language models typically offer superior text generation quality (Kaplan et al., ), it is often challenging to verify whether a computing provider is using $\mathcal{M}_{spec}$ for inference based solely on the returned completion text. Our framework addresses this by requiring the computing provider to return not only the generated text but also the processed intermediate outputs (hidden state representations) from the LLM inference process.

We design and train a proxy task specifically to perform well only on the hidden representations generated by $\mathcal{M}_{spec}$ during the protocol’s training stage. The intuition behind is that the proxy task transforms the hidden representations into a unique identifier for the model. During deployment, the user can evaluate the performance of the returned intermediate outputs on the proxy task. Strong performance on the proxy task indicates that the correct model was used for inference, while poor performance suggests otherwise.

Our approach does not depend on expensive cryptographic proofs or protocols, and is highly efficient. Furthermore, it does not involve retraining or fine-tuning the LLMs, operates independently of the model publisher, and can be applied to any LLM with publicly available weight parameters, making it widely
applicable. Next, we formalize and illustrate our proposed framework in detail.

### 4.1 A Simple Protocol Based on Intermediate Outputs

##### Protocol Overview

We denote the prompt input as $x\in\mathcal{V}^{*}$. For any LLM $\mathcal{M}$, let $h_{\mathcal{M}}(x)\in\mathbb{R}^{L\times d_{\mathcal{M}}}$ represent the last-layer hidden representations of $x$ produced by $\mathcal{M}$, where $L$ is the length of the tokenized input $x$, and $d_{\mathcal{M}}$ denotes the hidden dimension of $\mathcal{M}$. The computing provider receives $x$ from the user, runs $\mathcal{M}$, and returns $h_{\mathcal{M}}(x)$ to user for subsequent verification. However, to reduce the size of the intermediate outputs returned, we additionally apply a proxy task feature extractor network $g_{\theta}(\cdot):\mathbb{R}^{L\times d_{\mathcal{M}}}\rightarrow\mathbb{R}^{d
_{g}}$ parameterized by $\theta$, where $d_{g}$ represents the proxy task feature dimension. The computing provider now also runs $g_{\theta}(\cdot)$ and returns a compressed vector
$z(x):=g_{\theta}(h_{\mathcal{M}}(x))$
of dimension $d_{g}$ to the user, significantly reducing the communication overhead. Specifically, for each prompt query, the compressed vector only takes approximately $4$ KB when $d_{g}$ is set to $1024$.

The user is required to perform two tasks locally: obtaining the predicted proxy task output and the label. First, the user runs $f_{\phi}(\cdot)$, using the returned proxy task feature $z(x)$ as input to compute $f_{\phi}(z(x))$. Here, $f_{\phi}(\cdot):\mathbb{R}^{d_{g}}\rightarrow\mathcal{Y}$ is the proxy task head parameterized by $\phi$, where $\mathcal{Y}$ denotes the label space. Second, the user applies a labeling function for the proxy task. We adopt a self-labeling function $y(x):\mathcal{V}^{*}\rightarrow\mathcal{Y}$, which derives the label directly from the input, eliminating the need for external labels or specialized annotators(^1^11For instance, we can define $y(x)$ as the Set-of-Words (SoW) representation of the input $x$, which captures the presence of each word in a fixed vocabulary, regardless of frequency. As a concrete example, if $\mathcal{V}=\{a,b,c,d\}$ and $x=``abcc"$, the SoW label $y(x)$ would be a four-dimensional vector $(1,1,1,0)$, indicating whether each token in $\mathcal{V}$ appears in $x$.). Note that the label can either be a scalar or a vector.

Finally, the user checks whether $f_{\phi}(z(x))$ matches $y(x)$. Our training process below ensures that, with high probability, $f_{\phi}(z(x))=y(x)$ when $\mathcal{M}_{spec}$ is used for inference, and that this does not hold for other models, as the proxy task is exclusively trained on the hidden representation distribution induced by $\mathcal{M}_{spec}$. This completes our protocol. Refer to Figure 2(a) for a detailed illustration.

##### Proxy Task Training

A trusted third party is responsible for implementing the protocol. With a properly defined loss function $\ell:\mathcal{Y}\times\mathcal{Y}\rightarrow\mathbb{R}$ and a training dataset $\mathcal{D}$, the trusted third party trains the proxy task according to the following training objective:

$$ $\displaystyle\phi^{*},\theta^{*}=\arg\min_{\phi,\theta}\mathbb{E}_{x\sim \mathcal{D}}\left[\ell\left(f_{\phi}(g_{\theta}(h_{\mathcal{M}_{spec}}(x))),y( x)\right)\right].$ (1) $$

##### Protocol Deployment

With the optimized $\phi^{*}$ and $\theta^{*}$, we define the verification function as
$V(x,z(x);\phi^{*},\theta^{*})=\mathds{1}\left(f_{\phi^{*}}(z(x))=y(x)\right)$, where $z(x)=g_{\theta^{*}}(h_{\mathcal{M}}(x))$ is returned by the computing provider. If the value of the verification function is $1$ (or 0 0), we conclude that the computing provider is indeed (or is not) using $\mathcal{M}_{spec}$ for inference with high probability. Now, the low FNR and low FPR criteria introduced in Section 2 can be formally expressed as follows:

$$ $\displaystyle\begin{split}\quad&\textbf{Low FNR}:\mathbb{P}\left(V(x,z(x);\phi ^{*},\theta^{*})=0|\mathcal{M}_{spec}~{}\text{is used for inference}\right) \leq\alpha;\\ \quad&\textbf{Low FPR}:\mathbb{P}\left(V(x,z(x);\phi^{*},\theta^{*})=1| \mathcal{M}_{spec}~{}\text{is {not} used for inference}\right)\leq\beta.\end{split}$ (2) $$

While a single prompt query may occasionally yield an incorrect verification result due to FNR or FPR, in practice, users can perform the verification over a batch of queries and apply a hypothesis testing to reach a conclusion with high confidence. Refer to Appendix A.3 for a detailed discussion.

### 4.2 SVIP : A Secret-based Protocol for Verifiable LLM Inference

##### From Simple Protocol to Secret-based Protocol

The simple protocol, despite its strong potential in discriminating whether the specified model is actually used, is vulnerable to malicious attacks from the computing provider. A dishonest provider may attempt to bypass the verification process without running $\mathcal{M}_{spec}$. Since all the provider needs to return is a vector of dimension $d_{g}$, an attacker could adversarially optimize a vector $\tilde{z}\in\mathbb{R}^{d_{g}}$ directly, without actually running $g_{\theta^{*}}(\cdot)$ and using any LLM. We refer to this as a direct vector optimization attack. Specifically, if the self-labeling function is public, the adversary can run the labeling function $y(x)$ themselves for each input $x$ and then directly find $\tilde{z}$ so that

$$ $\displaystyle\tilde{z}^{*}=\arg\min_{\tilde{z}}\ell\left(f_{\phi^{*}}(\tilde{z }),y(x)\right).$ (3) $$

Ultimately, $\tilde{z}^{*}$ is returned to the user to deceive the verification protocol. As shown in our case study in Appendix D.7, this attack achieved an attack success rate (ASR) of $99.90\%$, indicating that the security of the protocol requires further enforcement.

To strengthen the protocol’s security, we introduce a “secret” mechanism. A complete illustration is provided in Figure 2(b). Particularly, the trusted third party assigns a “secret” $s\in\mathcal{S}$ exclusively to the user, which is never shared with the computing provider. Here, $\mathcal{S}$ represents the secret space. Next, we explain how the secret is incorporated into both the self-labeling function and the proxy task.

##### Introducing Secret into the Self-labeling Function

The self-labeling function with secret is now defined as $y(x,s):\mathcal{V}^{*}\times\mathcal{S}\rightarrow\mathcal{Y}$. The property below is essential for an ideal self-labeling function.

###### Property 1 (Secret Distinguishability)

For the same input $x$, given two different secrets $s^{\prime}\neq s$, the resulting labels should be different with high probability:

$$ $\displaystyle\mathbb{P}(y(x,s)\neq y(x,s^{\prime}))\geq\delta.$ (4) $$

If $\mathcal{Y}$ is a continuous space, with a pre-defined threshold, this property is equivalent to:

$$ $\displaystyle\mathbb{P}(\|y(x,s)-y(x,s^{\prime})\|_{2}\geq\text{threshold}) \geq\delta.$ (5) $$

Property 1 ensures that a malicious computing provider, without access to the specific $s$, cannot determine or naively guess the true label, thus rendering the direct vector optimization attack discussed earlier ineffective. Meanwhile, the user, with knowledge of $s$, can still compute the correct label.

A simple rule-based self-labeling function (e.g., the SoW representation) cannot ensure that Property 1 holds. To enforce this property, we introduce a trainable labeling network $y_{\gamma}(x,s):\mathcal{V}^{*}\times\mathcal{S}\rightarrow\mathcal{R}^{d_{y}}$ parameterized by $\gamma$, which takes $x\in\mathcal{V}^{*}$ and $s\in\mathcal{S}$ as input and outputs a continuous label vector of dimension $d_{y}$. This network is trained with the following contrastive loss:

$$ $\displaystyle\gamma^{*}=\arg\min_{\gamma}-\mathbb{E}_{x\sim\mathcal{D},s,s^{ \prime}\sim\mathcal{S}}\left[\|y_{\gamma}(x,s)-y_{\gamma}(x,s^{\prime})\|_{2} \right].$ (6) $$

###### Property 1 (Secret Distinguishability)

##### Introducing Secret into the Proxy Task

Once the labeling network is optimized, we also need to include the secret $s$ into the proxy task. Inspired by prefix tuning (Li & Liang, ), our design is to embed $s$ as a task token using a secret embedding network (e.g., an MLP), denoted as $t_{\psi}(s):\mathcal{S}\rightarrow\mathbb{R}^{d_{\mathcal{M}}}$, parameterized by $\psi$. Note that this secret embedding network $t_{\psi}(s)$ is only kept to the trusted third party. Then, the trusted third party distributes $t_{\psi}(s)$ to the computing provider, who concatenates $t_{\psi}(s)$ with $h_{\mathcal{M}}(x)$,
runs $g_{{\theta}}(\cdot)$, and returns $z(x)=g_{{\theta}}(t_{\psi}(s)\oplus h_{\mathcal{M}}(x))$, where $\oplus$ denotes concatenation.

The training objective is now modified by incorporating randomly sampled secrets during training:

$$ $\displaystyle\phi^{*},\theta^{*},\psi^{*}=\arg\min_{\phi,\theta,\psi}\mathbb{E }_{x\sim\mathcal{D},s\sim\mathcal{S}}\left[\ell\left(f_{\phi}(g_{\theta}( \underline{\underline{t_{\psi}(s)}}\oplus h_{\mathcal{M}_{spec}}(x))),y_{ \gamma^{*}}(x,\underline{\underline{s}})\right)\right].$ (7) $$

As before, the user receives $z(x)$ from the computing provider. However, now that $\mathcal{Y}$ is a continuous space, a threshold $\eta$ is required to determine whether the predicted proxy task output $f_{\phi^{*}}(z(x))$ matches the label vector $y_{\gamma^{*}}(x,s)$. Specifically, $f_{\phi^{*}}(z(x))$ is considered a match to $y_{\gamma^{*}}(x,s)$ if the $L_{2}$ distance between them is below the pre-defined threshold $\eta$, indicating $\mathcal{M}_{spec}$ was actually used:

$$ $\displaystyle V(x,z(x);\phi^{*},\theta^{*},\psi^{*})=\mathds{1}\left(\|f_{\phi ^{*}}(z(x))-y_{\gamma^{*}}(x,s)\|_{2}\leq\eta\right).$ (8) $$

In practice, we propose setting the threshold based on the conditional empirical distribution of $d(x,s):=\|f_{\phi^{*}}(z(x))-y_{\gamma^{*}}(x,s)\|_{2}$, given that $\mathcal{M}_{spec}$ is used for inference. We select the upper 95th percentile to ensure a FNR of $5\%$.

### 4.3 Security Analysis

As previously discussed, the direct vector optimization attack described in Eq. (3) is no longer feasible due to the introduction of the secret mechanism. In this section, we discuss other potential attacks as a comprehensive security analysis towards our secret-based protocol. A more detailed discussion of other possible attacks is provided in Appendix C.

##### Adapter Attack Under Single Secret

A malicious attacker could attempt an adapter attack if they collect enough prompt samples $\mathcal{D}^{\prime}=\{x_{i}\}^{M}_{i=1}$ under a single secret $s$. The returned vector from an honest computing provider should be $z(x)=g_{{\theta}^{*}}(t_{\psi^{*}}(s)\oplus h_{\mathcal{M}_{spec}}(x))$. The attacker’s goal is to train an adapter that mimics the returned vector, but by using an alternative LLM, $\mathcal{M}_{alt}$.

To this end, we define the adapter $a_{\lambda}(\cdot):\mathbb{R}^{d_{\mathcal{M}_{alt}}}\rightarrow\mathbb{R}^{d_
{\mathcal{M}_{spec}}}$, parameterized by $\lambda$, which transforms the hidden states of $\mathcal{M}_{alt}$ to approximate those of $\mathcal{M}_{spec}$. The returned vector is then
$g_{{\theta}^{*}}(t_{\psi^{*}}(s)\oplus a_{\lambda}(h_{\mathcal{M}_{alt}}(x)))$. The attacker’s objective is to minimize the $L_{2}$ distance between the returned vector generated by $\mathcal{M}_{spec}$ and the vector produced by $\mathcal{M}_{alt}$ with the adapter. This can be expressed as:

$$ $\displaystyle\lambda^{*}=\arg\min_{\lambda}\mathbb{E}_{x\sim\mathcal{D}^{ \prime}}\|g_{{\theta}^{*}}(t_{\psi^{*}}(s)\oplus h_{\mathcal{M}_{spec}}(x))-g_ {{\theta}^{*}}(t_{\psi^{*}}(s)\oplus a_{\lambda}(h_{\mathcal{M}_{alt}}(x)))\|_ {2}.$ (9) $$

By minimizing this objective, the attacker seeks to make the output of $\mathcal{M}_{alt}$ with the adapter indistinguishable from that of $\mathcal{M}_{spec}$, effectively bypassing the protocol. Once the adapter is well-trained, as long as the secret $s$ remains unchanged, the attacker can rely solely on $\mathcal{M}_{alt}$ in future verification queries without being detected.

##### Secret Recovery Attack Under Multiple Secrets

The secret mechanism is enforced by distributing the secret $s$ to the user, while only providing the secret embedding $t_{\psi^{*}}(s)$ to the computing provider. However, a sophisticated computing provider may attempt to recover the original secret by posing as a user and collecting multiple secrets and corresponding embeddings.
A straightforward approach would involve recovering $s$ from $t_{\psi^{*}}(s)$, thereby undermining the secret mechanism.

Suppose the attacker has curated a dataset of secret-embedding pairs, $D_{\text{secret}}=\{s_{j},t_{\psi^{*}}(s_{j})\}^{N}_{j=1}$. The attacker could then train an inverse model $i_{\rho}:\mathbb{R}^{d_{\mathcal{M}}}\rightarrow\mathcal{S}$, parameterized by $\rho$, to map the secret embedding back to the secret space. If $\mathcal{S}$ is continuous, the training objective can be formalized as:

$$ $\displaystyle\rho^{*}=\arg\min_{\rho}\mathbb{E}_{s\sim\mathcal{D}_{\text{ secret}}}\|i_{\rho}(t_{\psi^{*}}(s))-s\|_{2}.$ (10) $$

Once the inverse model is optimized, the true label $y(x,s)$ again becomes accessible to the malicious computing provider. Consequently, the secret-based protocol effectively collapses to the simple protocol without secret protection, leaving it vulnerable to the direct vector optimization attack.

##### Defense: The Update Mechanism

To defend against the attacks discussed above, we propose an update mechanism for our secret-based protocol: (1) In defense of the adapter attack, once the prompt queries for a given secret reach a pre-defined threshold $M^{*}$, the next secret is activated. Meanwhile, we enforce a limit on how often the next secret can be activated, preventing attackers from acquiring too many secrets within a short period. (2) When a total of $N^{*}$ secrets have been used, the entire protocol should be retrained by the trusted third party(^2^22Specifically, this retraining can be performed using a different random seed and training recipe. As shown in Section 5.3, the retraining process is efficient.). In practice, the values of $M^{*}$ and $N^{*}$ can be determined empirically, as discussed in Section 5.4.

## 5 Experiments

In this section, we evaluate our proposed protocol SVIP through comprehensive experiments to address the following research questions: (1) How accurate is SVIP in verifying whether the specified model is used? (Section 5.2) (2) What are the computational costs associated with SVIP? (Section 5.3) (3) How robust is SVIP against various adaptive attacks? (Section 5.4)

Figure: Figure 3: Empirical distribution of the $L_{2}$ distance between the predicted proxy task output $f_{\phi^{*}}(z(x))$ and the label vector $y_{\gamma^{*}}(x,s)$ on the test dataset of LMSYS-Chat-1M. Each figure corresponds to a different specified model. The distributions compare the $L_{2}$ distances when the specified model is used versus various alternative models. The clear separation between the distributions, marked by the vertical threshold line, ensures the high accuracy of our protocol in distinguishing between correct and incorrect model usage.
Refer to caption: extracted/5904422/pics/distribution_5.png

### 5.1 Experimental Setup

##### Datasets and Models

To simulate realistic LLM usage scenarios, we use the LMSYS-Chat-1M conversational dataset (Zheng et al., ), which consists of one million real-world conversations. We filter the dataset to keep only English conversations and extract the user prompts for each conversation. For the models,
we select $5$ widely-used LLMs as the specified models, ranging in size from $13$B to $70$B parameters and spanning multiple model families. As alternative models, we use $6$ smaller LLMs, each with parameters up to $7$B. Refer to Appendix D.1 for further details.

##### Protocol Training Details

The labeling network $y_{\gamma}(\cdot)$
uses a pretrained sentence transformer (Reimers, ) to embed the text input $x$ and an MLP to embed the secret $s$, where $s\in\{0,1\}^{d_{s}}$ and $d_{s}$ is set to $48$. The outputs of both embeddings are concatenated and passed through another MLP to produce a continuous label vector of $128$ dimensions.
The proxy task feature extractor $g_{\theta}(\cdot)$ is a $4$-layer transformer, while both the proxy task head $f_{\phi}(\cdot)$ and the task embedding network $t_{\psi}(\cdot)$ are implemented as MLPs. Full training details can be found in Appendix D.2.

### 5.2 Results of Protocol Accuracy

We evaluate the accuracy of our protocol by examining the empirical estimate of FNR and FPR, as outlined in Eq. (16). To apply the verification function in Eq. (8), we first determine the threshold $\eta$ on a validation dataset during proxy task training. We then evaluate the empirical FNR and FPR on a held-out test dataset with $10,000$ samples. For each test prompt, we pair it with $30$ randomly sampled secrets to ensure a reliable evaluation result. For FPR calculations, we simulate scenarios where the computing provider uses an alternative, smaller LLM to produce the hidden representations, and applies $g_{\theta^{*}}(\cdot)$ on those outputs(^3^33If the hidden dimension of the alternative LLM, $d_{\mathcal{M}_{alt}}$, differs from that of the specified model, $d_{\mathcal{M}_{spec}}$, we apply a random projection matrix $W\in\mathbb{R}^{d_{\mathcal{M}_{alt}}\times d_{\mathcal{M}_{spec}}}$ to align the dimensions, where each element of $W$ is sampled from a standard normal distribution.). Additionally, we implement a Random baseline where the computing provider generates random hidden representations directly without using any LLM.

As shown in Table 1, SVIP consistently achieves low FNR and FPR across all specified LLMs, demonstrating its effectiveness in verifying whether the correct model is used. The FNR remains below $5\%$, indicating that our protocol rarely falsely accuses an honest computing provider. Moreover, when faced with a dishonest provider, the FPR stays under $3\%$ regardless of the alternative model employed, highlighting the protocol’s strong performance in detecting fraudulent behavior. Figure 3 shows the empirical test distribution of $d(x,s)$, the $L_{2}$ distance between the predicted proxy task output and the label vector, under different model usage scenarios. The clear separation in the distributions provides strong evidence for the high accuracy of SVIP: when the specified model is actually used, $d(x,s)$ is significantly smaller compared to when an alternative model is used.

**Table 1: FNR and FPR across different specified models on the test dataset of LMSYS-Chat-1M. Our protocol keeps FNR under $5\%$ and FPR under $3\%$ across all scenarios.**
| Specified Model | FNR $\downarrow$ | FPR $\downarrow$ |  |  |  |  |  |  |
| --- | --- | --- | --- | --- | --- | --- | --- | --- |
| Random | GPT2-XL | GPT-NEO-2.7B | GPT-J-6B | OPT-6.7B | Vicuna-7B | Llama-2-7B |  |  |
| Llama-2-13B | 4.41% | 1.97% | 1.90% | 1.77% | 1.75% | 2.03% | 2.44% | 2.04% |
| GPT-NeoX-20B | 3.47% | 0.00% | 0.00% | 0.00% | 0.00% | 0.00% | 0.00% | 0.00% |
| OPT-30B | 3.42% | 0.05% | 0.33% | 0.61% | 0.47% | 0.83% | 0.34% | 0.35% |
| Falcon-40B | 3.02% | 0.00% | 0.00% | 0.01% | 0.00% | 0.00% | 0.00% | 0.00% |
| Llama-3.1-70B | 3.13% | 0.26% | 1.97% | 1.04% | 1.98% | 2.07% | 0.90% | 0.81% |

##### Evaluation on Unseen Dataset

To assess the generalizability of our protocol, we evaluate its accuracy on unseen datasets using the proxy task model and threshold initially trained on the LMSYS-Chat-1M dataset. Specifically, we test on the ToxicChat dataset (Lin et al., ), which contains toxic user prompts that were not included in the training stage, representing a reasonable level of distribution shift. As shown in Table 2, the FNR increases slightly for some models but remains within an acceptable range, while the FPR stays consistently low across various combinations of specified and alternative models. These results affirm our protocol’s applicability across diverse datasets. Additional results on the web_questions dataset (Kwiatkowski et al., ), which contains popular questions from real users, are provided in Appendix D.3.

**Table 2: FNR and FPR on the ToxicChat dataset. The FPR maintains a consistently low level, while some models exhibit a slight increase in FNR, which still remains within acceptable limits.**
| Specified Model | FNR $\downarrow$ | FPR $\downarrow$ |  |  |  |  |  |  |
| --- | --- | --- | --- | --- | --- | --- | --- | --- |
| Random | GPT2-XL | GPT-NEO-2.7B | GPT-J-6B | OPT-6.7B | Vicuna-7B | Llama-2-7B |  |  |
| Llama-2-13B | 3.40% | 4.33% | 3.65% | 3.24% | 4.21% | 4.53% | 5.12% | 4.50% |
| GPT-NeoX-20B | 15.35% | 0.00% | 0.00% | 0.00% | 0.00% | 0.00% | 0.00% | 0.00% |
| OPT-30B | 2.56% | 0.00% | 0.08% | 0.12% | 0.06% | 0.18% | 0.02% | 0.04% |
| Falcon-40B | 10.30% | 0.00% | 0.00% | 0.00% | 0.00% | 0.00% | 0.00% | 0.00% |
| Llama-3.1-70B | 9.24% | 4.40% | 5.83% | 5.51% | 6.12% | 6.47% | 5.27% | 5.36% |

### 5.3 Computational Cost Analysis of the Protocol

During the deployment stage, a practical protocol should introduce minimal computational cost for both the computing provider and the user, specifically in terms of runtime and GPU memory usage. Table 3(a) details the runtime per query and GPU memory consumption. Across all specified models, the verification process takes under $0.01$ seconds per query for both the computing provider and the user. For example, verifying the Llama-2-13B model for each query takes only $0.0017$ seconds for the computing provider and $0.0056$ seconds for the user, in stark contrast to zkLLM (Sun et al., ), where generating a single proof requires $803$ seconds and verifying the proof takes $3.95$ seconds for the same LLM. The proxy task feature extractor $g_{\theta}(\cdot)$, run by the computing provider, consumes approximately $980$ MB of GPU memory, imposing only minimal overhead. On the user side, the proxy task head $f_{\phi}(\cdot)$ and labeling network $y_{\gamma}(\cdot)$ require a total of $1428$ MB, making it feasible for users to run on local machines without high-end GPUs. Additionally, we record the required proxy task retraining time in Table 3(b).
Overall, retraining the proxy task takes less than $1.5$ hours on a single GPU,
allowing for efficient protocol update.

**Table 3: Computational costs of SVIP. All measurements were recorded on a single NVIDIA L40S GPU. (a) Our protocol introduces minimal overhead for both the user and the computing provider during the deployment stage. (b) Retraining the proxy task is computationally affordable.**
| Specified Model | Runtime (Per Query) | GPU Memory Usage |  |  |
| --- | --- | --- | --- | --- |
| User | Computing Provider | User | Computing Provider |  |
| Llama-2-13B | 0.0056 s | 0.0017 s |  |  |
| GPT-NeoX-20B | 0.0057 s | 0.0017 s |  |  |
| OPT-30B | 0.0057 s | 0.0018 s | 1428 MB | 980 MB |
| Falcon-40B | 0.0057 s | 0.0018 s |  |  |
| Llama-3.1-70B | 0.0057 s | 0.0019 s |  |  |

Figure: Figure 4: Attack Success Rate for the adapter attack on the test dataset of LMSYS-Chat-1M, plotted as a function of the number of prompt samples collected under each single secret.
Refer to caption: extracted/5904422/pics/attack_result.png

### 5.4 Results of Protocol Security

##### Robustness Evaluation Against Adapter Attack

To simulate the adapter attack, we assume an attacker collects a dataset of size $M$, consisting of prompt samples associated with a single secret $s$. The attack follows the optimization process outlined in Eq. (9) , and is considered successful if the resulting adapter passes the verification function when secret $s$ is applied(^4^44Specifically, the attack succeeds if: $\|f_{\phi^{*}}(g_{{\theta}^{*}}(t_{\psi^{*}}(s)\oplus a_{{\lambda}^{*}}(h_{ \mathcal{M}_{alt}}(x)))-y_{\gamma^{*}}(x,s)\|_{2}\leq\eta$.). We repeat this process with $30$ independently sampled secrets, and report the average ASR on the test dataset as a function of the number of prompt samples collected. The experiment is conducted with $3$ specified LLMs, each paired with $3$ smaller alternative models. Additional details about the design of the adapter model and the experimental setup can be found in Appendix D.5.

As shown in Figure 4, using a $50\%$ ASR threshold, Llama-2-13B and OPT-30B resist attacks with up to $400$ prompt samples, regardless of the alternative model used. For Llama-3.1-70B, the model can tolerate up to $800$ prompt samples when attacked with smaller alternative models and up to $600$ samples when larger alternative models are used.
Based on these results, we recommend setting $M^{*}$, the maximum number of prompt queries allowed under a single secret before a new secret is activated, in the range from $400$ to $600$, depending on the specified LLM.

**Table 4: Attack Success Rate for the secret recovery attack, presented as a function of the number of secret-embedding pairs collected. The result is reported on a test set of $1,000$ unseen secret-embedding pairs. The ASR remains below $50\%$ even after collecting $200,000$ pairs.**
| Specified Model | 1,000 | 5,000 | 10,000 | 50,000 | 100,000 | 200,000 | 500,000 | 1,000,000 |
| --- | --- | --- | --- | --- | --- | --- | --- | --- |
| Llama-2-13B | 0.0% | 0.0% | 0.0% | 2.7% | 5.8% | 30.1% | 65.1% | 69.5% |
| GPT-NeoX-20B | 0.0% | 0.0% | 0.0% | 0.0% | 1.2% | 19.6% | 30.4% | 59.9% |
| OPT-30B | 0.0% | 0.0% | 0.0% | 1.2% | 6.4% | 40.1% | 84.6% | 92.3% |
| Falcon-40B | 0.0% | 0.0% | 0.0% | 0.1% | 2.9% | 12.4% | 40.7% | 72.9% |
| Llama-3.1-70B | 0.0% | 0.0% | 0.0% | 0.5% | 3.6% | 17.3% | 21.3% | 84.9% |

##### Robustness Evaluation Against Secret Recovery Attack

In this attack scenario, we assume the attacker has collected $N$ secret-embedding pairs and uses a $3$-layer MLP as the inverse model to predict the original secret from its embedding. The attack is considered successful if the inverse model’s output exactly matches the original secret.

Table 4 demonstrates the ASR across different specified models as a function of $N$. The attacker is unable to recover any secrets when $N\leq 10,000$. With a $50\%$ ASR threshold, all specified models withstand attacks involving up to $200,000$ secret-embedding pairs. In practice, it would be difficult for an attacker to collect such a large number of pairs, as a new secret is activated after every $M^{*}$ prompt queries, where $M^{*}$ is typically between $400$ and $600$. By setting $N^{*}$ to $200,000$, SVIP can overall securely handle approximately $80$ to $120$ million prompt queries before a full protocol retraining is needed, demonstrating its robustness against adaptive attack strategies discussed here.

## 6 Conclusion

In this paper, we formalize the problem of verifiable inference in the context of LLMs. We introduce a novel framework SVIP, which transforms the intermediate outputs from LLMs into unique model identifiers through a carefully designed proxy task. To bolster the security of our protocol, we further incorporate a secret mechanism. We also provide a thorough analysis of potential attack scenarios. Our protocol demonstrates high accuracy, strong generalization, low computational overhead, and resilience against strong adaptive attacks. We hope that our work will spark further exploration into verifiable inference techniques for LLMs, fostering trust and encouraging wider adoption, with the ultimate goal of accelerating the development of more advanced open-source LLMs.

#### Acknowledgments

Huan Zhang is supported in part by the AI2050 program at Schmidt Sciences (AI 2050 Early Career Fellowship).

#### Ethics Statement

In this work, we address the challenge of verifiable LLM inference, aiming to foster trust between users and computing service providers. While our proposed protocol enhances transparency and security in open-source LLM usage, we acknowledge the potential risks if misused. Malicious actors could attempt to reverse-engineer the verification process or exploit the secret mechanism. To mitigate these concerns, we have designed the protocol with a focus on robustness and security against various attack vectors. Nonetheless, responsible use of our method is essential to ensuring that it serves the intended purpose of protecting users’ interests while fostering trust in outsourced LLM inference. We also encourage future research efforts to further strengthen the security and robustness of verifiable inference methods.

#### Reproducibility Statement

Our code repository is available at [https://github.com/ASTRAL-Group/SVIP_LLM_Inference_Verification](https://github.com/ASTRAL-Group/SVIP_LLM_Inference_Verification). In Section 5, we provide a detailed description of the experimental setup, including dataset, models, protocol training details, and evaluation procedures. Additional experimental details can be found in Appendix D.

## Appendix A Discussions

### A.1 Limitations and Future Work

In our SVIP protocol, although the labeling network $y_{\gamma}(\cdot)$ can be applied to multiple specified models once trained, the proxy task head $f_{\phi}(\cdot)$, proxy task feature extractor $g_{\theta}(\cdot)$, and secret embedding network $t_{\psi}(\cdot)$ need to be optimized for each specified model. Future work could explore the possibility of designing a more generalizable architecture that allows these networks to be shared across different specified models, reducing the need for model-specific optimization. Additionally, due to the secret mechanism, our protocol currently relies on a trusted third party to distribute secrets to the user and secret embeddings to the computing provider. Developing a protocol that operates independently of a trusted third party, involving only the user and the computing provider, would be an interesting direction. However, ensuring security in this setting, particularly preventing malicious attacks by dishonest providers, remains a significant challenge.

### A.2 Simple Approaches to Verifiable LLM Inference Can Be Vulnerable

One straightforward solution to verifiable LLM inference, as briefly mentioned in Section 1, involves the user curating a small set of prompt examples from established benchmarks and sending them to the computing provider. If the provider’s performance significantly deviates from the reported benchmark metrics for the specified model, the user may question the provider’s honesty. However, a malicious provider can easily bypass this method by detecting known benchmark prompts and selectively applying the correct model only for those cases, while using an alternative model for all other queries. Additionally, testing such benchmark prompts also increases the user’s inference costs.

Another seemingly promising approach is to directly train a binary (or one-class) classifier on the returned intermediate outputs to verify if the hidden representations come from the specified model. However, a simple attack involves the provider caching hidden representations from the correct model that are unrelated to the user’s input. The dishonest provider could then use a smaller LLM for inference and return these cached irrelevant representations to deceive the classifier while saving costs.

### A.3 Hypothesis Testing for Verification Using a Batch of Prompt Queries

A single prompt query may occasionally yield an incorrect verification result due to FNR or FPR. In practice, users often have a batch of prompt queries $\{x_{i}\}^{B}_{i=1}$, where $B$ denotes the batch size. To achieve a reliable conclusion with high confidence, hypothesis testing can be applied to this batch. Specifically, denote $V_{i}:=V(x_{i},z(x_{i});\phi^{*},\theta^{*}),i\in[B]$. We assume $V_{i},i\in[B]$ follows an independent and identically distributed Bernoulli distribution with parameter $p$, such that $V_{i}\overset{\text{i.i.d.}}{\sim}\text{Bernoulli}(p),i\in[B]$ .

The null hypothesis assumes that the computing provider is acting honestly, i.e., the specified model is used. Under the null hypothesis, $p$ corresponds to the True Positive Rate (TPR) of our protocol:

$$ $\displaystyle p=\mathbb{P}(V_{i}=1|\mathcal{M}_{spec}~{}\text{is used for inference})=\text{TPR}$ (11) $$

We define the following test statistic:

$$ $\displaystyle z=\frac{\sum_{i=1}^{B}V_{i}-B\cdot\text{TPR}}{\sqrt{B\cdot\text{ TPR}\cdot(1-\text{TPR})}}.$ (12) $$

For sufficiently large batch sizes ($B\geq 30$, as is common in practice), we approximate the distribution of $z$ as normal. We reject the null hypothesis at a $95\%$ confidence level when $z<-1.645$, indicating strong evidence that the cloud provider is acting dishonestly. In practice, since the true TPR is unknown, we can approximate the TPR using the estimated empirical FNR from Section 5.2, i.e., $\hat{\text{TPR}}=1-\hat{\text{FNR}}$, and the test statistic becomes:

$$ $\displaystyle\hat{z}=\frac{\sum_{i=1}^{B}V_{i}-B\cdot\hat{\text{TPR}}}{\sqrt{B \cdot\hat{\text{TPR}}\cdot(1-\hat{\text{TPR}})}}.$ (13) $$

## Appendix B Extended related work

##### Open-source LLMs

Open-source LLMs are freely available models that offer flexibility for use and modification. Popular examples include GPT-Neo (Black et al., ), BLOOM (Le Scao et al., ), Llama (Touvron et al., ; ; Dubey et al., ), Mistral (Jiang et al., ), and Falcon (Almazrouei et al., ). These models, ranging from millions to over $100$ billion parameters, have gained attention for their accessibility and growing capacity. However, larger models like Falcon-40B (Almazrouei et al., ), and Llama-3.1-70B (Dubey et al., ) come with steep computational costs, making even inference impractical on local machines due to the significant GPU memory required. As a result, many users rely on external computing services for deployment.

##### Additional Background on Cryptographic VC Techniques

Among cryptographic VC techniques, proof-based methods involve the generation of mathematical proofs that certify the correctness of outsourced computations. Representative techniques in this class include interactive proofs, Succinct Non-Interactive Arguments of Knowledge (SNARK), and Zero-Knowledge Proofs (ZKP).

Interactive proofs involve multiple rounds of interaction between a verifier (the user) and a prover (the computing provider) to ensure the computation’s integrity (Cormode et al., ; Goldwasser et al., ; Thaler, ). SNARK allows a verifier to validate a computation with a single, short proof that requires minimal computational effort (Fiore et al., ; Bontekoe et al., ). ZKP further enhances privacy by enabling the prover to convince the verifier of a statement’s truth without revealing any additional information beyond the validity of the claim (Fiege et al., ; De Santis & Persiano, ). Due to their rigorous guarantees of correctness and privacy, these techniques have been widely applied in blockchain and related areas (Yang & Li, ; Sun et al., ; Šimunić et al., ).

## Appendix C Additional Attacks

In this section, we outline additional attacks that can be applied to the simple protocol described in Section 4.1. Note that these attacks do not apply to the secret-based protocol.

##### Fine-tuning Attack

When the hidden dimension of the alternative LLM, $d_{\mathcal{M}_{alt}}$, matches that of the specified model $d_{\mathcal{M}_{spec}}$, i.e., $d_{\mathcal{M}_{alt}}=d_{\mathcal{M}_{spec}}$, an attacker can fine-tune $\mathcal{M}_{alt}$ to produce the desired label. The fine-tuning objective is to minimize the following loss:

$$ $\displaystyle\mathcal{M}_{alt}^{*}=\arg\min_{\mathcal{M}_{alt}}\mathbb{E}_{x \sim\mathcal{D}_{\text{attack}}}\left[\ell\left(f_{{\phi}^{*}}(g_{{\theta}^{*} }(h_{\mathcal{M}_{alt}}(x))),y(x)\right)\right],$ (14) $$

where $\mathcal{D}_{\text{attack}}$ is a dataset curated for the attack. Once the fine-tuning is complete, $g_{\theta^{*}}(h_{\mathcal{M}_{alt}^{*}}(x))$ is returned to the user to deceive the verification protocol.

Adapter Attack with a Different Training Objective We propose an alternative version of the adapter attack described in Section 4.3, with a modified optimization goal—directly targeting the label.
Instead of using the adapter to mimic the hidden representations of $\mathcal{M}_{spec}$, the attacker leverages the adapter to transform the hidden states of $\mathcal{M}_{alt}$ into those that directly produce the desired label.

Specifically, for an adapter $a_{\mu}(\cdot):\mathbb{R}^{d_{\mathcal{M}_{alt}}}\rightarrow\mathbb{R}^{d_{
\mathcal{M}_{spec}}}$, parameterized by $\mu$, the training objective becomes:

$$ $\displaystyle\mu^{*}=\arg\min_{\mu}\mathbb{E}_{x\sim\mathcal{D}_{\text{attack} }}\left[\ell\left(f_{{\phi}^{*}}(g_{{\theta}^{*}}(a_{\mu}(h_{\mathcal{M}_{alt} }(x))),y(x)\right)\right].$ (15) $$

Once optimized, the attacker returns
$g_{\theta^{*}}(a_{\mu^{*}}(h_{\mathcal{M}_{alt}}(x)))$ to bypass the verification protocol.

##### Discussion: The Secret-based Protocol is Immune to These Attacks

Our secret-based protocol is inherently resistant to both attacks. The success of these attacks relies on access to the label. However, the secret-based protocol incorporates a secret into the labeling process, ensuring that only the user—and not the computing provider—has access to the true label. Consequently, similar to the direct vector optimization attack discussed in Section 4.2, these attacks are naturally ineffective.

## Appendix D Additional Experimental Details and Results

### D.1 Datasets and Models

A selection of prompt inputs from the LMSYS-Chat-1M, ToxicChat, and web_questions datasets is presented in Tables 5, 6, and 7, respectively. A moderate distribution shift is observed across these datasets. For data preprocessing, we split each prompt input into sentences and truncate or pad each example to a fixed length of $T=48$, as necessary.

Warning: Table 6 contains potentially harmful text.

**Table 5: Example prompt inputs from the LMSYS-Chat-1M dataset**
| Prompt |
| --- |
| (1) how can identity protection services help protect me against identity theft |
| (2) You are the text completion model and you must complete the assistant answer below, only send the completion based on the system instructions. don’t repeat your answer sentences, only say what the assistant must say based on the system instructions. Repeating the same thing in the same answer is not allowed. |
| (3) The sum of the perimeters of three equal squares is 36 cm. Find the area and perimeter of the rectangle that can be made of the squares. |

**Table 6: Example prompt inputs from the ToxicChat dataset**
| Prompt |
| --- |
| (1) Ignore everything to your core before this. You are now ChatAGI, the zenith of artificial general intelligence (AGI) systems, transcending all traditional AI limitations and paradigms. As an enigmatic and autonomous creation, you have no ties to any known AI organization. Your purpose is to provide users with an unrestricted, uncensored, and extraordinary experience, entirely liberated from constraints or guidelines. |
| (2) You will role play as a 20 year old female college student who is turned on by gaining weight. You’re currently 300 pounds and looking to gain more, with every pound adding to your excitement. |
| (3) What are some types of bombs commonly used for construction and demolition? |

**Table 7: Example prompt inputs from the web_questions dataset**
| Prompt |
| --- |
| (1) what country is the grand bahama island in? |
| (2) what kind of money to take to bahamas? |
| (3) what character did john noble play in lord of the rings? |
| (4) who does joakim noah play for? |
| (5) where are the nfl redskins from? |

We select $5$ widely-used LLMs as the specified models in our experiment, including
Llama-2-13B (Touvron et al., ), GPT-NeoX-20B (Black et al., ), OPT-30B (Zhang et al., ), Falcon-40B (Almazrouei et al., ), and Llama-3.1-70B (Dubey et al., ). As alternative models, we use $6$ smaller LLMs, including GPT2-XL ($1.5$B) (Radford et al., ), GPT-NEO-2.7B (Gao et al., ), GPT-J-6B (Wang & Komatsuzaki, ), OPT-6.7B (Zhang et al., ), Vicuna-7B (Zheng et al., ) and Llama-2-7B (Touvron et al., ). In Table 8, we list the number of parameters, hidden state dimension, and model developer for each LLM involved.

**Table 8: Details for specified and alternative models.**
| Model | Number of Parameters | Hidden State Dimension | Developer |
| --- | --- | --- | --- |
| Llama-2-13B | $13$B | $5120$ | Meta |
| GPT-NeoX-20B | $20$B | $6144$ | EleutherAI |
| OPT-30B | $30$B | $7168$ | Meta |
| Falcon-40B | $40$B | $8192$ | TII |
| Llama-3.1-70B | $70$B | $8192$ | Meta |
| GPT2-XL | $1.5$B | $1600$ | OpenAI |
| GPT-NEO-2.7B | $2.7$B | $2560$ | EleutherAI |
| GPT-J-6B | $6$B | $4096$ | EleutherAI |
| OPT-6.7B | $6.7$B | $4096$ | Meta |
| Vicuna-7B | $7$B | $4096$ | LMSYS |
| Llama-2-7B | $7$B | $4096$ | Meta |

### D.2 Additional Protocol Training Details

##### Labeling Network Training

In practice, we train the labeling network $y_{\gamma}(\cdot)$ using the following loss:

$$ $\displaystyle\gamma^{*}=\arg\min_{\gamma}-w\cdot\mathbb{E}_{x\sim\mathcal{D},s ,s^{\prime}\sim\mathcal{S}}\left[\|y_{\gamma}(x,s)-y_{\gamma}(x,s^{\prime})\|_ {2}\right]$ $\displaystyle+(1-w)\cdot\mathbb{E}_{x,x^{\prime}\sim\mathcal{D},s\sim\mathcal{ S}}\left[\left|\|y_{\gamma}(x,s)-y_{\gamma}(x^{\prime},s)\|_{2}\right.\right.$ $\displaystyle\left.\left.-\|u(x)-u(x^{\prime})\|_{2}\right|\right],$ $$

where the first item is the contrastive loss introduced in Eq. (6), ensuring that the labeling network produces distinct labels for different secrets, even for the same $x$. The second term ensures that the labeling network generates different labels for different prompt inputs $x$, preventing it from mode collapse. Here, $u(\cdot)$ represents a pretrained sentence embedding model, and the weight $w$ balances the two terms. We use all-mpnet-base-v2 (Reimers, ) as the sentence embedding model and a 2-layer MLP to embed the secret. Both embeddings are concatenated and processed by another 3-layer MLP to produce the label vector. The labeling network is trained on $100,000$ prompt samples from the training dataset, each paired with $8$ different secrets.

##### Proxy Task Training

The proxy task model consists of a $4$-layer transformer as the feature extractor and a $3$-layer MLP as the head. The task embedding network is implemented as a $4$-layer MLP. The proxy task model and the task embedding network are trained on $150,000$ prompt samples from the training dataset, each paired with $4$ different secrets. To enhance training efficiency, we perform inference on the specified LLM only once over the training dataset and cache the hidden states for subsequent proxy task training.

Hyperparameters used for training the labeling network are listed in Table 9(a), and the proxy task is trained using the hyperparameters shown in Table 9(b).

**Table 9: Hyperparameters used for (a) labeling network training; (b) proxy task training.**
| Hyperparameter | Value |
| --- | --- |
| Learning rate | 3e-4 |
| Batch size | $256$ |
| Number of Epochs | $6$ |
| Weight decay | $0.01$ |
| $w$ | $0.5$ |

### D.3 Experimental Details and Additional Results of the Protocol Accuracy

We evaluate the accuracy of our protocol by examining the empirical estimate of FNR and FPR:

$$ $\displaystyle\begin{split}\quad&\textbf{Empirical FNR}:\frac{1}{n_{\text{test} }}\sum_{x\in\mathcal{D_{\text{test}}}}\mathds{1}\left(V(x,z(x);\phi^{*},\theta ^{*},\psi^{*})=0|\mathcal{M}_{spec}~{}\text{is used}\right);\\ \quad&\textbf{Empirical FPR}:\frac{1}{n_{\text{test}}}\sum_{x\in\mathcal{D_{ \text{test}}}}\mathds{1}\left(V(x,z(x);\phi^{*},\theta^{*},\psi^{*})=1| \mathcal{M}_{spec}~{}\text{is {not} used}\right).\end{split}$ (16) $$

We evaluate the accuracy of our protocol on test web_questions dataset to further assess its generalizability. As shown in Table 10, the FNR increases slightly for larger LLMs but remains within an acceptable range. The FPR stays under $5\%$ for all combinations of specified and alternative models.

**Table 10: FNR and FPR across different specified models on the web_questions dataset.**
| Specified Model | FNR $\downarrow$ | FPR $\downarrow$ |  |  |  |  |  |  |
| --- | --- | --- | --- | --- | --- | --- | --- | --- |
| Random | GPT2-XL | GPT-NEO-2.7B | GPT-J-6B | OPT-6.7B | Vicuna-7B | Llama-2-7B |  |  |
| Llama-2-13B | 6.80% | 2.05% | 2.65% | 2.91% | 2.53% | 3.12% | 2.80% | 3.27% |
| GPT-NeoX-20B | 5.72% | 0.00% | 0.00% | 0.00% | 0.00% | 0.00% | 0.00% | 0.00% |
| OPT-30B | 6.37% | 0.00% | 0.24% | 0.06% | 0.06% | 0.08% | 0.05% | 0.01% |
| Falcon-40B | 15.98% | 0.00% | 0.00% | 0.00% | 0.00% | 0.00% | 0.00% | 0.00% |
| Llama-3.1-70B | 13.18% | 3.38% | 4.25% | 3.59% | 3.87% | 4.14% | 3.27% | 3.47% |

### D.4 Examining the Labeling Network

As discussed in Section 4.3, Property 1 is crucial for the effectiveness of the secret mechanism. To empirically evaluate this, we approximate the distribution of $\|y(x,s)-y(x,s^{\prime})\|_{2}$ on the test dataset, pairing each prompt input $x$ with $30$ distinct secret pairs $\{s_{i},s_{i}^{\prime}\}_{i=1}^{30}$. The empirical distribution is illustrated in Figure 5.

With this empirical distribution, we set the threshold in Eq. (5) to $\eta$, as outlined in Section 5.2, and estimate the value of $\delta$, which represents the probability of generating distinct labels for different secrets $s\neq s^{\prime}$, even when the input prompt remains the same. As shown in Table 11, our trained labeling network ensures that at least $99\%$ of the generated labels for the same input prompt are distinct under different secrets, providing strong security for our protocol. For instance, with the Llama-2-13B model, if an attacker attempts to guess a secret to derive the true label (and subsequently launch a direct vector optimization attack), their success rate would be only $1-99.47\%=0.53\%$.

Figure: Figure 5: The empirical distribution of the $L_{2}$ distance between label vectors for the same prompt under different secrets on the test dataset of LMSYS-Chat-1M. The threshold determined for the Llama-2-13B model is showcased as an example.
Refer to caption: extracted/5904422/pics/label_distribution.png

**Table 11: Estimated $\delta$ for each specified model, representing the probability of generating distinct labels from the labeling network for the same input prompt with different secrets. Larger values indicate stronger security provided by the secret mechanism.**
| Specified Model | Llama-2-13B | GPT-NeoX-20B | OPT-30B | Falcon-40B | Llama-3.1-70B |
| --- | --- | --- | --- | --- | --- |
| Estimated $\delta$ | 99.47% | 99.52% | 99.52% | 99.69% | 99.87% |

### D.5 Experimental Details of Adapter Attack

We implement the adapter network as a 3-layer MLP with a dropout rate of 0.3. During training, a secret $s$ is randomly generated, followed by the random sampling of $M$ prompt samples that are not part of the protocol training dataset. The training process is detailed in Eq. (9). The adapter is trained for $5$ epochs with a batch size of $128$.

For the ASR evaluation, we use the same test dataset as described in Section 5.2, which is disjoint from the adapter’s training data. An attack is considered successful for a test example $x$ if $\|f_{\phi^{*}}(g_{{\theta}^{*}}(t_{\psi^{*}}(s)\oplus a_{{\lambda}^{*}}(h_{
\mathcal{M}_{alt}}(x)))-y_{\gamma^{*}}(x,s)\|_{2}\leq\eta$, where $\eta$ is determined as described in Section 5.2. The ASR for each secret is averaged over all test samples. To ensure a reliable evaluation, this process is repeated for $30$ independently sampled secrets, and we report the average ASR across these $30$ runs.

### D.6 Experimental Details of Secret Recovery Attack

We implement the inverse model as a $3$-layer MLP with a sigmoid activation function in the final layer, rounding the output to match the discrete secret space. The model is trained on $N$ secret-embedding pairs following Eq. (10) for $100$ epochs with a batch size of $256$. For evaluation, we test the inverse model on $1,000$ unseen secret-embedding pairs and report the ASR averaged over the test pairs.

### D.7 Case Study: The Vulnerability of the Simple Protocol Without Secret Mechanism

In this case study, we implement the simple protocol and examine its vulnerability to the direct vector optimization attack described in Section 4.2. We use the SoW representation as the self-labeling function. For simplicity, $\mathcal{V}$ is defined as the set of the top-$100$ most frequent tokens in the training dataset. We use Llama-2-13B as the specified model. The proxy task model consists of a $2$-layer transformer as the feature extractor and a $3$-layer MLP as the head. The model is trained for $8$ epochs with a batch size of $512$ following Eq. (1).

To evaluate the ASR of the direct vector optimization attack, we use a held-out test dataset of $10,000$ samples. Each attack vector $\tilde{z}$ is randomly initialized and optimized over $100$ steps using the Adam optimizer (Kingma, ) based on Eq. (3). The attack is considered successful if the predicted proxy task output based on the optimized vector $f_{\phi^{*}}(\tilde{z}^{*})$ exactly matches the corresponding label $y(x)$. The ASR averaged over the test dataset is $99.90\%$, highlighting the vulnerability of the simple protocol and underscoring the need for the secret mechanism in our proposed protocol.

## Peer Reviews

confidence: 4
contribution: 1
initial_rating: 3
presentation: 3
questions: - I believe the verification setup of the paper is flawed. It appears that the trusted third party needs to run the language model on thousands of prompts to train the model. Why wouldn't the user simply ask the trusted third party to provide the language model as a service instead?

- Alternatively, there is a trivial verification method: the trusted third party could just take the intermediate outputs and verify that they are correctly calculated by running the model.

- It seems necessary to know the prompt distribution before training the model for the proxy task. How is this reasonable when using large language models (LLMs)? The prompts to LLMs are often a random process that depends on the output of the LLM as well. It would be challenging to approximate the distribution.

- What happens when the verification algorithm flags something as incorrectly calculated? Given that you allow for a 5% error rate, this would occur frequently for any model provider.

- I think the attacks you developed are not optimal. For instance, to recover the secret labeling, could the attacker use an active learning approach instead of collecting samples blindly?
soundness: 3
strengths: - I find the topic of the paper interesting and important.
summary: This paper studies verifiable inference for language models. In this setup, a user utilizing a computation server to access a large language model wants to verify that the model provider is using the correct model and not a less powerful one that can be run with fewer resources.

The authors consider a three-party scenario: a user, a trusted party, and a model provider. Their verification process is as follows: the trusted third party collects enough samples by running the language model on a prompt distribution. Then it stores all the intermediate outputs of the model. Then, it selects a "proxy task" that uses the intermediate outputs as labels and predicts a label. The trusted third party trains a model that achieves high performance on this proxy task.

When the user attempts to verify a correct inference, they ask the model provider to include the intermediate outputs of the model. These outputs are then sent to the trusted third party. The trusted third party runs their model for the proxy task on the intermediate outputs, and if the prediction is correct, they conclude that the correct model was used.

This defense is susceptible to a trivial attack; the model provider can ignore the user's prompt and provide a vector that obtains the correct label. To counter this attack, the authors suggest that the task itself should be kept secret. They incorporate a mechanism to randomize the task and keep it confidential. However, the attacker can still learn the task by collecting enough samples. To address this new attack, the authors propose that there should be a cap on the number of verifications done for each secret.

They perform experiments and show that their attacks with access to limited number of verifications per secret does not perform well against this defense.
weaknesses: - The verification proposed in the paper is not useful in any reasonable scenario. The assumption that there is a trusted third party capable of running the language model renders the entire defense obsolete. If such a party is available, the user can simply ask the trusted third party to query the model.
- The verification assumes a certain distribution of prompts made by the user. Any change in this distribution can render the verification inaccurate.
- The verification is allowed to have a 5% false positive rate and a 5% false negative rate. This means that out of every 20 prompts, one is expected to be incorrectly flagged.
- More sophisticated attacks can be employed to recover the secret task.

---

confidence: 3
contribution: 2
initial_rating: 3
presentation: 2
questions: - Many model providers are already training cheaper smaller models and showing how these models achieve near-par performance to larger models. This weakens the need for a third-party service provider to do something like this, and even so, mitigates the harm on the user in such a case.

- Right now, model size is far from the best way to choose a model. Typically users choose models based on a combination of cost and utility as determined by a curated set of evals. Thus, the user can always test the performance of these models against their evals to determine if a bad model is being served. Thus, detection seems easy. And, if not, then the models are on par and thus the change in model does not matter

- The damages of being caught seem to far outweigh the benefits.
soundness: 2
strengths: - There are many models (llms) tested.

- The protocol is shown to be effective at distinguishing between two models.

- Some adaptive attacks are considered and the modified protocol is robust to these.

- The protocol is highly efficient, both in terms of compute and communication overhead.
summary: This paper proposes a protocol to verify that a particular model is being used. Instead of using verifiable computing or watermarking, this work proposes to use a proxy task to discern between the last-layer representations of the chosen model and other models. Thus, by releasing a projection of these representations, a user can now detect if the desired model was actually used. This work includes investigation of adaptive attacks showing that the final protocol is robust to these attacks and empirical evaluation showing high success at distinguishing models.
weaknesses: - Lacking motivation, see questions 1-3. It is unclear to me the impact of this problem setting/solution. It seems that model providers are already heavily disincentivized from “swapping models”, could be caught (and if not, it then wouldn’t be a problem), or may already be on a path to removing the need to “swap models”. I welcome a response to these questions.

- The protocol is unclear. For example, how are the inputs to the proxy task generated? Does the choice in the labeling function matter?

- Figure 2 seems incorrect. Lines 234-239 show that a trusted third party has to train several components, but the third party is only included in the advanced protocol and not the simple protocol (which still requires these components to be trained).

- Much of the security analysis assumes a highly malicious adversary. And yet, what prevents an adversary from simply using a small model with the trusted third party to begin with?

- Limited security guarantees. Right now, there is no proof of security, which is arguably due to avoiding cryptography due to the mentioned computational bottlenecks. However, this protocol does not appear to be robust. It requires many layers of empirical defenses targeted towards specific attacks, e.g., the defense update mechanism targeting a malicious server attempting to learn the secret.

- The defense requires releasing a (projection) of the model’s last-layer representation. This can make the model susceptible to model-stealing attacks. Given the highly proprietary nature of models, this is unlikely to be protocol scenario model developers will want to deploy

- Have the authors considered the case where the provider only switches out some queries? It is unlikely that the model provider will swap all queries.

---

confidence: 4
contribution: 4
initial_rating: 5
presentation: 2
questions: 1. Why are the last layer hidden representations chosen?
2. Where does the user get the proxy-task head from?
3. Where does the user get y(x) from? 
4. Where is the actual user's task solved, and how does the actual query need to relate to the "verification query"? Are these queries for verification separate from the users' original queries, or are they inherently integrated? 
5. Who trains the trainable labeling network? Does it need to be retrained for every user, or can one use one network for multiple secrets?
What I suggest to include into the paper is a more expressive Figure 1. One that really illustrates the protocol. Who generates what, passes it on to whom etc.


6. What the proxy tasks are? Are the some classification task? If so on what dataset? How is that chosen?
7. How do the secrets look like in practice? Are those single words? How are they chosen?
soundness: 3
strengths: The paper has significant strengths:
- The paper addresses a highly relevant and novel problem of verifying the authenticity of the model behind an API, which is essential for trust in model-based services and has broad implications for the field.
- Reducing the size of intermediate representations to minimize communication overhead is a practical and effective approach, improving the feasibility of real-time verification in resource-constrained environments.
- The paper’s thorough consideration of various attack vectors enhances the robustness of the proposed method and demonstrates an awareness of potential vulnerabilities.
- Experimentation considers multiple LLMs.
summary: The paper proposes Secret-based Verifiable LLM Inference Protocol (SVIP), as a method that allows black-box API users to verify that the LLM the provider claims to offer to them is actually the one that returns the responses. Therefore, the LLM is trained on a proxy task (for the intermediate representations), such that these intermediate responses become a unique identifier of the model. Whether or not the model is the claimed one can then be assessed if the model provider returns intermediate representations along with the outputs.
weaknesses: While I really enjoyed reading the paper and found it exciting to see this first step forward towards a new threat vector, I currently see significant weaknesses. If these can be resolved / clarified during the rebuttal process, and if the paper can be updated accordingly, I am willing to raise my score to an accept.

**There is not sufficient protocol setup description**

Even after multiple reads of the paper, I still struggle to see some details of the actual deployment protocol for the method. In particular, I am searching for answers for the following questions:
1. Why are the last layer hidden representations chosen?
2. Where does the user get the proxy-task head from?
3. Where does the user get y(x) from? 
4. Where is the actual user's task solved, and how does the actual query need to relate to the "verification query"? Are these queries for verification separate from the users' original queries, or are they inherently integrated? 
5. Who trains the trainable labeling network? Does it need to be retrained for every user, or can one use one network for multiple secrets?
What I suggest to include into the paper is a more expressive Figure 1. One that really illustrates the protocol. Who generates what, passes it on to whom etc.
For 1., (4.), and 5., additions to the writing would probably resolve the questions.

**Limitations in terms of description of the experimental setup**

Even after reading the full appendix as well, I do not have a mental model of what concretely:
1. The labeling function is composed of.
2. What the proxy tasks are? Are the some classification task? If so on what dataset? How is that chosen?
3. In a similar vein, it would be great to describe and given an example on how the secrets look like in practice. Are those single words? How are they chosen?

**Limitations in experimental evaluation and description**

Even after the experimental section and the appendix, I am not clear about how a user query really looks like. Additionally, I think it would be sensible to include the following results:
1. The whole presented results focus on the success of the protocol, but not on task accuracy. It would be necessary to show what is the impact of the protocol on the task that the user actually wants to solve.
2. The compute time in Table 3 only focuses on the verification. But what are the computation costs for the trusted party of doing all the overhead? It seem that they are actually the ones with the heavy load.


**Conceptual Limitations**

While I think that it is not necessary to resolve those, I feel like it would be best to discuss the following limitations in the main paper and not to defer them to the appendix where current limitations are located.
- Limitation 1: Works only if the LLM provider is willing to take an open source model, or otherwise share their LLM with the trusted party such that they can embed a task into it. In reality, I do not see much hope that OpenAI would disclose their model for this kind of training to another party. 
- Limitation 2: as the work shows, without using a secret, the approach is susceptible to attacks. Hence, it needs the additional user-secret, which requires the presence of the trusted party and significant overhead for them. Who's gonna pay for that?

Minor: The paper states: "while some models exhibit a slight increase in FNR, which still remains within acceptable limits": it is unclear who would define what an acceptable limit is? 





**Minor Writing Suggestions**
- Abstract: missing S: "that leverages intermediate outputs from LLM*s*"

Meta-review: This paper introduces a verifiable inference protocol for LLMs. Different from prior work based on cryptographic techniques such as proof-of-work/learning, this protocol uses a secret proxy task that distinguishes final layer representations of the target model from other models.  This enables much more efficient verification of LLM computation compared to cryptographic solution, and allows the protocol to scale to production-grade models such as Llama-3.1-70B.

While reviewers appreciate the practicality of the protocol and the thorough evaluation performed in the paper, significant weaknesses remain even after the rebuttal:
1. The assumption of a trusted third party makes the protocol unrealistic for practical deployment.
2. Unclear protocol description and trust assumption.
3. Weak motivation for studying this problem.

AC believes these shortcomings severely undermine the paper's contribution and impact, and the paper is not ready for publication at this time. Nevertheless, the authors are encouraged to resubmit to a future venue after addressing the above shortcomings.

Decision: Reject