felipemaiapolo commited on
Commit
1bd0fd9
1 Parent(s): 120b13a

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +62 -0
README.md ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ language:
4
+ - pt
5
+ ---
6
+
7
+ # BERTikal (aka `legalnlp-bert`)
8
+
9
+ BERTikal [1] is a cased BERT-base model for the Brazilian legal language and was trained from the BERTimbau's [2] checkpoint using Brazilian legal texts. More details on the datasets and training procedures can be found in [1].
10
+
11
+ ## Usage
12
+
13
+ ```python
14
+ from transformers import AutoTokenizer # Or BertTokenizer
15
+ from transformers import AutoModelForPreTraining # Or BertForPreTraining for loading pretraining heads
16
+ from transformers import AutoModel # or BertModel, for BERT without pretraining heads
17
+
18
+ model = AutoModelForPreTraining.from_pretrained('felipemaiapolo/legalnlp-bert')
19
+ tokenizer = AutoTokenizer.from_pretrained('felipemaiapolo/legalnlp-bert', do_lower_case=False)
20
+ ```
21
+
22
+ ### Ex. extracting BERT embeddings
23
+
24
+ ```python
25
+ import torch
26
+
27
+ model = AutoModel.from_pretrained('felipemaiapolo/legalnlp-bert')
28
+ input_ids = tokenizer.encode('Tinha uma pedra no meio do caminho.', return_tensors='pt')
29
+
30
+ with torch.no_grad():
31
+ outs = model(input_ids)
32
+ encoded = outs[0][0, 1:-1] # Ignore [CLS] and [SEP] special tokens
33
+
34
+ # encoded.shape: (8, 768)
35
+ # tensor([[-0.0398, -0.3057, 0.2431, ..., -0.5420, 0.1857, -0.5775],
36
+ # [-0.2926, -0.1957, 0.7020, ..., -0.2843, 0.0530, -0.4304],
37
+ # [ 0.2463, -0.1467, 0.5496, ..., 0.3781, -0.2325, -0.5469],
38
+ # ...,
39
+ # [ 0.0662, 0.7817, 0.3486, ..., -0.4131, -0.2852, -0.2819],
40
+ # [ 0.0662, 0.2845, 0.1871, ..., -0.2542, -0.2933, -0.0661],
41
+ # [ 0.2761, -0.1657, 0.3288, ..., -0.2102, 0.0029, -0.2009]])
42
+ ```
43
+ # Cite
44
+
45
+ Polo, Felipe Maia, et al. "LegalNLP-Natural Language Processing methods for the Brazilian Legal Language." Anais do XVIII Encontro Nacional de Inteligência Artificial e Computacional. SBC, 2021.
46
+
47
+ @inproceedings{polo2021legalnlp,
48
+ title={LegalNLP-Natural Language Processing methods for the Brazilian Legal Language},
49
+ author={Polo, Felipe Maia and Mendon{\c{c}}a, Gabriel Caiaffa Floriano and Parreira, Kau{\^e} Capellato J and Gianvechio, Lucka and Cordeiro, Peterson and Ferreira, Jonathan Batista and de Lima, Leticia Maria Paz and do Amaral Maia, Ant{\^o}nio Carlos and Vicente, Renato},
50
+ booktitle={Anais do XVIII Encontro Nacional de Intelig{\^e}ncia Artificial e Computacional},
51
+ pages={763--774},
52
+ year={2021},
53
+ organization={SBC}
54
+ }
55
+
56
+ # References
57
+
58
+ [1] Polo, Felipe Maia, et al. "LegalNLP-Natural Language Processing methods for the Brazilian Legal Language." Anais do XVIII Encontro Nacional de Inteligência Artificial e Computacional. SBC, 2021.
59
+
60
+ [2] Souza, F., Nogueira, R., and Lotufo, R. (2020). BERTimbau: pretrained BERT
61
+ models for Brazilian Portuguese. In 9th Brazilian Conference on Intelligent
62
+ Systems, BRACIS, Rio Grande do Sul, Brazil, October 20-23