Downloads · 30 days
3
8% of all-time downloads
rachitpandey26/byt5-pii-masking-ocr
byt5-pii-masking-ocr is a text generation model from rachitpandey26. Use it when you need the model to write or continue text. It is set up for transformers. The card lists the license as mit.
A 582M parameter, byte-level (google/byt5-base) model fully fine-tuned for two tasks:
Downloads · 30 days
3
8% of all-time downloads
All-time downloads
36
Public
Repo size
2.3 GB
Likes
0
Public
Click a slice to open those files.
.bin2.3 GB · 100%
From the Hugging Face model README
A 582M parameter, byte-level (google/byt5-base) model fully fine-tuned for two tasks:
[LABEL] tags, robust to OCR noise (character-level errors from scanned documents).Byte-level modeling was chosen deliberately: OCR errors are character-level corruptions
(0↔O, 1↔l, dropped/duplicated characters), and a byte-level model sees and can
correct these directly, unlike subword-tokenized models.
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
tok = AutoTokenizer.from_pretrained("rachitpandey26/byt5-pii-masking-ocr")
model = AutoModelForSeq2SeqLM.from_pretrained("rachitpandey26/byt5-pii-masking-ocr")
text = "Dear Omer, call 0151 555 0192 or email [email protected]."
inputs = tok(text, return_tensors="pt")
out = model.generate(**inputs, max_length=1024, num_beams=1)
print(tok.decode(out[0], skip_special_tokens=True))
# -> "Dear [FIRSTNAME], call [PHONENUMBER] or email [EMAIL]."
text = (
"[TABLE]\n"
"[HDR] name | order_id | email | city\n"
"[ROW] Omer | 4471 | [email protected] | Berlin\n"
"[ROW] Sara | 9982 | [email protected] | Lyon\n"
"[TASK] identify PII columns\n"
"[ANSWER]"
)
inputs = tok(text, return_tensors="pt")
out = model.generate(**inputs, max_length=256, num_beams=1)
print(tok.decode(out[0], skip_special_tokens=True))
# -> "name: FIRSTNAME\nemail: EMAIL" (non-PII columns omitted; "[NONE]" if none found)
Benchmark numbers not available at push time.
MIT