|
import time |
|
from transformers import AutoTokenizer, pipeline |
|
from optimum.onnxruntime import ORTModelForTokenClassification |
|
|
|
tokenizer = AutoTokenizer.from_pretrained("./bert-italian-ner-onnx-quantized-avx512") |
|
model = ORTModelForTokenClassification.from_pretrained("./bert-italian-ner-onnx-quantized-avx512") |
|
nerpipeline = pipeline('ner', model=model, tokenizer=tokenizer) |
|
|
|
text = "La sede storica della Olivetti è ad Ivrea" |
|
start_time = time.time() |
|
output = nerpipeline(text) |
|
print(f"--- {time.time() - start_time} seconds ---") |
|
print(output) |