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") - GLiNER2
How to use augustoFranke/GLiNER2.5-Decide-CoreML-FP16-MultiFn-L64-512 with GLiNER2:
from gliner2 import GLiNER2 model = GLiNER2.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 bench/plan.swift from augustoFranke/GLiNER2.5-Decide-CoreML-FP16-MultiFn-L64-512: direct link, hf CLI and curl.
- Browser
- Download file 2.59 kB
-
https://huggingface.co/augustoFranke/GLiNER2.5-Decide-CoreML-FP16-MultiFn-L64-512/resolve/main/bench/plan.swift
- Command line
-
hf download hf://augustoFranke/GLiNER2.5-Decide-CoreML-FP16-MultiFn-L64-512/bench/plan.swift
-
curl -L -o plan.swift https://huggingface.co/augustoFranke/GLiNER2.5-Decide-CoreML-FP16-MultiFn-L64-512/resolve/main/bench/plan.swift
2.59 kB
| // Step 0 diagnostic: where does CoreML place each op of the GLiNER2.5-Decide package? | |
| // Usage: plan <path.mlpackage|.mlmodelc> <out.json> | |
| import CoreML | |
| import Foundation | |
| func deviceName(_ d: MLComputeDevice) -> String { | |
| switch d { | |
| case .cpu: return "CPU" | |
| case .gpu: return "GPU" | |
| case .neuralEngine: return "ANE" | |
| @unknown default: return "?" | |
| } | |
| } | |
| struct OpRecord: Codable { | |
| let index: Int | |
| let op: String | |
| let outputs: [String] | |
| let preferred: String | |
| let supported: [String] | |
| let cost: Double | |
| } | |
| func walk(_ block: MLModelStructure.Program.Block, plan: MLComputePlan, into records: inout [OpRecord]) { | |
| for op in block.operations { | |
| let usage = plan.deviceUsage(for: op) | |
| let cost = plan.estimatedCost(of: op)?.weight ?? 0 | |
| records.append(OpRecord( | |
| index: records.count, | |
| op: op.operatorName, | |
| outputs: op.outputs.map { $0.name }, | |
| preferred: usage.map { deviceName($0.preferred) } ?? "none", | |
| supported: usage.map { $0.supported.map(deviceName) } ?? [], | |
| cost: cost)) | |
| for inner in op.blocks { walk(inner, plan: plan, into: &records) } | |
| } | |
| } | |
| let args = CommandLine.arguments | |
| let modelURL = URL(fileURLWithPath: args[1]) | |
| let outURL = URL(fileURLWithPath: args[2]) | |
| let compiledURL: URL | |
| if modelURL.pathExtension == "mlmodelc" { | |
| compiledURL = modelURL | |
| } else { | |
| let t0 = Date() | |
| let tmp = try await MLModel.compileModel(at: modelURL) | |
| compiledURL = modelURL.deletingPathExtension().appendingPathExtension("mlmodelc") | |
| try? FileManager.default.removeItem(at: compiledURL) | |
| try FileManager.default.moveItem(at: tmp, to: compiledURL) | |
| print("compiled in \(String(format: "%.1f", Date().timeIntervalSince(t0)))s -> \(compiledURL.lastPathComponent)") | |
| } | |
| var result: [String: [OpRecord]] = [:] | |
| for (label, units) in [("cpuAndNeuralEngine", MLComputeUnits.cpuAndNeuralEngine), ("all", MLComputeUnits.all)] { | |
| let config = MLModelConfiguration() | |
| config.computeUnits = units | |
| let plan = try await MLComputePlan.load(contentsOf: compiledURL, configuration: config) | |
| guard case let .program(program) = plan.modelStructure, let main = program.functions["main"] else { | |
| fatalError("not an ML program") | |
| } | |
| var records: [OpRecord] = [] | |
| walk(main.block, plan: plan, into: &records) | |
| result[label] = records | |
| print("\(label): \(records.count) ops") | |
| } | |
| let enc = JSONEncoder() | |
| enc.outputFormatting = [.prettyPrinted, .sortedKeys] | |
| try enc.encode(result).write(to: outURL) | |
| print("wrote \(outURL.path)") | |