ngrok publishes an interactive guide linking LLM prediction to compression

Annie Sexton's interactive guide explains how token probabilities become compression costs; ngrok separately operates an AI Gateway for routing model traffic.

By · Published

Primary source: ngrok

Why it matters

Ngrok is using deep technical education to carry its developer trust from localhost tunnels into AI infrastructure, where routing, latency and token economics shape buying decisions.

A highly magnified view of intricate, almost labyrinthine copper traces on a silicon wafer, interwoven with patterns of minuscule, algorithmically generated text. (macro photograph — extreme close-up of a physical object, razor-thin focus p

Alan Shreve's ngrok published an interactive guide to the shared mathematics behind lossless compression and large language models on August 11, showing how the quality of a prediction determines the number of bits needed to encode data.

The article, written by ngrok developer educator Annie Sexton, turns a dense information-theory concept into a sequence of working demonstrations. Readers can minify code, run a basic encoding scheme, step through arithmetic coding and watch a language model's token probabilities become compression costs.

Sexton has spent more than a decade working at developer platforms including Heroku, Render and Fly.io, according to her ngrok biography. That background shows in the structure: each abstraction arrives through a small program or visualization, rather than a wall of equations.

The approach also follows the pattern Shreve used to build ngrok. He studied computer science at the University of Michigan and joined Twilio as one of its earliest engineers, where he built the messaging team and worked on distributed systems. The practical problem behind ngrok came from developing webhook-based applications that needed public URLs while running locally. In a 2016 account of the tool's creation, Shreve said he initially built ngrok to learn Go and make web development easier.

That instinct - make difficult infrastructure understandable enough for a developer to use immediately - is the throughline connecting ngrok's original tunnel to Sexton's compression lesson.

Prediction has a price in bits

Sexton begins with the distinction between removing unnecessary material and exploiting predictable structure. Minification can shrink JavaScript by deleting comments, whitespace and human-readable names. A lossless compressor instead looks for redundancy that lets it describe the original data with fewer bits.

Her first example applies run-length encoding to a 28-character sequence containing repeated letters. Replacing each repeated run with a letter and count reduces the representation from 224 bits to 96 bits in the simplified example, a 57% reduction.

The article then divides a modern compressor into three broad components: transforms, models and entropy coders. A transform rearranges or preprocesses data. A model estimates the probability of each symbol. An entropy coder converts those probabilities and symbols into a bitstream.

Arithmetic coding provides the bridge to language models. Sexton's demonstration repeatedly narrows a numerical range as it processes the seven-character string "ABABAAC." The final interval can be represented by a 10-bit binary fraction, compared with 56 bits for the raw ASCII characters in the example.

That comparison isolates the encoded payload. A complete decoder also needs access to the probability model, the symbol ordering and enough information to know when decoding should stop. In production systems, those requirements and the computational cost of the model matter alongside the size of the final bitstream.

The core relationship remains: assigning a high probability to the correct next symbol lowers its information cost. Under the familiar formula -log2(probability), likely symbols cost fewer bits and surprising symbols cost more.

An LLM performs the same probability-estimation step when it predicts a next token. For compression, the actual next token is already known. The model supplies its probability, and an entropy coder uses that probability to encode the token. A confident, correct prediction produces a short representation. A confident mistake is expensive.

The theory predates the current AI cycle

Sexton's framing draws on "Language Modeling Is Compression," a paper published as an ICLR 2024 work. Its authors describe a long-established equivalence: predictive models can be converted into lossless compressors, while compressors can be used to construct predictive models.

The researchers tested foundation models as general-purpose compressors across text, images and audio. Their results showed that a model trained primarily on text could also identify useful statistical structure in other data types. The paper presented compression as a way to examine model scaling, tokenization and in-context learning through a common measurement: how much uncertainty remains about the next piece of data.

The equivalence needs a boundary. Sexton's article focuses on lossless compression, where every original symbol must be recovered. Lossy formats such as JPEG and MP3 can discard information according to a distortion target. LLM training also involves architectural choices, data selection, optimization and generation behavior that extend beyond the final entropy calculation.

Sexton handles the largest practical limitation directly. An LLM can make strong predictions, but using a large model to compress a small web response would consume far more storage and compute than gzip or Brotli. The model would also need to be available during decompression. Better compression ratios can lose their value when latency, memory use and deployment cost enter the calculation.

An AI education layer for a networking company

The subject fits ngrok's expansion beyond the localhost tunnel that established its developer following. Ngrok now describes itself as infrastructure for routing and securing traffic to applications, APIs and AI models. Its AI Gateway routes requests among hosted and self-hosted models through one endpoint, with access controls, failover and observability.

The compression article does not introduce an ngrok feature. It gives ngrok a way to teach developers how model probabilities affect compute, data movement and system design, the same audience ngrok needs to reach as it sells AI routing infrastructure.

Shreve built that audience before taking institutional capital. Ngrok says he grew the service to 5 million users before its first financing. On December 13, 2022, ngrok announced a $50 million Series A led by Lightspeed Venture Partners, with Coatue participating. Ngrok's current About page says 13 million developers have signed up, while its careers page describes a workforce of more than 70 people. Both figures are company-reported.

As ngrok moves from a developer utility toward a broader gateway business, technical education becomes part of its distribution. Sexton's article sells no compression product. It gives readers a usable mental model for a system they are increasingly expected to operate.

Reader comments

Conversation for this story loads after sign-in.