GLiNER2
Safetensors
Token Classification
Zero-Shot Classification
Text Classification
relation extraction
Structured extraction
Instructions to use bhaskars113/113-gliner-multi with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- GLiNER2
How to use bhaskars113/113-gliner-multi with GLiNER2:
from gliner2 import GLiNER2 model = GLiNER2.from_pretrained("bhaskars113/113-gliner-multi") # Extract entities text = "Apple CEO Tim Cook announced iPhone 15 in Cupertino yesterday." result = extractor.extract_entities(text, ["company", "person", "product", "location"]) print(result) - Notebooks
- Google Colab
- Kaggle
File size: 891 Bytes
25a79b4 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | import torch
import subprocess
import sys
class EndpointHandler:
def __init__(self, path=""):
# Ensure gliner is installed first
try:
import gliner
except ImportError:
subprocess.check_call([sys.executable, "-m", "pip", "install", "gliner==0.2.8"])
import gliner
from gliner import GLiNER
self.model = GLiNER.from_pretrained(path)
self.model = self.model.to("cuda")
self.model.eval()
def __call__(self, data):
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}
|