Add GLiNER 2.5 extraction backend and blog use cases - #11
Open
donvito wants to merge 4 commits into
Open
Conversation
Introduce a dedicated gliner25 extraction backend for span-free NER, long-document offsets, JSON records, constrained classification, and joint entity-relation graphs, plus a PII wrapper that reuses the same cached extractor. Ship examples, a GliGuard-style notebook, CPU benchmark, and labeled use-case evals covering the Fastino blog scenarios. Co-authored-by: Melvin Vivas <melvindave@gmail.com>
Commit the CPU accuracy report (8/8 cases, mean F1 0.88) and matching latency numbers, tighten the eval contract NER case for the small model, and cover the gold-matching helpers with unit tests that do not download Hub weights. Co-authored-by: Melvin Vivas <melvindave@gmail.com>
donvito
marked this pull request as ready for review
August 25, 2026 08:58
Expose extract_entities_batch on the extraction backend and public API, using gliner2 batch_extract_entities. Time it in the CPU benchmark, contrast unconstrained vs constrained guardrails in the notebook, and attach dosage-form attributes on the clinical example. Co-authored-by: Melvin Vivas <melvindave@gmail.com>
Re-run the CPU benchmark after adding extract_entities_batch. Warm NER is 260x faster than first load, and a size-8 batch is 3.4x faster per item than single-text extraction. Co-authored-by: Melvin Vivas <melvindave@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a dedicated GLiNER 2.5 extraction backend (same shape as GliGuard) covering the six Fastino blog use cases: constrained agent routing and guardrails, joint knowledge-graph extraction, long-document PII redaction, contract review, and clinical span attributes.
What’s included
gliner25extraction backend wrappingAutoExtractor/Classifier/JointIE, with process-level model reuseextract_entities,extract_entities_long,extract_entities_batch,extract_records,classify_schema,extract_graphredact_pii(backend="gliner25")using the same cached extractorexamples/tasks/gliner25_use_cases.pybenchmarks/benchmark_gliner25_cpu.py) and labeled use-case eval (evals/eval_gliner25.py)Install
pip install 'aibackends[gliner25]' python evals/eval_gliner25.py --device cpu --model gliner25-smallDefault checkpoint is
fastino/gliner2.5-small-v1(74M, CPU-friendly). Passmodel="gliner25-base"ormodel="gliner25-multi"for the larger models.Accuracy (CPU,
gliner25-small)Committed report:
evals/reports/2026-08-25_gliner25-small-cpu.mdA case passes when every gold label is found. Extra predicted labels (multi-label guardrails, extra clinical spans) lower precision but do not fail the case.
Latency (CPU, 4 cores, no GPU)
Committed report:
benchmarks/reports/2026-08-25_gliner25-small-cpu.mdWarm NER is about 260× faster than the first call that includes model loading. Native batch NER is about 3.4× faster per item than single-text warm extraction.
Unit tests use fakes and do not download Hub weights. Scoring helpers are covered in
tests/test_eval_gliner25.py.