Downloads · 30 days
12
14% of all-time downloads
ryanznie/layoutlmv3-lora-invoice-number
layoutlmv3-lora-invoice-number is a token classification model from ryanznie. Use it when you need labels on individual words, such as names. It is set up for peft. The card lists the license as mit.
Downloads · 30 days
12
14% of all-time downloads
All-time downloads
87
Public
Repo size
587 MB
Likes
0
Public
Click a slice to open those files.
.onnx502 MB · 83%
From the Hugging Face model README
| Field | Details |
|---|---|
| Base Model | microsoft/layoutlmv3-base |
| Model Name | layoutlmv3-lora-invoice-number |
| Fine-Tuning Method | LoRA (Low-Rank Adaptation) |
| Task | Token Classification — Invoice Number Extraction |
| Dataset | SROIE 2019 (invoice subset) |
| License | MIT (inherited from base model) |
| Developed by | Ryan Z. Nie |
This model fine-tunes LayoutLMv3-base using LoRA for the task of invoice number extraction from scanned receipts and invoices. It leverages both visual (layout) and textual information from documents to identify and extract invoice numbers accurately.
The model is lightweight and memory-efficient, trained with low-rank adapters on attention and MLP layers to minimize computational and storage costs without sacrificing accuracy.
Token classification for invoice number extraction from document images.
OCR-parsed document images containing:
Invoice number tokens tagged using BIO labels.
Extracting invoice or bill numbers from scanned receipts in accounting automation systems or document understanding pipelines.
This repository contains both the LoRA adapter and a production ONNX export.
Pin the full Hub commit SHA in production rather than downloading from main.
from transformers import (
AutoTokenizer,
LayoutLMv3ForTokenClassification,
LayoutLMv3ImageProcessor,
LayoutLMv3Processor,
)
from peft import PeftModel
from PIL import Image
import torch
adapter_id = "ryanznie/layoutlmv3-lora-invoice-number"
adapter_revision = "7dc28f5a3b14aa100ba432ee1b0a6cac6c7b2c5c"
base_revision = "cfbbbff0762e6aab37086fdd4739ad14fe7d5db4"
image_processor = LayoutLMv3ImageProcessor.from_pretrained(
adapter_id,
revision=adapter_revision,
apply_ocr=False,
)
tokenizer = AutoTokenizer.from_pretrained(
adapter_id,
revision=adapter_revision,
)
processor = LayoutLMv3Processor(
image_processor=image_processor,
tokenizer=tokenizer,
)
base_model = LayoutLMv3ForTokenClassification.from_pretrained(
"microsoft/layoutlmv3-base",
revision=base_revision,
num_labels=3,
)
model = PeftModel.from_pretrained(
base_model,
adapter_id,
revision=adapter_revision,
).merge_and_unload()
model.eval()
# Example input
image = Image.open("invoice_sample.jpg")
words = ["Invoice", "No.", "PEGIV-1030765"]
boxes = [[100, 200, 200, 230], [210, 200, 250, 230], [260, 200, 400, 230]]
# Preprocess
encoding = processor(image, words, boxes=boxes, return_tensors="pt")
# Predict
outputs = model(**encoding)
predictions = torch.argmax(outputs.logits, dim=-1)
# Print results
print(predictions)
The CPU deployment uses onnx/layoutlmv3_invoice_ner.onnx. Its SHA-256 is
fff762ae2eb7976f33137fdef64a9cc04c6cbbbe712a3fb0ae39f298fb8386dc.
See onnx/model_metadata.json and onnx/model_provenance.json for the pinned
source revisions, exporter identity, and PyTorch-to-ONNX parity result. The
onnx-v1 tag is provided for discovery; production builds pin the full Hub
commit SHA.
SROIE 2019 w/ invoices Dataset Dataset Documentations
| Component | Version |
|---|---|
| Python | 3.11.13 |
| PyTorch | 2.8.0 |
| Transformers | 4.57.0 |
| PEFT | 0.17.1 |
The model performs well on invoice number extraction tasks, correctly combining multi-token predictions into complete invoice numbers (e.g., PEGIV-1030765). After postprocessing, it achieves ~81% accuracy on the SROIE 2019 test set.
Carbon emissions estimated using the Machine Learning Impact Calculator presented in Lacoste et al. (2019).
If you use this model, please cite:
@misc{nie2025layoutlmv3lora,
author = {Ryan Z. Nie},
title = {LayoutLMv3-LoRA for Invoice Number Extraction},
year = {2025},
howpublished = {\url{https://huggingface.co/ryanznie/layoutlmv3-lora-invoice-number}},
note = {Fine-tuned LayoutLMv3 using LoRA on the SROIE 2019 dataset.}
}
For feedback, questions, or collaboration inquiries:
Model Card Author: Ryan Z. Nie
Date: October 2025