GLiNER2Swift

A Swift package that runs the GLiNER2 and GLiNER2.5 information-extraction models on-device with MLX, covering named entities, classification, structured extraction and relations on Apple silicon.

View on GitHub ↗
Stars
★ 43
Last commit
2 Dec 2026
Maintenance
Active
Licence
Apache-2.0
Category
On-device AI SDKs
GitHub
MacPaw/Gliner2Swift

Overview

GLiNER2Swift is a Swift package by MacPaw that ports GLiNER2, a schema-based information-extraction framework, to Apple silicon through MLX. One API can load GLiNER2 (span) or GLiNER2.5 (boundary) checkpoints, with the architecture taken from the checkpoint's config.json.

The package can extract named entities, classify text, pull structured fields from a schema, and extract relations. Long documents can be split into overlapping chunks, with spans mapped back to the original text. Optional int8 encoder quantisation reduces memory use, according to the README, and LoRA adapters can be merged at load time.

Models download automatically from Hugging Face, or can be loaded from a local directory. The documented catalogue includes fastino/gliner2-base-v1 and GLiNER2.5 small, base and multilingual checkpoints. Model weights have their own licences, separate from the package.

The code is licensed under Apache Licence 2.0, copyright 2026 MacPaw Way Ltd, with a NOTICE file that also covers the upstream GLiNER2 and MLX work. There are no tagged releases yet; the README installs from main.

The README describes this as an active port. It says inference for the documented checkpoints gives the same predictions as the Python reference. Training, PyTorch pickle checkpoints, some GLiNER2.5 extras and the larger GLiNER2 v1 span variants are not yet implemented.

Features

  • GLiNER2 and GLiNER2.5 checkpoints behind one API, for entities of any length on the 2.5 path, according to the README.
  • Named entity recognition, text classification, structured extraction and relation extraction, plus long-document chunking.
  • Optional int8 encoder quantisation, described by the author as about 40 per cent less memory, with an accuracy trade-off.
  • LoRA adapter loading, merged into base weights at load time.
  • Native MLX inference on Apple silicon (Metal GPU).
  • A research write-up on the MacPaw research site, linked from the README.

Requirements

  • macOS 14.0 or later, or iOS 17.0 or later.
  • Swift 5.9 or later.
  • Apple silicon on the Mac; an A-series device with Metal on iOS.
  • Network access for the first download from Hugging Face, unless a local weight directory is supplied.
  • Xcode, or another Swift Package Manager client, to add the package. Because there is no tag, a branch-based dependency will follow main.

Install

  1. Swift Package Manager: add .package(url: "https://github.com/MacPaw/Gliner2Swift", branch: "main") and depend on the GLiNER2Swift product. This is the method the README gives, and as of 3 Dec 2026 there is no version tag to pin instead.

  2. In Xcode: File, Add Package Dependencies, and enter the repository URL.

  3. In code: import GLiNER2Swift, then GLiNER2.fromPretrained("fastino/gliner2-base-v1"), or another documented checkpoint, and call extractEntities, classifyText or extract.

Example

Add the package to an iOS or macOS app, load fastino/gliner2-base-v1 or a GLiNER2.5 checkpoint, and extract people, organisations and places from a short piece of text on the device. For a long document, use the long-document helper so spans are merged back onto the original string.

Works with

Not stated by the source

Listed in

Read the code before you install anything. SwiftAgents doesn't review or endorse the tools listed here. Active: a commit in the last 90 days. Slowing: last commit within the past year. Stale: older than a year, or archived.

Report a correction

More in this category