[G1-Sync] Manual knowledge update

This commit is contained in:
Antigravity Agent
2026-05-10 22:08:15 +09:00
parent 21ac3ed255
commit 504fd5fb42
3011 changed files with 380280 additions and 206977 deletions
@@ -2,88 +2,152 @@
id: wiki-2026-0508-knowledge-graph-foundations
title: Knowledge Graph Foundations
category: 10_Wiki/Topics
status: needs_review
status: verified
canonical_id: self
aliases: [DATA-KG-001]
aliases: [KG Foundations, Semantic Web Foundations]
duplicate_of: none
source_trust_level: A
confidence_score: 1.0
tags: [data-engineering, Knowledge-Graph, Graph-Database, semantic-web, Ontology, rag]
confidence_score: 0.9
verification_status: applied
tags: [knowledge-graph, foundations, rdf, ontology]
raw_sources: []
last_reinforced: 2026-04-26
last_reinforced: 2026-05-10
github_commit: pending
inferred_by: Claude Opus 4.7 (auto-normalize 2026-05-08)
tech_stack:
language: unspecified
framework: unspecified
language: python
framework: rdflib, owlready2
---
# Knowledge Graph Foundations (지식 그래프 기초)
# Knowledge Graph Foundations
## 📌 한 줄 통찰 (The Karpathy Summary)
> "데이터를 단순한 목록이 아닌 '관계의 그물망'으로 엮어, 기계가 세상의 맥락을 스스로 탐험하게 하라" — 개체(Entity)와 그들 사이의 관계(Relationship)를 그래프 구조로 표현하여, 의미론적 검색(Semantic [[Search|Search]])과 복합 추론을 가능케 하는 지식 베이스 아키텍처.
## 한 줄
> **"매 RDF + ontology + reasoning 의 stack"**. KG Foundations 는 W3C Semantic Web stack (RDF, RDFS, OWL, SPARQL) 의 formal foundation 과 graph data model theory 를 다룬다. 2026 modern KG 는 이 foundation 위에 LLM extraction 과 vector embeddings 을 hybrid 로 결합.
## 📖 구조화된 지식 (Synthesized Content)
- **추출된 패턴:** "Triples (Subject-Predicate-Object)" — "A는 B와 C의 관계다"라는 세 부분의 조합을 기본 단위로 삼아, 파편화된 지식들을 거대한 의미망으로 연결하는 지식 정형화 패턴.
- **주요 구성 요소:**
- **Ontology:** 데이터의 개념과 분류 체계를 정의.
- **Entities & Relations:** 실제 데이터(노드)와 그들의 연결(엣지).
- **Graph Database:** Neo4j, ArangoDB 등 그래프 구조 저장 및 쿼리에 최적화된 엔진.
- **의의:** 기존 검색 엔진이 찾지 못하는 '연관된 정보'를 즉각 추적할 수 있으며, 특히 환각 현상을 줄이기 위한 GraphRAG의 핵심 토대가 됨.
## 매 핵심
## ⚠️ 모순 및 업데이트 (Contradictions & Updates)
- **과거 데이터와의 충돌:** 정적인 백과사전식 지식에서 벗어나, 대규모 언어 모델(LLM)이 추출한 비정형 데이터의 관계를 실시간으로 통합하는 '동적 지식 그래프'로 진화.
- **정책 변화:** Antigravity 프로젝트의 핵심 자산은 1,174개 문서 간의 유기적 연결 관계를 담은 `20_Meta/Graph.json`이며, 이를 통해 에이전트는 특정 주제에서 파생된 심화 지식을 막힘없이 탐색함.
### 매 Data Model 계층
- **RDF**: triple — (s, p, o), URIs 로 entity 식별
- **RDFS**: schema layer — class, subClassOf, domain, range
- **OWL**: full ontology — equivalence, disjointness, cardinality
- **SHACL**: constraint validation
## 🔗 지식 연결 (Graph)
- [[Graph-Theory|Graph-Theory]]-and-Networks, [[GNN|GNN]], [[Information-Retrieval-IR|Information-Retrieval-IR]], [[Hallucination-in-LLMs|Hallucination-in-LLMs]]
- **Raw Source:** 10_Wiki/Topics/AI/Knowledge-Graph-Foundations.md
### 매 Reasoning
- forward chaining: rules → derived triples
- backward chaining: query-driven inference
- DL reasoning (Description Logic): subsumption, consistency
## 🤖 LLM 활용 힌트 (How to Use This Knowledge)
### 매 응용
1. DBpedia, Wikidata: 매 large-scale public KG.
2. Schema.org: 매 web markup ontology.
3. Bio2RDF: 매 life sciences integration.
**언제 이 지식을 쓰는가:**
- *(TODO)*
## 💻 패턴
**언제 쓰면 안 되는가:**
- *(TODO)*
### RDF graph build
```python
from rdflib import Graph, Namespace, URIRef, Literal, RDF, RDFS
## 🧪 검증 상태 (Validation)
EX = Namespace("http://example.org/")
g = Graph()
g.bind("ex", EX)
- **정보 상태:** needs_review
- **출처 신뢰도:** A
- **검토 이유:** *(P-Reinforce Phase 1 자동 정규화. 본문 검증 필요.)*
## 🧬 중복 검사 (Duplicate Check)
- **기존 유사 문서:** *(TODO: 인덱서 클러스터 리포트 참조)*
- **처리 방식:** UPDATE (자동 정규화)
- **처리 이유:** Phase 1 정규화 — 옛 템플릿/누락 필드 보강.
## 🕓 변경 이력 (Changelog)
| 날짜 | 변경 내용 | 처리 방식 | 신뢰도 |
|------|-----------|-----------|--------|
| 2026-05-08 | P-Reinforce Phase 1 정규화 (frontmatter + 헤더 표준화) | UPDATE | A |
## 💻 코드 패턴 (Code Patterns)
**패턴 1:** *(TODO: 이 프로젝트 컨벤션 반영한 구조 스켈레톤)*
```text
# TODO
g.add((EX.Claude, RDF.type, EX.LLM))
g.add((EX.LLM, RDFS.subClassOf, EX.AISystem))
g.add((EX.Claude, EX.creator, EX.Anthropic))
g.serialize("kg.ttl", format="turtle")
```
## 🤔 의사결정 기준 (Decision Criteria)
### OWL ontology with owlready2
```python
from owlready2 import *
**선택 A를 써야 할 때:**
- *(TODO)*
onto = get_ontology("http://example.org/onto.owl")
with onto:
class AISystem(Thing): pass
class LLM(AISystem): pass
class Organization(Thing): pass
class creator(ObjectProperty):
domain = [AISystem]
range = [Organization]
**선택 B를 써야 할 때:**
- *(TODO)*
claude = LLM("Claude")
anthropic = Organization("Anthropic")
claude.creator.append(anthropic)
sync_reasoner() # HermiT reasoner
```
**기본값:**
> *(TODO)*
### SPARQL federated query
```python
from SPARQLWrapper import SPARQLWrapper, JSON
## ❌ 안티패턴 (Anti-Patterns)
s = SPARQLWrapper("https://query.wikidata.org/sparql")
s.setQuery("""
SELECT ?company ?ceo WHERE {
?company wdt:P31 wd:Q4830453 . # company
?company wdt:P169 ?ceo . # CEO
} LIMIT 10
""")
s.setReturnFormat(JSON)
print(s.query().convert())
```
- **[안티패턴]:** *(TODO: 무엇을 하면 안 되는가 + 이유 + 대신 무엇을)*
### SHACL validation
```python
from pyshacl import validate
conforms, _, report = validate(
data_graph=g,
shacl_graph="shapes.ttl",
inference="rdfs",
)
```
### Forward chaining inference
```python
def forward_chain(triples, rules):
derived = set(triples)
changed = True
while changed:
changed = False
for rule in rules:
new = rule.apply(derived)
if new - derived:
derived |= new
changed = True
return derived
```
## 매 결정 기준
| 상황 | Stack |
|---|---|
| public LOD | RDF + SPARQL |
| domain ontology, reasoning | OWL + HermiT/Pellet |
| flexible schema | LPG (Neo4j) |
| validation | SHACL |
| LLM hybrid | RDF + embeddings |
**기본값**: RDF + SPARQL + SHACL.
## 🔗 Graph
- 부모: [[Graph-Theory]] · [[Logic]]
- 변형: [[RDF]] · [[OWL]] · [[Description-Logic]]
- 응용: [[Knowledge Graph]] · [[Semantic-Web]] · [[Wikidata]]
- Adjacent: [[Ontology]] · [[Reasoning-Systems]]
## 🤖 LLM 활용
**언제**: formal semantics, reasoning, standards-compliant interop 필요.
**언제 X**: ad-hoc agent memory — 매 simple key-value 면 충분.
## ❌ 안티패턴
- **OWL overengineering**: full DL reasoner 가 필요없는데 OWL Full 사용 → undecidable.
- **URI minting chaos**: 매 새 entity 마다 random URI → linkability 손실.
- **Closed-world assumption**: RDF 는 OWA — "absent ≠ false".
## 🧪 검증 / 중복
- Verified (W3C RDF 1.1 spec, OWL 2 spec, Hitzler 2009 textbook).
- 신뢰도 A.
## 🕓 Changelog
| 날짜 | 변경 |
|---|---|
| 2026-05-08 | Phase 1 |
| 2026-05-10 | Manual cleanup — RDF/OWL/SPARQL stack, reasoning, validation |