From: aidotengineer
The concept of the “knowledge graph mullet” combines elements from both the property graph world and the RDF triple world to create a hybrid and versatile approach for managing knowledge graphs [01:08:00]. This analogy, inspired by the mullet haircut, suggests “business in the front, party in the back” [00:21:00]. In the context of knowledge graphs, this translates to a property graph model in the front and RDF triples in the back [00:54:00]. The goal is to leverage the benefits of both paradigms, offering a low-maintenance, easy-to-work-with, yet versatile and adaptable solution [00:38:00].
Property Graphs vs. RDF
Traditionally, property graphs and RDF are seen as distinct paradigms for working with graphs [01:25:00].
Property Graph Model
In the property graph world, the focus is on:
- Nodes [01:36:00]
- Relationships [01:40:00]
- Key-value pair properties [01:42:00]
- Graph traversal often uses pattern matching with query languages like Cypher [01:45:00].
A knowledge graph is considered an instance of a property graph [02:58:00]. Nodes can have one or more labels for grouping, similar to tables in relational databases [03:06:00]. Relationships have a single type and direction, and arbitrary key-value properties can be stored on both nodes and relationships [03:24:00]. The semantics of how entities are connected are encoded in the data model, focusing on representing “things, not strings” [03:40:00].
RDF World
The RDF world typically focuses on:
- Ontologies [01:54:00]
- Query languages like SPARQL [01:58:00]
- Triples (subject, predicate, object) [02:01:00] RDF originates from the Semantic Web and linked data movements [02:05:00]. A triple can be thought of as a sentence [05:40:00]:
- Subject: Always a node (specifically, a unique ID pointing to a node) [05:46:00], [06:40:00].
- Predicate: A relationship or a property [05:49:00].
- Object: If the predicate is a relationship, the object is another node; if it’s a property, the object is the value of that property [05:53:00].
Dgraph Implementation
Dgraph is an open-source project designed to work with knowledge graphs [02:43:00]. Released in 2017, Dgraph was initially optimized for large-scale distributed graph data, inspired by Google’s Spanner [04:23:00]. It’s a hybrid graph database that uses the property graph model for data modeling and querying, while employing RDF for data interchange, treating triples as the smallest unit of record [04:57:00].
To model a property graph as an RDF triple in Dgraph:
- Each node needs a unique ID, which maps to a disk offset for efficient traversal [06:10:00].
- The subject of an RDF triple is this unique node ID [06:42:00].
- The predicate is either a relationship or a property [06:53:00].
- The object is either another node ID (for relationships) or the value of the property [07:00:00].
Dgraph uses an optimization called a “posting list,” which groups by predicate and lists unique node IDs connected by that predicate, enabling efficient graph traversal [07:14:00].
DQL Query Language
Dgraph uses DQL (Dgraph Query Language), which was inspired by GraphQL [07:38:00]. DQL queries start with a well-defined root criteria, often using an index to find starting nodes [08:16:00]. A nested selection set structure specifies both properties to return and represents the graph traversal [08:29:00]. Results are returned in JSON format, matching the selection set’s structure [08:49:00].
Application: News Knowledge Graph
A practical example of using Dgraph is creating a knowledge graph for news articles [09:03:00].
Data Model
For a news article, entities like organizations, people, and topics are modeled as nodes [09:16:00]. An Article
node can have properties like URL, publish date, title, and abstract, and relationships to Author
, Topic
, Organization
, GeographicArea
, and Image
nodes [10:01:00]. This model allows traversal from an article to a topic and then to other articles with the same topic or geographic location [10:30:00].
Unstructured Data and Graph RAG
Unstructured data, such as article paragraphs, can be chunked and embedded [09:33:00]. Each chunk’s embedding is stored as a node property, enabling vector search as an entry point into the graph [10:44:00].
In a Graph RAG (Retrieval Augmented Generation) approach:
- Vector Search: Identifies relevant chunks in the “lexical graph” [11:04:00].
- Graph Traversal: From these initial chunks, the system traverses the “domain graph” to find related article nodes, topics, organizations, or other articles with overlapping interests [11:36:00]. This provides richer context than a naive RAG approach that would simply inject the found document [11:23:00].
Other entry points can include geospatial indexes (e.g., finding news near a location) or image embedding similarity searches [11:52:00]. Graph RAG is characterized by utilizing different subgraph entry points to gather relevant context for a model [12:32:00].
Dgraph’s vector similarity search allows finding articles close in vector space to a given embedding (e.g., “money laundering”) [14:20:00]. Further traversal can then identify related topics, geographic regions, or organizations, and even discover other articles with overlapping topics not found by vector search alone [14:51:00].
Dgraph MCP Server
The latest release of Dgraph includes the Model Context Protocol (MCP) server [15:57:00]. Fundamentally, MCP exposes tools to models, enabling models to interact with a database [16:33:00].
Each Dgraph instance serves an MCP server:
- Read-only instance: Exposes the ability to execute queries or inspect the schema [16:58:00].
- Full endpoint: Also exposes functionality for mutations (adding data) and altering the schema [17:06:00].
Use Cases
Dgraph MCP server use cases include:
- Agentic coding assistant environments: Tools like Windsurf or Cursor can leverage schema or retrieved data to autogenerate CRUD endpoints or DQL queries [17:21:00].
- Exploratory data analysis: Tools like Claude Desktop can generate DQL queries and fetch data to understand the graph’s contents [17:54:00].
When using database MCP servers, the model generates the database query and then uses the tools defined in the MCP server to execute those queries against the database [20:00:00]. This allows users to create graph schemas and add data without deep knowledge of the specific query language, while simultaneously serving as a learning tool for the query language [20:45:00].
Agent Orchestration with Modus
To build agentic applications, Hypermode created the Modus agent orchestration framework [24:14:00]. Modus is an open-source framework for creating AI agents, bringing data to models, and exposing tools and abstractions for agentic flows [24:21:00]. Key functionalities include:
- Abstractions for working with models and data [24:46:00].
- A runtime for managing a large number of stateful, long-running agents [24:53:00].
- An SDK library for working with agents [25:13:00].
Modus leverages WebAssembly to target multiple languages (like Go or AssemblyScript) for different SDKs, compiling code to WebAssembly and generating a unified GraphQL API [25:16:00]. The WebAssembly runtime also provides security and a sandboxed environment for AI agents [25:55:00].
Hypermode Agents
Hypermode Agents allow users to build domain-specific agents primarily from a prompt, exposing tools via MCP servers [26:31:00].
Example: Social Media Intern Agent
An agent can be defined with a background prompt (e.g., “social media expert”) and a reasoning model (e.g., GPT-4) [27:19:00]. Connections to MCP servers (e.g., GitHub, Notion, company docs) allow the agent to interact with its environment [27:47:00].
A task could involve analyzing a GitHub repo (like Hypernews, which contains Dgraph tooling) and generating social media posts explaining technical concepts [28:17:00]. The agent makes tool calls to search the repo and fetch file contents [28:44:00]. It can then be prompted to update these posts with relevant code snippets, using its tools to access source files [29:16:00]. Finally, the agent can save these posts to a Notion workspace by accessing it through the Notion MCP server [30:00:00].
A notable feature is the ability to “eject to code,” allowing users to obtain the underlying Modus code for the agent, enabling further customization and complex logic [31:18:00].
Conclusion
The “knowledge graph mullet” approach, implemented through tools like Dgraph, combines the strengths of property graphs and RDF triples to build powerful Graph RAG workflows [32:17:00]. This foundation can then be leveraged for constructing advanced AI agents, with features like the Dgraph MCP server and agent orchestration frameworks like Modus facilitating interaction with knowledge graphs and other services [32:30:00].