# Letters · Malte Therkildsen

> Letters is a network that learns the lowercase alphabet of Inter in your tab, on the graphics card through WebGPU, with no library. Every letter on the page is its output.

Source: https://therkildsen.dev/projects/letters

SoftwareCaseP41

  A network learns the alphabet in this tab.

# Letters

      0steps a second

      0points a second

      Pause
      Start the network

The network starts when this plate is in view

This plate needs WebGPU or WebGL 2, and this browser has neither.

    01
    **The letter, as the network draws it**
    The network trains on the graphics card while this plate is in view, and the page walks through the alphabet. Drag the letter to move it, or type a letter to go to it.

    WebGPUWGSLNo library[Open Letters](https://therkildsen.dev/lab/p41-letters/)

For each pixel on that plate the network outputs one number: the distance to the letter's edge.

    02
    **The levels of one table, at actual size**
    Each square is one level of the table for the letter a, at the size of the reference the network learns from. A filled cell is one whose centre is inside the letter.

    Multiresolution hash encoding

The small network behind the tables is shared by every letter, so the whole alphabet learns at once.

      Between two trained weights the page mixes the network's outputs for the two nearest.

    03
    **Every letter, one network**
    Each letter in the row is drawn by the network for each pixel, like the letter above. Move the weight and every letter moves with it. Press a letter to send the plate above to it.

    Inter[The typeface](https://rsms.me/inter/)

The references are the judge. Each step compares the network's distance with theirs at thousands of points.

      0.000

      mean squared error of the last step

    04
    **The judge**
    The letter moves into this plate in the Error view. Colour marks where the network's distance differs from the reference near the edge, and the line is the network's edge.

    `node --test web/identity/letters-case/letters-case.test.mjs`

The weights live only in this tab. The next plate throws them away.

      0steps since the last new weights

      New weights
      Sets every weight to a random number. The letter is lost at once, and the lines of the field show it come back as the network trains again.

    05
    **Throw the weights away**
    The Field view draws every level of the distance as a line, so the shape of the whole field shows, inside the letter and around it.

    Adam

Letters learns the lowercase alphabet of one typeface. The last plate says what else a font would need.

## Has

- **The lowercase alphabet of Inter** At five weights, from Thin to Black.

- **Distance fields** The network learns a distance for each point, so the edge stays sharp at any zoom.

- **Training on the graphics card** Four compute shaders a step, written by hand in WGSL.

- **A reserve for browsers without WebGPU** A smaller network trains one letter at a time on the processor.

## Does not have

- **Capitals, figures and punctuation** The tables are sized for the lowercase alphabet.

- **A second typeface** Each reference is set in Inter in this tab.

- **Outlines** The output is a field, and a font file needs curves.

- **Saved weights** A reload starts from random numbers again, and nothing goes to a server.

    06
    **What was left out**
    The tables follow the multiresolution hash encoding by Müller, Evans, Schied and Keller. The Lab page explains each step of the training.

    [How it works](https://therkildsen.dev/lab/p41-letters/)

[
  Next case
  Language
  A small language model that learns to write in the page
](https://therkildsen.dev/projects/language)
