shershah1024/gliner-native-runtime

Unofficial Swift + Core ML runtime for Fastino AI's GLiNER 2.5 model on Apple silicon

3

stars

2

commits

Swift

primary language

Aug 26, 2026

updated

apple-silicon
coreml
fastino
gliner
gliner2
named-entity-recognition
swift
Browse cluster: GLiNER Named Entity Recognition

README

Unofficial Swift runtime for Fastino's GLiNER 2.5

[!IMPORTANT] The GLiNER 2.5 model is not our model. GLiNER 2.5 and the fastino/gliner2.5-small-v1 checkpoint were created, trained, and published by Fastino AI. This repository is an independent, unofficial Swift/Core ML inference port. It is not affiliated with or endorsed by Fastino.

This repository packages a complete, local Swift inference runtime for Fastino's gliner2.5-small-v1 checkpoint. The DeBERTa-v3 encoder runs through Core ML on the Apple Neural Engine; tokenization, the GLiNER boundary head, span decoding, and character-offset recovery run in-process in Swift. Python is not needed for inference.

The repository includes the model assets needed to run immediately:

  • FP16 Core ML encoder packages for 128- and 192-token buckets
  • the boundary-head weights in Safetensors format
  • the pinned tokenizer and model configuration
  • a Swift library plus the gliner-extract command-line executable

Upstream model source: fastino/gliner2.5-small-v1, revision cab1bddfd30fda7b803a4691c41f90378a2d517a. The upstream model and this runtime port are separately distributed under Apache License 2.0. See ATTRIBUTION.md and THIRD_PARTY_NOTICES.md.

Requirements

  • Apple silicon Mac
  • macOS 14 or newer
  • Xcode 16 / Swift 6
  • Git LFS

Run it

git clone https://github.com/shershah1024/gliner-native-runtime.git
cd gliner-native-runtime
git lfs pull
swift build -c release

.build/release/gliner-extract Models Encoders \
  '{"text":"Apple CEO Tim Cook spoke in Cupertino.","labels":{"company":"A company or organization","person":"A named individual","location":"A place"},"threshold":0.1}'

Output is JSON with the label, exact source text, confidence, and half-open character offsets:

[
  {
    "confidence" : 0.99,
    "end" : 5,
    "label" : "company",
    "start" : 0,
    "text" : "Apple"
  }
]

The runtime chooses the smallest available encoder bucket that fits the combined label schema and text. This checkout supports inputs up to 192 encoded tokens. Label descriptions are strongly recommended because they disambiguate domain specific labels.

Use the library

Add the package as a Swift Package Manager dependency and create one extractor for the lifetime of your process:

import GlinerKit

let root = URL(fileURLWithPath: "/path/to/gliner-native-runtime")
let extractor = try GlinerExtractor(
    modelDirectory: root.appendingPathComponent("Models"),
    encoderDirectory: root.appendingPathComponent("Encoders")
)

let spans = try extractor.extract(
    text: "Email the launch notes to Priya tomorrow.",
    labels: [
        GlinerLabel("person", description: "The person receiving the message"),
        GlinerLabel("date", description: "The date or time phrase")
    ]
)

GlinerExtractor serializes inference internally because the Core ML models and boundary head are shared. Reuse it instead of rebuilding it for each request.

Regenerate the model assets

The checked-in assets are ready to use. To reproduce them from the pinned upstream checkpoint:

python3 -m venv .venv
source .venv/bin/activate
pip install -r Scripts/requirements.txt

python Scripts/export_native_runtime.py
python Scripts/convert_encoder.py 128
python Scripts/convert_encoder.py 192

Pass --checkpoint /path/to/checkpoint to convert_encoder.py, or a checkpoint directory as the first argument to export_native_runtime.py, to avoid a Hub download. Conversion requires macOS because Core ML compilation and validation run locally.

Scope

This Swift runtime implements GLiNER 2.5's entity-extraction path with the checkpoint's default flat non-overlap policy and trained null/abstention head. It does not currently expose the upstream Python package's classification, relations, or structured-record APIs.

The 128- and 192-token Core ML packages contain the same encoder weights at different fixed input shapes. Fixed shapes avoid dynamic relative-position indexing in the ANE graph.

License

The runtime port is licensed under Apache License 2.0. The redistributed model artifacts remain Fastino's GLiNER 2.5 checkpoint and are used under the upstream Apache-2.0 license. See LICENSE, ATTRIBUTION.md, and the original upstream model card.

Contributors

shershah1024

2 commits

shershah1024/gliner-native-runtime

