Skip to content

Quick Start

Knowledge Graph Generation

Configuration phase :

Before launching the graphes generation process you must follow these steps

  1. configure properly model parameters model_nbr and prompt strategies prompt_type in generate_ttl.py

    • model_nbr: Specifies the target LLM (reference: utils_gen/models/models.json)
    • prompt_type: Defines the generation strategy (reference: utils_gen/prompts/prompts.json)
  2. Place your ontology in the appropriate folders (utils_gen/ontologies/) and modify the ontologie_file variable in utils_gen/utils.py/build_folder_paths_and_files function accordingly.

  3. Modify utils_gen/prompts/prompts.json with your own prompt and set PROMPT_TYPE in generate_ttl.py accordingly.
  4. If you are using an API to call your LLM you have to
    • Store your api key in an environment variable called LLM_API_KEY
      export LLM_API_KEY="your_api_key"
      
    • Modify the base_url parameter of query LLM function, defined in generate_ttl_file/utils_gen/utils.py, accordingly to your API.
    • Modify utils_gen/prompts/models.json with the API's model name and set model_nbr in generate_ttl.py accordingly.

Once it is done you can launch the generation process

cd generate_ttl_files
python3 generate_ttl.py --nbrttl <number_of_graphs> --reasoner <reasoner>

Command Line Parameters :

  • number_of_graph: The number of graphs you want to generate.
  • reasoner : The reasonner (Pellet or HermiT) to use for ontological compliancy checking.

  • Generated Turtle files will be stored in a dynamically created results/synthetics_graphs/<date>/<model>/ folder.

  • Log files will be created in the corresponding logs/ subfolder.

Notes

  • Syntax, format and ontological compliancy are automatically checked when a graph is generated. Wrong graphs are automatically discarded and stored in specific folders.
  • Make sure to run the script from the generate_ttl_files directory for correct path resolution.
  • If you use a local LLM, query_llm function must be rewritten

Graph Consolidation

Multiple knowledge graphs can be merged using the consolidation module:

cd merge_ttl_files
python3 merge_ttl.py --path_file <input_path> --ontology <ontology_file>

Command Line Parameters :

  • input_path: Path to individual TTL files or directories containing multiple graphs
  • ontology: Ontology file path

The consolidation process generates several merged graphs that differ from each other in terms of their number of nodes and therefore their density. This process is based on the recognition of homonymous nodes, in the set of graphes generated by the LLM, and their sequential renaming from a merged graph where no homonymous are renamed to the renaming of all homonymous corresponding to the juxtaposition of graphs generated by the LLM.

Merged files are automatically checking by Turtle Validator for syntax validation. Each validated file is stored in a "merged" folder beside the LLM generated graphs folder.

Graph Visualization and Analysis

The visualization module supports both basic structural rendering and advanced analytical visualization:

cd display_graphs
python display_graphs.py --path <input_path> --ontology <ontology> --mode <visualization_mode>

Command Line Parameters :

  • input_path: Path to individual TTL files or directories containing multiple graphs
  • ontology: Ontology file path
  • visualization_mode: Either basic for structural visualization or advanced for analytical rendering