pierreguillou commited on
Commit
7a01a9b
·
1 Parent(s): ffc7dff

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +5 -34
README.md CHANGED
@@ -34,45 +34,16 @@ You can test this model into the widget of this page.
34
  ````
35
  # install pytorch: check https://pytorch.org/
36
  # !pip install transformers
37
- from transformers import AutoModelForTokenClassification, AutoTokenizer
38
- import torch
39
 
40
- # parameters
41
- model_name = "ner-bert-base-portuguese-cased-lenebr"
42
- model = AutoModelForTokenClassification.from_pretrained(model_name)
43
- tokenizer = AutoTokenizer.from_pretrained(model_name)
44
-
45
- input_text = "EMENTA: APELAÇÃO CÍVEL - AÇÃO DE INDENIZAÇÃO POR DANOS MORAIS - PRELIMINAR - ARGUIDA PELO MINISTÉRIO PÚBLICO EM GRAU RECURSAL - NULIDADE - AUSÊNCIA DE IN- TERVENÇÃO DO PARQUET NA INSTÂNCIA A QUO - PRESENÇA DE INCAPAZ - PREJUÍZO EXISTENTE - PRELIMINAR ACOLHIDA - NULIDADE RECONHECIDA."
46
-
47
- # tokenization
48
- inputs = tokenizer(input_text, max_length=512, truncation=True, return_tensors="pt")
49
- tokens = inputs.tokens()
50
-
51
- # get predictions
52
- outputs = model(**inputs).logits
53
- predictions = torch.argmax(outputs, dim=2)
54
-
55
- # print predictions
56
- for token, prediction in zip(tokens, predictions[0].numpy()):
57
- print((token, model.config.id2label[prediction]))
58
- ````
59
- You can use pipeline, too. However, it seems to have an issue regarding to the max_length of the input sequence.
60
  ````
61
- !pip install transformers
62
- import transformers
63
- from transformers import pipeline
64
 
65
- model_name = "ner-bert-base-portuguese-cased-lenebr"
66
-
67
- ner = pipeline(
68
- "ner",
69
- model=model_name
70
- )
71
-
72
- ner(input_text)
73
- ````
74
  ## Training procedure
75
 
 
 
76
  ### Training results
77
 
78
  ````
 
34
  ````
35
  # install pytorch: check https://pytorch.org/
36
  # !pip install transformers
37
+ from transformers import AutoTokenizer, AutoModelForMaskedLM
 
38
 
39
+ tokenizer = AutoTokenizer.from_pretrained("pierreguillou/bert-base-cased-pt-lenerbr")
40
+ model = AutoModelForMaskedLM.from_pretrained("pierreguillou/bert-base-cased-pt-lenerbr")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
  ````
 
 
 
42
 
 
 
 
 
 
 
 
 
 
43
  ## Training procedure
44
 
45
+ See the notebook...
46
+
47
  ### Training results
48
 
49
  ````