ubiai deep learning

How to Train the LILT Model on Invoices and Run Inference

Jan 3, 2023

LILT Model Architecture:

How to Train the LILT Model on Invoices and Run Inference
LILT Model Architecture. Source

Model Fine-tuning:

from transformers import LiltForTokenClassification
# huggingface hub model id
model_id = "SCUT-DLVCLab/lilt-roberta-en-base"

 

# load model with correct number of labels and mapping
model = LiltForTokenClassification.from_pretrained(
model_id, num_labels=len(label_list), label2id=label2id, id2label=id2label
)

NUM_TRAIN_EPOCHS = 120
PER_DEVICE_TRAIN_BATCH_SIZE = 6
PER_DEVICE_EVAL_BATCH_SIZE = 6
LEARNING_RATE = 4e-5
How to Train the LILT Model on Invoices and Run Inference
Image by Author: Model Training In Progress.
{
'eval_precision': 0.6335952848722987,
'eval_recall': 0.7413793103448276,
'eval_f1': 0.6832627118644069,
}
 torch.save(model,'/content/drive/MyDrive/LILT_Model/lilt.pth')

Model Inference:

 
How to Train the LILT Model on Invoices and Run Inference
Image by Author: LILT output on invoice 1
How to Train the LILT Model on Invoices and Run Inference

Image by Author: LILT output on invoice 2

How to Train the LILT Model on Invoices and Run Inference
Image by Author: LILT output on invoice 3

Conclusion

Unlocking the Power of SLM Distillation for Higher Accuracy and Lower Cost​

How to make smaller models as intelligent as larger ones

Recording Date : March 7th, 2025

Unlock the True Potential of LLMs !

Harnessing AI Agents for Advanced Fraud Detection

How AI Agents Are Revolutionizing Fraud Detection

Recording Date : February 13th, 2025

Unlock the True Potential of LLMs !

Thank you for registering!

Check your email for the live demo details

see you on February 19th

While you’re here, discover how you can use UbiAI to fine-tune highly accurate and reliable AI models!

Thank you for registering!

Check your email for webinar details

see you on March 5th

While you’re here, discover how you can use UbiAI to fine-tune highly accurate and reliable AI models!

Fine Tuning LLMs on Your Own Dataset ​

Fine-Tuning Strategies and Practical Applications

Recording Date : January 15th, 2025

Unlock the True Potential of LLMs !