Norm commited on
Commit
4880398
·
1 Parent(s): d58f724

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +32 -0
README.md CHANGED
@@ -1,3 +1,35 @@
1
  ---
2
  license: afl-3.0
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: afl-3.0
3
  ---
4
+
5
+ # ERNIE-Layout_Pytorch
6
+
7
+ This is an unofficial Pytorch implementation of [ERNIE-Layout](http://arxiv.org/abs/2210.06155) which is originally released through PaddleNLP.
8
+
9
+
10
+ **A Quick Example**
11
+ ```python
12
+ from networks.modeling_erine_layout import ErnieLayoutConfig, ErnieLayoutForQuestionAnswering
13
+ from networks.tokenizer import ErnieLayoutTokenizer
14
+
15
+
16
+ pretrain_torch_model_or_path = "path/to/pretrained-model"
17
+
18
+ # initialize tokenizer
19
+ tokenizer = ErnieLayoutTokenizer.from_pretrained(pretrained_model_name_or_path=pretrain_torch_model_or_path)
20
+ encodings = tokenizer.encode_plus(text="Question", text_pair="Answer", add_special_tokens=True,
21
+ max_length=512, truncation="only_second",
22
+ return_offsets_mapping=True, return_attention_mask=True,
23
+ return_overflowing_tokens=True)
24
+
25
+ # initialize config
26
+ config = ErnieLayoutConfig.from_pretrained(pretrained_model_name_or_path=pretrain_torch_model_or_path)
27
+ config.num_classes = 2
28
+
29
+ # initialize ERNIE for VQA
30
+ model = ErnieLayoutForQuestionAnswering.from_pretrained(
31
+ pretrained_model_name_or_path=pretrain_torch_model_or_path,
32
+ config=config,
33
+ )
34
+
35
+ ```