rubentito/longformer-base-mpdocvqa

Model

Longformer base fine-tuned on MP-DocVQA

0

12 commits

1 linked in READMEs

updated Nov 20, 2023

See the code

README

Longformer base fine-tuned on MP-DocVQA

This is Longformer-base trained on SQuAD v1 from Valhalla hub and fine-tuned on Multipage DocVQA (MP-DocVQA) dataset.

This model was used as a baseline in Hierarchical multimodal transformers for Multi-Page DocVQA.

  • Results on the MP-DocVQA dataset are reported in Table 2.
  • Training hyperparameters can be found in Table 8 of Appendix D.

How to use

Inference

How to use this model to perform inference on a sample question and context in PyTorch:

from transformers import LongformerTokenizerFast, LongformerForQuestionAnswering

tokenizer = LongformerTokenizerFast.from_pretrained("rubentito/longformer-base-mpdocvqa")
model = LongformerForQuestionAnswering.from_pretrained("rubentito/longformer-base-mpdocvqa")

text = "Huggingface has democratized NLP. Huge thanks to Huggingface for this."
question = "What has Huggingface done?"

encoding = tokenizer(question, text, return_tensors="pt")
output = model(encoding["input_ids"], attention_mask=encoding["attention_mask"])

start_pos = torch.argmax(output.start_logits, dim=-1).item()
end_pos = torch.argmax(output.end_logits, dim=-1).item()

context_tokens = tokenizer.convert_ids_to_tokens(encoding["input_ids"][0].tolist())
answer_tokens = context_tokens[start_pos: end_pos + 1]
pred_answer = tokenizer.decode(tokenizer.convert_tokens_to_ids(answer_tokens))

Metrics

Average Normalized Levenshtein Similarity (ANLS)

The standard metric for text-based VQA tasks (ST-VQA and DocVQA). It evaluates the method's reasoning capabilities while smoothly penalizes OCR recognition errors. Check Scene Text Visual Question Answering for detailed information.

Answer Page Prediction Accuracy (APPA)

In the MP-DocVQA task, the models can provide the index of the page where the information required to answer the question is located. For this subtask accuracy is used to evaluate the predictions: i.e. if the predicted page is correct or not. Check Hierarchical multimodal transformers for Multi-Page DocVQA for detailed information.

Model results

Extended experimentation can be found in Table 2 of Hierarchical multimodal transformers for Multi-Page DocVQA. You can also check the live leaderboard at the RRC Portal.

ModelHF nameParametersANLSAPPA
Bert largerubentito/bert-large-mpdocvqa334M0.418351.6177
Longformer baserubentito/longformer-base-mpdocvqa148M0.528771.1696
BigBird ITC baserubentito/bigbird-base-itc-mpdocvqa131M0.492967.5433
LayoutLMv3 baserubentito/layoutlmv3-base-mpdocvqa125M0.453851.9426
T5 baserubentito/t5-base-mpdocvqa223M0.50500.0000
Hi-VT5rubentito/hivt5-base-mpdocvqa316M0.620179.23

Citation Information

@article{tito2022hierarchical,
  title={Hierarchical multimodal transformers for Multi-Page DocVQA},
  author={Tito, Rub{\`e}n and Karatzas, Dimosthenis and Valveny, Ernest},
  journal={arXiv preprint arXiv:2212.05935},
  year={2022}
}
Document Question Answering
Document Visual Question Answering
DocVQA
endpoints_compatible
longformer
pytorch
question-answering
transformers

Contributors

rubentito

11 commits

RT
Rubèn Tito

1 commits

rubentito/longformer-base-mpdocvqa

Model

Longformer base fine-tuned on MP-DocVQA

0

12 commits

1 linked in READMEs

updated Nov 20, 2023

See the code

README

Longformer base fine-tuned on MP-DocVQA

This is Longformer-base trained on SQuAD v1 from Valhalla hub and fine-tuned on Multipage DocVQA (MP-DocVQA) dataset.

This model was used as a baseline in Hierarchical multimodal transformers for Multi-Page DocVQA.

  • Results on the MP-DocVQA dataset are reported in Table 2.
  • Training hyperparameters can be found in Table 8 of Appendix D.

How to use

Inference

How to use this model to perform inference on a sample question and context in PyTorch:

from transformers import LongformerTokenizerFast, LongformerForQuestionAnswering

tokenizer = LongformerTokenizerFast.from_pretrained("rubentito/longformer-base-mpdocvqa")
model = LongformerForQuestionAnswering.from_pretrained("rubentito/longformer-base-mpdocvqa")

text = "Huggingface has democratized NLP. Huge thanks to Huggingface for this."
question = "What has Huggingface done?"

encoding = tokenizer(question, text, return_tensors="pt")
output = model(encoding["input_ids"], attention_mask=encoding["attention_mask"])

start_pos = torch.argmax(output.start_logits, dim=-1).item()
end_pos = torch.argmax(output.end_logits, dim=-1).item()

context_tokens = tokenizer.convert_ids_to_tokens(encoding["input_ids"][0].tolist())
answer_tokens = context_tokens[start_pos: end_pos + 1]
pred_answer = tokenizer.decode(tokenizer.convert_tokens_to_ids(answer_tokens))

Metrics

Average Normalized Levenshtein Similarity (ANLS)

The standard metric for text-based VQA tasks (ST-VQA and DocVQA). It evaluates the method's reasoning capabilities while smoothly penalizes OCR recognition errors. Check Scene Text Visual Question Answering for detailed information.

Answer Page Prediction Accuracy (APPA)

In the MP-DocVQA task, the models can provide the index of the page where the information required to answer the question is located. For this subtask accuracy is used to evaluate the predictions: i.e. if the predicted page is correct or not. Check Hierarchical multimodal transformers for Multi-Page DocVQA for detailed information.

Model results

Extended experimentation can be found in Table 2 of Hierarchical multimodal transformers for Multi-Page DocVQA. You can also check the live leaderboard at the RRC Portal.

ModelHF nameParametersANLSAPPA
Bert largerubentito/bert-large-mpdocvqa334M0.418351.6177
Longformer baserubentito/longformer-base-mpdocvqa148M0.528771.1696
BigBird ITC baserubentito/bigbird-base-itc-mpdocvqa131M0.492967.5433
LayoutLMv3 baserubentito/layoutlmv3-base-mpdocvqa125M0.453851.9426
T5 baserubentito/t5-base-mpdocvqa223M0.50500.0000
Hi-VT5rubentito/hivt5-base-mpdocvqa316M0.620179.23

Citation Information

@article{tito2022hierarchical,
  title={Hierarchical multimodal transformers for Multi-Page DocVQA},
  author={Tito, Rub{\`e}n and Karatzas, Dimosthenis and Valveny, Ernest},
  journal={arXiv preprint arXiv:2212.05935},
  year={2022}
}
Document Question Answering
Document Visual Question Answering
DocVQA
endpoints_compatible
longformer
pytorch
question-answering
transformers

Contributors

rubentito

11 commits

RT
Rubèn Tito

1 commits