la-min/health-faq
Viewer
•
Updated
•
51.6k
•
6
from utca.core import (
AddData,
RenameAttribute,
Flush
)
from utca.implementation.predictors import (
TokenSearcherPredictor, TokenSearcherPredictorConfig
)
from utca.implementation.tasks import (
TokenSearcherNER,
TokenSearcherNERPostprocessor,
)
predictor = TokenSearcherPredictor(
TokenSearcherPredictorConfig(
device="cuda:0",
model="knowledgator/UTC-DeBERTa-base-v2"
)
)
ner_task = TokenSearcherNER(
predictor=predictor,
postprocess=[TokenSearcherNERPostprocessor(
threshold=0.5
)]
)
ner_task = TokenSearcherNER()
pipeline = (
AddData({"labels": ["scientist", "university", "city"]})
| ner_task
| Flush(keys=["labels"])
| RenameAttribute("output", "entities")
)
res = pipeline.run({
"text": """Dr. Paul Hammond, a renowned neurologist at Johns Hopkins University, has recently published a paper in the prestigious journal "Nature Neuroscience". """
})