But what is cross-entropy? | Compression is Intelligence Part 2

· Source: 3Blue1Brown · Field: Technology & Digital — Artificial Intelligence & Machine Learning, Data Science & Analytics · Depth: Advanced, extended

Summary

The concept of cross-entropy, a fundamental measure in information theory, is explored through its surprising connection to data compression and its critical role in training modern language models. The 2002 paper "Language Trees and Zipping" demonstrated how general file compression tools like gzip could cluster languages and recover lineage trees by measuring co-compression efficiency. This principle, where a compression scheme optimized for one context performs in another, directly relates to cross-entropy. The article illustrates this with a robot instruction example, showing how an encoding optimized for one probability distribution (Q) performs on a new distribution (P), resulting in an average of 2.625 bits per message. In machine learning, cross-entropy loss, typically using natural logarithms for gradient descent, serves as the objective function for pre-training language models, minimizing when the model's predicted token distribution matches the training data's statistics. It also underpins distillation, where smaller models learn from larger ones' full probability distributions.

Key takeaway

For Machine Learning Engineers designing loss functions or optimizing model training, understanding cross-entropy's deep connection to compression is crucial. Your choice of a negative logarithm for loss is mathematically forced if you want the model's output distribution to match data statistics, ensuring optimal learning. This perspective reframes LLM training as a compression task, guiding you to consider distillation with cross-entropy for efficient model approximation, rather than just next-token prediction.

Key insights

Cross-entropy quantifies how well a compression scheme optimized for one context performs in another, linking compression to AI.

Principles

Method

Language models are trained by minimizing cross-entropy loss, which is the average negative log probability the model assigns to true next tokens across vast datasets.

In practice

Topics

Best for: Research Scientist, AI Scientist, Machine Learning Engineer, AI Student

Related on AIssential

Open in AIssential →

Editorial summary, takeaway, and curation by AIssential. Original article published by 3Blue1Brown.