This model corrects OCR errors in Swedish text.
This model is a fine-tuned version of
byt5-small, a character-level multilingual transformer.
The fine-tuning data consists of OCR samples from Swedish newspapers and historical documents.
The model works on texts up to 128 UTF-8 bytes (see
Length limit).
The base model byt5 is pre-trained on
mc4. This fine-tuned version is further trained on:
This data includes characters not used in Swedish today, such as the long s (ſ) and the esszett ligature (ß), which means that the model should be able to handle texts with these characters.
See for example the example titled Long-s piano ad in the inference widget to the right.
Use the code below to get started with the model.
1from transformers import pipeline, T5ForConditionalGeneration, AutoTokenizer
2
3model = T5ForConditionalGeneration.from_pretrained('viklofg/swedish-ocr-correction')
4tokenizer = AutoTokenizer.from_pretrained('google/byt5-small')
5pipe = pipeline('text2text-generation', model=model, tokenizer=tokenizer)
6
7ocr = 'Den i HandelstidniDgens g&rdagsnnmmer omtalade hvalfisken, sorn fångats i Frölnndaviken'
8output = pipe(ocr)
9print(output)
The model accepts input sequences of at most 128 UTF-8 bytes, longer sequences are truncated to this limit. 128 UTF-8 bytes corresponds to slightly less than 128 characters of Swedish text since most characters are encoded as one byte, but non-ASCII characters such as Å, Ä, and Ö are encoded as two (or more) bytes.