The Learning Oracle: a magic 8-ball you can teach

Twenty-five words, one tiny network (75 inputs → 24 hidden neurons → 26 outputs), and your thumbs. The first three demos learned from examples you handed them. This one talks back, one word at a time, and learns from how you rate what it says: the idea behind training a chatbot on human feedback, shrunk to a word list.

1 · Ask

Mode:
Classic mode is pure chance: one of the twenty stock answers, picked at random. Nothing about your question reaches the answer, and rating it would change nothing, so there are no thumbs here. Switch to Learning Oracle.

2 · Curate the training data

This is the Oracle's training data. Some of these pairs make sense, some are word salad. Mark the ones that feel like a good answer to the question, the same way you picked the happy faces, then retrain. The Oracle learns only from what you approved.

3 · Vocabulary and corpus

The Oracle's entire world is this word list. Change it, and every question and answer has to be built from the new words. Corpus lines are question => answer; any line with a word that is not in the vocabulary is dropped.

How it works

Classic mode. Twenty fixed answers, one picked by Math.random(). Nothing about your question reaches the answer. Nothing you do can change it.

Learning mode. The Oracle is a real neural network, trained in your browser the moment the page loads. It never sees whole sentences; it only ever answers one question: given the question, and the last two words I said, what word comes next? It says a word, feeds it back in, and repeats until it picks [end].


      

Training means showing it the approved question/answer pairs over and over and nudging every weight a little in the direction that makes the right next word more likely. Each pass over the data is an epoch; the loss curve shows how surprised it is by its own training data.

Thumbs. A thumbs up takes the exact answer it just gave and runs six extra training steps on it, so those words become more likely for that question. A thumbs down runs six steps the other way, pushing each chosen word's probability down. That is the whole idea behind training chatbots on human feedback, shrunk to twenty-five words.

Why answers wander. The Oracle samples from its probabilities instead of always taking the top word, so the same question can get different answers. “Ask 10×” shows that spread. Feedback does not flip a switch; it tilts the odds.

The math, in one screen
// forward: question words + last two words said → 24 hidden neurons → 26 probabilities
h[j] = tanh( b1[j] + Σ_i x[i] · W1[i][j] )
z[k] = b2[k] + Σ_j h[j] · W2[j][k]           p = softmax(z)       // one probability per word, plus [end]

// training: cross-entropy on the next word, the same "predicted minus correct" line as the other demos
dz[k] = p[k] − (k === target ? 1 : 0)

// thumbs up:   6 steps of the line above on the answer it just gave (make those words MORE likely)
// thumbs down: 6 steps with the sign flipped and the step clipped (make those words LESS likely)
dz[k] = s · ( (k === target ? 1 : 0) − p[k] ),   s = min(p[target] / (1 − p[target]), 4)

Things to notice: in Classic mode your question never matters. In Learning mode the same question gets different answers because the Oracle rolls dice weighted by its probabilities. One thumbs up can swing the Ask 10× tally from an even split to nineteen-to-one; one thumbs down swings it back. And the Oracle cannot say a word that is not in its vocabulary, no matter how it is trained.

The Oracle's whole vocabulary

in your current question