Run this model with HF Jobs
Run DataDrivenAlex/invoice-fields-ner-bert-tiny-lora on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/DataDrivenAlex/invoice-fields-ner-bert-tiny-lora. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/DataDrivenAlex/invoice-fields-ner-bert-tiny-lora on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Instructions to use DataDrivenAlex/invoice-fields-ner-bert-tiny-lora with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use DataDrivenAlex/invoice-fields-ner-bert-tiny-lora with PEFT:
from peft import PeftModel from transformers import AutoModelForTokenClassification base_model = AutoModelForTokenClassification.from_pretrained("google/bert_uncased_L-2_H-128_A-2") model = PeftModel.from_pretrained(base_model, "DataDrivenAlex/invoice-fields-ner-bert-tiny-lora") - Notebooks
- Google Colab
- Kaggle
Invoice Fields NER β BERT Tiny LoRA
A compact token-classification adapter for extracting five fields from short, English invoice-like text: vendor, invoice ID, issue date, total amount, and currency. This is an experimental portfolio benchmark trained on generated fictional examples, not on real invoices.
Results
Evaluation uses exact character-span and entity-type matches on 240 held-out synthetic documents from invoice layouts not used for training or validation. Best checkpoint was selected on a separate 160-document validation set (epoch 10 of 12). Test micro span precision 0.635, recall 0.805, F1 0.710; exact all-fields document match 81/240 (33.8%). This result is only a small synthetic-layout generalization check, not a measure of real-world invoice accuracy.
| Field | Precision | Recall | Exact-span F1 |
|---|---|---|---|
| Vendor | 0.780 | 0.905 | 0.838 |
| Invoice ID | 0.906 | 0.915 | 0.910 |
| Issue date | 0.443 | 0.560 | 0.494 |
| Total | 0.390 | 0.645 | 0.486 |
| Currency | 0.800 | 1.000 | 0.889 |
Model details
- Base:
google/bert_uncased_L-2_H-128_A-2, pinned to revision30b0a37ccaaa32f332884b96992754e246e48c5f. - Fine-tuning: LoRA rank 8, alpha 16, dropout 0.05, applied to query/value projections; trainable classifier saved with the adapter. 9,611 trainable of 4,380,438 parameters.
- Training set: 1,200 generated examples (1,000 invoices and 200 negative non-invoice/quote/order examples). Validation: 160 (133 invoices, 27 negatives). Test: 240 (200 invoices, 40 negatives). Fixed generation seeds; data files are included in the companion dataset artifact.
- English only; short text blocks, at most 126 WordPiece tokens (128 including special tokens).
- Labels:
VENDOR,INVOICE_ID,ISSUE_DATE,TOTAL,CURRENCY; BIO token tags internally. - Adapter weights are small; loading requires the pinned base model.
Quick start
Install a compatible CPU PyTorch build, then the project dependencies:
pip install -r requirements.txt
python infer.py 'TAX INVOICE\nSupplier: Aster Workshop\nDocument ID: INV-1001\nIssued: 2025-04-12\nTotal amount due EUR 149.90'
infer.py loads this adapter from the Hub by default. To use a local adapter, pass --adapter .. It returns extracted spans and their character offsets; it does not normalize or calculate values. See examples/ for a fictional sample. train.py reproduces fine-tuning/evaluation, and make_data.py regenerates the synthetic splits.
Limitations and intended use
This is a learning/demo artifact, not a production extraction service. The generated examples are simple and templated, the held-out test uses a small set of synthetic layouts, and date/total scores show substantial errors. Real invoice scans, OCR, tables, multilingual documents, ambiguous totals, tax/VAT distinctions, currencies embedded in prose, and long documents were not evaluated. There is no OCR or page-level parsing. Do not use it to approve payments, make accounting or tax decisions, or process real personal/financial documents without an independently validated, privacy-safe system and human review. False positives and missed fields are expected.
Data and licensing
All included invoice-like examples are fictional synthetic strings, generated by make_data.py; they are not copied from customer documents. Dataset is released under Apache-2.0. The adapter is distributed under Apache-2.0 with its compatible Apache-2.0 base model. The base-model weights are not bundled; follow its model card for its terms.
Reproducibility
The report in model/evaluation.json contains per-field test metrics and epoch validation scores. model/test_predictions.jsonl contains model predictions for the fixed test IDs. Training seeds are fixed for data generation and initialization; results can vary across PyTorch/platform versions. No claim of independent replication is made.
- Downloads last month
- 27
Model tree for DataDrivenAlex/invoice-fields-ner-bert-tiny-lora
Base model
google/bert_uncased_L-2_H-128_A-2