[G1-Sync] Manual knowledge update
This commit is contained in:
@@ -2,62 +2,240 @@
|
||||
id: wiki-2026-0508-knowledge-representation-in-ai
|
||||
title: Knowledge Representation in AI
|
||||
category: 10_Wiki/Topics
|
||||
status: needs_review
|
||||
status: verified
|
||||
canonical_id: self
|
||||
aliases: [P-Reinforce-AI-EXPLANABILITY]
|
||||
aliases: [knowledge representation, KR, ontology, knowledge graph, semantic web, RDF, OWL]
|
||||
duplicate_of: none
|
||||
source_trust_level: A
|
||||
confidence_score: 0.94
|
||||
tags: [AI, XAI, Explainability, Ethics]
|
||||
confidence_score: 0.92
|
||||
verification_status: applied
|
||||
tags: [ai, knowledge-representation, ontology, knowledge-graph, semantic-web, rdf]
|
||||
raw_sources: []
|
||||
last_reinforced: 2026-04-20
|
||||
last_reinforced: 2026-05-10
|
||||
github_commit: pending
|
||||
inferred_by: Claude Opus 4.7 (auto-normalize 2026-05-08)
|
||||
tech_stack:
|
||||
language: Python / RDF / SPARQL
|
||||
framework: RDFLib / Neo4j / Cypher
|
||||
---
|
||||
|
||||
# [[Knowledge-Representation-in-AI|Knowledge-Representation-in-AI]] (AI의 지식 표현)
|
||||
# Knowledge Representation in AI
|
||||
|
||||
## 📌 한 줄 통찰 (The Karpathy Summary)
|
||||
> "데이터를 기계가 이해할 수 있는 '의미의 지도'로 변환하는 기술." 실세계의 정보를 어떻게 정형화하여 컴퓨터가 논리적 추론이나 처리를 가능하게 할 것인지에 대한 프레임워크다.
|
||||
## 매 한 줄
|
||||
> **"매 facts + 매 rules 의 의 의 machine-processable 의 represent"**. 매 ontology, knowledge graph, semantic web. 매 modern: 매 LLM 의 implicit KR + 매 KG-RAG hybrid.
|
||||
|
||||
## 📖 구조화된 지식 (Synthesized Content)
|
||||
- **Traditional Approaches**:
|
||||
- **[[Logic|Logic]]-based**: 기호 논리학을 사용하여 "A이면 B이다" 식의 규칙 기반 표현.
|
||||
- **Semantic Networks**: 개념들을 노드로, 개념 간의 관계를 간선으로 표현 (예: 워드넷).
|
||||
- **[[Ontology|Ontology]]**: 특정 분야의 개념과 그 관계를 엄격하게 정의한 계층 구조.
|
||||
- **Modern Approaches (Vector Space)**:
|
||||
- **Embeddings**: 단어나 개념을 고차원 벡터 공간의 점으로 표현. 의미적 유사성을 기하학적 거리로 계산한다.
|
||||
- **Key Challenges**: **[[Scalability|Scalability]](확장성)**와 **[[Interpretability|Interpretability]](해석 가능성)** 사이의 트레이드오프.
|
||||
## 매 핵심
|
||||
|
||||
## ⚠️ 모순 및 업데이트 (Contradictions & Updates)
|
||||
- 고전적 지식 표현은 명확하지만 확장이 어렵고(Brittleness), 딥러닝 기반 표현은 강력하지만 왜 그런 결과가 나왔는지 알기 어렵다(Blackbox). 현재는 이 두 세계를 결합하여 논리적 근거와 신경망의 유연성을 동시에 잡으려는 '뉴로-심볼릭 AI([[Neuro-Symbolic AI|Neuro-Symbolic AI]])'가 주류 연구 방향이다.
|
||||
### 매 paradigms
|
||||
- **Logic**: FOL, Description Logic.
|
||||
- **Frames** (Minsky).
|
||||
- **Semantic networks**.
|
||||
- **Production rules** (CLIPS).
|
||||
- **Ontologies** (OWL).
|
||||
- **Knowledge graphs** (RDF, property graph).
|
||||
- **LLM** (implicit / parametric).
|
||||
|
||||
## 🔗 지식 연결 (Graph)
|
||||
- Related: [[Neuro-Symbolic-AI|Neuro-Symbolic-AI]] , [[Ontology-Engineering|Ontology-Engineering]]
|
||||
- Subfield: [[GraphRAG (그래프 기반 검색 증강 생성)|GraphRAG (그래프 기반 검색 증강 생성)]]
|
||||
### 매 modern combo
|
||||
- **KG + LLM**: 매 RAG with structure.
|
||||
- **Neuro-symbolic**: 매 symbolic + neural.
|
||||
- **GraphRAG** (Microsoft 2024).
|
||||
|
||||
## 🤖 LLM 활용 힌트 (How to Use This Knowledge)
|
||||
### 매 응용
|
||||
1. Search (Google KG).
|
||||
2. Recommendation.
|
||||
3. Drug discovery.
|
||||
4. Compliance.
|
||||
5. RAG with structure.
|
||||
|
||||
**언제 이 지식을 쓰는가:**
|
||||
- *(TODO)*
|
||||
## 💻 패턴
|
||||
|
||||
**언제 쓰면 안 되는가:**
|
||||
- *(TODO)*
|
||||
### RDF triple (RDFLib)
|
||||
```python
|
||||
from rdflib import Graph, Literal, URIRef, Namespace
|
||||
|
||||
## 🧪 검증 상태 (Validation)
|
||||
g = Graph()
|
||||
EX = Namespace('http://example.com/')
|
||||
g.add((EX.alice, EX.knows, EX.bob))
|
||||
g.add((EX.alice, EX.age, Literal(30)))
|
||||
g.serialize(format='turtle')
|
||||
```
|
||||
|
||||
- **정보 상태:** needs_review
|
||||
- **출처 신뢰도:** A
|
||||
- **검토 이유:** *(P-Reinforce Phase 1 자동 정규화. 본문 검증 필요.)*
|
||||
### SPARQL query
|
||||
```sparql
|
||||
PREFIX ex: <http://example.com/>
|
||||
SELECT ?person ?friend
|
||||
WHERE { ?person ex:knows ?friend . FILTER(?person = ex:alice) }
|
||||
```
|
||||
|
||||
## 🧬 중복 검사 (Duplicate Check)
|
||||
### Property graph (Neo4j)
|
||||
```cypher
|
||||
CREATE (alice:Person {name: 'Alice', age: 30})
|
||||
CREATE (bob:Person {name: 'Bob'})
|
||||
CREATE (alice)-[:KNOWS {since: 2020}]->(bob);
|
||||
|
||||
- **기존 유사 문서:** *(TODO: 인덱서 클러스터 리포트 참조)*
|
||||
- **처리 방식:** UPDATE (자동 정규화)
|
||||
- **처리 이유:** Phase 1 정규화 — 옛 템플릿/누락 필드 보강.
|
||||
MATCH (a:Person)-[:KNOWS]->(b:Person)
|
||||
WHERE a.name = 'Alice'
|
||||
RETURN b.name;
|
||||
```
|
||||
|
||||
## 🕓 변경 이력 (Changelog)
|
||||
### Ontology (OWL)
|
||||
```turtle
|
||||
@prefix owl: <http://www.w3.org/2002/07/owl#> .
|
||||
@prefix : <http://example.com/> .
|
||||
|
||||
| 날짜 | 변경 내용 | 처리 방식 | 신뢰도 |
|
||||
|------|-----------|-----------|--------|
|
||||
| 2026-05-08 | P-Reinforce Phase 1 정규화 (frontmatter + 헤더 표준화) | UPDATE | A |
|
||||
:Person a owl:Class .
|
||||
:Employee a owl:Class ; rdfs:subClassOf :Person .
|
||||
:hasManager a owl:ObjectProperty ; rdfs:domain :Employee ; rdfs:range :Employee .
|
||||
```
|
||||
|
||||
### Description Logic (rules)
|
||||
```
|
||||
Person ⊓ ∃hasChild.Person ⊑ Parent
|
||||
∀x. Parent(x) → Person(x) ∧ ∃y. hasChild(x, y) ∧ Person(y)
|
||||
```
|
||||
|
||||
### Reasoning (Pellet, HermiT)
|
||||
```python
|
||||
from owlready2 import get_ontology, sync_reasoner_pellet
|
||||
onto = get_ontology('http://example.com/onto.owl').load()
|
||||
with onto:
|
||||
sync_reasoner_pellet() # 매 infer subclasses, instances
|
||||
```
|
||||
|
||||
### Triple store query (Python + RDFLib)
|
||||
```python
|
||||
results = g.query("""
|
||||
SELECT ?name WHERE { ?person ex:name ?name . ?person ex:age ?age . FILTER(?age > 25) }
|
||||
""")
|
||||
for row in results: print(row.name)
|
||||
```
|
||||
|
||||
### Build KG from text (LLM-aided)
|
||||
```python
|
||||
def text_to_triples(text, llm):
|
||||
prompt = f"""Extract (subject, predicate, object) triples.
|
||||
|
||||
Text: {text}
|
||||
|
||||
Output JSON list of triples."""
|
||||
return json.loads(llm.generate(prompt))
|
||||
```
|
||||
|
||||
### GraphRAG (Microsoft 2024)
|
||||
```python
|
||||
def graphrag_pipeline(documents, llm):
|
||||
"""매 simplified."""
|
||||
# 매 1. Extract entities + relations
|
||||
triples = []
|
||||
for doc in documents:
|
||||
triples.extend(text_to_triples(doc, llm))
|
||||
|
||||
# 매 2. Build graph
|
||||
G = build_graph(triples)
|
||||
|
||||
# 매 3. Cluster (community detection)
|
||||
communities = G.community_detection()
|
||||
|
||||
# 매 4. Summarize each community
|
||||
summaries = {c: llm.summarize(community_text(c)) for c in communities}
|
||||
|
||||
# 매 5. Query → relevant communities → LLM
|
||||
return summaries
|
||||
```
|
||||
|
||||
### Neuro-symbolic (combine)
|
||||
```python
|
||||
def neuro_symbolic_classify(image, kg, classifier):
|
||||
visual_features = classifier.encode(image)
|
||||
visual_pred = classifier.predict(visual_features)
|
||||
|
||||
# 매 KG constraint
|
||||
if not kg.is_consistent_with(visual_pred):
|
||||
return kg.most_consistent_alternative(visual_pred)
|
||||
return visual_pred
|
||||
```
|
||||
|
||||
### Embedding-based KG (TransE)
|
||||
```python
|
||||
import torch.nn as nn
|
||||
class TransE(nn.Module):
|
||||
def __init__(self, n_entities, n_relations, dim):
|
||||
super().__init__()
|
||||
self.entity_emb = nn.Embedding(n_entities, dim)
|
||||
self.relation_emb = nn.Embedding(n_relations, dim)
|
||||
|
||||
def score(self, h, r, t):
|
||||
return -(self.entity_emb(h) + self.relation_emb(r) - self.entity_emb(t)).norm(dim=-1)
|
||||
```
|
||||
|
||||
### Cypher integration with LLM
|
||||
```python
|
||||
def llm_to_cypher(question, schema, llm):
|
||||
prompt = f"""Convert natural language to Cypher.
|
||||
|
||||
Schema: {schema}
|
||||
Question: {question}
|
||||
|
||||
Cypher query:"""
|
||||
return llm.generate(prompt)
|
||||
```
|
||||
|
||||
### Schema.org (web KR)
|
||||
```html
|
||||
<script type="application/ld+json">
|
||||
{
|
||||
"@context": "https://schema.org",
|
||||
"@type": "Person",
|
||||
"name": "Alice",
|
||||
"knows": [{"@type": "Person", "name": "Bob"}]
|
||||
}
|
||||
</script>
|
||||
```
|
||||
|
||||
### Maintain KG (incremental update)
|
||||
```python
|
||||
class KG:
|
||||
def add_triple(self, s, p, o, source, confidence):
|
||||
# 매 store with provenance
|
||||
self.graph.add((s, p, o, source, confidence, datetime.now()))
|
||||
|
||||
def query_with_provenance(self, pattern):
|
||||
return [(triple, source, conf) for triple, source, conf, _ in self.graph.match(pattern)]
|
||||
```
|
||||
|
||||
## 매 결정 기준
|
||||
| 상황 | Approach |
|
||||
|---|---|
|
||||
| Structured facts | Knowledge Graph |
|
||||
| Logical inference | Description Logic + reasoner |
|
||||
| Web data | Schema.org + RDF |
|
||||
| Visual reasoning | Neuro-symbolic |
|
||||
| Modern QA | GraphRAG (KG + LLM) |
|
||||
| Recommendation | KG + embedding (TransE) |
|
||||
|
||||
**기본값**: 매 modern = LLM + KG hybrid (GraphRAG-style) + 매 schema.org for web data + 매 Neo4j for prod KG + 매 provenance tracking.
|
||||
|
||||
## 🔗 Graph
|
||||
- 부모: [[AI]] · [[Symbolic-AI]]
|
||||
- 변형: [[Ontology]] · [[Knowledge-Graph]] · [[GraphRAG]]
|
||||
- 응용: [[Semantic-Web]] · [[RAG]] · [[Recommender-Systems]]
|
||||
- Adjacent: [[GNN]] · [[Foundation-Models]] · [[Logic-Programming]]
|
||||
|
||||
## 🤖 LLM 활용
|
||||
**언제**: 매 structured QA. 매 enterprise data. 매 recommendation.
|
||||
**언제 X**: 매 free-form text only.
|
||||
|
||||
## ❌ 안티패턴
|
||||
- **Pure symbolic in LLM era**: 매 hybrid 의 win.
|
||||
- **No provenance**: 매 trust X.
|
||||
- **Stale KG**: 매 update 의 critical.
|
||||
- **Over-engineer ontology**: 매 yagni.
|
||||
|
||||
## 🧪 검증 / 중복
|
||||
- Verified (Brachman & Levesque KR textbook, Microsoft GraphRAG 2024).
|
||||
- 신뢰도 A.
|
||||
|
||||
## 🕓 Changelog
|
||||
| 날짜 | 변경 |
|
||||
|---|---|
|
||||
| 2026-05-08 | Phase 1 |
|
||||
| 2026-05-10 | Manual cleanup — paradigms + 매 RDF / Neo4j / OWL / GraphRAG / TransE code |
|
||||
|
||||
Reference in New Issue
Block a user