Skip to content

predict_entities truncates silently -- expose truncation programmatically #378

Description

@girishponkiya

On gliner 0.2.27, input past config.max_len is truncated with only a UserWarning (data_processing/processor.py:513-515). In a service, that is invisible: warnings do not reach structured logs and are deduplicated per process, so the caller gets a normal-looking result with ~70% of a news article never read (gliner_medium_news-v2.1, max_len=296).

Ask:
A per-call signal, e.g. predict_entities(..., return_truncation_info=True) returning {"truncated": True, "num_tokens": N, "max_len": M}, or a truncation="error" mode (#231 asked for the latter, unanswered). Today I count model.data_processor.words_splitter(text) against model.config.max_len, but both are internals.

Doc ask:
Truncation applies to the text tokens before the entity-type prompt is prepended, so the label count never reduces the text budget -- could you confirm and document this? The natural assumption for a uni-encoder is the opposite, and the recurring limit confusion (#183, #275, #185; #244 relatedly) suggests an "input limits" doc section would help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions