Olga Bystrova commited on
Commit
4b8cc82
·
1 Parent(s): ecfb6f0

add inference sample

Browse files
Files changed (1) hide show
  1. README.md +37 -0
README.md CHANGED
@@ -22,6 +22,42 @@ t5-base model tuned on conll2003 dataset.
22
 
23
  https://github.com/ovbystrova/InstructionNER
24
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
  ## Prediction Sample
26
  ```
27
  Sentence: The protest , which attracted several thousand supporters , coincided with the 18th anniversary of Spain 's constitution .
@@ -29,5 +65,6 @@ Instruction: please extract entities and their types from the input sentence, al
29
  Options: ORG, PER, LOC
30
 
31
  Prediction (raw text): Spain is a LOC.
 
32
  ```
33
 
 
22
 
23
  https://github.com/ovbystrova/InstructionNER
24
 
25
+ ## Inference
26
+ ```shell
27
+ git clone https://github.com/ovbystrova/InstructionNER
28
+ cd InstructionNER
29
+ ```
30
+
31
+ ```python
32
+ from src.Model import Model
33
+
34
+ model = Model(
35
+ model_path_or_name="olgaduchovny/t5-base-qa-ner-conll",
36
+ tokenizer_path_or_name="olgaduchovny/t5-base-qa-ner-conll"
37
+ )
38
+
39
+ options = ["LOC", "PER", "ORG", "MISC"]
40
+
41
+ instruction = "please extract entities and their types from the input sentence, " \
42
+ "all entity types are in options"
43
+
44
+ text = "The protest , which attracted several thousand supporters , coincided with the 18th anniversary of Spain 's constitution ."
45
+
46
+ generation_kwargs = {
47
+ "num_beams": 2,
48
+ "max_length": 128
49
+ }
50
+
51
+ pred_spans = model.predict(
52
+ text=text,
53
+ generation_kwargs=generation_kwargs,
54
+ instruction=instruction,
55
+ options=options
56
+ )
57
+
58
+ >>> [(99, 104, 'LOC')]
59
+ ```
60
+
61
  ## Prediction Sample
62
  ```
63
  Sentence: The protest , which attracted several thousand supporters , coincided with the 18th anniversary of Spain 's constitution .
 
65
  Options: ORG, PER, LOC
66
 
67
  Prediction (raw text): Spain is a LOC.
68
+ Prediction (span): [(99, 104, 'LOC')]
69
  ```
70