Skip to content

Add GLiNER 2.5 entity extraction and serving - #467

Open
hfiguera wants to merge 3 commits into
elixir-nx:mainfrom
hfiguera:gliner-entity-extraction
Open

hfiguera wants to merge 3 commits into
elixir-nx:mainfrom
hfiguera:gliner-entity-extraction

Conversation

@hfiguera

Copy link
Copy Markdown

Add entity extraction for fastino/gliner2.5-base-v1, with entity labels supplied per document. This includes the DeBERTa encoder adapter, boundary and span-scoring stages, candidate selection, Unicode preprocessing/decoding, checkpoint loading, and single-document Nx.Serving integration.

{:ok, model} =
  Bumblebee.Text.load_entity_extraction({:hf, "fastino/gliner2.5-base-v1"},
    defn_options: [compiler: EXLA]
  )

serving = Bumblebee.Text.entity_extraction(model, include_spans: true)
Nx.Serving.run(serving, %{text: "Tim Cook works at Apple.", labels: ["person", "company"]})

Spans use Unicode codepoint offsets into the original input. The decoder supports confidence thresholds, abstention, and flat overlap resolution. Synthetic terminal punctuation is removed from returned spans before overlap selection and deduplication. The supported scope is the boundary/shared-pool NER configuration; document batching and other GLiNER tasks are outside this contribution.

Depends on #466. Until that PR is merged, this PR includes its commits. GLiNER-only changes. Validation also uses elixir-nx/nx#1842 and elixir-nx/axon#681.

Validation on CPU:

  • Six model-stage/configuration tests and 14 decoding, preprocessing, and real-checkpoint serving tests passed on both macOS ARM64 and Linux x86_64.
  • The macOS audit passed 7,579 of 7,580 portable comparisons against Python, including all 1,265 public holdout cases. The remaining case (fewnerd-test-17748) has matching entity membership, labels, text, and offsets, but a near-tied confidence difference changes output order. That case passes on Linux. The full audit was run on macOS.
  • Stage fixtures and their Python generator are included, along with real-checkpoint reference examples.

AI disclosure: most of this implementation was generated with an AI coding agent.

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.

1 participant