π§Ώ NEUROSYMBOLIC AI β Ketika Neural Bertemu Simbolik
Knowledge Graph + LLM Β· GraphRAG Β· Causal AI Β· Explainable AI (XAI) Β· Hybrid Integration
Filosofi Fundamental
Neural network unggul di pattern recognition tapi lemah di reasoning terstruktur. Symbolic AI unggul di logika kaku tapi tidak bisa generalisasi dari data. Neurosymbolic AI adalah pernikahan keduanya: neural untuk fleksibilitas, simbolik untuk presisi. Dokumen ini membedah setiap jalur integrasi β dari GraphRAG (KG + LLM) yang siap produksi, Causal AI untuk reasoning melampaui korelasi, hingga XAI untuk membuka black box. Bukan sekadar teori β ada kode, arsitektur, dan trade-off setiap pendekatan.
Daftar Isi
- First Principles β Neural vs Symbolic
- Arsitektur Integrasi β Empat Pola
- GraphRAG β Knowledge Graph + LLM
- Causal AI β Dari Korelasi ke Kausalitas
- Explainable AI β Membuka Black Box
- Neurosymbolic untuk Cybersecurity
- Implementasi Langkah demi Langkah
- Tool & Framework Matrix
- Open Problems
- Catatan Terkait
First Principles β Neural vs Symbolic
Perbandingan Fundamental
| Dimensi | Neural | Symbolic |
|---|---|---|
| Representasi | Continuous (vektor, embeddings) | Discrete (simbol, logika, grafik) |
| Learning | Dari data (gradient descent) | Dari aturan (deduksi, induksi) |
| Generalization | Pattern-based (interpolation) | Rule-based (ekstrapolasi logis) |
| Interpretability | Black box | Transparan (jelas reasoning chain) |
| Noise tolerance | Tinggi | Rendah (one wrong rule = collapse) |
| Data efficiency | Rendah (butuh banyak data) | Tinggi (bisa dari knowledge engineer) |
| Reasoning | Implicit (dalam weights) | Explicit (dalam aturan) |
| Common sense | Learned from data | Need manual encoding |
Mengapa Neurosymbolic?
Masalah yang tidak bisa diselesaikan oleh neural atau symbolic sendiri:
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β YANG MEMBUTUHKAN NEUROSYMBOLIC β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β Medical diagnosis: Pattern dari imaging β
β (neural) + causal reasoning dari patient history β
β (symbolic) β
β β
β β Scientific discovery: Hipotesis dari data β
β (neural) + verifikasi logis (symbolic) β
β β
β β Autonomous driving: Object detection (neural) β
β + traffic rule compliance (symbolic) β
β β
β β Cybersecurity: Anomaly detection (neural) β
β + threat correlation + MITRE mapping (symbolic) β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Arsitektur Integrasi β Empat Pola
Pola 1: Hybrid β Terpisah, Berkomunikasi via API
[INPUT] βββΊ NEURAL (perception) βββΊ SYMBOLIC (reasoning) βββΊ OUTPUT
β β
Image Classification Logic Inference
Speech Recognition Rule Engine
NER Extraction Knowledge Graph Query
Implementasi: LLM + LangChain Graph. Neural ekstrak entitas, symbolic query KG.
Kelebihan: Modular, bisa ganti komponen independent, mudah debug. Kekurangan: Latency bottleneck di API call, konteks hilang antar komunikasi.
Pola 2: Unified β Dual Representasi dalam Satu Model
[INPUT] βββΊ SHARED REPRESENTATION βββΊ NEURAL HEAD βββΊ Pattern output
β SYMBOLIC HEAD βββΊ Structured output
Vektor +
Symbol Binding
Contoh: Logic Tensor Networks β tensor + first-order logic dalam satu loss function.
Kelebihan: Integrasi erat, gradient mengalir ke kedua sisi. Kekurangan: Kompleksitas matematis tinggi, belum mature.
Pola 3: Neuro β Symbolic
[INPUT] βββΊ NEURAL βββΊ Symbols βββΊ SYMBOLIC REASONING βββΊ OUTPUT
β β
Ekstrak entity, Validasi logis,
relation, label inferensi deduktif
Contoh: DeepProbLog β neural network ekstrak probabilitas fakta β ProbLog lakukan reasoning.
Pola 4: Symbolic β Neuro
[INPUT] βββΊ SYMBOLIC βββΊ Neural Prior βββΊ NEURAL LEARNING βββΊ OUTPUT
β β
Aturan domain Knowledge-guided
Knowledge graph training / data aug
Contoh: Rule-based data augmentation, KG-enhanced RAG.
GraphRAG β Knowledge Graph + LLM
GraphRAG vs Traditional RAG
| Dimensi | RAG Standar | GraphRAG |
|---|---|---|
| Retrieval unit | Chunk teks (flat) | Subgraph (struktur) |
| Context | Semantik vektor | Semantik + relasi + struktur |
| Multi-hop reasoning | Lemah (butuh luck) | Kuat (graph traversal eksplisit) |
| Hallucination | Masih mungkin | Lebih rendah (grounded di entitas) |
| Update | Re-index | Add node/edge incremental |
| Query complexity | Langsung ke vektor | Query + traverse + subgraph |
Arsitektur GraphRAG
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β USER QUERY β
β "Siapa yang terlibat dalam serangan X dan apa motifnya?" β
ββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β QUERY REWRITER (LLM) β
β Ekstrak entitas + intent dari query natural β
β β Person: ?, Event: "serangan X", Relation: "terlibat" β
ββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β GRAPH TRAVERSAL (Neo4j) β
β MATCH (e:Event {name: 'serangan X'}) β
β MATCH (p:Person)-[r]->(e) β
β RETURN p, r, e β
ββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β SUBGRAPH RETRIEVAL β
β { β
β entities: [Person_A, Person_B, Org_C], β
β relations: [Person_A -[orchestrates]-> Event_X, β
β Person_B -[funds]-> Person_A], β
β context_text: [chunk terkait dari dokuemn] β
β } β
ββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β CONTEXT ASSEMBLY + LLM GENERATION β
β Prompt: β
β "Berdasarkan knowledge graph berikut, jawab query user. β
β Graph: [subgraph serialization] β
β Chunks: [retrieved text] β
β Query: {original query}" β
ββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β FINAL ANSWER β
β "Serangan X diorkestrasi oleh Person_A dengan dana dari β
β Person_B melalui Org_C..." β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Implementasi GraphRAG dengan LangChain + Neo4j
from langchain_community.graphs import Neo4jGraph
from langchain_experimental.graph_transformers import LLMGraphTransformer
from langchain_core.documents import Document
# 1. Konek ke Neo4j
graph = Neo4jGraph(
url="bolt://localhost:7687",
username="neo4j",
password="password"
)
# 2. Transform dokumen ke graph
llm_transformer = LLMGraphTransformer(
llm=llm,
allowed_nodes=["Person", "Organization", "Event", "Location", "Tool", "Malware"],
allowed_relationships=[
"orchestrates", "funds", "uses", "targets", "works_at",
"related_to", "occurs_after", "mitigates"
],
node_properties=True, # Ekstrak properti juga
)
documents = [Document(page_content=raw_text)]
graph_documents = llm_transformer.convert_to_graph_documents(documents)
graph.add_graph_documents(
graph_documents,
baseEntityLabel=True,
include_source=True, # Link nodes ke source document
)
# 3. GraphRAG Chain
from langchain.chains import GraphCypherQAChain
graph_chain = GraphCypherQAChain.from_llm(
llm=llm,
graph=graph,
verbose=True,
validate_cypher=True, # Validasi syntax Cypher
top_k=10, # Max subgraph entities
return_intermediate_steps=True,
)
# 4. Query
result = graph_chain.invoke({
"query": "Siapa yang mendanai serangan siber terhadap perusahaan X?"
})Graph Schema Design untuk Intelijen
// Nodes
(:Person {
name: string,
aliases: string[],
threat_score: float, // 0-10
confidence: float, // 0-1
first_seen: datetime,
last_seen: datetime,
source_reliability: string // A-E
})
(:Organization {
name: string,
type: string, // state, criminal, hacktivist, corporate
country: string,
})
(:Event {
name: string,
type: string, // attack, meeting, transaction
timestamp: datetime,
impact: string,
})
(:Tool {
name: string,
category: string, // malware, exploit, framework
mitre_id: string, // T1059, etc
})
// Relations
(:Person)-[:ORCHESTRATES {confidence, evidence}]->(:Event)
(:Person)-[:FUNDS {amount, currency, method}]->(:Person)
(:Person)-[:USES {first_used, last_used}]->(:Tool)
(:Event)-[:TARGETS]->(:Organization)
(:Event)-[:OCCURS_AFTER]->(:Event)Query Patterns Berguna
// Cari semua path antara entitas (maks 4 hop)
MATCH p = (a:Person)-[*1..4]-(b:Person)
WHERE a.name = "Target" AND b.threat_score > 8
RETURN p LIMIT 20
// Temporal correlation: siapa yang aktif di periode yang sama?
MATCH (p:Person)-[:ORCHESTRATES]->(e:Event)
WHERE e.timestamp >= datetime("2026-01-01")
AND e.timestamp <= datetime("2026-03-01")
RETURN p, count(e) AS events
ORDER BY events DESC
// Cari "missing link" β entitas yang terhubung via proxy
MATCH (a:Person)-[:KNOWS]->(x)<-[:KNOWS]-(b:Person)
WHERE a.name = "Alice" AND b.name = "Bob"
AND NOT (a)-[:KNOWS]-(b)
RETURN x AS intermediaryCausal AI β Dari Korelasi ke Kausalitas
Pearlβs Causal Hierarchy
Level 3: COUNTERFACTUALS
"Jika saya tidak minum obat itu, apakah saya akan sembuh?"
Butuh: model struktural lengkap + SCM
Level 2: INTERVENTION
"Apa yang terjadi jika saya memberi obat ke semua pasien?"
Butuh: causal graph + do-calculus
Level 1: ASSOCIATION
"Pasien yang minum obat lebih sering sembuh?"
Butuh: data statistik saja (yang dilakukan ML biasa)
Machine learning konvensional hanya beroperasi di Level 1. Causal AI beroperasi di Level 2 dan 3.
Causal Discovery β Belajar Struktur Kausal dari Data
| Algorithm | Type | Data | Output | Scalability |
|---|---|---|---|---|
| PC Algorithm | Constraint-based | Observational | DAG | |
| FCI | Constraint-based | Observational + latent | PAG | |
| NOTEARS | Score-based (continuous) | Observational | DAG | β gradient-based |
| LiNGAM | ICA-based | Observational | DAG (linear) | |
| GES | Score-based (search) | Observational | DAG | eksponensial worst |
NOTEARS β Deep Learning untuk Causal Discovery:
# NOTEARS: Structural learning as continuous optimization
# Goal: cari weighted adjacency matrix W yang DAG
from notears import notears
# W = adjacency matrix (node β node)
# Loss = Ξ£||X_j - W_j Β· X||Β² + Ξ»||W||β (L1 untuk sparsity)
# Constraint: h(W) = tr(e^{WβW}) - d = 0 (acyclicity)
W_est = notears.linear_model(X, lambda1=0.1, loss_type="l2")
# W_est[i,j] > 0 β X_j cause X_iCausal Inference β Estimasi Effect
Di mana kita pakai?
Treatment β Population β Outcome
(obat) (pasien) (sembuh)
Yang ingin kita tahu: E[Y | do(T=1)] - E[Y | do(T=0)]
Effect of treatment on the treated (ATT) vs population (ATE)
Methods:
| Method | Assumption | Use Case |
|---|---|---|
| Propensity Score Matching | Unconfoundedness + overlap | Observational study |
| Double ML (DML) | Partially linear model | High-dimensional features |
| Causal Forest | Unconfoundedness | Heterogeneous treatment effects |
| IV (Instrumental Variables) | Exclusion restriction | Unobserved confounders |
| DoWhy | Multiple methods unified | Production pipeline |
Contoh DoWhy:
import dowhy
from dowhy import CausalModel
model = CausalModel(
data=df,
treatment="obat_diminum",
outcome="kesembuhan",
common_causes=["usia", "jenis_kelamin", "keparahan_awal"],
instruments=["randomized_assign"], # Jika ada
)
# Identify causal effect
identified = model.identify_effect(proceed_when_unidentifiable=False)
# Estimate
estimate = model.estimate_effect(
identified,
method_name="backdoor.propensity_score_matching",
method_params={"propensity_score_model": "logistic"}
)
# Refute
refutation = model.refute_estimate(
identified,
estimate,
method_name="random_common_cause"
)Neurosymbolic Causal AI β Integrasi
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β CAUSAL AI PIPELINE β
β β
β ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ β
β β DOMAIN β β CAUSAL β β NEURAL β β
β β KNOWLEDGE βββββΊβ GRAPH βββββΊβ REASONING β β
β β (Symbolic) β β (SCM) β β (Estimation) β β
β ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ β
β β β β β
β βΌ βΌ βΌ β
β Prior causal Causal graph Causal effect β
β knowledge dari dari discovery estimation β
β expert (KG) + domain prior + counterfactualβ
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Explainable AI β Membuka Black Box
Taxonomy XAI
ββββββββββββββββββββββββββββββββ
EXPLAINABLE AI β POST-HOC vs ANTE-HOC β
β β β
βββββββββββββββββ΄ββββββββββββββββ β Post-hoc: setelah model β
β β β dilatih (SHAP, LIME) β
βββββ΄βββββ βββββββ΄βββββββ β β
βPOST-HOCβ β ANTE-HOC β β Ante-hoc: model didesain β
βββββ¬βββββ β (self-exp) β β inherently explainable β
β ββββββββ¬βββββββ ββββββββββββββββββββββββββββββββ
β β
βββββ΄βββββββββββ ββββββββββββ΄βββββββββββ
β FEATURE β β INHERENTLY β
β ATTRIBUTION β β INTERPRETABLE β
ββββββββββββββββ€ ββββββββββββββββββββββββ€
β SHAP β β Linear Regression β
β LIME β β Decision Tree β
β Integrated β β SENN β
β Gradients β β Concept Bottleneck β
β Saliency Map β β Neural Additive β
ββββββββββββββββ ββββββββββββββββββββββββ
ββββββββββββββββ ββββββββββββββββββββββββ
β CONCEPT- β β COUNTERFACTUAL β
β BASED β β EXPLANATION β
ββββββββββββββββ€ ββββββββββββββββββββββββ€
β TCAV β β "Perubahan apa yang β
β ACE β β membuat prediksi β
β β β berubah?" β
ββββββββββββββββ ββββββββββββββββββββββββ
SHAP β Feature Attribution
import shap
import xgboost as xgb
# Train model
model = xgb.XGBClassifier().fit(X_train, y_train)
# SHAP explainer
explainer = shap.TreeExplainer(model)
shap_values = explainer.shap_values(X_test)
# 1. Global feature importance
shap.summary_plot(shap_values, X_test, feature_names=features)
# 2. Single prediction explanation
shap.force_plot(explainer.expected_value, shap_values[0], X_test.iloc[0])
# 3. Interaction detection
shap.dependence_plot("age", shap_values, X_test, interaction_index="income")Interpretasi SHAP:
- SHAP value positif β fitur mendorong prediksi ke kelas 1
- SHAP value negatif β fitur mendorong ke kelas 0
- Sum SHAP values + baseline = prediksi model
LIME β Local Surrogate Model
import lime
import lime.lime_tabular
explainer = lime.lime_tabular.LimeTabularExplainer(
X_train,
feature_names=features,
class_names=['benign', 'malicious'],
mode='classification',
)
exp = explainer.explain_instance(
X_test[42],
model.predict_proba,
num_features=5,
)
exp.show_in_notebook()
exp.as_list()
# Output: "feature_5 > 0.7 contributes 0.32 to malicious"Concept-based (TCAV)
TCAV (Testing with Concept Activation Vectors) menjawab: βApakah model menggunakan konsep X untuk prediksi?β
Cara kerja:
- Kumpulkan contoh konsep (e.g., gambar βstripedβ)
- Train linear classifier untuk deteksi konsep di layer tertentu
- Hitung sensitivity: βprediksi / βkonsep
Output: βModel 85% sensitive terhadap konsep βstripedβ untuk prediksi βzebraβ.β
Neurosymbolic untuk Cybersecurity
Arsitektur
RAW DATA βββΊ NEURAL (detection) βββΊ SYMBOLIC (correlation) βββΊ DECISION
β β
Anomaly detection MITRE ATT&CK mapping
Malware classification Kill chain analysis
Phishing detection Incident correlation
Implementasi β AI Security Analyst
class NeurosymbolicSecurityAnalyst:
def __init__(self):
self.detector = AnomalyDetectionModel() # Neural
self.kg = Neo4jGraph(...) # Symbolic
self.reasoner = RuleEngine() # Symbolic
def analyze_alert(self, raw_log):
# Neural β detect anomaly
anomaly_score = self.detector.predict(raw_log)
if anomaly_score < 0.7:
return {"level": "INFO", "message": "Normal activity"}
# Neural β extract entities
entities = self.extract_entities(raw_log) # LLM-based NER
# Symbolic β query knowledge graph
context = self.kg.query(f"""
MATCH (e:Event {{id: '{entities['event_id']}'}})
MATCH (t:Tactic)-[:INCLUDES]->(e)
RETURN e, t
""")
# Symbolic β MITRE mapping via rule engine
mitre_mapping = self.reasoner.match_mitre(
technique=entities['technique'],
context=context
)
# Neurosymbolic fusion
recommendation = self.fuse(
confidence=anomaly_score,
mitre=mitre_mapping,
historical=context
)
return recommendationImplementasi Langkah demi Langkah
Langkah 1: Setup Knowledge Graph dari Dokumen
# Pipeline: Dokumen β KG β Query
def build_intel_kg(documents):
# 1. Chunk
chunks = chunk_documents(documents)
# 2. Neural β ekstrak entitas + relasi
triples = []
for chunk in chunks:
ner_result = llm.extract_triples(chunk)
triples.extend(ner_result.triples)
# 3. Symbolic β masukkan ke graph
for (subj, pred, obj) in triples:
graph.query("""
MERGE (s:Entity {name: $subj})
MERGE (o:Entity {name: $obj})
MERGE (s)-[r:RELATION {type: $pred}]->(o)
""", params={"subj": subj, "pred": pred, "obj": obj})
# 4. Validasi β cek inkonsistensi logis
inconsistencies = validate_graph(graph)
return {"graph": graph, "inconsistencies": inconsistencies}Langkah 2: Causal Discovery untuk Decision Support
# Dari data observasional β causal graph β decision
def discover_causal_structure(data, domain_knowledge):
# 1. Domain knowledge sebagai prior (symbolic)
prior_graph = nx.DiGraph()
prior_graph.add_edges_from(domain_knowledge) # [(x, y), ...]
# 2. Data-driven discovery (NOTEARS)
estimated_graph = notears(data, lambda1=0.1)
# 3. Neural + Symbolic fusion
# Weighted average: 0.6 data-driven + 0.4 domain
# Atau: prior sebagai hard constraint
fused_graph = fuse_graphs(estimated_graph, prior_graph, alpha=0.6)
return fused_graphLangkah 3: XAI untuk Stakeholder
def explain_prediction(model, instance, stakeholder="regulator"):
"""Generate explanation sesuai level stakeholder"""
if stakeholder == "regulator":
# Counterfactual: perubahan minimal untuk hasil berbeda
cf = generate_counterfactual(instance, model)
return f"Prediksi akan berubah jika {cf.changed_features}"
elif stakeholder == "engineer":
# SHAP detailed
shap_values = shap.Explainer(model).shap_values(instance)
return shap_plot(shap_values)
elif stakeholder == "end_user":
# Natural language
top_features = get_top_k_features(model, instance, k=3)
return f"Keputusan ini berdasarkan {top_features[0]}, {top_features[1]}, dan {top_features[2]}"Tool & Framework Matrix
| Framework | Pendekatan | Neural | Symbolic | Kapan |
|---|---|---|---|---|
| LangChain Graph | GraphRAG β | β (LLM) | β (Neo4j) | Production-ready, flexible |
| PyKEEN | KG Embedding | β | β οΈ | Link prediction, completion |
| DeepProbLog | NeuroβSymbolic | β | β (ProbLog) | Probabilistic reasoning |
| LTN (Logic Tensor Networks) | Unified | β | β | Loss-based integration |
| DoWhy | Causal Inference | β | β | Causal analysis |
| SHAP / LIME | XAI | β | β | Model explanation |
| TCAV | Concept XAI | β | β | High-level concept testing |
Open Problems
| Problem | Deskripsi | Progress |
|---|---|---|
| Gradient through symbolic | Symbolic reasoning diskrit β tidak differentiable | Relaxation, REINFORCE, Gumbel-softmax |
| Knowledge graph completeness | KG selalu incomplete β missing edges β wrong reasoning | Open-world assumption, KG completion |
| Scalability of reasoning | Symbolic reasoning polynomial/exponential di worst case | Approximation, bounded reasoning |
| Causal discovery accuracy | PC/FCI masih salah di high-dim, low-sample | NOTEARS, differentiable causal discovery |
| XAI faithfulness | SHAP approximation β seberapa setia ke model asli? | SHAP game-theoretic guarantees, LIME stability |
| Neurosymbolic training | End-to-end masih sulit | Two-stage training, alternating optimization |
Catatan Terkait
- cognitive-architecture-engineering β Arsitektur kognitif (inspirasi neurosymbolic)
- ai-evaluation-framework β Evaluasi AI (XAI metrics)
- llm-finetuning-toolchain β Fine-tuning LLM (neural component)
- agentic-ai-mcp-architecture-deepdive β Agentic AI (reasoning + tool use)
- swarm-ai-imam-robandi β Swarm intelligence (decentralized symbolic)
- dual-use-spectrum-and-ethical-framework β Etika dual-use (dari symbolic rules)
Prinsip Praktis
Neurosymbolic AI bukan tentang memilih satu pendekatan β tapi tentang menggabungkan kekuatan keduanya untuk masalah yang tepat. Aturan praktis: Neural untuk persepsi dan generalisasi (data mentah β pola), Symbolic untuk reasoning dan constraint (pola β keputusan yang bisa dipertanggungjawabkan). GraphRAG adalah pintu masuk paling praktis karena maturity toolsnya (LangChain + Neo4j sudah enterprise-grade). Causal AI adalah frontier berikutnya β ketika Anda tidak hanya ingin prediksi, tapi pemahaman tentang mengapa sesuatu terjadi dan apa yang akan terjadi jika Anda intervensi. XAI bukan opsional β di regulated industry, explainability adalah syarat.