NielsRogge / Transformers-Tutorials

This repository contains demos I made with the Transformers library by HuggingFace.
MIT License
9.49k stars 1.45k forks source link

How to save the predicted output from LayoutLM or LayoutLMv2 ? #101

Open karndeepsingh opened 2 years ago

karndeepsingh commented 2 years ago

I trained LayoutLM for my dataset and I am getting predictions at the word level like in the image "ALVARO FRANCISCO MONTOYA" is true labeled as "party_name_1" but while prediction "ALVARO " is tagged as "party_name_1", "FRANCISCO" is tagged as "party_name_1", "MONTOYA" is tagged as "party_name_1". In short, i am getting prediction for each word but how to save these prediction as one predicted output like "ALVARO FRANCISCO MONTOYA" as "party_name_1". How to save this as a single output? Any help would be greatful. Below image is the predicted output image from LayoutLM. download (2) (2)

sankalp-wns commented 2 years ago

Use BIO tagging. Instead of using the label party_name_1 for each word in ALVARO FRANCISCO MONTOYA, map ALVARO : b-party_name_1, FRANCISCO : i-party_name_1, MONTOYA : i-party_name_1

jyotiyadav94 commented 2 years ago

@karndeepsingh ,

This issue is resolved in LayoutLMV3.