rubentito commited on
Commit
e36eb6f
1 Parent(s): 5ed0c36

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +54 -0
README.md CHANGED
@@ -1,3 +1,57 @@
1
  ---
2
  license: gpl-3.0
 
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: gpl-3.0
3
+ tags:
4
+ - DocVQA
5
+ - Document Question Answering
6
+ - Document Visual Question Answering
7
+ datasets:
8
+ - MP-DocVQA
9
+ language:
10
+ - en
11
  ---
12
+
13
+ # Longformer base fine-tuned on MP-DocVQA
14
+
15
+ This is Longformer-base trained on SQuAD v1 from [Valhalla hub](https://huggingface.co/valhalla/longformer-base-4096-finetuned-squadv1) and fine-tuned on Multipage DocVQA (MP-DocVQA) dataset.
16
+
17
+
18
+ This model was used as a baseline in [Hierarchical multimodal transformers for Multi-Page DocVQA](https://arxiv.org/pdf/2212.05935.pdf).
19
+ - Results on the MP-DocVQA dataset are reported in Table 2.
20
+ - Training hyperparameters can be found in Table 8 of Appendix D.
21
+
22
+ ## How to use
23
+
24
+ Here is how to use this model to get the features of a given text in PyTorch:
25
+
26
+ ```python
27
+ import torch
28
+ from transformers import LongformerTokenizerFast, LongformerForQuestionAnswering
29
+
30
+ tokenizer = LongformerTokenizerFast.from_pretrained("rubentito/longformer-base-mpdocvqa")
31
+ model = LongformerForQuestionAnswering.from_pretrained("rubentito/longformer-base-mpdocvqa")
32
+
33
+ text = "Huggingface has democratized NLP. Huge thanks to Huggingface for this."
34
+ question = "What has Huggingface done?"
35
+ encoding = tokenizer(question, text, return_tensors="pt")
36
+ input_ids = encoding["input_ids"]
37
+
38
+ # default is local attention everywhere
39
+ # the forward method will automatically set global attention on question tokens attention_mask=encoding["attention_mask"]
40
+
41
+ start_scores, end_scores = model(input_ids, attention_mask=attention_mask)
42
+ all_tokens = tokenizer.convert_ids_to_tokens(input_ids[0].tolist())
43
+
44
+ answer_tokens = all_tokens[torch.argmax(start_scores) :torch.argmax(end_scores)+1]
45
+ answer = tokenizer.decode(tokenizer.convert_tokens_to_ids(answer_tokens))
46
+ ```
47
+
48
+ ## BibTeX entry
49
+
50
+ ```tex
51
+ @article{tito2022hierarchical,
52
+ title={Hierarchical multimodal transformers for Multi-Page DocVQA},
53
+ author={Tito, Rub{\`e}n and Karatzas, Dimosthenis and Valveny, Ernest},
54
+ journal={arXiv preprint arXiv:2212.05935},
55
+ year={2022}
56
+ }
57
+ ```