Token Classification
GLiNER
PyTorch
multilingual
Inference Endpoints
gliner_large-v2.1 / handler.py
Antoine
add custom handler
01f73e6
raw
history blame contribute delete
468 Bytes
from gliner import GLiNER
from typing import Dict, List, Any
class EndpointHandler():
def __init__(self, path=""):
self.model = GLiNER.from_pretrained("urchade/gliner_large-v2.1")
def __call__(self, data: Dict[str, Any]) -> List[Dict[str, Any]]:
# get inputs
inputs = data.pop("inputs", data)
labels = data.pop("labels", None)
prediction = self.model.batch_predict_entities(inputs, labels)
return prediction