Instructions to use anrol13/gliner_medium-v2.1 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- GLiNER
How to use anrol13/gliner_medium-v2.1 with GLiNER:
from gliner import GLiNER model = GLiNER.from_pretrained("anrol13/gliner_medium-v2.1") text = "Cristiano Ronaldo dos Santos Aveiro was born on 5 February 1985 in Funchal, Madeira, Portugal." labels = ["person", "date", "location"] entities = model.predict_entities(text, labels) for entity in entities: print(entity["text"], "=>", entity["label"]) - Notebooks
- Google Colab
- Kaggle
File size: 463 Bytes
826f064 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | from gliner import GLiNER
from typing import Dict, List, Any
class EndpointHandler():
def __init__(self, path=""):
self.model = GLiNER.from_pretrained("urchade/gliner_medium-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.predict_entities(inputs, labels)
return prediction
|