Skip to content

Add GLiNER 2.5 extraction backend and blog use cases - #11

Open
donvito wants to merge 4 commits into
mainfrom
melvin/gliner25-extraction-4421
Open

Add GLiNER 2.5 extraction backend and blog use cases#11
donvito wants to merge 4 commits into
mainfrom
melvin/gliner25-extraction-4421

Conversation

@donvito

@donvito donvito commented Aug 25, 2026

Copy link
Copy Markdown
Owner

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

  • gliner25 extraction backend wrapping AutoExtractor / Classifier / JointIE, with process-level model reuse
  • Public tasks: extract_entities, extract_entities_long, extract_entities_batch, extract_records, classify_schema, extract_graph
  • PII backend redact_pii(backend="gliner25") using the same cached extractor
  • Colab notebook modeled on the GliGuard demo, plus examples/tasks/gliner25_use_cases.py
  • CPU latency benchmark (benchmarks/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-small

Default checkpoint is fastino/gliner2.5-small-v1 (74M, CPU-friendly). Pass model="gliner25-base" or model="gliner25-multi" for the larger models.

Accuracy (CPU, gliner25-small)

Committed report: evals/reports/2026-08-25_gliner25-small-cpu.md

Metric Score
Exact case pass rate 8/8 (100%)
Mean precision 0.79
Mean recall 1.00
Mean F1 0.88
Mean latency per case 61 ms

A 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.md

Scenario Mean
First entity extraction (load + inference) 5,335.4 ms
Warm entity extraction 20.5 ms
Warm constrained classification 20.2 ms
Warm joint IE 64.9 ms
Warm long-document extraction 208.5 ms
Native NER batch (size 8) 47.6 ms (6.0 ms/item, 168 items/s)

Warm 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.

Open in Web Open in Cursor 

cursoragent and others added 2 commits August 25, 2026 08:53
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
donvito marked this pull request as ready for review August 25, 2026 08:58
cursoragent and others added 2 commits August 25, 2026 09:03
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants