Vahini Playground

How does a pen read handwriting?

Draw a letter or pick a real one: see what the pen feels, what the AI does and what it answers. Every answer is a real result on people the AI never learned from.

Read
Writer ?
Hand

1How the pen works simulation

Give the AI one character, one of two ways. The pen feels movement, not ink.

ADraw it draw every part, then press Recognize

draw a, h, n, O, S…

BOr pick a real recording the dot says how the AI did

2How the AI works practice signal

  1. Clean
  2. CNNspots short strokes
  3. BiLSTMreads them in order
CNN-BiLSTM run
Learned from

3What it answers

Draw a character or press Recognize.

Everything about this recording: all sensors, raw numbers, the 5 runs, the code

What the pen felt

Raw sensor numbers

Raw sensor counts; g and °/s use the conversions in imu2text/filters.py (the gyroscope one is inferred).

What each of the 5 runs said

For developers: choosing a recording
For developers: the signal
For developers: the model

How it works

1. The pen feels, it does not see

Sensors in the pen record how it moves, turns and presses, 100 times a second. Nothing records where the ink goes. The AI has to work out the letter from movement alone.

2. The AI learned from examples

It was shown about 20,000 letters with the right answer, and learned which movements go with which letter. Then it was tested on people it had never seen, which is the fair test for a new pen owner.

3. Small or capital is hard

A small o and a capital O are the same movement at a different size, and the pen barely feels size. 43% of the AI's mistakes are exactly this. Ignoring small and capital, it reads 84.3% right.

4. Five heads are better than one

Five copies of the AI were trained separately and vote together. Together they read 74.46% right; one alone reads 72.18% on average. When they disagree, it is a sign the writing is unusual.

Seven ideas, in motion

The words that trip people up on this page, each as a short loop. The drawings are sketches, not recordings; every number written in them comes from a real run. The glossary below has the one-line meanings.

Offline and online handwriting

a photo: pixels Offline: a scan or photo of finished ink The shape only. Which stroke came first is lost. Examples: a scanned exam, a cheque, a photo of a note. 1 2 3 points in order x 44 y 64 t 0.00 s x 30 y 60 t 0.05 s x 76 y 64 t 0.42 s x 96 y 50 t 0.90 s Online: the pen tip, point by point Where the tip is, in writing order, with time. Examples: a stylus on a tablet or phone screen. movement over time 13 sensor signals, 100 a second Online, with a sensor pen: this page Ink on real paper; the pen feels how it moves. No camera, no tablet, and no x, y position.
OnHW stands for online handwriting: every recording here is the third kind. Online data keeps the order and speed of the strokes, which the shape alone does not have, but the sensor pen has to work out the letter without ever knowing where the tip is.

Writer-independent and writer-dependent

4 writers Training Test Writer-dependent ("familiar people") Everyone is on both sides. 80.07% right. never trained on Writer-independent ("new people") The test writer is kept out, like a new pen owner. 72.46% right.
Official OnHW-chars split, 52 classes, one model. New people is the fair test, and the one the scores on this page use.

Uncertainty: when five runs disagree

run 1 run 2 run 3 run 4 run 5 aaaaa They agree: "a" Trust the answer. adqao They disagree: the writing is unusual Unlike the letters they learned from. Ask the writer. o|Oo|Oo|Oo|Oo|O All hesitate between o and O The movement fits both. Asking again will not help. bar = how sure the five runs are together
Five runs voting read 74.46% right, against 72.18% for one run on average. See uncertainty and ensemble.

Left-handed writers

Right hand pulls → Left hand pushes → same letter, different signal 74.92% right-handed 59.47% left-handed
Most training letters come from right-handed people. The same five runs, trained with the 9 left-handed writers added, read 59.47% of left-handed letters right (417 letters, a split of those 9 writers made here, so not a published benchmark).

Small or capital

o grows into O small and capital: the signals almost overlap 43% of mistakes: a letter read as its other case Ignore small and capital and the AI reads 84.3% right.
The pen feels movement, not size. A bigger O is also written faster, so the acceleration the pen feels comes out about the same.

Why it gets it wrong: missing what?

