🧿 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

Perbandingan Fundamental

DimensiNeuralSymbolic
RepresentasiContinuous (vektor, embeddings)Discrete (simbol, logika, grafik)
LearningDari data (gradient descent)Dari aturan (deduksi, induksi)
GeneralizationPattern-based (interpolation)Rule-based (ekstrapolasi logis)
InterpretabilityBlack boxTransparan (jelas reasoning chain)
Noise toleranceTinggiRendah (one wrong rule = collapse)
Data efficiencyRendah (butuh banyak data)Tinggi (bisa dari knowledge engineer)
ReasoningImplicit (dalam weights)Explicit (dalam aturan)
Common senseLearned from dataNeed 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

DimensiRAG StandarGraphRAG
Retrieval unitChunk teks (flat)Subgraph (struktur)
ContextSemantik vektorSemantik + relasi + struktur
Multi-hop reasoningLemah (butuh luck)Kuat (graph traversal eksplisit)
HallucinationMasih mungkinLebih rendah (grounded di entitas)
UpdateRe-indexAdd node/edge incremental
Query complexityLangsung ke vektorQuery + 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 intermediary

Causal 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

AlgorithmTypeDataOutputScalability
PC AlgorithmConstraint-basedObservationalDAG
FCIConstraint-basedObservational + latentPAG
NOTEARSScore-based (continuous)ObservationalDAG β€” gradient-based
LiNGAMICA-basedObservationalDAG (linear)
GESScore-based (search)ObservationalDAG 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_i

Causal 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:

MethodAssumptionUse Case
Propensity Score MatchingUnconfoundedness + overlapObservational study
Double ML (DML)Partially linear modelHigh-dimensional features
Causal ForestUnconfoundednessHeterogeneous treatment effects
IV (Instrumental Variables)Exclusion restrictionUnobserved confounders
DoWhyMultiple methods unifiedProduction 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:

  1. Kumpulkan contoh konsep (e.g., gambar β€œstriped”)
  2. Train linear classifier untuk deteksi konsep di layer tertentu
  3. 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 recommendation

Implementasi 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_graph

Langkah 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

FrameworkPendekatanNeuralSymbolicKapan
LangChain GraphGraphRAG β­βœ… (LLM)βœ… (Neo4j)Production-ready, flexible
PyKEENKG Embeddingβœ…βš οΈLink prediction, completion
DeepProbLogNeuroβ†’Symbolicβœ…βœ… (ProbLog)Probabilistic reasoning
LTN (Logic Tensor Networks)Unifiedβœ…βœ…Loss-based integration
DoWhyCausal InferenceβŒβœ…Causal analysis
SHAP / LIMEXAIβœ…βŒModel explanation
TCAVConcept XAIβœ…βœ…High-level concept testing

Open Problems

ProblemDeskripsiProgress
Gradient through symbolicSymbolic reasoning diskrit β†’ tidak differentiableRelaxation, REINFORCE, Gumbel-softmax
Knowledge graph completenessKG selalu incomplete β€” missing edges β†’ wrong reasoningOpen-world assumption, KG completion
Scalability of reasoningSymbolic reasoning polynomial/exponential di worst caseApproximation, bounded reasoning
Causal discovery accuracyPC/FCI masih salah di high-dim, low-sampleNOTEARS, differentiable causal discovery
XAI faithfulnessSHAP approximation β€” seberapa setia ke model asli?SHAP game-theoretic guarantees, LIME stability
Neurosymbolic trainingEnd-to-end masih sulitTwo-stage training, alternating optimization

Catatan Terkait


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.