01 UNDER THE HOOD

How does SOL work?

Each corpus is a distribution of texts, and each text a distribution of tokens. Double slicing turns this nested optimal transport problem into many one-dimensional ones, each solved exactly by sorting.

Reference corpus

5,000 text sequences

Generated corpus

5,000 text sequences

The OWT benchmark uses 5,000 sequences per corpus. Scroll on to follow 6 synthetic sequences per corpus so every one stays visible.

One sequence = one text sample. See its tokens.

A sequence can be a sentence, a passage, or a fixed-length chunk. For example:

Small birds fly across the quiet lake as the sun rises.
Smallbirdsflyacrossthequietlakeasthesunrises.

A token can be a word, part of a word, or punctuation. This token split illustrates the idea; the plotted positions are synthetic.

One dot → one token state
The encoder represents each token with a vector that depends on its context.
One cloud → one sequence
Keep all token states from one text sample together in one cloud.
One corpus → many sequences
Green cards R1–R6 form the reference corpus. Pink cards G1–G6 form the generated corpus.

Select a sequence here or in the plot. Its label stays with it through all four steps.

  1. 01
  2. 02
  3. 03
  4. 04
  5. 05
  6. 06
  7. 07
  8. 08
  9. 09

STEP 01 / 09

Two corpora of texts.

A reference corpus and a generated corpus, each a collection of text sequences. The OpenWebText benchmark uses 5,000 per side; here we follow six per corpus.

Scroll to move through the method. The picture follows your reading position.

STEP 02 / 09

Embed every token in ℝᵈ.

The encoder maps each token to a contextual hidden state, so each text becomes a cloud of token states. One labeled cloud stands for one sequence.

Here d = 2 so the clouds can be drawn. GPT-2 Large uses d = 1,280 and Dream 7B uses d = 3,584.

STEP 03 / 09

Pick one direction ξ.

Draw a unit direction ξ uniformly from the sphere. Every sequence in both corpora is sliced along this same direction.

SOL repeats the whole construction for many directions and averages the results.

STEP 04 / 09

Project the tokens.

Each token state moves perpendicularly onto the line through ξ. Its position along the line, ⟨ξ, hᵢ⟩, is now one number.

STEP 05 / 09

One distribution per sequence.

The projected values of each sequence form a one-dimensional distribution: one row per sequence, R1–R6 and G1–G6, on a shared scale.

This is the first slice. Every sequence keeps its own identity.

STEP 06 / 09

Sort into a quantile curve.

Sorting a row gives its quantile function Q: the rank of a token sets the fraction u, and its value sets the height Q(u).

Each dot lands on its sequence’s curve. The 12 curves share one set of axes.

STEP 07 / 09

Integrate against g.

A Gaussian-process draw g turns each curve into one number. This second slice leaves each corpus with six scalars, one per sequence.

μᵢ is the token distribution of sequence i; M maps it to one number.

STEP 08 / 09

Sort and match.

The two sets of scalars form a one-dimensional optimal transport problem. It is solved exactly by sorting, in O(n log n): match the values by rank and add the squared gaps.

Matching follows rank, so R1 can meet any G sequence.

STEP 09 / 09

Average over many slices.

Repeat for many directions ξ and functions g, average the transport costs, multiply by the hidden dimension d, and take one square root.

μ and ν are the reference and generated corpora.

Toy SOL · both corpora
+

Lower distance. Closer distributions. SOL compares both the content of individual texts and the variety across a corpus.

Explore the math ↗

02 MEASURED EXAMPLES

How does SOL behave?

Three controlled comparisons: sampling temperature, context length, and the news topics a corpus covers.

Click or drag across the plot to inspect a setting. Arrow keys also work.

Loading measured examples…

Corpus excerpt · GPT-2 Large · first saved document
Values, protocol, and uncertainty

Measured distances

Download all values (CSV) ↓ · Data and source hashes (JSON) ↓ · AG News protocol and provenance ↓

See the OpenWebText leaderboard →
PASS IT ON

Cite SOL

@misc{kornhardt2026solmeasuringgapstext,
      title={SOL: Measuring Gaps between Text Distributions by Double Sliced Wasserstein Metrics},
      author={Gregor Kornhardt and Moritz Piening and Jannis Chemseddine and Gabriele Steidl},
      year={2026},
      eprint={2610.06513},
      archivePrefix={arXiv},
      primaryClass={cs.CL},
      url={https://arxiv.org/abs/2610.06513},
}