Unofficial Swift + Core ML runtime for Fastino AI's GLiNER 2.5 model on Apple silicon

3

stars

2

commits

Swift

primary language

Aug 26, 2026

updated

apple-silicon
coreml
fastino
gliner
gliner2
named-entity-recognition
swift
Browse cluster: GLiNER Named Entity Recognition

README

Unofficial Swift runtime for Fastino's GLiNER 2.5

[!IMPORTANT] The GLiNER 2.5 model is not our model. GLiNER 2.5 and the fastino/gliner2.5-small-v1 checkpoint were created, trained, and published by Fastino AI. This repository is an independent, unofficial Swift/Core ML inference port. It is not affiliated with or endorsed by Fastino.

This repository packages a complete, local Swift inference runtime for Fastino's gliner2.5-small-v1 checkpoint. The DeBERTa-v3 encoder runs through Core ML on the Apple Neural Engine; tokenization, the GLiNER boundary head, span decoding, and character-offset recovery run in-process in Swift. Python is not needed for inference.

The repository includes the model assets needed to run immediately:

  • FP16 Core ML encoder packages for 128- and 192-token buckets
  • the boundary-head weights in Safetensors format
  • the pinned tokenizer and model configuration
  • a Swift library plus the gliner-extract command-line executable

Upstream model source: fastino/gliner2.5-small-v1, revision cab1bddfd30fda7b803a4691c41f90378a2d517a. The upstream model and this runtime port are separately distributed under Apache License 2.0. See ATTRIBUTION.md and THIRD_PARTY_NOTICES.md.

Requirements

  • Apple silicon Mac
  • macOS 14 or newer
  • Xcode 16 / Swift 6
  • Git LFS

Run it

git clone https://github.com/shershah1024/gliner-native-runtime.git
cd gliner-native-runtime
git lfs pull
swift build -c release

.build/release/gliner-extract Models Encoders \
  '{"text":"Apple CEO Tim Cook spoke in Cupertino.","labels":{"company":"A company or organization","person":"A named individual","location":"A place"},"threshold":0.1}'

Output is JSON with the label, exact source text, confidence, and half-open character offsets:

[
  {
    "confidence" : 0.99,
    "end" : 5,
    "label" : "company",
    "start" : 0,
    "text" : "Apple"
  }
]

The runtime chooses the smallest available encoder bucket that fits the combined label schema and text. This checkout supports inputs up to 192 encoded tokens. Label descriptions are strongly recommended because they disambiguate domain specific labels.

Use the library

Add the package as a Swift Package Manager dependency and create one extractor for the lifetime of your process:

import GlinerKit

let root = URL(fileURLWithPath: "/path/to/gliner-native-runtime")
let extractor = try GlinerExtractor(
    modelDirectory: root.appendingPathComponent("Models"),
    encoderDirectory: root.appendingPathComponent("Encoders")
)

let spans = try extractor.extract(
    text: "Email the launch notes to Priya tomorrow.",
    labels: [
        GlinerLabel("person", description: "The person receiving the message"),
        GlinerLabel("date", description: "The date or time phrase")
    ]
)

GlinerExtractor serializes inference internally because the Core ML models and boundary head are shared. Reuse it instead of rebuilding it for each request.

Regenerate the model assets

The checked-in assets are ready to use. To reproduce them from the pinned upstream checkpoint:

python3 -m venv .venv
source .venv/bin/activate
pip install -r Scripts/requirements.txt

python Scripts/export_native_runtime.py
python Scripts/convert_encoder.py 128
python Scripts/convert_encoder.py 192

Pass --checkpoint /path/to/checkpoint to convert_encoder.py, or a checkpoint directory as the first argument to export_native_runtime.py, to avoid a Hub download. Conversion requires macOS because Core ML compilation and validation run locally.

Scope

This Swift runtime implements GLiNER 2.5's entity-extraction path with the checkpoint's default flat non-overlap policy and trained null/abstention head. It does not currently expose the upstream Python package's classification, relations, or structured-record APIs.

The 128- and 192-token Core ML packages contain the same encoder weights at different fixed input shapes. Fixed shapes avoid dynamic relative-position indexing in the ANE graph.

License

The runtime port is licensed under Apache License 2.0. The redistributed model artifacts remain Fastino's GLiNER 2.5 checkpoint and are used under the upstream Apache-2.0 license. See LICENSE, ATTRIBUTION.md, and the original upstream model card.

Contributors

shershah1024

2 commits

Languages

Swift

83.2%

Python

16.8%