Zubnet AIApprendreWiki › Logits
Fondamentaux

Logits

Raw Scores, Pre-Softmax Outputs
Les scores bruts non normalisés qu'un modèle sort avant qu'ils soient convertis en probabilités par la fonction softmax. Pour un modèle de langage, les logits sont un vecteur avec une valeur par token dans le vocabulaire — les valeurs plus hautes indiquent les tokens que le modèle considère plus probables. Les logits sont la sortie la plus informative qu'un modèle produit, contenant plus d'information que la distribution de probabilités finale.

Pourquoi c'est important

Comprendre les logits t'aide à comprendre comment les modèles « pensent ». Le sampling par temperature, top-p et top-k opèrent tous sur les logits. La classifier-free guidance en génération d'images manipule les logits. Le logit bias (ajouter des offsets à des tokens spécifiques) te laisse steerer le comportement du modèle. Si tu construis des applications IA au-delà du chat basique, tu finiras par avoir besoin de travailler directement avec les logits.

Deep Dive

The model's final layer produces a vector of size V (vocabulary size, typically 32K–128K). Each element is a logit for that token. Softmax converts these to probabilities: P(token_i) = exp(logit_i) / ∑ exp(logit_j). Before softmax, the logits can be any real number — positive, negative, or zero. A logit of 10 vs. 5 means the model considers the first token about e^5 ≈ 150x more likely.

Logit Manipulation

Several techniques work directly on logits. Temperature divides all logits by T before softmax (T<1 sharpens, T>1 flattens). Top-k zeroes out all logits except the k highest. Top-p (nucleus sampling) zeroes out logits for tokens outside the smallest set whose cumulative probability exceeds p. Logit bias adds a fixed offset to specific tokens' logits — adding +10 to the logit for "JSON" makes the model strongly prefer starting with JSON. Repetition penalty reduces logits of recently generated tokens.

Log-Probabilities

Most APIs can return log-probabilities (log of the softmax output) alongside generated tokens. These are useful for: measuring model confidence (low log-prob = uncertain), calibrating outputs (are 90%-confident predictions correct 90% of the time?), and building classifiers from LLMs (compare log-probs of different completions). Log-probs are more numerically stable than raw probabilities for extreme values.

Concepts liés

← Tous les termes
← llama.cpp LoRA →