[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
@@ -1,125 +1,193 @@
---
id: wiki-2026-0508-ontology
title: Ontology
category: Computer_Science_and_Theory
status: needs_review
category: 10_Wiki/Topics
status: verified
canonical_id: self
aliases: [P-Reinforce-AUTO-ONT-001]
aliases: [Formal Ontology, Knowledge Ontology, Domain Model]
duplicate_of: none
source_trust_level: A
confidence_score: 1.0
tags: [auto-reinforced, ontology, knowledge-engineering, taxonomy, semantic-web, data-modeling]
confidence_score: 0.9
verification_status: applied
tags: [knowledge-representation, semantic-web, philosophy, AI]
raw_sources: []
last_reinforced: 2026-05-04
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/turtle
framework: rdflib/owlready2
---
# [[Ontology|Ontology]]
# Ontology
## 📌 한 줄 통찰 (The Karpathy Summary)
> "지식의 세계관 설계: 단순히 데이터를 분류하는 것을 넘어, 특정 도메인 내에 존재하는 개념들의 본질과 그들 사이의 엄격한 관계 규칙을 정의하여 컴퓨터가 세상을 이해하는 논리적 틀을 제공하는 것."
## 한 줄
> **"매 specification of a conceptualization (Gruber 1993) — 매 domain 의 entity, class, relation 의 formal definition"**. Aristotle 의 categories 에서 출발, Tim Berners-Lee 의 Semantic Web (RDF/OWL) 으로 web-scale 구현. 매 2026 의 사용처: knowledge graph (Wikidata, Google KG), biomedical (Gene Ontology, SNOMED CT), enterprise data fabric, LLM 의 retrieval-augmented generation grounding.
## 📖 구조화된 지식 (Synthesized Content)
온톨로지(Ontology)는 특정 지식 도메인 내의 개념(Class), 개체(Instance), 속성(Property) 및 그들 간의 관계를 정형화하여 표현한 모델입니다.
## 매 핵심
1. **온톨로지의 구성 요소**:
* **클래스 (Class)**: 사물이나 개념의 집합. (예: '사람', '도시', '프로젝트')
* **속성 (Property)**: 클래스의 특징이나 관계를 정의. (예: '나이', '위치한 곳')
* **제약 조건 (Constraint)**: 관계의 규칙을 정의. (예: '도시'는 반드시 하나의 '국가'에 속해야 함)
### 매 핵심 구성요소
- **Class (Concept)**: 매 entity type (e.g., Person, Drug).
- **Individual (Instance)**: 매 구체적 entity (e.g., :alice).
- **Property**: 매 entity 간 또는 entity-literal 의 binary relation.
- **ObjectProperty**: 매 entity → entity (e.g., :hasParent).
- **DatatypeProperty**: 매 entity → literal (e.g., :hasAge xsd:int).
- **Axiom**: 매 logical statement (subClassOf, equivalentClass, disjointWith).
- **Hierarchy**: 매 taxonomy (is-a) + partonomy (part-of).
2. **분류 체계(Taxonomy)와의 차이**:
* **Taxonomy**: 단순히 부모-자식 관계(A는 B의 일종이다)의 계층 구조만 가집니다.
* **Ontology**: '소유하다', '제작하다', '거주하다' 등 훨씬 더 복잡하고 다양한 관계를 표현할 수 있습니다.
### 매 stack
- **RDF**: 매 triple (subject, predicate, object) — graph data model.
- **RDFS**: 매 lightweight schema (subClassOf, domain, range).
- **OWL 2**: 매 description logic 기반 — 매 SROIQ(D), reasoning 가능.
- **SPARQL**: 매 query language (SQL for RDF).
- **SHACL**: 매 shape-based validation.
3. **지식 관리 시스템에서의 역할**:
* **[[Knowledge Graph|Knowledge Graph]]의 뼈대**: 그래프가 어떤 형태로 구축되어야 하는지 가이드를 제공합니다.
* **데이터 통합**: 서로 다른 이름으로 불리는 같은 개념을 통일된 용어로 매핑합니다.
* **추론 가동**: 정의된 규칙을 바탕으로 명시되지 않은 새로운 지식을 도출합니다.
### 매 응용
1. Wikidata, DBpedia (general knowledge graph).
2. Gene Ontology, SNOMED CT, UMLS (biomedical).
3. schema.org (web markup, Google rich results).
4. Enterprise: data catalogs (Collibra, Atlan).
5. LLM grounding (GraphRAG, knowledge-graph augmented retrieval).
## ⚠️ 모순 및 업데이트 (Contradictions & Updates)
* **고도의 전문성 요구**: 효과적인 온톨로지를 설계하기 위해서는 해당 도메인에 대한 깊은 이해와 지식 공학(Knowledge Engineering) 기술이 필수적입니다.
* **경직성 리스크**: 너무 엄격하게 설계된 온톨로지는 빠르게 변화하는 최신 지식을 수용하기 어렵고 유연성이 떨어질 수 있습니다.
* **구축 비용**: 초기 설계와 지속적인 갱신에 상당한 시간과 인적 자원이 소요됩니다.
## 💻 패턴
## 💻 실전 구현 코드 (Boilerplate)
지식의 계층과 관계를 정의하는 마크다운 기반의 약식 온톨로지 정의 예시입니다.
### Turtle (RDF/OWL syntax)
```turtle
@prefix : <http://example.org/> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
```markdown
# Antigravity Knowledge Ontology v1.0
:Person a owl:Class .
:Drug a owl:Class .
:Antibiotic rdfs:subClassOf :Drug .
## 1. Core Classes (개념군)
- [[Agent]]: 자율적으로 행동하는 AI 주체
- [[Wiki]]: 정제된 지식의 보관 단위
- [[Protocol]]: 지식 처리를 위한 규약
:hasPrescribed a owl:ObjectProperty ;
rdfs:domain :Person ;
rdfs:range :Drug .
## 2. Relationships (관계 정의)
- [Agent] -- FOLLOWS --> [Protocol]
- [Protocol] -- STANDARDIZES --> [Wiki]
- [Agent] -- REINFORCES --> [Wiki]
## 3. Data Properties (속성 정의)
- Agent.version: 시스템 버전
- Wiki.category: 지식 분류 (AI_and_ML, Backend 등)
- Protocol.last_updated: 최신 갱신일
:alice a :Person ;
:hasPrescribed :amoxicillin .
:amoxicillin a :Antibiotic .
```
## 🔗 지식 연결 (Graph)
* **상위 개념**: [[Computer Science and Theory|Computer Science]], [[Information Science|Information Science]]
* **활용 기술**: [[Knowledge Graph|Knowledge Graph]], [[Semantic Web|Semantic Web]]
* **관련 도구**: [[RDF|RDF]], [[OWL|OWL]], [[Protégé|Protégé]]
### rdflib (Python) — load + query
```python
from rdflib import Graph
---
*Last updated: 2026-05-04*
g = Graph()
g.parse("ontology.ttl", format="turtle")
## 🤖 LLM 활용 힌트 (How to Use This Knowledge)
**언제 이 지식을 쓰는가:**
- *(TODO)*
**언제 쓰면 안 되는가:**
- *(TODO)*
## 🧪 검증 상태 (Validation)
- **정보 상태:** 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
# SPARQL: who was prescribed an antibiotic?
q = """
PREFIX : <http://example.org/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?person ?drug WHERE {
?person :hasPrescribed ?drug .
?drug a/rdfs:subClassOf* :Antibiotic .
}
"""
for row in g.query(q):
print(row.person, row.drug)
```
## 🤔 의사결정 기준 (Decision Criteria)
### owlready2 (OWL with reasoning)
```python
from owlready2 import *
**선택 A를 써야 할 때:**
- *(TODO)*
onto = get_ontology("http://example.org/onto.owl")
with onto:
class Person(Thing): pass
class Drug(Thing): pass
class Antibiotic(Drug): pass
class hasPrescribed(ObjectProperty):
domain = [Person]
range = [Drug]
**선택 B를 써야 할 때:**
- *(TODO)*
alice = Person("alice")
amox = Antibiotic("amoxicillin")
alice.hasPrescribed.append(amox)
**기본값:**
> *(TODO)*
sync_reasoner_pellet() # 매 inference: amox is Drug (subclass)
```
## ❌ 안티패턴 (Anti-Patterns)
### SHACL validation
```turtle
:PersonShape a sh:NodeShape ;
sh:targetClass :Person ;
sh:property [
sh:path :hasAge ;
sh:datatype xsd:integer ;
sh:minInclusive 0 ;
sh:maxInclusive 150 ;
] .
```
- **[안티패턴]:** *(TODO: 무엇을 하면 안 되는가 + 이유 + 대신 무엇을)*
### LLM + ontology RAG (GraphRAG-style)
```python
def graph_rag(question, llm, kg):
# 1. Extract entities from question
entities = llm.extract_entities(question)
# 2. SPARQL: get neighborhood
facts = []
for e in entities:
facts.extend(kg.query(f"""
SELECT ?p ?o WHERE {{ <{e}> ?p ?o }} LIMIT 50
"""))
# 3. Answer with grounded context
return llm.generate(question, context=facts)
```
### Ontology alignment (string + embedding)
```python
from sentence_transformers import SentenceTransformer, util
def align_classes(onto_a_labels, onto_b_labels, threshold=0.85):
model = SentenceTransformer("all-mpnet-base-v2")
emb_a = model.encode(onto_a_labels, convert_to_tensor=True)
emb_b = model.encode(onto_b_labels, convert_to_tensor=True)
sim = util.cos_sim(emb_a, emb_b)
matches = []
for i, row in enumerate(sim):
j = row.argmax().item()
if row[j] > threshold:
matches.append((onto_a_labels[i], onto_b_labels[j], row[j].item()))
return matches
```
## 매 결정 기준
| 상황 | Approach |
|---|---|
| simple tagging / faceting | flat taxonomy |
| domain modeling, no reasoning | RDFS |
| reasoning required (subsumption, equivalence) | OWL 2 + reasoner |
| validation rules | SHACL |
| massive scale, low schema | property graph (Neo4j) |
| LLM grounding | knowledge graph + GraphRAG |
**기본값**: 매 enterprise → SKOS + RDFS; 매 reasoning critical → OWL 2 EL/QL profile.
## 🔗 Graph
- 부모: [[Knowledge Graph]] · [[Semantic Web]] · [[Knowledge Representation]]
- 변형: [[OWL]] · [[RDFS]] · [[SKOS]]
- 응용: [[Gene Ontology]] · [[schema.org]] · [[Wikidata]] · [[GraphRAG]]
- Adjacent: [[Description Logic]] · [[SPARQL]] · [[Linked Data]] · [[Taxonomy]]
## 🤖 LLM 활용
**언제**: 매 hallucination 감소를 위한 grounding, 매 enterprise data fabric, 매 named-entity resolution against canonical IDs.
**언제 X**: 매 small unstructured task — overhead 큼. 매 ontology engineering 비용 > 가치.
## ❌ 안티패턴
- **OWL Full 사용**: 매 reasoning undecidable. 매 OWL 2 DL profile (EL/QL/RL) 사용.
- **subClassOf 의 오용** as instanceOf: 매 class hierarchy ≠ instance membership.
- **No URI versioning**: 매 schema 진화 시 breakage. 매 owl:versionIRI 사용.
- **Free-text label only, no canonical URI**: 매 alignment 불가능.
- **Reasoning everything** every query: 매 비싸다 — materialize 후 cache.
## 🧪 검증 / 중복
- Verified (Gruber 1993; W3C OWL 2 spec; *Foundations of Semantic Web Technologies* Hitzler et al.; GraphRAG Microsoft 2024).
- 신뢰도 A.
## 🕓 Changelog
| 날짜 | 변경 |
|---|---|
| 2026-05-08 | Phase 1 |
| 2026-05-10 | Manual cleanup — Ontology FULL with RDF/OWL/SHACL/GraphRAG patterns |