SensorDataAlgorithm writtenc → the AI readC Missing: position. The sensor cannot feel size. The pen feels movement, not where the tip is, so c and C look alike. More data or a bigger AI cannot add what the pen never measured. 43.1% of letter mistakes are this. SensorDataAlgorithm writtena → the AI readd Missing: examples. Too few writers like this one. Only 9 left-handed people are in the data, so the AI has seen few hands like theirs: 59.47% right, against 74.46% for right-handed people. More writers would help here. SensorDataAlgorithm writtenging → the AI readsing Missing: method. The algorithm can do better. The word reader is small and trained for 15 rounds; it gets 8.9% of words exactly before the word list. A published reader on the same words reaches 7.37% letter errors.
The fix depends on what is missing. A sensor limit needs a different signal or the word around the letter; a data limit needs more writers; a method limit needs a better model or training. The examples are typical mistakes; the numbers are from Why is it not 99%? (the published reader is Li et al., iWOAR 2025, OnHW-words500, new people).

What made it more accurate, and what did not

75% 60% What helped: changes that stop it memorising CNN-BiLSTM, plain69.2% + stretched and shaken copies (augmentation)70.0% + attention70.9% + label smoothing, learning-rate schedule72.5% 5 runs voting (ensemble)74.46% What did not: a bigger model, or masking CNN-BiLSTM, plainlearned 90.1% of training69.2% Bigger: 2 BiLSTM layers of 100learned 95.5%69.6% Bigger + every trick abovelearned 99.2%70.4% Ignore the padding (masking), 4 runs+0.22: no clear gain72.67% The bigger model learned almost every training letter, yet read new people only 1.2 points better than plain.
Writer-independent (new people), official OnHW-chars split, 52 classes, one run each, seed 0, fold 0; the voting row is five runs, and the masking row is a mean of four runs against 72.45% for the same four without it. The bars start at 60% so the steps are visible. The next gain is not a bigger model: 43% of the mistakes are small or capital, which the pen barely feels.

How CNN, LSTM and hybrid neural networks read handwriting

The deep learning behind this page, one idea per loop: what a neural network is, how a CNN and an LSTM read a pen signal, what attention adds, and how the hybrid used here puts them together. The drawings are sketches; the sizes and scores are this project's.

What is a neural network?

sensor valuesneuronsletter scores accgyromagforceado Reading: numbers in, scores out Each neuron adds up its inputs, each times a learned weight. Learning: the right answer was "d" The error flows back and nudges every weight toward "d".
The networks on this page learned from about 20,000 letters with their right answers, 30 passes over them. Nothing is programmed letter by letter: the weights are all learned.

What is a CNN (convolutional neural network)?

a filter: one small pattern where it matches The same filter slides along the whole signal and lights up wherever its pattern appears, early or late.
The CNN here has 64 filters, then 128, each 3 time steps wide, and halves the number of steps twice. It finds strokes; it does not know which stroke came first. See CNN.

What is an LSTM, and a BiLSTM?

the signal, moment by moment t1t2t3t4t5t6 memory carried forward a loop is stored still known at t5 LSTM: reads in order and remembers Gates decide what to keep, forget and add at each moment. forwards backwards BiLSTM: one reads forwards, one backwards Each moment sees what came before and what comes after.
LSTM means long short-term memory. The model here has one BiLSTM layer with 64 memory units in each direction. See BiLSTM.

What is attention?

how much each moment counts crossbar loop Attention scores every moment, then averages by those scores, so the moments that matter count most.
The scores are learned, not set by hand. With augmentation, adding attention took new people from 70.0% to 70.9% (official OnHW-chars split, 52 classes, seed 0). See attention.

A hybrid: CNN, then BiLSTM, then attention

each part does what the others cannot Signal13 × 100CNNstrokesBiLSTMorderAttentionwhat countsAnswer"A" CNN: short shapes. BiLSTM: their order. Attention: which moments decide the letter. Together: 72.46% of letters from new people
This is the design behind the answers on this page. The plain CNN-BiLSTM, without attention or the training changes, read 69.2% on the same test (official OnHW-chars split, 52 classes, seed 0); Ott et al. (ACM MM 2022) report 68.06% for theirs.

Compare the algorithms

Hover or tap a bar for its source. Every score is letters read right on the same test.

Which algorithm reads best?

Four designs, one small set

The left-handed OnHW-chars_L set, 2,270 letters, with writers shared between training and test. Only good for comparing these four with each other.

Training curves for every algorithm

Curves, calibration and mix-ups per algorithm appear here once each design is trained on the same test. That is an open task: it takes hours on a CPU.

bash scripts/run_algorithms.sh data/onhw-chars_2021-06-30

How sure is the AI?

The CNN-BiLSTM ×5 vote on all 7,956 test letters from new people. Hover or tap a point to read it. Method and papers: docs/uncertainty.md.

Does "80% sure" mean 80% right?

