Zero-Shot Classification
Core ML
GLiNER
GLiNER2
English
coremltools
deberta-v3
apple-silicon
fp16
multifunction
Instructions to use augustoFranke/GLiNER2.5-Decide-CoreML-FP16-MultiFn-L64-512 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- GLiNER
How to use augustoFranke/GLiNER2.5-Decide-CoreML-FP16-MultiFn-L64-512 with GLiNER:
from gliner import GLiNER model = GLiNER.from_pretrained("augustoFranke/GLiNER2.5-Decide-CoreML-FP16-MultiFn-L64-512") 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"]) - GLiNER2
How to use augustoFranke/GLiNER2.5-Decide-CoreML-FP16-MultiFn-L64-512 with GLiNER2:
from gliner2 import AutoExtractor extractor = AutoExtractor.from_pretrained("augustoFranke/GLiNER2.5-Decide-CoreML-FP16-MultiFn-L64-512") # 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
Download tests/test_router.py from augustoFranke/GLiNER2.5-Decide-CoreML-FP16-MultiFn-L64-512: direct link, hf CLI and curl.
- Browser
- Download file 2.26 kB
-
https://huggingface.co/augustoFranke/GLiNER2.5-Decide-CoreML-FP16-MultiFn-L64-512/resolve/cb96101a108e3e756eb581e6be780eac3a93b2f2/tests/test_router.py
- Command line
-
hf download hf://augustoFranke/GLiNER2.5-Decide-CoreML-FP16-MultiFn-L64-512@cb96101a108e3e756eb581e6be780eac3a93b2f2/tests/test_router.py
-
curl -L -o test_router.py https://huggingface.co/augustoFranke/GLiNER2.5-Decide-CoreML-FP16-MultiFn-L64-512/resolve/cb96101a108e3e756eb581e6be780eac3a93b2f2/tests/test_router.py
2.26 kB
| """The Core ML router must reproduce the native PyTorch model (tests/golden.json).""" | |
| import json | |
| from pathlib import Path | |
| import pytest | |
| from cases import CASES, SUPPORT_TASKS | |
| from gliner_decide_coreml import BUCKETS, DecideRouter | |
| GOLDEN = json.loads((Path(__file__).parent / "golden.json").read_text())["cases"] | |
| CONFIDENCE_TOLERANCE = 0.02 # fp16 Core ML vs fp32 PyTorch | |
| def router(): | |
| return DecideRouter() | |
| def entries(value): | |
| return value if isinstance(value, list) else [value] | |
| def test_matches_native(router, case): | |
| result, route = router.classify_with_route(case["text"], case["tasks"]) | |
| assert route.bucket == case["bucket"] and route.calls == 1 | |
| native = GOLDEN[case["id"]] | |
| assert list(result) == list(native) | |
| for head, expected in native.items(): | |
| got = {e["label"]: e["confidence"] for e in entries(result[head])} | |
| want = {e["label"]: e["confidence"] for e in entries(expected)} | |
| assert set(got) == set(want), f"{head}: {sorted(got)} != {sorted(want)}" | |
| for label, confidence in want.items(): | |
| assert got[label] == pytest.approx(confidence, abs=CONFIDENCE_TOLERANCE), f"{head}/{label}" | |
| def test_every_bucket_is_exercised(): | |
| assert {c["bucket"] for c in CASES} == set(BUCKETS) | |
| def test_long_text_is_chunked(router): | |
| text = " ".join([CASES[0]["text"]] * 40) # ~1,000 tokens: larger than the 512 bucket | |
| result, route = router.classify_with_route(text, SUPPORT_TASKS) | |
| assert route.bucket is None and route.chunks >= 2 and route.calls == route.chunks | |
| assert result["intent"]["label"] == "refund_request" | |
| def test_more_than_four_heads_are_split_across_calls(router): | |
| tasks = {**CASES[4]["tasks"], "language": ["english", "spanish", "german"], "sentiment": ["positive", "negative"]} | |
| result, route = router.classify_with_route(CASES[4]["text"], tasks) | |
| assert list(result) == list(tasks) and route.calls == 2 | |
| assert result["language"]["label"] == "english" | |
| def test_too_many_labels_is_rejected(router): | |
| with pytest.raises(ValueError, match="labels"): | |
| router.classify("hello", {"topic": [f"label_{i}" for i in range(33)]}) | |