Commit
·
c63c45a
1
Parent(s):
6f824d1
Update README.md
Browse files
README.md
CHANGED
@@ -31,28 +31,48 @@ model = AutoModelForPreTraining.from_pretrained('felipemaiapolo/legalnlp-bert')
|
|
31 |
tokenizer = AutoTokenizer.from_pretrained('felipemaiapolo/legalnlp-bert', do_lower_case=False)
|
32 |
```
|
33 |
|
34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
|
36 |
```python
|
37 |
-
import
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
#
|
47 |
-
#
|
48 |
-
#
|
49 |
-
#
|
50 |
-
#
|
51 |
-
#
|
52 |
-
#
|
53 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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.
|
|
|
31 |
tokenizer = AutoTokenizer.from_pretrained('felipemaiapolo/legalnlp-bert', do_lower_case=False)
|
32 |
```
|
33 |
|
34 |
+
|
35 |
+
### Ex. BERT embeddings
|
36 |
+
|
37 |
+
```python
|
38 |
+
from transformers import pipeline
|
39 |
+
|
40 |
+
pipe = pipeline("feature-extraction", model='felipemaiapolo/legalnlp-bert')
|
41 |
+
encoded_sentence = pipe('Juíz negou o recurso.')
|
42 |
+
|
43 |
+
|
44 |
+
### Masked language modeling prediction example
|
45 |
|
46 |
```python
|
47 |
+
from transformers import pipeline
|
48 |
+
|
49 |
+
pipe = pipeline('fill-mask', model=model, tokenizer=tokenizer)
|
50 |
+
|
51 |
+
pipe('Juíz negou o [MASK].')
|
52 |
+
# [{'score': 0.6387444734573364,
|
53 |
+
# 'token': 7608,
|
54 |
+
# 'token_str': 'julgamento',
|
55 |
+
# 'sequence': 'juiz negou o julgamento.'},
|
56 |
+
# {'score': 0.09632532298564911,
|
57 |
+
# 'token': 7509,
|
58 |
+
# 'token_str': 'voto',
|
59 |
+
# 'sequence': 'juiz negou o voto.'},
|
60 |
+
# {'score': 0.06424401700496674,
|
61 |
+
# 'token': 17225,
|
62 |
+
# 'token_str': 'julgado',
|
63 |
+
# 'sequence': 'juiz negou o julgado.'},
|
64 |
+
# {'score': 0.05929475650191307,
|
65 |
+
# 'token': 8190,
|
66 |
+
# 'token_str': 'recurso',
|
67 |
+
# 'sequence': 'juiz negou o recurso.'},
|
68 |
+
# {'score': 0.011442390270531178,
|
69 |
+
# 'token': 6330,
|
70 |
+
# 'token_str': 'registro',
|
71 |
+
# 'sequence': 'juiz negou o registro.'}]
|
72 |
+
|
73 |
```
|
74 |
+
|
75 |
+
|
76 |
# References
|
77 |
|
78 |
[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.
|