Structured knowledge extraction from meeting transcripts โ PostgreSQL ontology graph
Project description
๐ง Ontology Engine
Transform unstructured text into structured knowledge graphs โ powered by LLMs, stored in PostgreSQL.
An open-source, schema-driven framework that extracts entities, relationships, decisions, and action items from meeting transcripts (or any text) into a PostgreSQL-backed knowledge graph. Designed for multi-agent AI systems that need shared organizational memory.
Architecture
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Ontology Engine โ
โ โ
Text Input โโโโโโโบ โโโโโโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโโโ โ
(meetings, โ โ BRONZE โ โ SILVER โ โ GOLD โ โ
documents, โ โ โ โ โ โ โ โ
reports) โ โ Raw doc โโโโบ Schema- โโโโบ Entity โ โ
โ โ storage โ โ driven โ โ resoln + โ โ
โ โ (append โ โ extract โ โ merge + โ โ
โ โ only) โ โ + valid โ โ embeds โ โ
โ โโโโโโโโโโโโ โโโโโโโโโโโโ โโโโโโฌโโโโโโ โ
โ โ โ
โ โโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโ โ
โ โ Agent โ โ โ
โ โ SDK โโโโ PostgreSQL + pgvector โ
โ โ + REST โ (JSONB knowledge graph) โ
โ โ API โ โ
โ โโโโโโฌโโโโโโ โ
โโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโผโโโโโโโโ
โ AI Agents โ
โ query, write โ
โ subscribe โ
โโโโโโโโโโโโโโโโโ
Bronze Layer โ Immutable, append-only raw document store with deduplication (SHA-256).
Silver Layer โ Schema-driven LLM extraction pipeline: preprocessing โ 4-pass extraction (entities, relations, decisions, actions) โ 3-layer auto-correction.
Gold Layer โ Entity resolution (Jaro-Winkler + alias matching + embeddings), deduplication, and computed aggregation. The canonical knowledge graph.
Agent SDK โ Python async client + FastAPI REST API for AI agents to query, write, and subscribe to the knowledge graph.
Quick Start
Install
pip install ontology-engine[all]
Extract knowledge from text (3 lines)
import asyncio
from ontology_engine.pipeline.engine import PipelineEngine
from ontology_engine.core.config import OntologyConfig
async def main():
engine = await PipelineEngine.create(OntologyConfig())
result = await engine.ingest("meeting_notes.md")
print(f"Found {len(result.extraction.entities)} entities, "
f"{len(result.extraction.decisions)} decisions")
asyncio.run(main())
Or use the CLI
# Set your LLM API key
export GEMINI_API_KEY="your-key"
# Process a single file
ontology-engine ingest meeting.md -o result.json
# Process a directory
ontology-engine ingest-dir ./meetings/ --pattern "*.md"
# Use a domain schema
ontology-engine ingest meeting.md --schema edtech
Features
๐ค Bronze Layer โ Raw Document Storage
- Append-only, immutable document store
- SHA-256 content deduplication
- Source tracking (type, URI, format, language)
- CLI:
ontology-engine bronze list,ontology-engine bronze show <id>
โช Silver Layer โ Schema-Driven Extraction
- Preprocessing: text cleaning, topic segmentation, coreference resolution
- 4-Pass extraction: Entities โ Relations โ Decisions โ Action Items
- 3-Layer validation: factual correction, semantic checks, consistency enforcement
- 6 built-in entity types: Person, Decision, ActionItem, Project, Risk, Deadline
- 13 link types: participates_in, makes, assigned_to, relates_to, generates, supersedes, depends_on, mitigates, blocks, reports_to, collaborates_with, owns, deadline_for
- Provenance tracking: every fact traced to source text + extraction pass
๐ก Gold Layer โ Entity Resolution & Embeddings
- Entity resolution: exact match, alias matching, Jaro-Winkler fuzzy matching
- Configurable thresholds: auto-merge (>0.95), review (0.80โ0.95), distinct (<0.80)
- Embedding generation: OpenAI text-embedding-3-small for semantic search
- Incremental builds: only process new Silver entities
- Full rebuild: clear and recompute from Silver at any time
๐ค Agent SDK & REST API
- Python async client (
OntologyClient): query, search, assert entities/links, subscribe to events - Agent registry: agents register what they produce/consume
- FastAPI REST API: 12 endpoints for HTTP integration
- Event system: PostgreSQL LISTEN/NOTIFY for real-time change notifications
๐ Domain Schemas (YAML)
- Define custom entity types, link types, and properties per domain
- Built-in schemas:
default,edtech,finance - Extraction hints for LLM guidance
- Validation rules per schema
Domain Schemas
Define domain-specific ontologies in YAML:
domain: edtech
version: "1.0.0"
description: "Education technology domain"
entity_types:
- name: Student
description: "A student or learner"
properties:
- { name: student_id, type: string, required: true }
- { name: grade_level, type: string }
- { name: enrollment_status, type: enum, enum_values: ["active","graduated","withdrawn"] }
extraction_hint: "ๅญฆ็ใๅญฆๅใๅๅญฆ็ญ"
- name: Course
description: "A course or class"
properties:
- { name: course_code, type: string, required: true }
- { name: credits, type: integer }
link_types:
- { name: enrolled_in, source_types: [Student], target_types: [Course] }
- { name: teaches, source_types: [Tutor], target_types: [Course] }
extraction:
system_prompt: |
You are an education-focused knowledge extraction system.
Extract students, courses, knowledge units, and their relationships.
Use with CLI: ontology-engine ingest meeting.md --schema edtech
Manage schemas:
ontology-engine schema list # List available schemas
ontology-engine schema show edtech # Show schema details
ontology-engine schema validate my_schema.yaml
Agent SDK
Build AI agents that read and write to the shared knowledge graph:
from ontology_engine.sdk.client import OntologyClient
async with OntologyClient("postgresql://localhost/ontology") as client:
# Register your agent
await client.register_agent(
id="meeting-bot",
display_name="Meeting Bot",
produces=["Decision", "ActionItem"],
consumes=["Person", "Project"],
)
# Write: assert entities and links
decision_id = await client.assert_entity(
entity_type="Decision",
name="Adopt microservices architecture",
properties={"detail": "Migrate monolith to microservices by Q3", "rationale": "Scalability"},
source="meeting:2024-01-15",
confidence=0.95,
)
# Read: query and search
decisions = await client.query("Decision", filters={"status": "active"})
results = await client.search("microservices", limit=5)
# Traverse the graph
linked = await client.get_linked(decision_id, direction="outgoing", depth=2)
# Schema introspection (for autonomous agents)
schema = await client.describe("Decision")
# Subscribe to changes (PostgreSQL LISTEN/NOTIFY)
async def on_change(event):
print(f"Entity changed: {event.entity_type} {event.entity_id}")
await client.subscribe("Decision", on_change)
API Reference
Start the API server:
# Via module
python -m ontology_engine.api.server --db-url "postgresql://..." --port 8000
# Or with uvicorn
uvicorn ontology_engine.api.server:app --reload
Endpoints
| Method | Path | Description |
|---|---|---|
GET |
/api/v1/health |
Health check |
GET |
/api/v1/query |
Query entities by type + filters |
GET |
/api/v1/search?q=... |
Full-text search (trigram similarity) |
GET |
/api/v1/entity/{id} |
Get entity by ID |
GET |
/api/v1/linked/{id} |
Graph traversal from entity |
POST |
/api/v1/ingest |
Ingest raw text (Bronze) |
POST |
/api/v1/assert/entity |
Create/update entity |
POST |
/api/v1/assert/link |
Create relationship |
GET |
/api/v1/describe/{type} |
Schema introspection |
GET |
/api/v1/agents |
List registered agents |
POST |
/api/v1/agents/register |
Register an agent |
Interactive docs at http://localhost:8000/docs (Swagger UI).
Configuration
Environment Variables
| Variable | Description | Default |
|---|---|---|
GEMINI_API_KEY |
Google Gemini API key | โ |
OPENAI_API_KEY |
OpenAI API key (for embeddings) | โ |
DATABASE_URL |
PostgreSQL connection URL | โ |
Config File
{
"llm": {
"provider": "gemini",
"model": "gemini-2.5-flash",
"api_key": "your-key",
"temperature": 0.1
},
"database": {
"url": "postgresql://localhost:5432/ontology",
"db_schema": "ontology"
},
"pipeline": {
"min_confidence": 0.6,
"segment_topics": true,
"resolve_coreferences": true
},
"known_entities": {
"aliases": {
"Yann": ["Yannๅฅ", "้ญๅ", "้ช"]
}
}
}
Use with: ontology-engine -c config.json ingest meeting.md
LLM Model Tiers
| Tier | Default Model | Used For |
|---|---|---|
| Fast | gemini-2.0-flash-lite |
Preprocessing, simple tasks |
| Default | gemini-2.5-flash |
Extraction, validation |
| Strong | gemini-2.5-pro |
Complex reasoning, conflict resolution |
Supports pluggable LLM providers: Gemini (default), OpenAI.
Database Setup
# Initialize schema (creates tables, indexes, extensions)
ontology-engine init --db-url "postgresql://user:pass@localhost:5432/ontology"
Requires PostgreSQL 15+ with extensions:
pgvectorโ vector similarity searchpg_trgmโ trigram text search
Or use Docker:
docker compose up -d
Testing
# Unit tests (no API key or DB required, fast)
pytest tests/ --ignore=tests/integration/ -v
# Integration tests (requires GEMINI_API_KEY + PostgreSQL)
pytest tests/integration/ -v -s
# All tests
pytest -v
# With coverage
pytest --cov=ontology_engine --cov-report=term-missing
Project Structure
ontology-engine/
โโโ src/ontology_engine/
โ โโโ core/ # Types, config, errors, schema format
โ โ โโโ types.py # 6 Entity + 13 Link type definitions
โ โ โโโ config.py # Pydantic configuration models
โ โ โโโ schema_format.py # Domain schema Pydantic models
โ โ โโโ schema_registry.py # Schema loader + registry
โ โ โโโ errors.py # Custom exception hierarchy
โ โโโ pipeline/ # BronzeโSilver extraction pipeline
โ โ โโโ preprocessor.py # Text cleaning, segmentation
โ โ โโโ extractor.py # 4-Pass LLM extraction
โ โ โโโ validator.py # 3-Layer auto-correction
โ โ โโโ engine.py # Pipeline orchestrator
โ โโโ fusion/ # SilverโGold aggregation
โ โ โโโ entity_resolver.py # Jaro-Winkler + alias entity resolution
โ โ โโโ gold_builder.py # Gold layer builder
โ โ โโโ embeddings.py # OpenAI embedding generation
โ โโโ storage/ # PostgreSQL persistence
โ โ โโโ bronze.py # Bronze document repository
โ โ โโโ repository.py # Silver entity/link CRUD
โ โ โโโ gold_repository.py # Gold entity/link CRUD
โ โ โโโ schema.py # DDL + migrations
โ โโโ sdk/ # Agent SDK
โ โ โโโ client.py # OntologyClient (async)
โ โ โโโ registry.py # Agent registration + discovery
โ โโโ api/ # FastAPI REST API
โ โ โโโ server.py # App factory + lifespan
โ โ โโโ routes.py # 12 API endpoints
โ โ โโโ models.py # Request/response schemas
โ โโโ llm/ # LLM provider abstraction
โ โ โโโ base.py # Abstract interface
โ โ โโโ gemini.py # Google Gemini
โ โ โโโ openai.py # OpenAI
โ โโโ events/ # Event system
โ โ โโโ notifier.py # PG LISTEN/NOTIFY pub/sub
โ โโโ cli.py # CLI entry point (Click + Rich)
โโโ domain_schemas/ # Built-in YAML domain schemas
โ โโโ default.yaml
โ โโโ edtech.yaml
โ โโโ finance.yaml
โโโ tests/ # 258 unit + 46 integration tests
โโโ docs/ # Documentation
โโโ pyproject.toml
โโโ Dockerfile
โโโ docker-compose.yml
โโโ CHANGELOG.md
Contributing
We welcome contributions! Here's how to get started:
# Clone and install in development mode
git clone https://github.com/Yvnminc/ontology-engine.git
cd ontology-engine
python3 -m venv .venv
source .venv/bin/activate
pip install -e ".[all,dev]"
# Run linting
ruff check src/ tests/
ruff format src/ tests/
# Run type checking
mypy src/ontology_engine/
# Run tests
pytest -v
Please open an issue first to discuss significant changes.
Roadmap
โ Phase 1: Static Ontology (current โ v0.1.0)
- Bronze โ Silver โ Gold full pipeline
- Schema-driven extraction with YAML domain schemas
- Entity resolution + embedding generation
- Agent SDK + FastAPI REST API
- PostgreSQL + pgvector storage
- CLI tools
๐ Phase 2: Kinetic Ontology
- Real-time streaming ingestion
- Incremental Gold updates on every ingest
- Conflict detection and resolution
- Temporal queries (point-in-time knowledge graph)
- Webhook integrations
๐ฎ Phase 3: Dynamic Ontology
- Schema evolution and migration
- Cross-domain knowledge fusion
- Autonomous agent orchestration
- Graph neural network embeddings
- Multi-tenant deployment
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ontology_engine-0.1.0.tar.gz.
File metadata
- Download URL: ontology_engine-0.1.0.tar.gz
- Upload date:
- Size: 140.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fb01e268015d6888ad88cd5c8609561b4b836710583e221c33d762a5d1d8484a
|
|
| MD5 |
bedb1c3f1c65dd2ad9dc0563a53176d4
|
|
| BLAKE2b-256 |
eb92dcffc684e7a18cbeb12ff18ec7038a1adf3f2741478161919f4935db943f
|
Provenance
The following attestation bundles were made for ontology_engine-0.1.0.tar.gz:
Publisher:
publish.yml on Yvnminc/ontology-engine
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ontology_engine-0.1.0.tar.gz -
Subject digest:
fb01e268015d6888ad88cd5c8609561b4b836710583e221c33d762a5d1d8484a - Sigstore transparency entry: 1114521599
- Sigstore integration time:
-
Permalink:
Yvnminc/ontology-engine@8786cd9836f10f948a981a69881468c64fecebf7 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Yvnminc
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@8786cd9836f10f948a981a69881468c64fecebf7 -
Trigger Event:
push
-
Statement type:
File details
Details for the file ontology_engine-0.1.0-py3-none-any.whl.
File metadata
- Download URL: ontology_engine-0.1.0-py3-none-any.whl
- Upload date:
- Size: 93.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e50aef2035853eafd5db34acf188d63ba797ea9cfe374f251870e6f2709677ee
|
|
| MD5 |
aa1491bbd808cdd2f7150b97b45767db
|
|
| BLAKE2b-256 |
2b297f72266a929b1f1478d98672a760a5757863cf7caeb37d9fb1c0a124f11c
|
Provenance
The following attestation bundles were made for ontology_engine-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on Yvnminc/ontology-engine
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ontology_engine-0.1.0-py3-none-any.whl -
Subject digest:
e50aef2035853eafd5db34acf188d63ba797ea9cfe374f251870e6f2709677ee - Sigstore transparency entry: 1114521616
- Sigstore integration time:
-
Permalink:
Yvnminc/ontology-engine@8786cd9836f10f948a981a69881468c64fecebf7 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Yvnminc
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@8786cd9836f10f948a981a69881468c64fecebf7 -
Trigger Event:
push
-
Statement type: