Skip to main content

agrag.ingestion.extract.EscalatingExtractor

EscalatingExtractor(primary:Extractor, escalate_to:Extractor, *, min_confidence:float = 0.5, min_chunk_words:int = 8, tracer:Tracer | None = None) -> None

Bases: Extractor

Run a cheap extractor on every chunk and a stronger one on weak results.

The primary extractor runs first. A chunk escalates when the primary finds no entities in a chunk of at least min_chunk_words words, or when the mean entity confidence is below min_confidence. An escalated chunk gets the escalate_to result alone. The two results are never combined. A common pairing is GlinerExtractor as primary and BAMLExtractor as fallback.

Parameters:

  • primary (Extractor) – Extractor that runs on every chunk.
  • escalate_to (Extractor) – Extractor that replaces the primary result when escalation triggers.
  • min_confidence (float) – Escalate when the primary's mean reported confidence is below this value.
  • min_chunk_words (int) – Treat an empty primary result as weak only when the chunk has at least this many words.
  • tracer (Tracer | None) – Opens the agrag.extraction.escalating span. None opens no recorded span.

Functions:

  • extract – Extract with the primary extractor, escalating when it is weak.

Attributes:

escalate_to​

escalate_to = escalate_to

extract​

extract(chunk:Chunk, schema:GraphSchema) -> ExtractionResult

Extract with the primary extractor, escalating when it is weak.

Parameters:

  • chunk (Chunk) – The chunk to read.
  • schema (GraphSchema) – The entity and relation types to extract.

Returns:

  • ExtractionResult – The primary result, or the escalation result when escalation triggers.

min_chunk_words​

min_chunk_words = min_chunk_words

min_confidence​

min_confidence = min_confidence

primary​

primary = primary