Charan | AI Journey · Tiny language model lab
#charan

What if an AI learned one character at a time?

This tiny browser-based model reads text character by character, learns which characters tend to follow other characters, then predicts the next character. Explore how tokenization, vocabulary IDs, training counts, and generation fit together.

01 · Feed text into the character tokenizer

Every letter, space, digit, and punctuation mark becomes its own token.
Character-level input
Character tokens0
Unique vocabulary symbols0
Vocabulary and character IDs:

02 · Train a tiny next-character model

This model counts which character follows each previous character in your sample.
Bigram model
1 · EncodeMap every unique character to an ID.
2 · CountCount adjacent character pairs.
3 · LearnEstimate likely next characters.
4 · GenerateSample one character at a time.
Unique character IDs0
Adjacent pairs learned0
Example ID mapping:
This is a small statistical model, not a modern neural LLM. It learns local character-to-character patterns from the text you provide.

03 · Predict the next character

Enter a starting prefix. The model uses learned counts to continue one character at a time.
Live generation
Generated textCharan ?
Possible next characters after the final character

04 · Why keep the vocabulary small?

Character tokenization can represent new words by reusing known characters.
Whole-word viewtokenizer
One token only if the whole word exists in its vocabulary.
Character-level viewt · o · k · e · n · i · z · e · r
Nine character tokens made from reusable symbols.
Trade-off: fewer vocabulary entries, but longer sequences. This bigram model is intentionally simple; neural character models can learn richer patterns but still process longer sequences.

Everything runs locally in this HTML file. Your text is processed in your browser and is not sent to a server.