gliner.streaming module¶

Synchronous fixed-batch and asynchronous streaming inference surfaces.

class gliner.streaming.AsyncStreamingEngine(model, *, max_batch_size=32, batch_wait_timeout_ms=2.0, queue_capacity=4096)[source]¶

Bases: object

Dynamically microbatch independently arriving streaming sessions.

__init__(model, *, max_batch_size=32, batch_wait_timeout_ms=2.0, queue_capacity=4096)[source]¶
async start()[source]¶

Start the scheduler lazily on the current event loop.

async append(session_id, text, labels, *, threshold=0.5, flat_ner=True, multi_label=False, return_class_probs=False, recompute=False)[source]¶

Queue one append; concurrent callers are dynamically microbatched.

async stream(session_id, chunks, labels, **kwargs)[source]¶

Yield a session snapshot for every chunk from sync or async input.

async clear_session(session_id)[source]¶

Wait for prior work on a session, then discard its cache.

async close()[source]¶

Drain queued work and stop the scheduler. Idempotent.

class gliner.streaming.StreamingBatch(model, session_ids, labels)[source]¶

Bases: object

Persistent fixed-order batch for synchronous streaming inference.

The session-to-row mapping is immutable, allowing the decoder KV cache to remain batched between calls without stacking or splitting historical keys.

__init__(model, session_ids, labels)[source]¶
property closed: bool¶
property initialized: bool¶
append(texts, *, threshold=0.5, flat_ner=True, multi_label=False, return_class_probs=False, recompute=False)[source]¶

Append one text chunk per fixed session row and return snapshots.

reset()[source]¶

Discard the entire persistent cache while retaining row ownership.

close()[source]¶

Release the persistent batch cache. Idempotent.