tittle
tittle is a small model that puts punctuation, capitals and digits back into the lower-case words a speech recognizer gives you. It has 2M parameters, is an 8 MB ONNX file, and reads about 14,000 words a second on one CPU thread.
okay so i was born in nineteen eighty four and i still use an iphone every day is that strange
Okay, so I was born in 1984 and I still use an iPhone every day. Is that strange?
| Parameters | 2,039,691 |
| Input | Lower-case English words, cut into 3,999 word pieces |
| Output, per word | The mark after it, its case, its part in a number |
| Marks | comma, full stop, question mark |
| Cases | lower, Capital, UPPER, special spelling (iPhone, YouTube; 2,411 words) |
| Numbers | Whole numbers written in digits: 1984, 150, 300,000 |
| Pretrained weights in the model | None |
| License | Apache-2.0 |
Files
| File | Size | Contents |
|---|---|---|
tittle.pt |
4.1 MB | PyTorch weights, float16 |
onnx/model.onnx |
8.3 MB | ONNX export, float32, opset 17 |
pieces.txt |
The word pieces, one per line; the piece number is the line number, from 1 | |
spellings.json |
Special spellings: lower-case word to written form | |
config.json |
Model settings and the meaning of the outputs |
SHA256:
tittle.pt:abe852e2ea711f9a8ed29d4f5d43b4c527b0f7eb0fee2296ff69e1bb380e53daonnx/model.onnx:85607341f71c21aa63fc82d4f19381dba350ae3fc853f5370b0bdecf913ad637
Samples
Real output of the released weights. The input is the same text in lower case with no marks and with the numbers spelled out.
| Written by the model |
|---|
| What time is the meeting in New York tomorrow? Can you send me the link? I think I lost it. |
| I work at Google in San Francisco and I met Doctor Smith from NASA on Monday. She flew in from London. |
| We shipped it in 2026 and it cost ten dollars a month. There were 150 people in the room and one of them left early. |
| The company was founded in 1998 and now has 12,500 people in 40 countries. |
| She had never seen the sea before, and for a long while, she stood at the edge of the water without saying a word. Then she laughed, took off her shoes, and ran. |
| Call me at five or six and bring two or three friends. |
Usage
Python
pip install "tittle[torch] @ git+https://github.com/n4ze3m/tittle"
hf download n4ze3m/tittle --local-dir tittle
python -m tittle.infer --weights tittle \
--text "we shipped it in twenty twenty six and it cost ten dollars a month"
from tittle.infer import Punctuator
p = Punctuator.load("tittle") # Punctuator.load("tittle", onnx=True) needs no PyTorch
p.text("what time is the meeting in new york tomorrow")
# 'What time is the meeting in New York tomorrow?'
| Option | Meaning |
|---|---|
--text |
The words. Without it, and without --text-file, they are read from standard input. |
--text-file |
Read the words from a file. |
--onnx |
Run onnx/model.onnx with ONNX Runtime instead of PyTorch. |
--no-digits |
Keep numbers as words. |
Text of any length works. Marks, capitals and digits that are already in the text are taken out first.
ONNX
The graph takes word-piece numbers and returns three scores for every piece. Cutting words into pieces and writing the text from the scores happen outside the graph; the code below does both by hand for the marks and capitals.
import json
import numpy as np
import onnxruntime as ort
pieces = [line.rstrip("\n") for line in open("tittle/pieces.txt", encoding="utf-8")]
vocab = {piece: i + 1 for i, piece in enumerate(pieces)} # 0 is padding
longest = max(map(len, pieces))
spellings = json.load(open("tittle/spellings.json", encoding="utf-8"))
def cut(word): # longest match from the left; "β" starts a word
s, i, out = "β" + word, 0, []
while i < len(s):
for j in range(min(len(s), i + longest), i, -1):
if s[i:j] in vocab:
out.append(vocab[s[i:j]])
i = j
break
else:
i += 1
return out or [vocab["β"]]
words = "what time is the meeting in new york tomorrow".split()
ids, last = [], []
for word in words:
ids += cut(word)
last.append(len(ids) - 1) # the scores of a word are read at its last piece
session = ort.InferenceSession("tittle/onnx/model.onnx")
mark, case, number = session.run(None, {"tokens": np.array([ids], dtype=np.int64)})
mark, case = mark[0, last].argmax(-1), case[0, last].argmax(-1)
out, new = [], True
for word, m, c in zip(words, mark, case):
if c == 3:
word = spellings.get(word, word.capitalize())
elif c == 2:
word = word.upper()
elif c == 1 or new:
word = word.capitalize()
out.append(word + ["", ",", ".", "?"][m])
new = m >= 2
print(" ".join(out))
tittle.infer.Punctuator does the same and also writes the numbers, closes the
last sentence and reads long texts in windows.
| Input | Type | Shape | Meaning |
|---|---|---|---|
tokens |
int64 | [1, T] | Word-piece numbers; 0 is padding |
| Output | Type | Shape | Meaning |
|---|---|---|---|
mark |
float32 | [1, T, 4] | Scores for the mark after the word: none, comma, full stop, question mark |
case |
float32 | [1, T, 4] | Scores for the case: lower, Capital, UPPER, special spelling |
number |
float32 | [1, T, 3] | Scores for the word's part in a number in digits: none, first word, later word |
The outputs are scores before softmax. The largest difference between the ONNX file and the PyTorch model on random input is 4.8e-6.
JavaScript
The code repository has the same logic in two plain files, tittle.js and
numbers.js, for the browser and Node on top of onnxruntime-web. On 400
random texts they give exactly the same output as the Python code. The same
file has LiveWriter for captions that are still arriving.
Numbers
The model only decides which words are a number that should be written in digits. The digits come from fixed rules, and a run of words is converted only if the digits, read back, give the same words again. When the model marks words that are not a clean number, they stay as words.
| Words the model marked | What the rules write |
|---|---|
| nineteen eighty four | 1984 |
| twenty oh five | 2005 |
| one hundred and fifty | 150 |
| three hundred thousand | 300,000 |
| five or six | five or six (not one number) |
| ten dollars | 10 dollars (only "ten" is a number) |
Model
Each word is cut into word pieces by longest match against a list of 3,999 pieces (a SentencePiece BPE list, but the cutting needs no library). The pieces go through an embedding and 4 blocks; each block has self-attention with rotary position embeddings, a depthwise convolution over 7 pieces, and two feed-forward layers. Everything uses 128 channels and 4 heads. Three linear layers read the result at the last piece of every word. The model sees the words on both sides.
| Component | Parameters |
|---|---|
| Piece embedding | 512,000 |
| 4 blocks | 1,526,272 |
| Three output layers | 1,419 |
| Total | 2,039,691 |
Training
| Data | Manual English captions of YODAS, parts en000 to en005 |
| Words | 140,207,233 for training; 827,837 and 765,081 held out, split by video |
| Steps | 50,000, each with 256 pieces of 96 words |
| Optimizer | AdamW, learning rate 1e-3 with warm-up and cosine decay |
| Hardware | One RTX 3090, 1 hour 45 minutes, $0.42 |
Only videos with careful captions are kept: sentences of a sensible length, enough commas, capitals at sentence starts, a capital "I". The captions are then turned into what a recognizer would give: lower case, no marks, numbers read out as words. A number can be said in more than one way ("twenty twenty six", "two thousand twenty six"), so the usual reading is used two times in three and another reading otherwise. An exclamation mark counts as a full stop, a colon or semicolon as a comma.
In training, 3% of the words are swapped for random ones, as a recognizer makes mistakes, and "uh" and "um" are put in at random, because captions leave them out.
Evaluation
Scored on held-out videos against the captions as their authors wrote them: the first 200,000 words of the test set for marks and capitals, all 765,081 for numbers.
| Precision | Recall | F1 | |
|---|---|---|---|
| Comma | 60.6 | 49.0 | 54.2 |
| Full stop | 64.8 | 74.6 | 69.4 |
| Question mark | 63.0 | 65.9 | 64.4 |
| Capital | 81.4 | 80.2 | 80.8 |
| UPPER | 86.6 | 79.3 | 82.8 |
| Special spelling | 83.2 | 73.5 | 78.0 |
The captions come from many writers who do not agree with each other, above all about commas and about where a spoken sentence ends, so these scores have a ceiling well below 100.
Numbers, counted as right only when the same digits stand at the same word as in the caption:
| Numbers written in digits in the captions | 4,125 |
| Found by the model | 89.8% |
| Right, of those the model wrote in digits | 85.4% |
Numbers of two or more words are almost always found. Most misses are single numbers below ten, which captions sometimes write as a digit and sometimes as a word.
With only a few words of look-ahead, as in live captions (F1):
| Words of look-ahead | Comma | Full stop | Question mark | Capital |
|---|---|---|---|---|
| 0 | 22.1 | 27.1 | 37.5 | 74.3 |
| 1 | 48.2 | 60.1 | 57.6 | 77.6 |
| 2 | 49.8 | 64.6 | 63.6 | 80.6 |
| 4 | 53.5 | 67.2 | 64.8 | 77.9 |
| 8 | 54.1 | 67.2 | 64.3 | 81.3 |
| 16 | 55.5 | 69.8 | 71.3 | 79.0 |
Four words of look-ahead give nearly the full score, which is why LiveWriter
fixes a word's marks four words behind the speaker.
Speed, 20,000 words on one cloud machine (AMD EPYC, 8 virtual CPUs):
| Runtime | Words a second |
|---|---|
| PyTorch, 1 thread | 14,400 |
| PyTorch, 4 threads | 20,000 |
| ONNX Runtime, default threads | 33,500 |
Limitations
- English only.
- Commas are the weakest mark.
- Three marks only: comma, full stop, question mark. No exclamation marks, colons, quotation marks or dashes.
- Whole numbers only. Money, decimals, percentages, times and ordinals stay as words, and so do most single numbers below ten.
- Large round numbers come out in full: "forty million" is written 40,000,000.
- Some sentences can be read two ways: "one twenty dollar bill" may come out as "120 dollar bill".
- A name the model has never seen gets a capital only when the words around it make that likely.
- It learned from video captions, so it suits speech better than formal writing. It has not been tested on other kinds of text for this card.
- In
LiveWriter, a number of which the model marks only a part ("one hundred and 50") is not repaired as it is for finished text.
Support
It cost less than a coffee to train. If you like it, you can buy me one: https://ko-fi.com/n4ze3m
License
The weights and code are released under Apache-2.0. The training text is from
YODAS (CC BY 3.0); pieces.txt
and spellings.json are word lists derived from it.
Citation
@software{nazeem2026tittle,
author = {Nazeem, Muhammed},
title = {tittle: a 2M-parameter model for punctuation, capitals and digits in speech transcripts},
year = {2026},
url = {https://huggingface.co/n4ze3m/tittle}
}
Author: Muhammed Nazeem (ORCID 0009-0002-9991-0217).
- Downloads last month
- -