Commit
·
3f0f342
1
Parent(s):
fa375d2
Update README.md
Browse files
README.md
CHANGED
|
@@ -1,3 +1,63 @@
|
|
| 1 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
license: mit
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
language:
|
| 3 |
+
- en
|
| 4 |
+
|
| 5 |
+
tags:
|
| 6 |
+
- pytorch
|
| 7 |
+
- ner
|
| 8 |
+
- qa
|
| 9 |
+
|
| 10 |
+
inference: false
|
| 11 |
+
|
| 12 |
license: mit
|
| 13 |
+
|
| 14 |
+
datasets:
|
| 15 |
+
- conll2003
|
| 16 |
+
|
| 17 |
+
metrics:
|
| 18 |
+
- f1
|
| 19 |
---
|
| 20 |
+
# t5-base-qa-ner-conll
|
| 21 |
+
|
| 22 |
+
Unofficial implementation of [InstructionNER](https://arxiv.org/pdf/2203.03903v1.pdf).
|
| 23 |
+
t5-base model tuned on conll2003 dataset.
|
| 24 |
+
|
| 25 |
+
https://github.com/ovbystrova/InstructionNER
|
| 26 |
+
|
| 27 |
+
## Inference
|
| 28 |
+
```shell
|
| 29 |
+
git clone https://github.com/ovbystrova/InstructionNER
|
| 30 |
+
cd InstructionNER
|
| 31 |
+
```
|
| 32 |
+
|
| 33 |
+
```python
|
| 34 |
+
from instruction_ner.model import Model
|
| 35 |
+
model = Model(
|
| 36 |
+
model_path_or_name="olgaduchovny/t5-base-ner-mit-movie",
|
| 37 |
+
tokenizer_path_or_name="olgaduchovny/t5-base-ner-mit-movie"
|
| 38 |
+
)
|
| 39 |
+
options = ["LOC", "PER", "ORG", "MISC"]
|
| 40 |
+
instruction = "please extract entities and their types from the input sentence, " \
|
| 41 |
+
"all entity types are in options"
|
| 42 |
+
text = "The protest , which attracted several thousand supporters , coincided with the 18th anniversary of Spain 's constitution ."
|
| 43 |
+
generation_kwargs = {
|
| 44 |
+
"num_beams": 2,
|
| 45 |
+
"max_length": 128
|
| 46 |
+
}
|
| 47 |
+
pred_spans = model.predict(
|
| 48 |
+
text=text,
|
| 49 |
+
generation_kwargs=generation_kwargs,
|
| 50 |
+
instruction=instruction,
|
| 51 |
+
options=options
|
| 52 |
+
)
|
| 53 |
+
>>> [(99, 104, 'LOC')]
|
| 54 |
+
```
|
| 55 |
+
|
| 56 |
+
## Prediction Sample
|
| 57 |
+
```
|
| 58 |
+
Sentence: The protest , which attracted several thousand supporters , coincided with the 18th anniversary of Spain 's constitution .
|
| 59 |
+
Instruction: please extract entities and their types from the input sentence, all entity types are in options
|
| 60 |
+
Options: ORG, PER, LOC
|
| 61 |
+
Prediction (raw text): Spain is a LOC.
|
| 62 |
+
Prediction (span): [(99, 104, 'LOC')]
|
| 63 |
+
```
|