Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -16,7 +16,15 @@ ner_models = {
|
|
16 |
'bioNER': 'd4data/biomedical-ner-all',
|
17 |
'SpaCy English NER': 'en_core_web_trf',
|
18 |
}
|
19 |
-
spacy
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
spacy_ner_model = spacy.load(ner_models['SpaCy English NER'])
|
21 |
ner_model_bio = pipeline('token-classification', model='d4data/biomedical-ner-all')
|
22 |
from transformers import AutoTokenizer
|
|
|
16 |
'bioNER': 'd4data/biomedical-ner-all',
|
17 |
'SpaCy English NER': 'en_core_web_trf',
|
18 |
}
|
19 |
+
import spacy
|
20 |
+
from spacy.tokens import Doc
|
21 |
+
from spacy_transformers import TransformersLanguage, TransformersWordPiecer, TransformersTok2Vec
|
22 |
+
|
23 |
+
# Initialize the spaCy language class with transformer components
|
24 |
+
nlp = TransformersLanguage(trf_name="en_core_web_trf", meta={"lang": "en"})
|
25 |
+
nlp.add_pipe(TransformersWordPiecer.from_pretrained(nlp.vocab, "en_core_web_trf"))
|
26 |
+
nlp.add_pipe(TransformersTok2Vec.from_pretrained(nlp.vocab, "en_core_web_trf"))
|
27 |
+
|
28 |
spacy_ner_model = spacy.load(ner_models['SpaCy English NER'])
|
29 |
ner_model_bio = pipeline('token-classification', model='d4data/biomedical-ner-all')
|
30 |
from transformers import AutoTokenizer
|