Version: latest
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. GlinerExtractor is a local
extractor. LLMExtractor marks the LLM role: Graph gives it only
the weakest chunks, as llm_extractor. Graph drops any entity or
relation whose label the schema does not declare, and logs the count.
Graph runs up to max_concurrency extract calls at the same
time. An extractor that is not safe to call from several tasks at once
sets max_concurrency to 1 or makes its calls take turns itself, for
example with an asyncio.Lock.
Attributes:
- max_concurrency (
int) – The mostextractcalls that run at once for one batch of chunks. Must be positive.
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. Onlychunk.textandchunk.idare used. - schema (
GraphSchema) – The entity/relation types to extract. Every returned entity'slabeland relation'slabelmust be declared in this schema.
Returns:
ExtractionResult– The entities and relations this call found, in extraction order.
max_concurrency
max_concurrency: int = 8