zkLLM: Zero Knowledge Proofs for Large Language Models

Haochen Sun, Jason Li, Hongyang Zhang

Abstract

As Large Language Models (LLMs) are increasingly deployed in sensitive domains, the need for verifiable computation becomes paramount. We present zkLLM, the first specialized zero-knowledge proof (ZKP) system designed for LLMs. zkLLM enables a model provider to prove that a specific output was generated by a specific model (e.g., LLaMa-2) without revealing proprietary weights. By introducing technical innovations like tlookup and zkAttn, zkLLM generates correctness proofs for a 13-billion parameter model in under 15 minutes, with a final proof size of less than 200 kB.

Introduction

The integration of LLMs into legal, medical, and governmental workflows has highlighted a critical trust gap. Users and regulators require assurance that model outputs are authentic and haven't been manipulated. However, standard verification methods are either computationally prohibitive at the scale of billions of parameters or require the disclosure of proprietary model weights.

Existing ZKP frameworks struggle with the complexity of LLMs, particularly non-arithmetic operations like Softmax and GELU activations. The sheer scale of these models creates massive computational overhead. zkLLM addresses these challenges by prioritizing parallelization and optimizing the verification of the attention mechanism.

Methods

The zkLLM architecture is designed to handle the standard Transformer block used in modern LLMs, as illustrated in the high-level diagram below.

High-level architecture of a Transformer layer within the zkLLM framework.

To achieve practical performance, zkLLM introduces two primary innovations that move away from univariate polynomials toward multilinear extensions and sumcheck protocols, unlocking GPU-level performance.

1. tlookup (Tensor Lookup)

Traditional ZK lookup arguments are sequential, making them a bottleneck for tensor-heavy computations. tlookup is a parallelized lookup argument designed for tensor operations. It treats lookups as set inclusions over tensors, allowing for full GPU acceleration via CUDA without asymptotic overhead in memory or time.

2. zkAttn

The attention mechanism's Softmax function is particularly challenging for ZKPs due to its multivariate and non-linear nature. zkAttn simplifies this by exploiting the shift-invariance property of Softmax. By subtracting a constant from the input, all inputs to the exponential function become non-positive, making them predictable and easier to verify via pre-computed tables.

The zkAttn mechanism utilizing b-ary segments and tlookup for parallelized Softmax verification.

As shown in the figure above, zkAttn decomposes the operation into base-$b$ segments and uses tlookup to verify the exponentiation in parallel. This approach treats "most significant" and "least significant" parts of a number differently, allowing for precision optimizations where negligible values are ignored without sacrificing overall model accuracy.

Experimental Evaluation

The researchers evaluated zkLLM using the OPT family (125M to 13B parameters) and LLaMa-2 (7B and 13B versions). Testing was conducted on samples from the C4 (Colossal Clean Crawled Corpus) dataset with a sequence length of 2048 tokens. Perplexity was measured to ensure that the quantization required for ZKPs did not degrade model performance.

Key Results

  • Scalability: zkLLM successfully handles models up to 13 billion parameters, a 10x improvement over previous state-of-the-art ZKML systems.
  • Efficiency: Proof generation for a 13B parameter model takes less than 15 minutes. The resulting proof is compact (<200 kB) and can be verified in 1–3 seconds.
  • Fidelity: The numerical errors introduced are negligible, with an increase in perplexity on the C4 dataset of less than 0.01 for 13B models.

Conclusion and Future Work

zkLLM demonstrates that zero-knowledge verification for multi-billion parameter models is feasible. While currently focused on inference, future work will address the even greater challenge of proving the training process. Additionally, while optimized for 13B models on a single A100 GPU (requiring ~23.1 GB VRAM), scaling to 70B+ models will necessitate multi-GPU configurations and further memory optimizations.

Summary updated

BibTeX
@inproceedings{sun2024zkllm,
  author = {Haochen Sun and Jason Li and Hongyang Zhang},
  title = {{zkLLM: Zero Knowledge Proofs for Large Language Models}},
  booktitle = {CCS},
  year = {2024},
}
Figure