Inspiration
Building a knowledge graph is relatively simple, but determining what the graph should actually mean is the real challenge.
Most knowledge graph systems require users to either draft a schema manually from scratch or directly map the table headers into graph nodes. In reality, an effective data model completely depends on the problem we are solving. The same underlying HarmBench AI Safety Benchmark requires a completely different conceptual structure for Adversarial Threat Patterns & Vulnerabilities (which prioritizes entities like AdversarialAttack, VulnerabilityPattern, ThreatCluster, RiskSeverity) than Regulatory Compliance & Risk Auditing (which prioritizes entities like BehaviorTestCase, ComplianceFramework, HarmCategory, and MitigationPolicy, RefusalFilter)
We created this Ontology Generator to solve this challenge. Since there is no off-the-shelf ontology model that satisfies users' last mile needs, instead of forcing domain experts to manually design ontologies , our system analyzes raw data alongside the user's objective to infer a task-conditioned ontology.
How we built it
We implemented a structural architecture where AI handles semantic reasoning and deterministic Python manages database writes.
- Source Profiler (Pandas): Summarizes messy input files by computing clean schema definitions, data types, sample values, and statistical distributions.
- Semantic Induction Engine (K2 Horizon): Passes the source profiles and the user's objective to K2 Horizon. K2 resolves concept equivalence, isolates key entities, and defines meaningful relationships.
- Ontology Intermediate Representation (IR): The model outputs a JSON IR defining entities, properties, and source mappings.
- Pydantic Boundary: Validates that all relationship sources and targets reference defined entities, types are consistent, and required keys exist.
- Graph Compiler & Neo4j Storage: Python code translates the IR and source data into Cypher queries to instantiate nodes and edges inside Neo4j.
- Next.js/React Frontend: Renders both the interactive ontology schema and the compiled knowledge graph.
Challenges we ran into
The model successfully interprets different prompts and generates different meaningful ontologies for multiple use cases. We tested the system repeatedly on the same input dataset while changing the user objective, then compared the resulting entity types, relationships, and source mappings. Establishing that these were meaningful structural changes—not just wording differences—was an important part of validating the system.
Accomplishments that we're proud of
We built a working end-to-end pipeline that turns raw CSV/JSON data and a user objective into a validated, executable knowledge graph. We also built both ontology-level and instance-level graph visualizations in the frontend, so users can see not only what the system thinks the graph should mean, but also the actual graph created from their data.
What we learned
- "Same Data + Different Goal = Different Ontology": Data models are much more effective when conditioned on the user's explicit task rather than derived purely on raw database tables.
- Agentic Reasoning Belongs at the Conceptual Layer: High-capacity reasoning models like K2 Horizon excel at higher-order semantic tasks and domain reconciliation.
What's next for K2 Ontology Generator
We want to turn the current pipeline into an iterative ontology-building workflow: larger datasets, human review and revision, provenance for modeling decisions, and an agentic K2 loop that can inspect ambiguous sources and refine the ontology before updating Neo4j. We also plan to add natural-language querying so users can move directly from raw data to a task-specific graph to analysis.
Built With
- ontology
- python