Instructions to use Utk113Raj/Gliner_113_Entity_Large with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- GLiNER
How to use Utk113Raj/Gliner_113_Entity_Large with GLiNER:
from gliner import GLiNER model = GLiNER.from_pretrained("Utk113Raj/Gliner_113_Entity_Large") 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
Download handler.py from Utk113Raj/Gliner_113_Entity_Large: direct link, hf CLI and curl.
- Browser
- Download file 789 Bytes
-
https://huggingface.co/Utk113Raj/Gliner_113_Entity_Large/resolve/main/handler.py
- Command line
-
hf download hf://Utk113Raj/Gliner_113_Entity_Large/handler.py
-
curl -L -o handler.py https://huggingface.co/Utk113Raj/Gliner_113_Entity_Large/resolve/main/handler.py
789 Bytes
| from gliner import GLiNER | |
| import torch | |
| class EndpointHandler: | |
| def __init__(self, path=""): | |
| # Load without device_map, then move to GPU | |
| self.model = GLiNER.from_pretrained(path) # Remove device_map="cuda" | |
| self.model = self.model.to("cuda") | |
| self.model.eval() # Lock for inference | |
| def __call__(self, data): | |
| # If data is wrapped in 'inputs' (as Hugging Face does), unwrap it | |
| if isinstance(data, dict) and "inputs" in data: | |
| data = data["inputs"] | |
| text = data.get("text", "") | |
| labels = data.get("labels", []) | |
| if not text or not labels: | |
| return {"error": "Please provide 'text' and 'labels'"} | |
| entities = self.model.predict_entities(text, labels) | |
| return {"entities": entities} | |