Log-sum-exp: Why does a big score stabilize the cross-enthon

Multiple cross-alcers can be calculated directly from logits without having to write all probabilities.

Thematic shorts • IntroductionCollate in 2 self-measured2 First-hand sources
Start Body
Learning objectives and first steps2 objectives . 1 first fix

Try to do it after reading

  • Explain Log-sum-exp: Why a big score also stabilizes the mechanisms and prerequisites for cross-oxychloride
  • Positioning the mechanism ' s fault limits with fixed examples

Suggested first

  • Index logarithm and class cross entropy

Issues and mechanisms

Multiple cross-alcers can be calculated directly from logits without having to write all probabilities. The key attribution is log-sum-exp: logarithmic index and logarithmic. The index, which directly seeks large scores, may spill over, while the equivalent is reduced by the maximum value and then added back to the maximum value, thus preserving the target and improving the stability of the value. This technique changes the computational path, not the training.

Set m as the maximum fraction of the current vector, then log-sum-exp equals m plus log for exp (z less m). The maximum index after the reduction is one and not more than one. Cross entropy for category y minus real category fraction zy. If classes are blocked, the maximum value and the conclusion can only take place within a legal assembly; The whole collection is empty and requires obvious treatment, and stabilization techniques cannot be expected to solve undefined problems.

log(∑iezi)=m+log(∑iezi−m),m=maxizi

A concrete example

The total components [1000,999] are the second in the true category. The maximum value is [0,−1], expressed as approximately 1000 plus log (1 plus exp negative I), 999 less, obtained approximately 1.313262. If the exp 1000 is calculated first, the normal floating point is likely to spill; If the scores are reduced to the same ceiling, they change the relative difference and have different probabilities. Stabilizing equivalents is better than severing.

Borders and checks

Inputs must be legal and limited points, and the reasons for the upstream location should be in place when there is infinity or infinity. Combining accuracy may also cause minor differences to be rounded out and even stabilization of claims does not restore information that has already been lost. Checks whether the loss interface is receiving logits and avoids re-entering the loss function with a homogenization after softmax, resulting in a duplicate change.

It may also add any constant to all fractions at the same time, and the loss of validation remains unchanged; This is a specific, non-variable test of the location error at the axis.

A method of verification

A large constant may also be added to all fractions at the same time, and the verification of stable losses shall remain unchanged; Re-exchange order of categories and synchronized exchange of labels to confirm that the results are consistent. The first check of public deviations and the last check of target indexes. If the model reverses the last two dimensions of the volume, the conclusion may still be returned to the mark but cannot be tested in such semantic terms. When a class block is encountered, only these two non-variable entries should be checked and the denials should be listed separately for full blockage input.

Check understanding

The reduction in the maximum value would reduce the true category fractions, and would the gradient be changed?

No, the whole formula is added to the public mass and is re-allocated in the same way. It does not merely reduce the real item, but rather implements a consistent equivalent price change for all participating items.

All positions are blocked. Can you fix the maximum?

Can't. There is no normal unipolation denominator without a legitimizing item, and rejection, skipping or other assignment must be defined and the probability of evenness cannot be created in silence.

Sources and reconciliations

Definitions, methods and interfaces are available.

  1. Stanford CS336 — Language Modeling from Scratch, Spring 2025
  2. Hugging Face Transformers — Generation

Figures and calculations are reorganized according to this chapter. Mathematical measurements, framework operations and real business effects are described separately in the body of the text.

← Back to the knowledge directory
Ask Max Ask about this site
Ask Max ↗

Opening the assistant…

Paper figure

Photo comments

LEAVE A NOTE

About this photograph

Connecting to the discussion board…

    Comments become public after moderation. You can delete your own comments from this browser.
    No email is required. Clearing cookies prevents this browser from claiming earlier comments.

    MAX WANG / INDEX

    Find something

    Enter a keyword, or explore the directory below.