nikolamilosevic commited on
Commit
c7b407e
1 Parent(s): 7edec27

Update code

Browse files
Files changed (1) hide show
  1. README.md +14 -8
README.md CHANGED
@@ -19,6 +19,7 @@ tags:
19
  - medical
20
  - zero-shot
21
  - few-shot
 
22
  ---
23
  # Zero and few shot NER for biomedical texts
24
 
@@ -27,17 +28,22 @@ Model takes as input two strings. String1 is NER label. String1 must be phrase f
27
  model outputs list of zeros and ones corresponding to the occurance of Named Entity and corresponing to the tokens(tokens given by transformer tokenizer) of the Sring2.
28
 
29
  ## Example of usage
30
-
31
  from transformers import AutoTokenizer
32
- modelname='./' #modelpath
 
 
33
  tokenizer = AutoTokenizer.from_pretrained(modelname) ## loading the tokenizer of that model
34
- string1='Drug'
35
- string2='No recent antibiotics or other nephrotoxins, and no symptoms of UTI with benign UA.'
36
- encodings = tokenizer(string1,string2, is_split_into_words=False,
37
- padding=True, truncation=True, add_special_tokens=True, return_offsets_mapping=False,max_length=512,return_tensors='pt')
38
- from transformers import BertForTokenClassification #AutoModelForPreTraining
 
39
  model = BertForTokenClassification.from_pretrained(modelname, num_labels=2)
40
- prediction_logits=model(**encodings)
 
 
41
 
42
  ## Code availibility
43
 
 
19
  - medical
20
  - zero-shot
21
  - few-shot
22
+ library_name: transformers
23
  ---
24
  # Zero and few shot NER for biomedical texts
25
 
 
28
  model outputs list of zeros and ones corresponding to the occurance of Named Entity and corresponing to the tokens(tokens given by transformer tokenizer) of the Sring2.
29
 
30
  ## Example of usage
31
+ ```
32
  from transformers import AutoTokenizer
33
+ from transformers import BertForTokenClassification
34
+
35
+ modelname = 'ProdicusII/ZeroShotBioNER' # modelpath
36
  tokenizer = AutoTokenizer.from_pretrained(modelname) ## loading the tokenizer of that model
37
+ string1 = 'Drug'
38
+ string2 = 'No recent antibiotics or other nephrotoxins, and no symptoms of UTI with benign UA.'
39
+ encodings = tokenizer(string1, string2, is_split_into_words=False,
40
+ padding=True, truncation=True, add_special_tokens=True, return_offsets_mapping=False,
41
+ max_length=512, return_tensors='pt')
42
+
43
  model = BertForTokenClassification.from_pretrained(modelname, num_labels=2)
44
+ prediction_logits = model(**encodings)
45
+ print(prediction_logits)
46
+ ```
47
 
48
  ## Code availibility
49