Filiberto 124M Instruct
is a small specialized model for OCR correction of Spanish Golden Age Dramas OCR, based on the
OCRonos-Vintage
model for cultural heritage archives OCR correction.
Filiberto 124M Instruct is only 124 million parameters. It can run easily on CPU or provide correction at scale on GPUs (>10k tokens/seconds).
Training
The pre-trained included a collection of individual verses and their correction taken from the
TEXORO
corpus, via a collaboration with
ETSO
, totalling ~5 million tokens.
Pre-training ran on 5 epochs with levanter (500 steps total, each processing 1024 sequences of 512 tokens) on a TPUv4-32 for 15 minutes.
Tokenization is currently done with the GPT-2 tokenizer.
Example of OCR correction
Filiberto 124M Instruct has been pre-trained on an instruction dataset with a hard-coded structure:
### Text ###
for OCRized text submissiong and
### Correction ###
for the generated correction.
Filiberto 124M Instruct can be imported like any GPT-2 like model:
import torch
from transformers import GPT2LMHeadModel, GPT2Tokenizer
# Load pre-trained model and tokenizer
model_name = "bertin-project/filiberto-124M-instruct"
model = GPT2LMHeadModel.from_pretrained(model_name)
tokenizer = GPT2Tokenizer.from_pretrained(model_name)
# Set the device to GPU if available, otherwise use CPU
device = torch.device("cuda"if torch.cuda.is_available() else"cpu")
model.to(device)
And afterwards inference can be run like this:
# Function to generate textdefocr_correction(prompt, max_new_tokens=600):
prompt = f"""### Text ###\n{prompt}\n\n\n### Correction ###\n"""
input_ids = tokenizer.encode(prompt, return_tensors="pt").to(device)
# Generate text
output = model.generate(input_ids,
max_new_tokens=max_new_tokens,
pad_token_id=tokenizer.eos_token_id,
top_k=50)
# Decode and return the generated textreturn tokenizer.decode(output[0], skip_special_tokens=True).split("### Correction ###")[-1].strip()
ocr_result = ocr_correction(prompt)
print(ocr_result)
An example of an OCRized drama:
Otra vez, Don Iuan, me dad,
y otras mil vezes los braços.
Otra, y otras mil sean lazos
de nuestra antigua amistad.
Como venis?
Yo me siento
tan alegre, tan vfano,
tan venturoso, tan vano,
que no podrà el pensamiento
encareceros jamàs
las venturas que posseo,
porque el pensamiento creo
would yield this result:
Otra vez, Don Iuan, me dad,
y otras mil vezes los braços.
Otra, y otras mil sean lazos
de nuestra antigua amistad.
Como venis?
Yo me siento
tan alegre, tan vfano,
tan venturoso, tan vano,
que no podrà el pensamiento
encareceros jamàs
las venturas que posseo,
porque el pensamiento creo
Runs of bertin-project filiberto-124M-instruct on huggingface.co
34
Total runs
0
24-hour runs
1
3-day runs
4
7-day runs
-30
30-day runs
More Information About filiberto-124M-instruct huggingface.co Model
filiberto-124M-instruct huggingface.co is an AI model on huggingface.co that provides filiberto-124M-instruct's model effect (), which can be used instantly with this bertin-project filiberto-124M-instruct model. huggingface.co supports a free trial of the filiberto-124M-instruct model, and also provides paid use of the filiberto-124M-instruct. Support call filiberto-124M-instruct model through api, including Node.js, Python, http.
filiberto-124M-instruct huggingface.co is an online trial and call api platform, which integrates filiberto-124M-instruct's modeling effects, including api services, and provides a free online trial of filiberto-124M-instruct, you can try filiberto-124M-instruct online for free by clicking the link below.
bertin-project filiberto-124M-instruct online free url in huggingface.co:
filiberto-124M-instruct is an open source model from GitHub that offers a free installation service, and any user can find filiberto-124M-instruct on GitHub to install. At the same time, huggingface.co provides the effect of filiberto-124M-instruct install, users can directly use filiberto-124M-instruct installed effect in huggingface.co for debugging and trial. It also supports api for free installation.
filiberto-124M-instruct install url in huggingface.co: