liveBook · Manning

Logit

As explained in Server-Side WebAssembly

A logit is an unnormalized score produced for a candidate class or token before conversion into probabilities.

A logit is a raw, unnormalized score that a neural network assigns to each possible next token. It becomes a probability only after applying softmax. section 5.4.2

Selecting the next token

After inference, read the model's "logits" output, convert its bytes to f32 values, isolate the final token's vocabulary slice, and apply softmax. The resulting probabilities can drive weighted sampling of the next token. section 5.4.2

let output_data = exec_context.get_output("logits").unwrap().data();
let output_f32 = bytes_to_f32_vec(&output_data);

Inspect the inference output and convert the raw logits bytes into f32 values before selecting the relevant token scores. section 5.4.2

How Server-Side WebAssembly covers it

How deep it goes
Explains raw scores, vocabulary slicing, softmax conversion, and weighted sampling, without deriving the underlying neural-network computation.
Examples
Uses an ONNX language model to extract final-token logits and sample a continuation from the resulting distribution.
What it assumes
Assumes familiarity with token IDs, vocabulary dimensions, tensors, and executing a neural-network model.
What you can do after
Apply it via softmax and weighted sampling to generate the next token from model inference output.
How it connects
Connects logits to softmax, probability distributions, tokenization, vocabulary, tensors, and neural-network inference.

Also explained in

Compare how 17 books explain logit →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Server-Side WebAssembly. The section links point to the parts of the book it draws on.