Configure your R2R graph system.

R2R supports robust knowledge graph functionality to enhance document understanding and retrieval.

By default, R2R creates graphs by first extracting the entities and relationships associated with a given document. Next collections can be formed out of your ingested documents. For each collection, a corresponding graph can be built over the input documents.

You can find out more about this with the knowledge graph cookbook and the GraphRAG cookbook. To configure the knowledge graph settings for your project, edit the database section in your r2r.toml file:

r2r.toml
1[database]
2default_collection_name = "Default"
3default_collection_description = "Your default collection."
4collection_summary_prompt = "collection_summary"
5
6 [database.graph_creation_settings]
7 graph_entity_description_prompt = "graph_entity_description"
8 graph_extraction_prompt = "graph_extraction"
9 entity_types = [] # if empty, all entities are extracted
10 relation_types = [] # if empty, all relations are extracted
11 automatic_deduplication = true # enable automatic deduplication of entities
12
13 [database.graph_enrichment_settings]
14 graph_communities_prompt = "graph_communities"

Setting configuration values in the r2r.toml will override environment variables by default.

Knowledge Graph Operations

  1. Entity Management: Add, update, and retrieve entities in the knowledge graph.
  2. Relationship Management: Create and query relationships between entities.
  3. Batch Import: Efficiently import large amounts of data using batched operations.
  4. Vector Search: Perform similarity searches on entity embeddings.
  5. Community Detection: Identify and manage communities within the graph.

Customization

You can customize the knowledge graph extraction and search processes by modifying the kg_triples_extraction_prompt and adjusting the model configurations in kg_extraction_settings and graph_settings. Moreover, you can customize the LLM models used in various parts of the knowledge graph creation process. All of these options can be selected at runtime, with the only exception being the specified database provider. For more details, refer to the knowledge graph settings in the search API.

By leveraging the knowledge graph capabilities, you can enhance R2R’s understanding of document relationships and improve the quality of search and retrieval operations.

Next Steps

For more detailed information on configuring specific components of the ingestion process, please refer to the following pages:

Built with