[G1-Sync] Manual knowledge update
This commit is contained in:
@@ -2,68 +2,164 @@
|
||||
id: wiki-2026-0508-ontology-engineering
|
||||
title: Ontology Engineering
|
||||
category: 10_Wiki/Topics
|
||||
status: needs_review
|
||||
status: verified
|
||||
canonical_id: self
|
||||
aliases: [P-Reinforce-AUTO-ONT-001]
|
||||
aliases: [Ontology Engineering, Ontological Engineering, Ontology-Driven Relevancy Filtering, OWL Modeling]
|
||||
duplicate_of: none
|
||||
source_trust_level: A
|
||||
confidence_score: 0.94
|
||||
tags: [auto-reinforced, Ontology, semantic-web, knowledge-engineering]
|
||||
confidence_score: 0.9
|
||||
verification_status: applied
|
||||
tags: [ontology, owl, rdf, sparql, knowledge-graph, protege, semantic-web, kg-rag]
|
||||
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/turtle, framework: rdflib/owlready2/protege }
|
||||
---
|
||||
|
||||
# [[Ontology-Engineering]]
|
||||
# Ontology Engineering
|
||||
|
||||
## 📌 한 줄 통찰 (The Karpathy Summary)
|
||||
> "지식의 뼈대를 세우는 법: 세상의 개념들과 그들 사이의 관계를 컴퓨터가 이해할 수 있는 엄밀한 논리 구조(Ontology)로 설계하는 지식 공학의 핵심."
|
||||
도메인의 개념·관계·제약을 형식 모델(OWL/RDF)로 표현하는 엔지니어링. 2025년 KG-based RAG로 재부상.
|
||||
|
||||
## 📖 구조화된 지식 (Synthesized Content)
|
||||
온톨로지 공학(Ontology Engineering)은 특정 도메인의 지식을 명시적으로 표현하기 위해 개념(Concepts), 속성(Properties), 관계(Relations) 및 제약 조건(Constraints)을 개발하는 방법론입니다.
|
||||
## 핵심
|
||||
|
||||
1. **구조의 계층**:
|
||||
* **Classes (클래스)**: 개념의 집합 (예: '동물', '사람').
|
||||
* **Instances (인스턴스)**: 구체적인 개체 (예: '나', '대표님').
|
||||
* **Properties (속성)**: 개체 간의 관계 (예: '...은 ...의 부모다') 혹은 개체의 특징.
|
||||
2. **개발 방법론 (Ontology Development 101)**:
|
||||
* 도메인과 범위 결정 -> 기존 온톨로지 재사용 검토 -> 용어 추출 -> 계층 구조 정의 -> 속성 및 제약 조건 정의.
|
||||
3. **표준 언어**:
|
||||
* **RDF/S**: 기초적인 자원 기술 프레임워크.
|
||||
* **OWL (Web Ontology Language)**: 복잡한 논리적 추론이 가능한 시맨틱 웹 표준 언어.
|
||||
### 구성요소
|
||||
- **Class** (개념): `Person`, `Drug`, `Symptom`.
|
||||
- **Individual** (인스턴스): `:John a :Person`.
|
||||
- **ObjectProperty / DataProperty**: `hasParent`, `hasAge`.
|
||||
- **Axioms**: subClassOf, equivalentClass, disjointWith, cardinality.
|
||||
- **Restrictions**: `someValuesFrom`, `allValuesFrom`, `hasValue`.
|
||||
|
||||
## ⚠️ 모순 및 업데이트 (Contradictions & Updates)
|
||||
- **과거 데이터와의 충돌**: 과거 온톨로지는 수작업 기반으로 매우 경직되어 '지식의 노후화' 문제를 겪었으나, 현대 공학은 머신러닝을 활용해 텍스트에서 자동으로 온톨로지를 추출하고 확장하는 '동적 온톨로지'로 진화함.
|
||||
- **정책 변화(RL Update)**: 엔터프라이즈 레벨의 AI 시스템 구축 시, 데이터 사일로(Silo) 현상을 막고 상호 운용성([[Inter[[Opera]]bility]])을 확보하기 위해 '표준 온톨로지 준수'가 데이터 거버넌스의 핵심 정책으로 도입됨.
|
||||
### 표현 언어
|
||||
- **RDF / RDFS**: 그래프 데이터 모델 + 기본 어휘.
|
||||
- **OWL 2 DL**: description logic, decidable. 추론기(reasoner) 지원.
|
||||
- **OWL 2 EL/QL/RL**: 큰 온톨로지 / 쿼리 / 룰 최적화 프로파일.
|
||||
- **SHACL**: shape constraints, validation.
|
||||
- **SPARQL 1.1**: 그래프 쿼리.
|
||||
|
||||
## 🔗 지식 연결 (Graph)
|
||||
- **Related**: Semantic Grounding Provenance, Knowledge Graphs, Semantic Web, [[Logic]]
|
||||
- **Modern Tech/Tools**: Protege, TopBraid Composer, Neo4j.
|
||||
---
|
||||
### 방법론
|
||||
- **METHONTOLOGY**: 명세 → 개념화 → 형식화 → 구현 → 평가.
|
||||
- **NeOn**: re-engineering, alignment, modular ontology.
|
||||
- **Ontology Development 101** (Stanford): iterative + competency questions.
|
||||
- **OBO Foundry**: 생명과학 표준 (orthogonality, FAIR).
|
||||
|
||||
## 🤖 LLM 활용 힌트 (How to Use This Knowledge)
|
||||
### 도구
|
||||
- **Protégé**: 데스크톱 OWL 에디터, plugin (HermiT, ELK reasoner).
|
||||
- **WebProtégé**: 협업.
|
||||
- **owlready2** / **rdflib** (Python), **Apache Jena** (Java).
|
||||
- **GraphDB / Stardog / Neo4j+n10s**: triple/labeled-property store.
|
||||
|
||||
**언제 이 지식을 쓰는가:**
|
||||
- *(TODO)*
|
||||
### 모던 응용 (2025-2026)
|
||||
- **KG-based RAG**: LLM이 ontology 기반 KG를 조회 (vs vector-only RAG). 정확도/추적성 향상.
|
||||
- **GraphRAG (Microsoft)**: 커뮤니티 요약 + 엔티티 그래프.
|
||||
- **NL2SPARQL**: LLM이 자연어 → SPARQL 변환.
|
||||
- **Ontology-driven 분류/필터링**: 문서를 도메인 개념으로 태깅 → relevancy filtering.
|
||||
|
||||
**언제 쓰면 안 되는가:**
|
||||
- *(TODO)*
|
||||
## 💻 패턴
|
||||
|
||||
## 🧪 검증 상태 (Validation)
|
||||
### Turtle (TTL) 도메인 모델
|
||||
```turtle
|
||||
@prefix : <http://ex.com/med#> .
|
||||
@prefix owl: <http://www.w3.org/2002/07/owl#> .
|
||||
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
|
||||
|
||||
- **정보 상태:** needs_review
|
||||
- **출처 신뢰도:** A
|
||||
- **검토 이유:** *(P-Reinforce Phase 1 자동 정규화. 본문 검증 필요.)*
|
||||
:Drug a owl:Class .
|
||||
:Antibiotic a owl:Class ; rdfs:subClassOf :Drug .
|
||||
:treats a owl:ObjectProperty ; rdfs:domain :Drug ; rdfs:range :Disease .
|
||||
:Amoxicillin a :Antibiotic ; :treats :StrepThroat .
|
||||
```
|
||||
|
||||
## 🧬 중복 검사 (Duplicate Check)
|
||||
### owlready2 — 동적 클래스 정의 + 추론
|
||||
```python
|
||||
from owlready2 import *
|
||||
onto = get_ontology("http://ex.com/med.owl")
|
||||
with onto:
|
||||
class Drug(Thing): pass
|
||||
class Antibiotic(Drug): pass
|
||||
class treats(ObjectProperty): pass
|
||||
class Amoxicillin(Antibiotic): pass
|
||||
sync_reasoner() # HermiT 호출, 클래스 계층 추론
|
||||
```
|
||||
|
||||
- **기존 유사 문서:** *(TODO: 인덱서 클러스터 리포트 참조)*
|
||||
- **처리 방식:** UPDATE (자동 정규화)
|
||||
- **처리 이유:** Phase 1 정규화 — 옛 템플릿/누락 필드 보강.
|
||||
### SPARQL 쿼리 (rdflib)
|
||||
```python
|
||||
from rdflib import Graph
|
||||
g = Graph().parse("med.ttl", format="turtle")
|
||||
q = """
|
||||
PREFIX : <http://ex.com/med#>
|
||||
SELECT ?drug WHERE {
|
||||
?drug a/rdfs:subClassOf* :Antibiotic ;
|
||||
:treats :StrepThroat .
|
||||
}
|
||||
"""
|
||||
for row in g.query(q): print(row.drug)
|
||||
```
|
||||
|
||||
## 🕓 변경 이력 (Changelog)
|
||||
### Competency questions → 평가
|
||||
```python
|
||||
COMPETENCY_QUESTIONS = [
|
||||
"What antibiotics treat strep throat?",
|
||||
"Which drugs interact with warfarin?",
|
||||
]
|
||||
def evaluate_ontology(graph, questions):
|
||||
return {q: bool(graph.query(translate_to_sparql(q))) for q in questions}
|
||||
```
|
||||
|
||||
| 날짜 | 변경 내용 | 처리 방식 | 신뢰도 |
|
||||
|------|-----------|-----------|--------|
|
||||
| 2026-05-08 | P-Reinforce Phase 1 정규화 (frontmatter + 헤더 표준화) | UPDATE | A |
|
||||
### KG-based RAG (LLM + ontology lookup)
|
||||
```python
|
||||
def kg_rag(question: str, llm, kg) -> str:
|
||||
sparql = llm.generate(f"Translate to SPARQL using ontology schema:\n{kg.schema}\nQ: {question}")
|
||||
facts = kg.query(sparql)
|
||||
return llm.generate(f"Answer using facts:\n{facts}\nQ: {question}")
|
||||
```
|
||||
|
||||
### Ontology-driven relevancy filter
|
||||
```python
|
||||
def filter_docs_by_ontology(docs: list[str], target_concept: str, kg) -> list[str]:
|
||||
# tag each doc with concepts via NER + ontology mapping
|
||||
relevant_concepts = set(kg.descendants_of(target_concept))
|
||||
return [d for d in docs
|
||||
if relevant_concepts & extract_concepts(d, kg)]
|
||||
```
|
||||
|
||||
## 결정 기준
|
||||
|
||||
| 상황 | 권장 |
|
||||
|---|---|
|
||||
| 작은 schema, 빠른 ETL | RDFS + SHACL |
|
||||
| 추론 필요 (subsumption) | OWL 2 EL (확장성) |
|
||||
| 복잡 제약, 의료/법률 | OWL 2 DL + HermiT |
|
||||
| LPG (속성 그래프) 워크로드 | Neo4j + neosemantics |
|
||||
| LLM 통합 RAG | OWL 2 EL + GraphDB + NL2SPARQL |
|
||||
| 협업 편집 | WebProtégé |
|
||||
|
||||
기본값: **OWL 2 EL + Protégé + GraphDB** + competency-question 기반 평가.
|
||||
|
||||
## 🔗 Graph
|
||||
|
||||
- 부모: [[Knowledge Representation]], [[Semantic Web]]
|
||||
- 변형: [[Knowledge Graphs]], [[Taxonomies]], [[Thesauri]]
|
||||
- 응용: [[KG-based RAG]], [[Ontology-Driven Search]], [[Biomedical Ontologies]]
|
||||
- Adjacent: [[OWL]], [[RDF]], [[SPARQL]], [[SHACL]], [[Protégé]], [[GraphRAG]]
|
||||
|
||||
## 🤖 LLM 활용
|
||||
|
||||
- 언제: NL→SPARQL 변환, 클래스 라벨링/정의 초안, axiom 검토 페어, ontology alignment 후보 제안, KG-RAG 답변 합성.
|
||||
- 언제 X: critical 도메인 axiom 단독 결정 (전문가 검토 필수), reasoner를 LLM으로 대체 (decidability 보장 X).
|
||||
|
||||
## ❌ 안티패턴
|
||||
|
||||
- 평면 taxonomy를 ontology로 부르기 (axiom/속성 없음).
|
||||
- 클래스를 인스턴스로 사용 (metamodeling 혼동).
|
||||
- 모든 것을 owl:Thing 직속 (계층 부재).
|
||||
- Reasoner 없이 disjointWith 남발 (불일치 탐지 안됨).
|
||||
- Competency question 없이 모델 시작 → scope creep.
|
||||
- Ontology를 LLM 컨텍스트에 raw로 주입 (token 폭발) — schema-only로 축약.
|
||||
|
||||
## 🧪 검증 / 중복
|
||||
|
||||
- 검증: HermiT/ELK consistency check, SHACL validation, competency Q coverage, FAIR 점수.
|
||||
- 중복: [[Ontological-Engineering]], [[Ontology-Driven-Relevancy-Filtering]] → 본 문서로 redirect.
|
||||
|
||||
## 🕓 Changelog
|
||||
|
||||
- 2026-05-10: 표준 포맷, KG-based RAG / GraphRAG / NL2SPARQL 추가, redirect 통합.
|
||||
|
||||
Reference in New Issue
Block a user