Offer: Virgo is available for free to use within your infrastructure. Book a demo

Entity extraction hooks

Extraction is the step where Virgo reads content and pulls out entities and the relationships between them. It is driven by a language model, and a triple extraction hook customizes what that model is asked to find, so domain-specific entities land in the graph.

Implementing a TripleExtractionHook

A hook extends TripleExtractionHook and provides the prompt used for extraction. The model returns triples, a head entity, a relationship, and a tail entity, which become nodes and edges. Override get_system_prompt to steer it, and optionally get_schema to constrain the output or post_process to clean the result.

Private preview

The Python SDK is in private preview, so APIs may still change. Email sales@virgo.fyi for early access.

class IncidentExtractionHook(TripleExtractionHook):
    async def get_system_prompt(self) -> str:
        return (
            "Extract services and incidents as entities, and the "
            "'affected_by' relationships between them."
        )

Register it by overriding triple_extraction_hook() on the connector or on a specific entity. GitHub, for example, attaches its own extraction hook to several entities.

Canonicalization

Extraction also feeds canonicalization: entities the model surfaces are matched against existing nodes by their identifier, so repeated mentions of the same thing collapse into one. Set the identifier field with EntityIdProperty to control how records are merged.