feat(inference): add GLiNER2.5 inference/training and speed up GLiNER2 - #720
Conversation
| @@ -0,0 +1,29 @@ | |||
| Source: SciPy v1.16.3 scipy/optimize/rectangular_lsap/rectangular_lsap.cpp | |||
There was a problem hiding this comment.
we use it for Gliner2.5 finetuning purposes when solving the Assignment Problem. Astra implemented Scipy's Rectangular Linear Sum Assignment Problem (LSAP) (which is used by the python versions) in zig, hence the license.
| minimum: 0 | ||
| maximum: 1 | ||
| x-go-type-skip-optional-pointer: false | ||
| ExtractionDecisionProbability: |
There was a problem hiding this comment.
Should these be more general than "extraction" seems like they're InclusiveProbability/ExclusionProbabability or something?
Also we should visit this as an API and make sure all these options make the most sense? Maybe they should be model options instead of extraction options?
[codex] Extraction API and UX reviewReviewed commit Recommendation: address the playground issues before presenting this as a usable GLiNER2.5 feature. The versioned API is promising, but public GLiNER2.5 serving remains deliberately gated off. The UI should reflect that distinction. Issues
Model/provider UX recommendationsPioneer is a provider; GLiNER2.5 is a model family. Keep these choices separate:
Pioneer integration gap — predates this PRPioneer's documented native API uses Validation and review limits
|
|
/ci run 22a46e7 |
|
/ci run 22a46e7 |
|
/ci run 58de571 |
Implement native Zig CPU and Metal support for GLiNER2.5 small, base, and multilingual checkpoints, including extraction APIs/SDKs, training, checkpoint/resume, and export. Shared execution changes also improve legacy GLiNER2 performance and batched contextual-label handling. Native inference and training do not require Python; pinned Fastino/PyTorch provides reference results.
Public GLiNER2.5 serving remains gated by the empty production qualification table. Larger numerical fixtures are omitted pending separate object-storage integration, reducing default CI coverage.
Inference and API
POST /ai/v1/extract, inference-servicePOST /extract, and embedded extraction withschema_version: 2; retain version 1 when omitted. Add GoExtractV2, Pythonextract_v2, TypeScriptextractV2, and generated OpenAPI clients.Artifacts and training
inside_weightcompatibility.Quantized training and automatic quality evaluation/calibration/model selection are unsupported.
Shared runtime
Performance against Fastino Python (CPU and MPS)
These are historical measurements from frozen builds; the complete timing campaigns have not been rerun on the final PR tree.
GLiNER2.5: original FP32 corpus
Representative mixed-task extraction, with latency medians across three fresh-process repetitions:
Paired speedups aggregate individual timing ratios and can differ from the ratio of displayed latency medians. CPU and GPU rows come from separate matched campaigns.
Base-model mixed extraction measured 20.61–21.68 ms on Metal versus 71.56–72.49 ms on MPS. Timing includes schema compilation, preprocessing, encoder, heads, decoding, and temporary cleanup; loading and protocol I/O are excluded. MPS synchronizes both ends. Intervals are per repetition; an independent audit recomputed 2,700 Metal timing pairs.
Legacy GLiNER2: warm entity extraction
Speedup above 1 favors Antfly; below 1 favors Fastino. Default Metal uses F16 encoder mirrors with FP32 head/activations; explicit FP32 keeps FP32 weights without F16 or quantized execution. Default Metal is approximately 3% slower on the short case. In the supplemental B8 run, default/FP32 Metal have 8.2%/7.4% lower latency than MPS.
Values are medians of two fresh-process warm medians, with reversed arm order, three warmups, and nine timed requests. The B8 GPU row comes from a separate GPU-only repeat with ten seconds idle before each process: primary MPS B8 medians varied from 573.38 to 874.47 ms, so their aggregate is not used as a stable speedup estimate. Timing includes preparation, inference, and extraction; loading, startup, and result destruction are excluded. MPS synchronizes both ends. These local comparisons do not establish serving-tail latency or optimal thread counts.
Validation
Latest fixture-policy validation used the repository Zig build graph with
-Dmetal=false -Dcuda=false -j1, testing both omitted and temporarily restored payloads.Python skip totals include subtests. Negative probes rejected same-size external corruption and missing required fixtures without skipping.
fixture_support.py --require-allrejects incomplete restoration. Runtime functionality, assertions, tolerances, and surviving capture values are unchanged; the final branch omits all 27 payloads.