Let it say "not sure"

Which letters is it least sure about?

What gets mixed up with what?

Left-handed writing puzzles the runs

Why is it not 99%?

The pen cannot feel size

A small c and a capital C are the same movement, bigger. The pen measures speed and turning, not position, and capitals are also written faster, so the signals nearly match. 43.1% of the mistakes are this mix-up; ignoring small and capital, one CNN-BiLSTM reads 84.34% of letters from new people right instead of 72.46%.

New people write differently

Everyone has their own habits. For numbers and symbols, the same design reads 94.71% when it has seen the writer before and 71.03% for new people.

Few left-handed examples

Most training letters come from right-handed people. For new left-handed people the 5-run vote reads 59.47%, against 74.46% for right-handed people.

Words run together

In a word the model also has to find where each letter starts and ends. The word model here trained for only 15 rounds and reads 40.78% of words exactly.

Be careful with 99%

A model tested on the same people it learned from can score near 99% and still fail on a new writer. Every score on this page is on people the model never saw, unless it says "familiar people".

Questions to think about

These are open in this repo. Pick one, try it, and share what you find.

  1. The pen cannot feel size. What else could tell c from C? A capital often starts a word. Would reading the whole word help? Start: imu2text/seq2seq.py
  2. Left-handed people often push the pen where right-handed people pull it. Could flipped right-handed recordings work as left-handed practice data? Start: imu2text/augment.py
  3. When the 5 runs disagree, should an app ask the writer to write again? How much disagreement is too much? Start: the developer notes under step 3
  4. Which sensor matters most? Train without the magnetometer, or without the force sensor, and compare. Start: imu2text/models.py
  5. How many writers are enough? Does accuracy keep rising with every new person, or does it level off? Start: scripts/make_learning_curve.py
  6. Which cleaning filter would you design? Try it on step 2 and see if the AI reads better. Start: playground/stages.js

Results behind the page

Every number is in docs/benchmarks.md with how it was measured.

WhatWritten byAIRead right
Letters (52: small and capital)new people5 models together74.46%
Lettersnew left-handed people5 models, also learned from left-handed people59.47%
Numbers and symbols (15)new peopleone model71.03%
Numbers and symbols (15)familiar peopleone model94.71%
Wordsnew peopleword reader with a word list40.78% of words exactly

Not built yet

Each card is an open piece of work. Pick one, and the playground shows your result next.

Why a CNN-BiLSTM? The other AI designs

The other ways to read a pen recording, what each scored, and why this page uses a CNN-BiLSTM. Open to read.

A pen recording is a short time series: 13 numbers, 100 times a second. Each design below reads it differently. Scores are letters from people the model never saw, unless the row says otherwise; "not measured" means nobody has run it on this data in this project yet.

CNN 48.7%*

Slides small windows along the signal and spots short patterns, like a quick upstroke.

Good when You need speed or a small chip.

CNN-BiLSTM 72.46%

The design on this page. The CNN finds the strokes, the BiLSTM joins them in order, attention picks the moments that matter.

Good when Little data, short signals. The design Ott et al. benchmark on OnHW.

Here 72.46% on the official test, 74.46% as a 5-run vote; 64.8%* on the left-handed split

LSTM, BiLSTM 43.8%* · 56.2%*

Reads the signal in time order and remembers what came before. A BiLSTM also reads it backwards.

Good when Order matters more than shape.

Transformer built

Every moment looks at every other moment through attention; no reading order.

Good when Much more data than OnHW has.

Mixture of experts built

Several small models, the experts, plus a router that sends each recording to the experts that suit it.

Good when Writers differ a lot, for example left- and right-handed.

Here built (build_moe), not measured

CNN-GRU not measured

A GRU is an LSTM with fewer parts. It learns the same kind of order.

Good when You want a smaller, faster model.

CNN-GNN no fair test yet

Treats the 13 sensors as connected points and learns how they relate.

Good when Sensors that move together carry the signal.

CNN-MLP not measured

After the CNN, a plain layer looks at everything at once and forgets the order.

Good when Very short, simple shapes.

Autoencoder not measured

Learns to squeeze a recording and rebuild it, without any labels.

Good when You have many recordings but few with answers.

VAE or GAN not measured

Learns to make new, realistic recordings.

Good when A group is rare in the data, like left-handed people.

Hybrid quantum not measured

A small quantum circuit does part of the work, for example the filter of a CNN, and a normal network does the rest.

Good when Research only so far. Zaman et al. (2024) compared three such designs on 4 handwritten digits, 100 to 500 training images, on a quantum simulator.

