← back to cult

cult / how it works

tl;dr

You give us a cultural work. We turn it into a vector. We find a short, signed combination of more famous works whose vectors sum to roughly the same place. The result reads like an equation, e.g.

The Wire ≈ Breaking Bad + The Sopranos − Game of Thrones

Everything runs in your browser. No server, no API key.

The pipeline

Five stages:

  1. Curate. A static list of ~750 ubiquitously famous works lives in basis.js (movies, books, TV, games, comics, manga, albums, musicals, franchises).
  2. Embed the basis (in CI). A GitHub Action runs whenever basis.js changes, downloads the embedding model on the runner, turns each title into a 384-dimensional unit vector, and commits the result back as basis.bin (raw Float32 matrix) and basis.json (titles + metadata).
  3. Ship. The browser fetches the prebuilt artifacts (~1.1 MB total) and parses them straight into a Float32Array. No model needed yet.
  4. Embed the query. The model loads in the background as soon as the basis is ready. Your input goes through the same model.
  5. Decompose. A greedy sparse-coding pass picks a handful of basis vectors (with positive or negative signs) whose weighted sum lands closest to your query.

If the prebuilt artifacts are missing (e.g. during local development), the browser falls back to embedding the basis itself and caching the result in IndexedDB.

The model

We use Xenova/all-MiniLM-L6-v2 via transformers.js. It's a sentence-transformer trained to map similar phrases to nearby points on the unit sphere.

384dimensions
~25 MBquantized weights
~1.1 MBprebuilt basis matrix
~1 ssubsequent loads

The model loads from jsDelivr's ESM CDN and runs entirely in WASM/WebGPU. The basis matrix is fetched once over HTTP and parsed straight into a Float32Array; the browser caches both via standard HTTP cache headers. Nothing leaves your device — your query is embedded locally and the dot products run in plain JS.

The basis

The dictionary is hand-picked for name recognition rather than orthogonality. Roughly:

The bias is intentional: the goal is decompositions that read well. "Severance ≈ Black Mirror + The Office" is funnier and more useful than the same answer with three obscure short stories you've never heard of.

The math

Given a query vector q and a dictionary of N unit-norm basis vectors b₁ … b_N, we run matching pursuit: a classic greedy sparse-coding algorithm.

# initial residual is the query itself
r ← q
chosen ← []

# up to 4 iterations
for step in 1..K:
    # find the basis vector most aligned with the residual
    i* ← argmax_i |⟨r, b_i⟩|
    c  ← ⟨r, b_i*⟩          # signed coefficient

    # subtract its contribution from the residual
    r ← r − c · b_i*
    chosen.append((i*, c))

    # block near-duplicates so we don't pick "Star Wars" twice
    block all j where ⟨b_i*, b_j⟩ > 0.85

Three small twists make the output readable:

Reading the output

The equation

Terms are sorted by absolute coefficient (strongest contributor first). A + means the basis vector points in the same direction as the residual at that step; a − means it points opposite.

Hover any term to see its category and exact coefficient. Click a term to decompose that work next.

Cosine fit

The fit % reports how close the reconstructed vector Σ cᵢ · b_i is to your query, in cosine similarity. 100% would mean a perfect linear combination; in practice 60–85% is typical and makes for the best-reading equations.

What "−" actually means

Subtraction is the model saying: "your title is a lot like X but minus the Y-ness of it." Useful negatives often capture genre or tone differences — e.g. a slow horror film might come out as The Shining minus Psycho (slow horror ≈ canonical horror minus jump-scare snappiness).

Honest limitations

Why?

Cultural recommendation engines tend to give you nearest neighbors: "if you liked X, try Y." This is the inverse — given the work, can you describe it as a sentence in the language of things everyone already knows? The output is closer to a critic's opening line than a recommendation.

It's also a quick test of an underappreciated property of embedding spaces: they're approximately additive over short distances. Pop culture happens to have enough mass and structure that you can do meaningful arithmetic on it.