Skip to content

Knowledge Graph Quick Start

Get started with NetIntel-OCR's Knowledge Graph capabilities in 5 minutes.

Prerequisites

# Install NetIntel-OCR (KG included by default in v0.1.17+)
pip install netintel-ocr

# Configure external Ollama server
export OLLAMA_HOST="http://your-ollama-server:11434"

# Verify Ollama has required models
curl $OLLAMA_HOST/api/tags | jq '.models[].name'

# IMPORTANT: Different models serve different purposes
# ================================================
# INGESTION MODELS (for processing PDFs):
# - qwen2.5vl:7b (for network/diagram analysis during ingestion)
# - Nanonets-OCR-s:latest (for OCR during ingestion)
#
# MINIRAG MODELS (for Q&A after ingestion):
# - gemma3:4b-it-qat (for LLM inference/generation)
# - qwen3-embedding:8b (for semantic search embeddings)

# Pull INGESTION models (for PDF processing)
curl -X POST $OLLAMA_HOST/api/pull -d '{"name":"qwen2.5vl:7b"}'
curl -X POST $OLLAMA_HOST/api/pull -d '{"name":"Nanonets-OCR-s:latest"}'

# Pull MINIRAG models (for Q&A)
curl -X POST $OLLAMA_HOST/api/pull -d '{"name":"gemma3:4b-it-qat"}'
curl -X POST $OLLAMA_HOST/api/pull -d '{"name":"qwen3-embedding:8b"}'

# Start required graph/vector services with Docker
docker run -d --name falkordb -p 6379:6379 falkordb/falkordb
docker run -d --name milvus -p 19530:19530 milvusdb/milvus:latest

# Verify everything is ready
netintel-ocr kg check-requirements
# ✅ Ollama: Connected (http://your-ollama-server:11434)
# ✅ FalkorDB: Connected (localhost:6379)
# ✅ Milvus: Connected (localhost:19530)

Basic Workflow

1. Process Your First Document

# Process a PDF with Knowledge Graph extraction (enabled by default)
netintel-ocr process file document.pdf

# The output folder will contain:
# - Extracted text and diagrams
# - kg_entities.json - Extracted entities
# - kg_relations.cypher - Graph relationships

2. View What Was Extracted

# See graph statistics
netintel-ocr kg stats

# Output:
# Entities: 47
# Relationships: 156
# Types: Router(5), Switch(12), Firewall(3), Server(15)...

3. Query Your Knowledge Graph

# Find dependencies
netintel-ocr kg query \
  --type dependencies \
  --entity "Database-Server"

# Find paths between components
netintel-ocr kg query \
  --type path \
  --from "Internet" \
  --to "Database"

# Search by properties
netintel-ocr kg search \
  --property "type=firewall"

Essential Commands

Processing Documents

# Process with specific KG model (default: RotatE)
netintel-ocr process file document.pdf --kg-model RotatE

# Process multiple documents into one KG
netintel-ocr process batch --collection my_network *.pdf

# Disable KG if not needed (faster processing)
netintel-ocr process file document.pdf --no-kg

Querying

# Basic entity query
netintel-ocr kg query --entity "Router-Core-01"

# Find all connections
netintel-ocr kg query --type connections --entity "Switch-01"

# Complex graph query with Cypher
netintel-ocr kg query \
  --cypher "MATCH (n:Firewall)-[r]-(m) RETURN n,r,m"

Analysis

# Find single points of failure
netintel-ocr kg analyze --type spof

# Check compliance
netintel-ocr kg compliance --framework PCI-DSS

# Find similar configurations
netintel-ocr kg find-similar --entity "FW-01" --threshold 0.85

Using MiniRAG (Q&A System)

# Ask questions about your documents
netintel-ocr rag query \
  --question "What are the database dependencies?" \
  --collection my_network

# Get compliance answers
netintel-ocr rag query \
  --question "Does our network meet PCI requirements?" \
  --compliance-framework PCI-DSS

Export Your Graph

# Export for visualization
netintel-ocr kg export --format json --output graph.json

# Export for Neo4j
netintel-ocr kg export --format cypher --output graph.cypher

# Generate visualization
netintel-ocr kg visualize --output network.html

Common Use Cases

Network Documentation Analysis

# Process network architecture PDFs
netintel-ocr process file network-architecture.pdf
netintel-ocr kg stats  # See what was extracted
netintel-ocr kg query --type dependencies --entity "Core-Router"

Security Compliance Check

# Process security policies
netintel-ocr process file security-policies.pdf
netintel-ocr kg compliance --framework PCI-DSS
netintel-ocr kg analyze --type access-paths

Incident Response

# Find impact of component failure
netintel-ocr kg impact --entity "Database-01" --failure-type complete
netintel-ocr rag query --question "What's the recovery procedure?"

Configuration Options

Option Description Default
--kg-model TransE, RotatE, ComplEx, etc. RotatE
--kg-epochs Training iterations 100
--collection KG collection name default
--no-kg Disable KG extraction False

Available KG Models

  • RotatE (default) - Best for complex relationships
  • TransE - Fast, good for hierarchical data
  • ComplEx - Good for bidirectional relationships

Troubleshooting

# If KG extraction is slow
netintel-ocr kg config model TransE --kg-epochs 50 document.pdf

# If out of memory
netintel-ocr kg config batch-size 128 document.pdf

# Debug mode
netintel-ocr --debug --kg-verbose document.pdf

Next Steps


Quick Reference Card

# Process
netintel-ocr process file document.pdf

# Query
netintel-ocr kg query --entity "System-Name"

# Analyze
netintel-ocr kg analyze --type spof

# Ask Questions
netintel-ocr rag query --question "Your question here"

# Export
netintel-ocr kg export --format json --output graph.json