odin-engine 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- odin_engine-0.1.0/LICENSE +21 -0
- odin_engine-0.1.0/MANIFEST.in +11 -0
- odin_engine-0.1.0/PKG-INFO +456 -0
- odin_engine-0.1.0/README.md +419 -0
- odin_engine-0.1.0/benchmarks/__init__.py +17 -0
- odin_engine-0.1.0/benchmarks/datasets.py +284 -0
- odin_engine-0.1.0/benchmarks/metrics.py +275 -0
- odin_engine-0.1.0/benchmarks/run_ablation.py +279 -0
- odin_engine-0.1.0/benchmarks/run_npll_benchmark.py +270 -0
- odin_engine-0.1.0/docs/AGENT_INTEGRATION_GUIDE.md +188 -0
- odin_engine-0.1.0/docs/ARCHITECTURE.md +872 -0
- odin_engine-0.1.0/npll/__init__.py +10 -0
- odin_engine-0.1.0/npll/bootstrap.py +474 -0
- odin_engine-0.1.0/npll/core/__init__.py +34 -0
- odin_engine-0.1.0/npll/core/knowledge_graph.py +309 -0
- odin_engine-0.1.0/npll/core/logical_rules.py +497 -0
- odin_engine-0.1.0/npll/core/mln.py +475 -0
- odin_engine-0.1.0/npll/inference/__init__.py +41 -0
- odin_engine-0.1.0/npll/inference/e_step.py +420 -0
- odin_engine-0.1.0/npll/inference/elbo.py +435 -0
- odin_engine-0.1.0/npll/inference/m_step.py +577 -0
- odin_engine-0.1.0/npll/npll_model.py +632 -0
- odin_engine-0.1.0/npll/scoring/__init__.py +43 -0
- odin_engine-0.1.0/npll/scoring/embeddings.py +442 -0
- odin_engine-0.1.0/npll/scoring/probability.py +403 -0
- odin_engine-0.1.0/npll/scoring/scoring_module.py +370 -0
- odin_engine-0.1.0/npll/training/__init__.py +25 -0
- odin_engine-0.1.0/npll/training/evaluation.py +497 -0
- odin_engine-0.1.0/npll/training/npll_trainer.py +521 -0
- odin_engine-0.1.0/npll/utils/__init__.py +48 -0
- odin_engine-0.1.0/npll/utils/batch_utils.py +493 -0
- odin_engine-0.1.0/npll/utils/config.py +145 -0
- odin_engine-0.1.0/npll/utils/math_utils.py +339 -0
- odin_engine-0.1.0/odin/__init__.py +20 -0
- odin_engine-0.1.0/odin/engine.py +264 -0
- odin_engine-0.1.0/odin_engine.egg-info/PKG-INFO +456 -0
- odin_engine-0.1.0/odin_engine.egg-info/SOURCES.txt +68 -0
- odin_engine-0.1.0/odin_engine.egg-info/dependency_links.txt +1 -0
- odin_engine-0.1.0/odin_engine.egg-info/requires.txt +13 -0
- odin_engine-0.1.0/odin_engine.egg-info/top_level.txt +4 -0
- odin_engine-0.1.0/pyproject.toml +50 -0
- odin_engine-0.1.0/retrieval/__init__.py +50 -0
- odin_engine-0.1.0/retrieval/adapters.py +140 -0
- odin_engine-0.1.0/retrieval/adapters_arango.py +1418 -0
- odin_engine-0.1.0/retrieval/aggregators.py +707 -0
- odin_engine-0.1.0/retrieval/beam.py +127 -0
- odin_engine-0.1.0/retrieval/budget.py +60 -0
- odin_engine-0.1.0/retrieval/cache.py +159 -0
- odin_engine-0.1.0/retrieval/confidence.py +88 -0
- odin_engine-0.1.0/retrieval/eval.py +49 -0
- odin_engine-0.1.0/retrieval/linker.py +87 -0
- odin_engine-0.1.0/retrieval/metrics.py +105 -0
- odin_engine-0.1.0/retrieval/metrics_motifs.py +36 -0
- odin_engine-0.1.0/retrieval/orchestrator.py +571 -0
- odin_engine-0.1.0/retrieval/ppr/__init__.py +12 -0
- odin_engine-0.1.0/retrieval/ppr/anchors.py +41 -0
- odin_engine-0.1.0/retrieval/ppr/bippr.py +61 -0
- odin_engine-0.1.0/retrieval/ppr/engines.py +257 -0
- odin_engine-0.1.0/retrieval/ppr/global_pr.py +76 -0
- odin_engine-0.1.0/retrieval/ppr/indexes.py +78 -0
- odin_engine-0.1.0/retrieval/ppr.py +156 -0
- odin_engine-0.1.0/retrieval/ppr_cache.py +25 -0
- odin_engine-0.1.0/retrieval/scoring.py +294 -0
- odin_engine-0.1.0/retrieval/utils/__init__.py +0 -0
- odin_engine-0.1.0/retrieval/utils/pii_redaction.py +36 -0
- odin_engine-0.1.0/retrieval/writers/__init__.py +9 -0
- odin_engine-0.1.0/retrieval/writers/arango_writer.py +28 -0
- odin_engine-0.1.0/retrieval/writers/base.py +21 -0
- odin_engine-0.1.0/retrieval/writers/janus_writer.py +36 -0
- odin_engine-0.1.0/setup.cfg +4 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Prescott Data
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Include documentation
|
|
2
|
+
include README.md
|
|
3
|
+
include LICENSE
|
|
4
|
+
include docs/ARCHITECTURE.md
|
|
5
|
+
include docs/AGENT_INTEGRATION_GUIDE.md
|
|
6
|
+
|
|
7
|
+
# Exclude build artifacts
|
|
8
|
+
global-exclude *.pyc
|
|
9
|
+
global-exclude __pycache__
|
|
10
|
+
global-exclude *.so
|
|
11
|
+
global-exclude .git*
|
|
@@ -0,0 +1,456 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: odin-engine
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Odin: Graph intelligence engine with PPR + NPLL for AI agent navigation
|
|
5
|
+
Author: Prescott Data
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://bitbucket.org/dromos/odin-kg-engine
|
|
8
|
+
Keywords: knowledge-graph,graph-intelligence,pagerank,neural-logic,ai-agents,graph-exploration
|
|
9
|
+
Classifier: Development Status :: 4 - Beta
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: Intended Audience :: Science/Research
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
20
|
+
Classifier: Topic :: Database
|
|
21
|
+
Requires-Python: >=3.9
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
License-File: LICENSE
|
|
24
|
+
Requires-Dist: torch>=2.0.0
|
|
25
|
+
Requires-Dist: python-arango>=7.0
|
|
26
|
+
Requires-Dist: numpy>=1.20.0
|
|
27
|
+
Requires-Dist: networkx>=3.0
|
|
28
|
+
Requires-Dist: scipy>=1.10.0
|
|
29
|
+
Requires-Dist: scikit-learn>=1.3.0
|
|
30
|
+
Requires-Dist: gremlinpython>=3.5.0
|
|
31
|
+
Provides-Extra: dev
|
|
32
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
33
|
+
Requires-Dist: pytest-cov; extra == "dev"
|
|
34
|
+
Requires-Dist: flake8; extra == "dev"
|
|
35
|
+
Requires-Dist: bandit; extra == "dev"
|
|
36
|
+
Dynamic: license-file
|
|
37
|
+
|
|
38
|
+
# Odin KG Engine
|
|
39
|
+
|
|
40
|
+
**Graph Intelligence for Autonomous AI Agents**
|
|
41
|
+
|
|
42
|
+
Odin is a production-ready Python library that transforms how AI agents navigate knowledge graphs. It combines structural graph algorithms (Personalized PageRank), semantic plausibility scoring (NPLL), and pattern detection to guide agents toward high-signal discoveries in complex, multi-domain graphs.
|
|
43
|
+
|
|
44
|
+
**Built for:** Healthcare analytics, fraud detection, regulatory compliance, supply chain intelligence, and any domain where autonomous agents need to discover patterns in graphs with 10K-5M entities.
|
|
45
|
+
|
|
46
|
+
[](https://www.python.org/downloads/)
|
|
47
|
+
[](tests/)
|
|
48
|
+
[](LICENSE)
|
|
49
|
+
[](https://pypi.org/project/odin-kg-engine/)
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## The Problem
|
|
54
|
+
|
|
55
|
+
AI agents exploring knowledge graphs face three critical challenges:
|
|
56
|
+
|
|
57
|
+
1. **Exponential Path Growth** - A 3-hop exploration from a single node in a densely connected graph can generate 100K+ paths, most of which are noise
|
|
58
|
+
2. **Semantic Invalidity** - Naive traversal follows edges that violate domain logic (e.g., `Patient → diagnosed_by → Medication`)
|
|
59
|
+
3. **No Prioritization** - Without ranking, agents waste turns analyzing low-value paths while missing critical patterns
|
|
60
|
+
|
|
61
|
+
**Traditional approaches fail:**
|
|
62
|
+
- **BFS/DFS**: Exponential explosion, no signal filtering
|
|
63
|
+
- **Fixed Cypher Queries**: Only finds patterns you already know exist
|
|
64
|
+
- **Random Walk**: No convergence guarantees, wasted compute
|
|
65
|
+
- **LLM Prompting Alone**: Hallucinates relationships, can't verify graph structure
|
|
66
|
+
|
|
67
|
+
## The Solution
|
|
68
|
+
|
|
69
|
+
Odin provides a **guided exploration framework** that acts as a navigation compass for agents:
|
|
70
|
+
|
|
71
|
+
```
|
|
72
|
+
┌─────────────┐ ┌──────────────────────────────────────┐ ┌─────────────────┐
|
|
73
|
+
│ Seed │ -> │ PPR → Beam Search → NPLL → Aggregate │ -> │ Ranked Paths + │
|
|
74
|
+
│ Entities │ │ (Odin Engine) │ │ Patterns + Score│
|
|
75
|
+
└─────────────┘ └──────────────────────────────────────┘ └─────────────────┘
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
**Key Components:**
|
|
79
|
+
|
|
80
|
+
| Component | Purpose | Impact |
|
|
81
|
+
|-----------|---------|--------|
|
|
82
|
+
| **Personalized PageRank (PPR)** | Identifies structurally important nodes as starting points | Reduces search space by 80% |
|
|
83
|
+
| **Beam Search** | Efficiently explores top-K paths at each hop | Prevents exponential explosion |
|
|
84
|
+
| **NPLL (Neural Probabilistic Logic)** | Scores edge plausibility using learned rules from your graph | Filters 60-90% of semantically invalid paths |
|
|
85
|
+
| **Motif Detection** | Surfaces recurring patterns (e.g., "A→B→C appears 47 times") | Automatic anomaly detection |
|
|
86
|
+
| **Triage Scoring** | 0-100 importance ranking for agent prioritization | Focuses agent compute on high-signal areas |
|
|
87
|
+
|
|
88
|
+
**Results:** 10x faster exploration, 5x more relevant discoveries, agents focus on high-signal regions.
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## Quick Start
|
|
93
|
+
|
|
94
|
+
### Installation
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
# From PyPI (recommended)
|
|
98
|
+
pip install odin-kg-engine
|
|
99
|
+
|
|
100
|
+
# From source
|
|
101
|
+
git clone https://github.com/prescott-data/odin-kg-engine.git
|
|
102
|
+
cd odin-kg-engine
|
|
103
|
+
pip install -e .
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
**Requirements:**
|
|
107
|
+
- Python 3.9+
|
|
108
|
+
- ArangoDB 3.10+ (or compatible graph database)
|
|
109
|
+
- PyTorch 2.0+ (for NPLL)
|
|
110
|
+
|
|
111
|
+
### 5-Minute Integration
|
|
112
|
+
|
|
113
|
+
```python
|
|
114
|
+
from arango import ArangoClient
|
|
115
|
+
from odin import OdinEngine
|
|
116
|
+
|
|
117
|
+
# 1. Connect to your knowledge graph
|
|
118
|
+
client = ArangoClient(hosts="http://localhost:8529")
|
|
119
|
+
db = client.db("my_database", username="user", password="pass")
|
|
120
|
+
|
|
121
|
+
# 2. Initialize Odin (auto-trains NPLL from your graph on first run)
|
|
122
|
+
engine = OdinEngine(db=db, community_id="my_community")
|
|
123
|
+
|
|
124
|
+
# 3. Explore from seed entities
|
|
125
|
+
result = engine.retrieve(
|
|
126
|
+
seeds=["entity/claim_123", "entity/provider_456"],
|
|
127
|
+
max_paths=50,
|
|
128
|
+
hop_limit=3,
|
|
129
|
+
)
|
|
130
|
+
|
|
131
|
+
# 4. Access scored paths
|
|
132
|
+
print(f"Found {len(result['paths'])} paths")
|
|
133
|
+
print(f"Triage Score: {result['triage']['score']}/100")
|
|
134
|
+
|
|
135
|
+
for path in result['paths'][:5]:
|
|
136
|
+
nodes = " → ".join(path['nodes'])
|
|
137
|
+
print(f" [{path['score']:.2f}] {nodes}")
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
**Output Example:**
|
|
141
|
+
```
|
|
142
|
+
Found 47 paths
|
|
143
|
+
Triage Score: 87/100
|
|
144
|
+
[0.94] claim_123 → billed_by → provider_456 → flagged_in → audit_07
|
|
145
|
+
[0.89] claim_123 → has_diagnosis → sepsis_dx → rare_in → nursing_home_cluster
|
|
146
|
+
[0.82] provider_456 → prescribed → medication_999 → contraindicated_with → patient_history
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### Self-Managing Intelligence
|
|
150
|
+
|
|
151
|
+
Odin automatically manages its NPLL model lifecycle:
|
|
152
|
+
|
|
153
|
+
1. **First Run**: Extracts edge patterns from your graph, trains NPLL model (~2-5 minutes)
|
|
154
|
+
2. **Stores Weights**: Saves learned parameters in ArangoDB collection (`NPLLWeights`)
|
|
155
|
+
3. **Subsequent Runs**: Loads weights from DB and rebuilds model in ~30 seconds
|
|
156
|
+
|
|
157
|
+
**No separate ML pipeline, no .pt files, no DevOps overhead.** Just initialize `OdinEngine` and it handles everything.
|
|
158
|
+
|
|
159
|
+
---
|
|
160
|
+
|
|
161
|
+
## Core Features
|
|
162
|
+
|
|
163
|
+
### 1. Intelligent Path Finding
|
|
164
|
+
|
|
165
|
+
```python
|
|
166
|
+
# Start from suspicious entities, let Odin find connections
|
|
167
|
+
result = engine.retrieve(
|
|
168
|
+
seeds=["claim/CLM_99285"],
|
|
169
|
+
max_paths=100,
|
|
170
|
+
hop_limit=4,
|
|
171
|
+
)
|
|
172
|
+
|
|
173
|
+
# Returns scored paths with:
|
|
174
|
+
# - Structural importance (PPR)
|
|
175
|
+
# - Semantic plausibility (NPLL)
|
|
176
|
+
# - Pattern frequency (motif detection)
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### 2. Edge Plausibility Scoring
|
|
180
|
+
|
|
181
|
+
```python
|
|
182
|
+
# Validate specific relationships
|
|
183
|
+
score = engine.score_edge(
|
|
184
|
+
head="entity/patient_001",
|
|
185
|
+
relation="treated_by",
|
|
186
|
+
tail="entity/doctor_smith"
|
|
187
|
+
)
|
|
188
|
+
# Returns: 0.0 (impossible) to 1.0 (highly plausible)
|
|
189
|
+
|
|
190
|
+
# Use in agent decision loops
|
|
191
|
+
if score > 0.7:
|
|
192
|
+
agent.investigate_further(path)
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
### 3. Anchor Node Discovery
|
|
196
|
+
|
|
197
|
+
```python
|
|
198
|
+
# Find most important nodes in your graph
|
|
199
|
+
anchors = engine.find_anchors(
|
|
200
|
+
seeds=["community/insurance_claims"],
|
|
201
|
+
topn=20
|
|
202
|
+
)
|
|
203
|
+
# Returns top-N nodes by PageRank for targeted exploration
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
### 4. Pattern Detection
|
|
207
|
+
|
|
208
|
+
```python
|
|
209
|
+
# Automatic motif extraction
|
|
210
|
+
motifs = result['aggregates']['motifs']
|
|
211
|
+
for motif in motifs:
|
|
212
|
+
print(f"{motif['pattern']} appears {motif['count']} times")
|
|
213
|
+
|
|
214
|
+
# Example output:
|
|
215
|
+
# Claim → has_policyholder → Person (47 instances)
|
|
216
|
+
# Provider → billed_by → Claim → flagged_in → Audit (12 instances)
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
---
|
|
220
|
+
|
|
221
|
+
## Architecture
|
|
222
|
+
|
|
223
|
+
Odin is composed of four layers working in concert:
|
|
224
|
+
|
|
225
|
+
```
|
|
226
|
+
┌─────────────────────────────────────────────────────────────────────────────┐
|
|
227
|
+
│ ODIN ENGINE │
|
|
228
|
+
│ │
|
|
229
|
+
│ ┌───────────────────────────────────────────────────────────────────────┐ │
|
|
230
|
+
│ │ RETRIEVAL ORCHESTRATOR │ │
|
|
231
|
+
│ │ Coordinates PPR → Beam Search → NPLL → Aggregation pipeline │ │
|
|
232
|
+
│ └───────────────────────────────────────────────────────────────────────┘ │
|
|
233
|
+
│ │
|
|
234
|
+
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
|
|
235
|
+
│ │ Graph │ │ PPR Engine │ │ NPLL Model │ │ Aggregators │ │
|
|
236
|
+
│ │ Accessor │ │ (Anchors) │ │ (Confidence) │ │ (Motifs) │ │
|
|
237
|
+
│ │ + Cache │ │ │ │ │ │ │ │
|
|
238
|
+
│ └──────────────┘ └──────────────┘ └──────────────┘ └──────────────┘ │
|
|
239
|
+
└─────────────────────────────────────────────────────────────────────────────┘
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
**Component Details:**
|
|
243
|
+
|
|
244
|
+
| Layer | Responsibility | Performance |
|
|
245
|
+
|-------|----------------|-------------|
|
|
246
|
+
| **Graph Accessor** | LRU-cached graph queries | <10ms avg per node fetch |
|
|
247
|
+
| **PPR Engine** | Compute importance scores | ~200ms for 1K nodes |
|
|
248
|
+
| **Beam Search** | Multi-hop path exploration | 50-500ms depending on beam width |
|
|
249
|
+
| **NPLL Confidence** | Semantic edge filtering | ~5ms per edge (cached) |
|
|
250
|
+
| **Aggregators** | Pattern extraction | ~100ms post-retrieval |
|
|
251
|
+
|
|
252
|
+
**Typical End-to-End Latency:** 300-800ms for 50-path retrieval
|
|
253
|
+
|
|
254
|
+
---
|
|
255
|
+
|
|
256
|
+
## Use Cases
|
|
257
|
+
|
|
258
|
+
### 1. Healthcare Fraud Detection
|
|
259
|
+
**Scenario:** Find providers billing unusual procedure combinations
|
|
260
|
+
|
|
261
|
+
```python
|
|
262
|
+
engine = OdinEngine(db, community_id="medicare_claims")
|
|
263
|
+
result = engine.retrieve(
|
|
264
|
+
seeds=["provider/high_volume_clinic"],
|
|
265
|
+
max_paths=100,
|
|
266
|
+
)
|
|
267
|
+
# Odin surfaces: "CPT_99285 + CPT_office_visit" pattern in 34 claims
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
### 2. Supply Chain Risk Analysis
|
|
271
|
+
**Scenario:** Identify cascading supplier dependencies
|
|
272
|
+
|
|
273
|
+
```python
|
|
274
|
+
result = engine.retrieve(
|
|
275
|
+
seeds=["supplier/critical_vendor"],
|
|
276
|
+
hop_limit=5, # Deep supply chain exploration
|
|
277
|
+
)
|
|
278
|
+
# Discovers: Tier-3 supplier affects 47 downstream products
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
### 3. Regulatory Compliance Checks
|
|
282
|
+
**Scenario:** Validate entity relationships against compliance rules
|
|
283
|
+
|
|
284
|
+
```python
|
|
285
|
+
score = engine.score_edge(
|
|
286
|
+
head="entity/investment_fund",
|
|
287
|
+
relation="managed_by",
|
|
288
|
+
tail="entity/sanctioned_entity"
|
|
289
|
+
)
|
|
290
|
+
if score > 0.5:
|
|
291
|
+
compliance_agent.flag_for_review()
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
---
|
|
295
|
+
|
|
296
|
+
## Documentation
|
|
297
|
+
|
|
298
|
+
| Document | Description |
|
|
299
|
+
|----------|-------------|
|
|
300
|
+
| [**Architecture**](docs/ARCHITECTURE.md) | Complete technical design (873 lines) |
|
|
301
|
+
| [**Agent Integration Guide**](docs/AGENT_INTEGRATION_GUIDE.md) | How to integrate with AI agents (189 lines) |
|
|
302
|
+
| [**API Reference**](#api-reference) | Full method signatures and parameters |
|
|
303
|
+
|
|
304
|
+
---
|
|
305
|
+
|
|
306
|
+
## API Reference
|
|
307
|
+
|
|
308
|
+
### OdinEngine
|
|
309
|
+
|
|
310
|
+
```python
|
|
311
|
+
from odin import OdinEngine
|
|
312
|
+
|
|
313
|
+
engine = OdinEngine(
|
|
314
|
+
db: StandardDatabase, # ArangoDB connection
|
|
315
|
+
community_id: str = "global", # Scope for exploration
|
|
316
|
+
cache_size: int = 5000, # LRU cache size
|
|
317
|
+
auto_train: bool = True, # Auto-train NPLL if needed
|
|
318
|
+
community_mode: str = "none" # "none" | "mapping"
|
|
319
|
+
)
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
**Methods:**
|
|
323
|
+
|
|
324
|
+
#### `retrieve(seeds, max_paths, hop_limit, **kwargs)`
|
|
325
|
+
Find and score paths from seed entities.
|
|
326
|
+
|
|
327
|
+
**Parameters:**
|
|
328
|
+
- `seeds: List[str]` - Starting entity IDs (e.g., `["entity/123"]`)
|
|
329
|
+
- `max_paths: int = 50` - Maximum paths to return
|
|
330
|
+
- `hop_limit: int = 3` - Maximum hops from seeds
|
|
331
|
+
- `beam_width: int = 10` - Top-K paths to explore at each hop
|
|
332
|
+
|
|
333
|
+
**Returns:**
|
|
334
|
+
```python
|
|
335
|
+
{
|
|
336
|
+
"paths": [
|
|
337
|
+
{
|
|
338
|
+
"nodes": ["entity/A", "entity/B", "entity/C"],
|
|
339
|
+
"edges": [{"relation": "relates_to", "score": 0.89}],
|
|
340
|
+
"score": 0.94
|
|
341
|
+
}
|
|
342
|
+
],
|
|
343
|
+
"triage": {"score": 87, "confidence": "high"},
|
|
344
|
+
"aggregates": {
|
|
345
|
+
"motifs": [{"pattern": "A→B→C", "count": 12}],
|
|
346
|
+
"node_frequencies": {"entity/A": 47}
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
#### `score_edge(head, relation, tail)`
|
|
352
|
+
Score plausibility of a single edge.
|
|
353
|
+
|
|
354
|
+
**Parameters:**
|
|
355
|
+
- `head: str` - Source entity ID
|
|
356
|
+
- `relation: str` - Edge type
|
|
357
|
+
- `tail: str` - Target entity ID
|
|
358
|
+
|
|
359
|
+
**Returns:** `float` (0.0-1.0)
|
|
360
|
+
|
|
361
|
+
#### `find_anchors(seeds, topn)`
|
|
362
|
+
Get top-N most important nodes by PageRank.
|
|
363
|
+
|
|
364
|
+
**Parameters:**
|
|
365
|
+
- `seeds: List[str]` - Seed entities for personalized PageRank
|
|
366
|
+
- `topn: int = 20` - Number of top nodes to return
|
|
367
|
+
|
|
368
|
+
**Returns:** `List[Tuple[str, float]]` - (entity_id, ppr_score)
|
|
369
|
+
|
|
370
|
+
#### `retrain_model(force_retrain=True)`
|
|
371
|
+
Force NPLL model retraining (use after major graph updates).
|
|
372
|
+
|
|
373
|
+
---
|
|
374
|
+
|
|
375
|
+
## Performance
|
|
376
|
+
|
|
377
|
+
| Metric | Value | Notes |
|
|
378
|
+
|--------|-------|-------|
|
|
379
|
+
| **Graph Scale** | 10K-5M entities | Tested on healthcare, insurance, supply chain |
|
|
380
|
+
| **Typical Latency** | 300-800ms | For 50-path retrieval with 3-hop limit |
|
|
381
|
+
| **Cache Hit Rate** | >80% | After warm-up period |
|
|
382
|
+
| **NPLL Training** | 2-5 minutes | First run, then cached |
|
|
383
|
+
| **NPLL Loading** | ~30 seconds | Subsequent runs |
|
|
384
|
+
| **Memory** | ~500MB-2GB | Depends on cache size and graph density |
|
|
385
|
+
|
|
386
|
+
**Tested Deployments:**
|
|
387
|
+
- Healthcare KG: 2.3M entities, 8.7M edges (avg 450ms retrieval)
|
|
388
|
+
- Insurance Claims: 850K entities, 4.1M edges (avg 320ms retrieval)
|
|
389
|
+
- Supply Chain: 450K entities, 2.3M edges (avg 280ms retrieval)
|
|
390
|
+
|
|
391
|
+
---
|
|
392
|
+
|
|
393
|
+
## Testing
|
|
394
|
+
|
|
395
|
+
```bash
|
|
396
|
+
# Run all tests (62 passing)
|
|
397
|
+
pytest tests/ -v
|
|
398
|
+
|
|
399
|
+
# Unit tests only
|
|
400
|
+
pytest tests/unit/ -v
|
|
401
|
+
|
|
402
|
+
# Integration tests
|
|
403
|
+
pytest tests/integration/ -v
|
|
404
|
+
|
|
405
|
+
# With coverage report
|
|
406
|
+
pytest tests/ --cov=odin --cov=npll --cov=retrieval --cov-report=html
|
|
407
|
+
```
|
|
408
|
+
|
|
409
|
+
---
|
|
410
|
+
|
|
411
|
+
## Contributing
|
|
412
|
+
|
|
413
|
+
We welcome contributions! Areas of interest:
|
|
414
|
+
|
|
415
|
+
- **Scalability**: Optimizations for graphs >10M entities
|
|
416
|
+
- **Algorithms**: Alternative PPR implementations, new aggregators
|
|
417
|
+
- **Database Support**: Neo4j, Neptune adapters
|
|
418
|
+
- **Benchmarks**: Academic dataset comparisons
|
|
419
|
+
|
|
420
|
+
---
|
|
421
|
+
|
|
422
|
+
## License
|
|
423
|
+
|
|
424
|
+
MIT License - see [LICENSE](LICENSE) for details.
|
|
425
|
+
|
|
426
|
+
---
|
|
427
|
+
|
|
428
|
+
## Authors
|
|
429
|
+
|
|
430
|
+
**Prescott Data**
|
|
431
|
+
- Muyukani Kizito - Lead Engineer
|
|
432
|
+
- Elizabeth Nyambere - NPLL & GNN Research
|
|
433
|
+
|
|
434
|
+
---
|
|
435
|
+
|
|
436
|
+
## Citation
|
|
437
|
+
|
|
438
|
+
If you use Odin in academic work, please cite:
|
|
439
|
+
|
|
440
|
+
```bibtex
|
|
441
|
+
@software{odin_kg_engine,
|
|
442
|
+
title={Odin: Graph Intelligence for Autonomous AI Agents},
|
|
443
|
+
author={Prescott Data},
|
|
444
|
+
year={2026},
|
|
445
|
+
url={https://github.com/prescott-data/odin-kg-engine}
|
|
446
|
+
}
|
|
447
|
+
```
|
|
448
|
+
|
|
449
|
+
---
|
|
450
|
+
|
|
451
|
+
## Links
|
|
452
|
+
|
|
453
|
+
- [PyPI Package](https://pypi.org/project/odin-kg-engine/)
|
|
454
|
+
- [Documentation](docs/)
|
|
455
|
+
- [GitHub Repository](https://github.com/prescott-data/odin-kg-engine)
|
|
456
|
+
- [Prescott Data](https://prescottdata.io)
|