DBN not measured

An older stack of layers trained one at a time, from before CNNs and LSTMs took over.

Good when Mostly of historical interest.

* Left-handed OnHW-chars_L, 2,270 letters, a split that shares writers between training and test, so these four are only comparable with each other. The official-test figures are right-handed OnHW-chars, 52 classes, seed 0. Details in docs/benchmarks.md.

Bigger is not better here

A larger BiLSTM (2 layers of 100) scored 99.2% on its own training letters and 70.4% on new people. It memorised. The smaller one with the same tricks did better on new people.

Combine, then vote

Training the same design 5 times and averaging lifts letters from new people from 72.18% (one run, on average) to 74.46%. A vote of different designs, say a CNN-BiLSTM and a Transformer, has not been tried.

Worth trying

A CNN in front of a Transformer, as speech models do. An autoencoder trained on unlabelled recordings first, then taught letters. A router that sends each recording to one of several small experts (build_moe is in the code, not measured).

Glossary

Plain meanings of the words on this page. Open to read.

Short, plain meanings of the words on this page, in five groups. The coloured row in each group is the word to know first. More detail in docs/glossary.md.

Sensor pen (IMU)
A pen with motion sensors inside. IMU means inertial measurement unit: sensors that feel movement.
Recording or sample
One letter, symbol or word as a table of sensor numbers over time.
Accelerometer
Feels speeding up, slowing down and gravity, in three directions (x, y, z). This pen has two, front and back.
Gyroscope
Feels how fast the pen turns.
Magnetometer
A compass: feels the Earth's magnetic field, which changes as the pen points another way.
Force sensor
Feels how hard the tip presses on the paper.
Filter
A way to clean a signal before the AI sees it, for example smoothing out fast wiggles.
Model or neural network
The AI: a program that learned from examples which movements mean which letter.
CNN-BiLSTM
The AI design used on this page. For letters and symbols: a CNN, then a BiLSTM, then attention. The word reader is a CNN and a BiLSTM.
CNN
The part of the model that spots short movement patterns, like a quick upstroke.
BiLSTM
The part that reads the movement in time order, forwards and backwards, to connect the strokes.
Attention
Lets the model weigh the moments of a recording that matter most.
GRU
A simpler LSTM. It remembers what came before with fewer parts, so it is smaller and faster.
Autoencoder
A model that learns to squeeze a recording and rebuild it. It learns without answers.
Transformer
A model where every moment of a recording looks at every other moment. It needs a lot of data.
VAE
Variational autoencoder: an autoencoder that can also make new, realistic recordings.
GNN
Graph neural network: treats things, here the 13 sensors, as points connected to each other.
Mixture of experts
A team of small models. A router picks which of them answers each recording.
Hybrid quantum network
A network where a small quantum circuit, today usually simulated on a normal computer, does one step.
Training and testing
Training is learning from examples with answers. Testing is checking on examples the model never saw.
New people
Test writers who were not in the training data. Also called writer-independent. The fair test for a new pen owner.
Familiar people
The same people appear in training and test, so the model already knows their handwriting. Also called writer-dependent. Scores are higher.
Epoch or training round
One pass over all training letters. Training here runs 30.
Validation letters
Letters from training writers held back to check progress while training. The test people stay unseen.
Seed
The random starting point of training. The same design trained from 5 seeds gives CNN-BiLSTM #1 to #5.
Ensemble ("all 5 together")
Several models answer, and their scores are averaged into one answer.
Augmentation
Making extra training examples by slightly stretching or shaking real ones.
CTC
A training method that lets a model spell out a word without being told where each letter starts.
Confidence
How much of its score the model gives to an answer. 90% means it is quite sure.
Accuracy
The share of test samples read correctly.
Uncertainty
Two kinds. If the 5 models disagree, the writing is unlike what they learned from. If all hesitate between the same two answers, the movement itself fits both.
Calibration
Whether "80% sure" really means right 80% of the time. The calibration gap is how far off it is on average (ECE).
Entropy (bits)
How spread out the AI's scores are. 0 bits: all on one letter. Higher: it hesitates between several.
Disagreement (mutual information)
The part of the doubt that comes from the 5 runs giving different answers.
Confusion matrix
A grid of which letter was written (rows) and what the AI read (columns). Off the diagonal are mistakes.
Word list (lexicon)
A list of allowed words. The model scores every word on the list and picks the most likely one.
Character error rate (CER)
How many letters are wrong, as a share of the word's length. Lower is better.