Skip to content

GLiNER-family adapters: hardening follow-ups from #380 and #381 #382

Description

@svonava

Hardening follow-ups for the GLiNER-family adapters, from the review of #380 and #381. None of them block those PRs.

  • GLiNER2 caller errors should raise InvalidInputError. Bad metadata.entities on relations, invalid labels or schema, and multi_label misuse currently raise ValueError, which surfaces as a server error. Raise InvalidInputError instead, as GLiREL now does, so these return 400 INVALID_INPUT.
  • Count GLiNER2's real prompt. Measure the prompt gliner2 actually builds, as the GLiNER path does, instead of estimating it. The estimate over-counts plain field specs, so some valid schemas are rejected, and it can under-count JSON-heavy ones by about 2%.
  • Validate the prompt before windowing the document in GLiNER2. Today the document is windowed and metered first. That work is already bounded, so this is an efficiency change.
  • Apply the 128-character label check to the GLiNER bi-encoder. This matches the other GLiNER-family adapters.
  • GLiNER2 metering covers the window. GLiNER2 meters document tokens up to 512, while the window it reads can hold up to 2048 subwords. Consider metering the window's subwords, as GLiNER does.
  • Docstring. Update the 50-field schema figure in _prompt_limit.py to about 1,260 tokens.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions