# GLiNER2Swift

A Swift and MLX implementation of the GLiNER2 information-extraction model, running named entity recognition, text classification, structured JSON extraction and relation extraction entirely on-device on Apple Silicon.

GLiNER2Swift ports the GLiNER2 framework to Swift with Apple's MLX library, running on the Metal GPU of Apple Silicon Macs and iPhones. It performs named entity recognition, text classification with optional label descriptions and few-shot examples, structured data extraction against a JSON schema, and relation extraction, and it chunks long documents automatically while remapping extracted spans back to the original text.

It supports optional int8 quantization of the encoder for roughly 40% less memory use, and it can load LoRA adapters, merged in at load time with no added runtime overhead. It installs as a Swift Package and requires macOS 14 or iOS 17 or later on Apple Silicon or A-series hardware.

Its extraction methods are synchronous rather than `async`; only loading a pretrained model is asynchronous. A single 205-million-parameter base model is currently published for it on Hugging Face.

Website: https://github.com/MacPaw/Gliner2Swift
