Skip to main content

agrag.ingestion.extract.Extractor

Bases: ABC

Reads one chunk and returns the entities and relations it contains.

Note

Subclass this class to provide custom extraction. Graph awaits extract once for each chunk. The built-in extractors are GlinerExtractor (a local model), BAMLExtractor (an LLM call), and EscalatingExtractor (a cheap extractor first, a stronger one when the result is weak).

Functions:

  • extract – Extract entities and relations from one chunk.

extract​

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

Extract entities and relations from one chunk.

Parameters:

  • chunk (Chunk) – The chunk to read. Only chunk.text and chunk.id are used.
  • schema (GraphSchema) – The entity/relation types to extract. Every returned entity's label and relation's label must be declared in this schema.

Returns:

  • ExtractionResult – The entities and relations this call found, in extraction order.