Encrypted Softmax

L4 · Application Components
softmax · 1 specification · 0 implementations · no benchmarks yet
WHAT IT ISMap an encrypted real vector to a probability distribution over its slots under CKKS.
CKKS
SIGNATURE
kernel softmax<N: u32>(
%xs: secret<tensor<N x f64>>,
) -> %ys: secret<tensor<N x f64>>
Sizes and element types are left open here. A specification fixes them; an implementation says over which of them it works.
DESCRIPTION

Definition

Softmax maps a vector of real scores to a probability distribution over its positions. Given

x=(x0,x1,,xN1),x = (x_0, x_1, \ldots, x_{N-1}),

the result is the vector yy with

yi=exij=0N1exj,0i<N.y_i = \frac{e^{x_i}}{\sum_{j=0}^{N-1} e^{x_j}}, \qquad 0 \le i < N .

Every output is in [0,1][0, 1] and the outputs sum to one, so yy lies on the probability simplex. Larger inputs receive larger shares, and the mapping is invariant to adding a constant to every input: softmax(x+c1)=softmax(x)\operatorname{softmax}(x + c\mathbf{1}) = \operatorname{softmax}(x).

Mathematical Domain

Softmax is defined over real vectors. It is a non-polynomial function: it combines the transcendental exponential with a normalisation (a division by the sum of exponentials). Over encrypted data neither the exponential nor the reciprocal is a native operation, so both must be realised by approximation, and the approximation is only meaningful over a bounded input range.

The kernel does not fix the cryptographic scheme, the length N, the input range over which softmax is approximated, or the accuracy tolerance. These are defined by individual specifications.

Parameters Defined by Specifications

A specification narrows the general softmax into a concrete computational problem by defining, for example:

  • the cryptographic scheme and element domain;
  • the length N;
  • the input range over which the exponential and normalisation are approximated;
  • the input and output representation;
  • the accuracy tolerance used to score closeness to the exact softmax.

Applications

Softmax is the output activation of classifiers and the core of the attention mechanism in transformers. Evaluating it over encrypted data enables privacy-preserving inference — confidential classification and language-model attention — and confidential probabilistic scoring and ranking.

MAINTAINER
FM
fairmathreviews specifications · resolves disputes
USED BY · 0 KERNELS
Kernels above this one. If this kernel is wrong, or slow, they are wrong or slow with it.Nothing depends on this kernel yet.
BUILDS ON · 0 KERNELS
Kernels this one is stated in terms of. Not a call graph — a statement of dependence between problems.Nothing. This kernel sits at the bottom of the graph.
RECENT ACTIVITYNothing yet.