Downloads · 30 days
4
11% of all-time downloads
Aadhi852/lightonocr-w9-finetuned
lightonocr-w9-finetuned is a image-text-to-text model from Aadhi852. Use it for the image-text-to-text task on the model card, and read the license before you ship it in a product. The card lists the license as apache-2.0.
Fine-tuned version of LightOnOCR-2-1B-base for structured field extraction from IRS W-9 tax forms.
Downloads · 30 days
4
11% of all-time downloads
All-time downloads
36
Public
Parameters
1B
2 GB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors2 GB · 99%
From the Hugging Face model README
Fine-tuned version of LightOnOCR-2-1B-base for structured field extraction from IRS W-9 tax forms.
| Parameter | Value |
|---|---|
| Epochs | 3 |
| Train samples | 439 |
| Val samples | 61 |
| Learning rate | 2e-4 |
| Effective batch size | 8 |
| LR scheduler | Cosine |
| Optimizer | AdamW 8-bit |
| Final train loss | ~0.15 |
Evaluated on 61 held-out synthetic W-9 forms.
| Metric | Baseline (base model) | Fine-tuned | Target |
|---|---|---|---|
| CER (Character Error Rate) | 1.0000 | 0.0353 | < 0.05 |
| JSON Parse Rate | 0.0000 | 1.0000 | > 0.95 |
| Field Exact Match | 0.0000 | 0.9594 | > 0.90 |
| Empty Field Accuracy | 1.0000 | 1.0000 | > 0.95 |
| Hallucination Rate | 0.0000 | 0.0000 | ~0.00 |
| Field | Accuracy |
|---|---|
| form_type | 1.0000 |
| form_version | 1.0000 |
| line_1_name | 1.0000 |
| line_2_business_name | 0.8361 |
| line_3a_tax_classification | 1.0000 |
| line_3a_llc_class | 1.0000 |
| line_3a_other_desc | 1.0000 |
| line_3b_foreign_partners | 1.0000 |
| line_4_exempt_code | 0.8852 |
| line_4_fatca_code | 0.9672 |
| line_5_address | 1.0000 |
| line_6_city_state_zip | 1.0000 |
| requester_name_address | 0.8033 |
| line_7_account_numbers | 0.7377 |
| tin_type | 1.0000 |
| social_security_number | 1.0000 |
| employer_identification_number | 1.0000 |
| signature | 1.0000 |
| date | 1.0000 |
Trained on 500 synthetic W-9 forms generated programmatically:
import torch
from transformers import LightOnOcrProcessor, LightOnOcrForConditionalGeneration
from PIL import Image
model_id = "Aadhi852/lightonocr-w9-finetuned"
processor = LightOnOcrProcessor.from_pretrained(model_id)
model = LightOnOcrForConditionalGeneration.from_pretrained(
model_id,
torch_dtype=torch.bfloat16,
device_map="auto",
)
model.eval()
image = Image.open("w9_form.png").convert("RGB")
prompt = "Extract all fields from this form and return a valid JSON object only. Do not include any explanation or additional text."
messages = [{"role": "user", "content": [
{"type": "image"},
{"type": "text", "text": prompt},
]}]
text = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
encoding = processor(images=image, text=text, return_tensors="pt")
encoding = {k: v.to(model.device) for k, v in encoding.items() if hasattr(v, 'to')}
with torch.no_grad():
output_ids = model.generate(**encoding, max_new_tokens=512, do_sample=False)
input_len = encoding['input_ids'].shape[1]
result = processor.decode(output_ids[0][input_len:], skip_special_tokens=True)
print(result) # {"name": "...", "tin": "...", ...}
If you use this model, please cite the base model: