Core AI model zoo

GLiNER2-PII — Core AI

The zoo’s first NER / schema-driven information-extraction model, and its first DeBERTa-v3 (disentangled-attention) port. Zero-shot entity extraction — pass any label set at call time and the model finds those entities in the text. The flagship use is on-device PII redaction. fastino/gliner2-privacy-filter-PII-multi (Apache-2.0) on a multilingual mDeBERTa-v3 base (278M), fused into one static Core AI graph; the tokenizer, schema linearization, and span decode run in the Swift host.

Uncontested on iPhone. An on-device GLiNER2 already exists (GLiNER2Swift) but it is macOS-CPU / MLX only. This runs the GPU on iPhone (and, AOT-compiled, the ANE) — the first GLiNER on Apple Silicon’s accelerators.

Use it

Three lines with CoreAIKitInformationExtractor downloads the bundle once, then runs fully offline:

import CoreAIKitEmbeddings

let extractor = try await InformationExtractor(model: .gliner2PII)

// zero-shot: any labels, decided at call time
let entities = try await extractor.extract(
    from: "Contact Dr. Sarah Johnson at sarah.j@acme.com or +1-415-555-0142.",
    entities: ["person", "email", "phone number"])
// ["person": ["Sarah Johnson"], "email": ["sarah.j@acme.com"], "phone number": ["+1-415-555-0142"]]

// or redact in place (default replacement is [LABEL]; pass your own for ██ blocks)
let clean = try await extractor.redact(
    "SSN 123-45-6789, card 4111 1111 1111 1111.",
    entities: ["social security number", "credit card number"])
// "SSN [SOCIAL SECURITY NUMBER], card [CREDIT CARD NUMBER]."

Runnable demo: Examples/InfoExtract ↗ — a paste-text → detect-and-redact PII app (iOS), plus an infoextract-cli (macOS, --redact / --gate).

How it works

One fused static graph runs the whole model; the host handles the text↔schema plumbing that keeps it schema-agnostic.

Verification

Byte-gated against reference GLiNER2 ext.extract at every tier — the Swift collator matches Python collate_fn_inference (input ids + gather indices), the fp16 graph matches the fp32 reference (span-scores cos 0.999993), and decoded entities match exactly:

Reproduce (Mac):

python conversion/export_gliner2_pii.py --output-dir /tmp/gliner2_out --dtype float16   # all gates
# then, in coreai-kit:
swift run infoextract-cli --bundle /tmp/gliner2_out --gate                              # kit E2E, ALL PASS

Conversion + the fused-graph export: conversion/export_gliner2_pii.py. Porting lessons (disentangled-attention export, the swift-transformers tokenizer routing, the schema-agnostic collator): knowledge/gliner2-pii.md.