Formatter
post-ASR text cleanup
2 min readupdated
This model automatically cleans up speech-to-text transcripts (such as Whisper output) for English and Portuguese. It strips out filler words, false starts, and mid-sentence self-corrections while restoring punctuation—classifying each word individually instead of rewriting the whole text. Built on the lightweight Multilingual-MiniLM-L12-H384 backbone (~117M parameters), it runs directly on a CPU. It is designed for local voice notes and dictation tools where speed matters and running a heavy LLM isn't practical.
Key features
- Fast inference: processes 60 words in just 30–50 ms on a standard laptop CPU.
- Token classification: assigns each word one of 5 labels (drop or keep with the right punctuation), eliminating hallucinations and word substitutions.
- Trained on synthetic data: trained on a dataset of 135k+ examples simulating natural spoken disfluencies.
- Lightweight: runs locally with no need for a powerful GPU.
What you can do
- Clean up dictation: plug the model into a local script to post-process transcribed audio recordings.
- Voice typing: use it in desktop voice-input apps or bots to quickly filter out spoken clutter.
Example
import torch
from transformers import AutoModelForTokenClassification, AutoTokenizer
repo = "guihassen/formatter"
tokenizer = AutoTokenizer.from_pretrained(repo)
model = AutoModelForTokenClassification.from_pretrained(repo).eval()
words = "compre o bolo na verdade não compre a torta".split()
encoding = tokenizer(words, is_split_into_words=True, return_tensors="pt")
with torch.no_grad():
predictions = model(**encoding).logits.argmax(-1)[0].tolist()
labels, previous = [], None
for position, word_id in enumerate(encoding.word_ids()):
if word_id is not None and word_id != previous:
labels.append(model.config.id2label[predictions[position]])
previous = word_id
print(list(zip(words, labels)))
Read more
DetailsArchitecture: Multilingual-MiniLM-L12-H384 (12 layers, hidden size 384).
Metrics: validation macro F1 is 0.921, with 97.8% accuracy on filler removal.
Limitations: supports only English and Portuguese, does not fix spelling errors within words, and struggles with rare pause patterns.










Comments