Skip to content

The Knowledge Laboratory (KLAB) - A hub for learning, conducting research, and building community on knowledge technologies.

Notifications You must be signed in to change notification settings

giuseppefutia/klab

Repository files navigation

KLAB: The Knowledge Laboratory

The Knowledge Laboratory (KLAB) is a hub for learning, conducting research, and building community around cutting-edge knowledge technologies.

  1. Building a Hybrid Knowledge Graph System

  2. Unlocking Graph Neural Networks


🚀 Building a Hybrid Knowledge Graph System

Integrating LPG, RDF, and LLMs for Advanced Analytics

  • Knowledge Graph Conference 2025 - SLIDES

🧪 Step 1: Create and Activate Your Virtual Environment

virtualenv -p python3 venv
source venv/bin/activate

📦 Step 2: Install Required Dependencies

pip install -r requirements.lock

📁 Step 3: Download the Data

Download the dataset from this Google Drive folder and place the files in:

data/chicago/

Alternatively, download neo4.dump from the same folder to load into your Neo4j database (version 5.26.4 enterprise edition recommended).

🧱 Step 4: Build the Chicago Knowledge Graph (CKG)

To build the KG, you have to update the config.ini file in the root folder (neo4j access).

Run the full setup script:

./run_chicago_factory.sh
Or manually execute each step:
python -m factory.chicago.owner --backend neo4j --file Business_Owners_20240103.csv
python -m factory.chicago.employee --backend neo4j --file Employees_20250422.csv
python -m factory.chicago.people_cluster --backend neo4j
python -m factory.chicago.contract --backend neo4j --file Contracts_20240103.csv
python -m factory.chicago.license --backend neo4j --file Business_Licenses_20240103.csv
python -m factory.chicago.org_cluster --backend neo4j
python -m factory.chicago.dept_similarity --backend neo4j

To delete and reset the graph:

python -m factory.chicago.delete --backend neo4j

🔁 Step 5: Extract RDF from the LPG Database

The RDF generation is currently performed manually. Look at the mapping.py files in the regulatory_compliance/, conflict_of_interest/, three_sixty_degree_view folders within the analysis and adjust the queries accordingly based on your Neo4j node ids.

python -m analysis.chicago.regulatory_compliance.rdf_mapper --backend neo4j
python -m analysis.chicago.conflict_of_interest.mapper --backend neo4j
python -m analysis.chicago.three_sixty_degree_view.mapper --backend neo4j

🔍 Step 6: Use Case Analysis

To build the KG, you have to update the config.ini file in the root folder (openai api-key).

Run the following queries to check the results of your agent.

Regulatory Compliance Test Query
MATCH path=(c:Contract)<-[:INCLUDED_IN_CONTRACT]-(contractRecord:ContractRecord)-[:HAS_VENDOR]->(contractOrg:Organization)-[:BELONGS_TO_ORG_GROUP]->(o:OrganizationGroup)<-[:BELONGS_TO_ORG_GROUP]-(licenseOrg:Organization)-[:ORG_HAS_LICENSE]->(license:LicenseRecord)
WHERE licenseOrg.name = "Stage Left, Inc."
RETURN path
Conflict of Interest Test Query - Example 1
 MATCH 
   path=(p2:Person)<-[:RECORD_RESOLVED_TO]-(:PersonRecord)
   -[:WORKS_FOR_DEPARTMENT]->(dept1:Department)
   -[:IS_SIMILAR_TO]->(dept2:Department)
   -[:ASSIGNS_CONTRACT]->(:Contract)<-[:INCLUDED_IN_CONTRACT]-(c:ContractRecord)
   -[:HAS_VENDOR]->(vendor1:Organization)
   -[:BELONGS_TO_ORG_GROUP]->(orgGroup:OrganizationGroup)<-[:BELONGS_TO_ORG_GROUP]-
   (vendor2:Organization)<-[:WORKS_FOR_ORG]-(p1:Person)
WHERE 
   (
      elementId(p2) = "4:5bc9e9e3-9f8e-4060-84df-00fa505e2753:527380"OR 
      elementId(p1) = "4:5bc9e9e3-9f8e-4060-84df-00fa505e2753:520260"
   )
   AND vendor1 <> vendor2
   AND p1 <> p2
   AND toLower(p1.name) <> toLower(p2.name)
   AND split(toLower(p1.name), " ")[-1] = split(toLower(p2.name), " ")[-1]
RETURN path
LIMIT 5
Conflict of Interest Test Query - Example 2
 MATCH 
   path=(p2:Person)<-[:RECORD_RESOLVED_TO]-(:PersonRecord)
   -[:WORKS_FOR_DEPARTMENT]->(dept1:Department)
   -[:IS_SIMILAR_TO]->(dept2:Department)
   -[:ASSIGNS_CONTRACT]->(:Contract)<-[:INCLUDED_IN_CONTRACT]-(c:ContractRecord)
   -[:HAS_VENDOR]->(vendor1:Organization)
   -[:BELONGS_TO_ORG_GROUP]->(orgGroup:OrganizationGroup)<-[:BELONGS_TO_ORG_GROUP]-
   (vendor2:Organization)<-[:WORKS_FOR_ORG]-(p1:Person)
WHERE 
   (
      elementId(p2) = "4:5bc9e9e3-9f8e-4060-84df-00fa505e2753:527206"OR 
      elementId(p1) = "4:5bc9e9e3-9f8e-4060-84df-00fa505e2753:486091"
   )
   AND vendor1 <> vendor2
   AND p1 <> p2
   AND toLower(p1.name) <> toLower(p2.name)
   AND split(toLower(p1.name), " ")[-1] = split(toLower(p2.name), " ")[-1]
RETURN path
LIMIT 5
360-Degree View Test Query
MATCH path=(pr:PersonRecord)-[:RECORD_RESOLVED_TO]->(p:Person)
                -[:WORKS_FOR_ORG]->(:Organization)
                -[:BELONGS_TO_ORG_GROUP]->(:OrganizationGroup)<-[:BELONGS_TO_ORG_GROUP]-
                (o:Organization)<-[:HAS_VENDOR]-(c:ContractRecord)-[:INCLUDED_IN_CONTRACT]->(x:Contract)
WHERE p.name = "Sister Marie Valerie Chaillou"
AND c.amount <> 0
RETURN path
LIMIT 10

🤖 Unlocking Graph Neural Networks

A Hands-on Journey from Basics to Breakthroughs

  • Knowledge Graph Conference 2025 - SLIDES

📚 Theory

🧱 Layers

🎯 Applications

About

The Knowledge Laboratory (KLAB) - A hub for learning, conducting research, and building community on knowledge technologies.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published