RelikGraphTransformer#

class langchain_experimental.graph_transformers.relik.RelikGraphTransformer(model: str = 'relik-ie/relik-relation-extraction-small', relationship_confidence_threshold: float = 0.1, model_config: Dict[str, Any] = {}, ignore_self_loops: bool = True)[source]#

A transformer class for converting documents into graph structures using the Relik library and models.

This class leverages relik models for extracting relationships and nodes from text documents and converting them into a graph format. The relationships are filtered based on a specified confidence threshold.

For more details on the Relik library, visit their GitHub repository:

SapienzaNLP/relik

Parameters:
  • model (str) – The name of the pretrained Relik model to use. Default is β€œrelik-ie/relik-relation-extraction-small-wikipedia”.

  • relationship_confidence_threshold (float) – The confidence threshold for filtering relationships. Default is 0.1.

  • model_config (Dict[str, any]) – Additional configuration options for the Relik model. Default is an empty dictionary.

  • ignore_self_loops (bool) – Whether to ignore relationships where the source and target nodes are the same. Default is True.

Methods

__init__([model,Β ...])

convert_to_graph_documents(documents)

Convert a sequence of documents into graph documents.

process_document(document)

__init__(model: str = 'relik-ie/relik-relation-extraction-small', relationship_confidence_threshold: float = 0.1, model_config: Dict[str, Any] = {}, ignore_self_loops: bool = True) β†’ None[source]#
Parameters:
  • model (str) –

  • relationship_confidence_threshold (float) –

  • model_config (Dict[str, Any]) –

  • ignore_self_loops (bool) –

Return type:

None

convert_to_graph_documents(documents: Sequence[Document]) β†’ List[GraphDocument][source]#

Convert a sequence of documents into graph documents.

Parameters:
  • documents (Sequence[Document]) – The original documents.

  • kwargs – Additional keyword arguments.

Returns:

The transformed documents as graphs.

Return type:

Sequence[GraphDocument]

process_document(document: Document) β†’ GraphDocument[source]#
Parameters:

document (Document) –

Return type:

GraphDocument