Quick Start¶
Knowledge Graph Generation¶
Configuration phase :
Before launching the graphes generation process you must follow these steps
-
configure properly model parameters
model_nbrand prompt strategiesprompt_typein generate_ttl.pymodel_nbr: Specifies the target LLM (reference:utils_gen/models/models.json)prompt_type: Defines the generation strategy (reference:utils_gen/prompts/prompts.json)
-
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. - Modify
utils_gen/prompts/prompts.jsonwith your own prompt and setPROMPT_TYPEin generate_ttl.py accordingly. - 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
- Modify the
base_urlparameter ofquery LLMfunction, defined ingenerate_ttl_file/utils_gen/utils.py, accordingly to your API. - Modify
utils_gen/prompts/models.jsonwith the API's model name and setmodel_nbrin generate_ttl.py accordingly.
Once it is done you can launch the generation process
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_filesdirectory for correct path resolution. - If you use a local LLM,
query_llmfunction must be rewritten
Graph Consolidation¶
Multiple knowledge graphs can be merged using the consolidation module:
Command Line Parameters :
input_path: Path to individual TTL files or directories containing multiple graphsontology: 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 graphsontology: Ontology file pathvisualization_mode: Eitherbasicfor structural visualization oradvancedfor analytical rendering