599 lines
19 KiB
Markdown
599 lines
19 KiB
Markdown
|
|
# 온톨로지 시스템 구축 플랫폼 (Ontology System Construction Platform)
|
|||
|
|
|
|||
|
|
## 플랫폼 개요
|
|||
|
|
|
|||
|
|
이 플랫폼은 **웹 데이터에서 시작하여 구조화된 지식 그래프(Knowledge Graph)를 자동으로 구축하고, 이를 활용해 지능형 응답을 제공하는 end-to-end 시스템**입니다.
|
|||
|
|
|
|||
|
|
### 핵심 목표
|
|||
|
|
```
|
|||
|
|
Raw Web Data → Structured Ontology → Knowledge Graph → AI Reasoning
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## 온톨로지(Ontology)란?
|
|||
|
|
|
|||
|
|
### 정의
|
|||
|
|
**온톨로지**: 어떤 영역의 개념(entities), 속성(properties), 관계(relationships)를 형식화(formalize)한 구조
|
|||
|
|
|
|||
|
|
### 예시
|
|||
|
|
```
|
|||
|
|
의학 온톨로지:
|
|||
|
|
├── Entity (개념)
|
|||
|
|
│ ├── Disease (질병)
|
|||
|
|
│ │ ├── Diabetes
|
|||
|
|
│ │ ├── Hypertension
|
|||
|
|
│ └── Drug (약)
|
|||
|
|
│ ├── Aspirin
|
|||
|
|
│ └── Metformin
|
|||
|
|
│
|
|||
|
|
├── Relationships
|
|||
|
|
│ ├── treats (약이 질병을 치료함)
|
|||
|
|
│ ├── causes (원인 관계)
|
|||
|
|
│ └── prevents (예방 관계)
|
|||
|
|
│
|
|||
|
|
└── Properties
|
|||
|
|
├── Disease.severity (중증도)
|
|||
|
|
├── Drug.sideEffects (부작용)
|
|||
|
|
└── Drug.dosage (용량)
|
|||
|
|
|
|||
|
|
Example:
|
|||
|
|
Aspirin --treats--> Headache
|
|||
|
|
Aspirin --has_sideEffect--> GastricBleeding
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
### 온톨로지의 가치
|
|||
|
|
- **상호운용성**: 다양한 시스템 간 데이터 교환 가능
|
|||
|
|
- **추론 능력**: 규칙 기반 새로운 지식 도출
|
|||
|
|
- **질의응답**: 구조화된 데이터로 정확한 답변
|
|||
|
|
- **재사용성**: 한번 구축한 온톨로지는 여러 앱에서 사용
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## 플랫폼 아키텍처
|
|||
|
|
|
|||
|
|
```
|
|||
|
|
┌─────────────────────────────────────────────────────────────┐
|
|||
|
|
│ ONTOLOGY PLATFORM │
|
|||
|
|
├─────────────────────────────────────────────────────────────┤
|
|||
|
|
│ │
|
|||
|
|
│ [Phase 0-2: Data Collection & Extraction] │
|
|||
|
|
│ ┌────────────────────────────────────────────────────┐ │
|
|||
|
|
│ │ 웹 크롤링 → HTML/텍스트 추출 → 후보 데이터 수집 │ │
|
|||
|
|
│ │ - URL 추출 (Phase 0) │ │
|
|||
|
|
│ │ - Crawl4AI 동적 크롤링 (Phase 1-2) │ │
|
|||
|
|
│ │ - 정적/동적 페이지 모두 지원 │ │
|
|||
|
|
│ └────────────────────────────────────────────────────┘ │
|
|||
|
|
│ ↓ │
|
|||
|
|
│ [Phase 3: Validation & Cleaning] │
|
|||
|
|
│ ┌────────────────────────────────────────────────────┐ │
|
|||
|
|
│ │ 추출 데이터 검증 → 정제 → 온톨로지 변환 │ │
|
|||
|
|
│ │ - OntoCast 가벼운 검증 (Phase 3) │ │
|
|||
|
|
│ │ - 데이터 품질 확인 │ │
|
|||
|
|
│ │ - RDF/트리플 변환 │ │
|
|||
|
|
│ └────────────────────────────────────────────────────┘ │
|
|||
|
|
│ ↓ │
|
|||
|
|
│ [Phase 4: Knowledge Graph Storage] │
|
|||
|
|
│ ┌────────────────────────────────────────────────────┐ │
|
|||
|
|
│ │ 구조화된 데이터 → Neo4j 저장 │ │
|
|||
|
|
│ │ - 벡터 임베딩 (all-MiniLM-L6-v2) │ │
|
|||
|
|
│ │ - 유사도 기반 검색 가능 │ │
|
|||
|
|
│ │ - 대규모 그래프 지원 (10K+ 노드) │ │
|
|||
|
|
│ └────────────────────────────────────────────────────┘ │
|
|||
|
|
│ ↓ │
|
|||
|
|
│ [Phase 5: Graph Intelligence] │
|
|||
|
|
│ ┌────────────────────────────────────────────────────┐ │
|
|||
|
|
│ │ 그래프 분석 및 최적화 │ │
|
|||
|
|
│ │ - 의미적 중복 제거 (Entity Resolution) │ │
|
|||
|
|
│ │ - 부분 그래프 추출 (Subgraph Retrieval) │ │
|
|||
|
|
│ │ - 패턴 분석 (Path Finding, Cycles, Motifs) │ │
|
|||
|
|
│ │ - 중심성/커뮤니티 분석 (Graph Analytics) │ │
|
|||
|
|
│ └────────────────────────────────────────────────────┘ │
|
|||
|
|
│ ↓ │
|
|||
|
|
│ [Phase 6: API & Integration] │
|
|||
|
|
│ ┌────────────────────────────────────────────────────┐ │
|
|||
|
|
│ │ REST API / GraphQL / RAG 파이프라인 제공 │ │
|
|||
|
|
│ │ - /graph/* - 그래프 작업 (10개 엔드포인트) │ │
|
|||
|
|
│ │ - /rag/* - RAG 컨텍스트 추출 │ │
|
|||
|
|
│ │ - /graphql - 유연한 쿼리 │ │
|
|||
|
|
│ └────────────────────────────────────────────────────┘ │
|
|||
|
|
│ ↓ │
|
|||
|
|
│ [Phase 7-8: Future Enhancements] │
|
|||
|
|
│ ┌────────────────────────────────────────────────────┐ │
|
|||
|
|
│ │ - Phase 7: LLM 직접 통합 (스트리밍, 캐싱) │ │
|
|||
|
|
│ │ - Phase 8: 멀티테넌트, 실시간 업데이트 │ │
|
|||
|
|
│ └────────────────────────────────────────────────────┘ │
|
|||
|
|
│ │
|
|||
|
|
└─────────────────────────────────────────────────────────────┘
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## Phase별 역할 정리
|
|||
|
|
|
|||
|
|
### Phase 0-2: 데이터 수집 (Data Collection)
|
|||
|
|
**목표**: 웹에서 원본 데이터 추출
|
|||
|
|
|
|||
|
|
| Phase | 기능 | 기술 |
|
|||
|
|
|-------|------|------|
|
|||
|
|
| **0** | URL 기반 텍스트 추출 | Trafilatura |
|
|||
|
|
| **1** | 동적 페이지 크롤링 | Crawl4AI (Playwright) |
|
|||
|
|
| **2** | 프로필별 크롤링 전략 | fast_static, dynamic_page |
|
|||
|
|
|
|||
|
|
**Input**: `웹 URL`
|
|||
|
|
**Output**: `텍스트, HTML, 메타데이터`
|
|||
|
|
|
|||
|
|
```
|
|||
|
|
예: https://example.com → "Apple is a technology company..."
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
### Phase 3: 데이터 검증 (Validation & Cleaning)
|
|||
|
|
**목표**: 추출 데이터의 품질 확보 및 온톨로지 변환
|
|||
|
|
|
|||
|
|
| 작업 | 기술 | 결과 |
|
|||
|
|
|------|------|------|
|
|||
|
|
| **텍스트 정제** | 정규식, 토큰화 | 깔끔한 텍스트 |
|
|||
|
|
| **엔티티 추출** | NER (Named Entity Recognition) | ["Apple", "Tim Cook"] |
|
|||
|
|
| **관계 추출** | 경량 NLP | [("Apple", "produces", "iPhone")] |
|
|||
|
|
| **검증** | OntoCast, 규칙 기반 | 신뢰도 점수 |
|
|||
|
|
|
|||
|
|
**Input**: `추출된 텍스트`
|
|||
|
|
**Output**: `RDF 트리플 (Subject-Predicate-Object)`
|
|||
|
|
|
|||
|
|
```
|
|||
|
|
예:
|
|||
|
|
("Apple Inc.", "produces", "iPhone")
|
|||
|
|
("Apple Inc.", "founded_by", "Steve Jobs")
|
|||
|
|
("iPhone", "has_feature", "Face ID")
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
### Phase 4: 그래프 저장 (Knowledge Graph Storage)
|
|||
|
|
**목표**: 온톨로지를 Neo4j 그래프 데이터베이스에 저장
|
|||
|
|
|
|||
|
|
| 작업 | 기술 | 특징 |
|
|||
|
|
|------|------|------|
|
|||
|
|
| **변환** | RDF → Property Graph | 노드 + 관계 변환 |
|
|||
|
|
| **임베딩** | SentenceTransformer | 벡터 유사도 검색 |
|
|||
|
|
| **인덱싱** | Neo4j 인덱스 | 빠른 조회 |
|
|||
|
|
| **배치 처리** | UNWIND + MERGE | 대량 데이터 효율 처리 |
|
|||
|
|
|
|||
|
|
**Input**: `RDF 트리플`
|
|||
|
|
**Output**: `Neo4j Knowledge Graph`
|
|||
|
|
|
|||
|
|
```
|
|||
|
|
Neo4j에 저장:
|
|||
|
|
(Apple:Company) -[produces]-> (iPhone:Product)
|
|||
|
|
(Apple:Company) -[founded_by]-> (Steve_Jobs:Person)
|
|||
|
|
(iPhone:Product) -[has_feature]-> (FaceID:Feature)
|
|||
|
|
|
|||
|
|
벡터 저장:
|
|||
|
|
Apple → [0.23, -0.45, 0.67, ...] (384차원)
|
|||
|
|
iPhone → [0.12, 0.34, -0.56, ...] (384차원)
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
### Phase 5: 그래프 지능화 (Graph Intelligence)
|
|||
|
|
**목표**: 저장된 그래프를 분석하여 품질 향상 및 인사이트 도출
|
|||
|
|
|
|||
|
|
#### 5.0: 데이터 정제 (Deduplication & Conversion)
|
|||
|
|
- **Entity Resolver**: "Apple Inc." vs "Apple" 같은 중복 감지
|
|||
|
|
- **RDF 변환**: 쿼리 성능을 위해 Property Graph 최적화
|
|||
|
|
|
|||
|
|
```
|
|||
|
|
Before: Apple, APPLE, Apple Inc., Apple Corporation (4개)
|
|||
|
|
After: Apple Inc. (1개) + aliases: [Apple, APPLE, Apple Inc., ...]
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
#### 5.1: 컨텍스트 추출 (Subgraph & Patterns)
|
|||
|
|
- **Neighborhood Extraction**: 특정 엔티티 주변 2-hop 이웃 추출
|
|||
|
|
- **Pattern Matching**: 경로, 순환, 구조 패턴 분석
|
|||
|
|
- **데이터 품질 검증**: 순환 의존성, 연결성 분석
|
|||
|
|
|
|||
|
|
```
|
|||
|
|
Apple의 2-hop 이웃:
|
|||
|
|
Apple → produces → iPhone → has_feature → Face ID
|
|||
|
|
Apple → founded_by → Steve Jobs
|
|||
|
|
Apple → headquarters → Cupertino
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
#### 5.2: 분석 (Analytics)
|
|||
|
|
- **중심성 분석**: 가장 중요한 엔티티 식별
|
|||
|
|
- **커뮤니티 감지**: 자동으로 관련 엔티티 그룹화
|
|||
|
|
- **그래프 통계**: 전체 구조 이해
|
|||
|
|
|
|||
|
|
```
|
|||
|
|
Top entities by importance:
|
|||
|
|
1. Apple (PageRank: 0.95)
|
|||
|
|
2. iPhone (PageRank: 0.87)
|
|||
|
|
3. Steve Jobs (PageRank: 0.82)
|
|||
|
|
|
|||
|
|
Communities:
|
|||
|
|
- Apple Products (iPhone, iPad, Mac)
|
|||
|
|
- Apple People (Tim Cook, Steve Jobs)
|
|||
|
|
- Apple Locations (Cupertino, China)
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
### Phase 6: API & 통합 (API & RAG Integration)
|
|||
|
|
**목표**: 구축한 온톨로지를 외부에 공개하고 LLM과 연계
|
|||
|
|
|
|||
|
|
#### REST API
|
|||
|
|
```bash
|
|||
|
|
# 그래프 조회
|
|||
|
|
GET /api/v1/graph/analytics/influential
|
|||
|
|
→ 가장 영향력 있는 엔티티들
|
|||
|
|
|
|||
|
|
# 패턴 분석
|
|||
|
|
POST /api/v1/graph/patterns/paths
|
|||
|
|
→ Apple에서 iPhone까지의 모든 경로
|
|||
|
|
|
|||
|
|
# RAG 컨텍스트
|
|||
|
|
POST /api/v1/rag/context-extraction
|
|||
|
|
→ "Apple의 제품?"에 필요한 그래프 컨텍스트
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
#### RAG (Retrieval Augmented Generation) 파이프라인
|
|||
|
|
```
|
|||
|
|
사용자 쿼리: "Apple의 제품은?"
|
|||
|
|
↓
|
|||
|
|
그래프 검색: Apple 엔티티 찾기
|
|||
|
|
↓
|
|||
|
|
컨텍스트 추출: Apple 주변 2-hop 이웃
|
|||
|
|
↓
|
|||
|
|
LLM 프롬프트 구성:
|
|||
|
|
You are a helpful assistant.
|
|||
|
|
|
|||
|
|
KNOWLEDGE GRAPH CONTEXT:
|
|||
|
|
Apple produces: iPhone, iPad, Mac, Apple Watch
|
|||
|
|
Apple was founded by Steve Jobs
|
|||
|
|
Apple is headquartered in Cupertino
|
|||
|
|
|
|||
|
|
Question: Apple의 제품은?
|
|||
|
|
↓
|
|||
|
|
LLM 응답: "Apple의 주요 제품은..."
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
#### GraphQL 지원
|
|||
|
|
```graphql
|
|||
|
|
{
|
|||
|
|
entity(id: 1) {
|
|||
|
|
label
|
|||
|
|
type
|
|||
|
|
neighbors(hops: 2) {
|
|||
|
|
label
|
|||
|
|
relationship
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
**Input**: `REST/GraphQL 쿼리`
|
|||
|
|
**Output**: `JSON 응답 + LLM 프롬프트`
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## 엔드투엔드 워크플로우
|
|||
|
|
|
|||
|
|
### 시나리오: 기술 회사 온톨로지 구축
|
|||
|
|
|
|||
|
|
#### 1단계: 데이터 수집
|
|||
|
|
```bash
|
|||
|
|
# Phase 0-2
|
|||
|
|
URL 목록 입력:
|
|||
|
|
- apple.com
|
|||
|
|
- wikipedia.org/wiki/Apple
|
|||
|
|
- crunchbase.com/organization/apple
|
|||
|
|
|
|||
|
|
↓
|
|||
|
|
|
|||
|
|
추출 결과:
|
|||
|
|
"Apple is a technology company..."
|
|||
|
|
"Founded by Steve Jobs in 1976"
|
|||
|
|
"Produces iPhone, iPad, Mac..."
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
#### 2단계: 데이터 검증 및 온톨로지 변환
|
|||
|
|
```python
|
|||
|
|
# Phase 3
|
|||
|
|
Raw Text Input:
|
|||
|
|
"Apple produces iPhone and iPad"
|
|||
|
|
|
|||
|
|
↓
|
|||
|
|
|
|||
|
|
검증 및 추출:
|
|||
|
|
Entity 1: Apple (Company) - confidence: 0.95
|
|||
|
|
Entity 2: iPhone (Product) - confidence: 0.92
|
|||
|
|
Relation: produces - confidence: 0.88
|
|||
|
|
|
|||
|
|
↓
|
|||
|
|
|
|||
|
|
RDF 트리플:
|
|||
|
|
(Apple, produces, iPhone)
|
|||
|
|
(Apple, produces, iPad)
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
#### 3단계: 그래프 저장 및 벡터화
|
|||
|
|
```
|
|||
|
|
# Phase 4
|
|||
|
|
Neo4j 저장:
|
|||
|
|
CREATE (a:Company {name: "Apple"})
|
|||
|
|
CREATE (p:Product {name: "iPhone"})
|
|||
|
|
CREATE (a)-[:PRODUCES]->(p)
|
|||
|
|
SET a.embedding = [0.23, -0.45, ...]
|
|||
|
|
SET p.embedding = [0.12, 0.34, ...]
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
#### 4단계: 그래프 지능화
|
|||
|
|
```
|
|||
|
|
# Phase 5
|
|||
|
|
Quality Check:
|
|||
|
|
- 중복 감지: "Apple", "APPLE", "Apple Inc." → 1개로 통합
|
|||
|
|
- 구조 분석: Apple의 2-hop 이웃 = 45개 엔티티
|
|||
|
|
- 중요도: Apple (0.95), iPhone (0.87), iPad (0.85)
|
|||
|
|
|
|||
|
|
Communities:
|
|||
|
|
- Apple Products: [iPhone, iPad, Mac, Watch]
|
|||
|
|
- Apple People: [Tim Cook, Steve Jobs]
|
|||
|
|
- Apple Locations: [Cupertino, China Factory]
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
#### 5단계: API 공개 및 LLM 통합
|
|||
|
|
```
|
|||
|
|
# Phase 6
|
|||
|
|
API 엔드포인트:
|
|||
|
|
|
|||
|
|
GET /graph/analytics/influential
|
|||
|
|
→ Top 20 entities by importance
|
|||
|
|
|
|||
|
|
POST /graph/patterns/paths
|
|||
|
|
→ Apple과 Steve Jobs를 연결하는 모든 경로
|
|||
|
|
|
|||
|
|
POST /rag/query
|
|||
|
|
Input: "Apple의 제품은?"
|
|||
|
|
Output:
|
|||
|
|
{
|
|||
|
|
"llm_prompt": "Knowledge Graph...\n\nQuestion: Apple의 제품은?",
|
|||
|
|
"context": {nodes: 45, edges: 120},
|
|||
|
|
"relevant_entities": ["iPhone", "iPad", "Mac"]
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
↓
|
|||
|
|
|
|||
|
|
LLM Service (외부):
|
|||
|
|
Input: llm_prompt
|
|||
|
|
Output: "Apple의 주요 제품은 iPhone, iPad, Mac 등입니다..."
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## 플랫폼이 해결하는 문제
|
|||
|
|
|
|||
|
|
### 1️⃣ 정보의 구조화
|
|||
|
|
**문제**: 웹에 산재된 정보는 비구조화 상태
|
|||
|
|
**해결**: Phase 0-3으로 자동 구조화
|
|||
|
|
|
|||
|
|
```
|
|||
|
|
Before: "Apple produces iPhone, iPad, and Mac. Steve Jobs founded it."
|
|||
|
|
After:
|
|||
|
|
(Apple) -[produces]-> (iPhone)
|
|||
|
|
(Apple) -[produces]-> (iPad)
|
|||
|
|
(Apple) -[produces]-> (Mac)
|
|||
|
|
(Apple) -[founded_by]-> (Steve Jobs)
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
### 2️⃣ 중복된 정보
|
|||
|
|
**문제**: "Apple", "APPLE Inc.", "Apple Computer"는 같은가?
|
|||
|
|
**해결**: Phase 5.0 Entity Resolver로 자동 중복 제거
|
|||
|
|
|
|||
|
|
```
|
|||
|
|
Before: 100개 Apple 관련 엔티티
|
|||
|
|
After: 1개 Apple + aliases: [APPLE, Apple Inc., ...]
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
### 3️⃣ 데이터 품질 문제
|
|||
|
|
**문제**: 추출 데이터에 오류, 불완전, 부정확
|
|||
|
|
**해결**: Phase 3 검증 + Phase 5 분석으로 문제 식별
|
|||
|
|
|
|||
|
|
```
|
|||
|
|
확인:
|
|||
|
|
✓ 필수 엔티티 모두 포함?
|
|||
|
|
✓ 관계가 논리적으로 타당?
|
|||
|
|
✓ 순환 의존성은 없나?
|
|||
|
|
✓ 신뢰도 점수는 충분한가?
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
### 4️⃣ 정보 활용의 어려움
|
|||
|
|
**문제**: "Apple의 제품은?" 같은 질문에 자동으로 답하기 어려움
|
|||
|
|
**해결**: Phase 4-6으로 검색 가능한 지식 그래프 구축 + LLM 연계
|
|||
|
|
|
|||
|
|
```
|
|||
|
|
자동 답변:
|
|||
|
|
Q: "Apple의 제품은?"
|
|||
|
|
A: "Apple은 iPhone, iPad, Mac, Watch를 생산합니다"
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## 플랫폼 사용 시나리오
|
|||
|
|
|
|||
|
|
### 시나리오 1: 의료 온톨로지 구축
|
|||
|
|
```
|
|||
|
|
목표: 의약 정보 자동 추출 및 의사 지원
|
|||
|
|
|
|||
|
|
Phase 0-2: 의료 사이트 크롤링
|
|||
|
|
✓ FDA.gov, Medline, 의료 뉴스 등
|
|||
|
|
|
|||
|
|
Phase 3: 약물-질병-치료법 추출
|
|||
|
|
✓ "Aspirin treats Headache"
|
|||
|
|
✓ "Metformin manages Diabetes"
|
|||
|
|
|
|||
|
|
Phase 4: Neo4j에 저장
|
|||
|
|
✓ 약물, 질병, 부작용, 용량 등 관계
|
|||
|
|
|
|||
|
|
Phase 5: 의료 지식 분석
|
|||
|
|
✓ "이 증상을 일으키는 약물은?"
|
|||
|
|
✓ "안전한 약물 조합은?"
|
|||
|
|
|
|||
|
|
Phase 6: 의사용 API
|
|||
|
|
GET /api/drug/{drugId}/interactions
|
|||
|
|
→ 상호작용 정보 즉시 제공
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
### 시나리오 2: 기업 경쟁 분석
|
|||
|
|
```
|
|||
|
|
목표: 경쟁사 정보 자동 수집 및 분석
|
|||
|
|
|
|||
|
|
Phase 0-2: 뉴스, 재무제표, 공식 사이트 크롤링
|
|||
|
|
✓ Samsung, Apple, Sony 정보
|
|||
|
|
|
|||
|
|
Phase 3: 제품, 전략, 파트너십 추출
|
|||
|
|
✓ "Samsung produces OLED displays"
|
|||
|
|
✓ "Apple partners with TSMC"
|
|||
|
|
|
|||
|
|
Phase 4: 경쟁 관계 그래프
|
|||
|
|
✓ 공급망, 기술 경쟁, M&A 관계
|
|||
|
|
|
|||
|
|
Phase 5: 분석
|
|||
|
|
✓ "Apple과 경쟁하는 기업은?"
|
|||
|
|
✓ "가장 영향력 있는 기업은?"
|
|||
|
|
|
|||
|
|
Phase 6: 분석가용 API
|
|||
|
|
POST /api/competitor-analysis
|
|||
|
|
→ 경쟁 지형도 자동 생성
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
### 시나리오 3: 학술 지식 그래프
|
|||
|
|
```
|
|||
|
|
목표: 과학 논문에서 자동으로 지식 추출
|
|||
|
|
|
|||
|
|
Phase 0-2: arXiv, PubMed 크롤링
|
|||
|
|
✓ 학술 논문 데이터
|
|||
|
|
|
|||
|
|
Phase 3: 개념, 방법론, 결과 추출
|
|||
|
|
✓ "BERT improves NLP tasks"
|
|||
|
|
✓ "Transformer uses attention mechanism"
|
|||
|
|
|
|||
|
|
Phase 4: 학술 지식 그래프
|
|||
|
|
✓ 기술, 저자, 논문, 인용 관계
|
|||
|
|
|
|||
|
|
Phase 5: 분석
|
|||
|
|
✓ "가장 영향력 있는 논문은?"
|
|||
|
|
✓ "이 분야의 선도 연구자는?"
|
|||
|
|
|
|||
|
|
Phase 6: 연구자용 API
|
|||
|
|
GET /api/research-topics/trending
|
|||
|
|
→ 최신 연구 방향 추천
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## 기술 스택
|
|||
|
|
|
|||
|
|
### 데이터 수집
|
|||
|
|
- **Trafilatura**: HTML → 텍스트 추출
|
|||
|
|
- **Crawl4AI**: 동적 페이지 크롤링 (Playwright 기반)
|
|||
|
|
|
|||
|
|
### NLP & 추출
|
|||
|
|
- **LightweightExtractor**: 엔티티/관계 추출
|
|||
|
|
- **OntoCast**: 검증 및 온톨로지 변환
|
|||
|
|
|
|||
|
|
### 그래프 데이터베이스
|
|||
|
|
- **Neo4j**: 그래프 저장 및 쿼리
|
|||
|
|
- **SentenceTransformer**: 벡터 임베딩
|
|||
|
|
|
|||
|
|
### API & 서빙
|
|||
|
|
- **FastAPI**: REST API 서버
|
|||
|
|
- **GraphQL**: 유연한 쿼리 언어
|
|||
|
|
|
|||
|
|
### LLM 통합
|
|||
|
|
- **OpenAI/Claude API**: 자연어 생성
|
|||
|
|
- **SSE/WebSocket**: 스트리밍 응답
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## 플랫폼 사용 시작하기
|
|||
|
|
|
|||
|
|
### 1️⃣ 온톨로지 구축
|
|||
|
|
```bash
|
|||
|
|
# Phase 0-2: 데이터 수집
|
|||
|
|
python -m ontology_platform.crawler --url https://example.com
|
|||
|
|
|
|||
|
|
# Phase 3: 검증 및 변환
|
|||
|
|
python -m ontology_platform.validator --input extracted_data.json
|
|||
|
|
|
|||
|
|
# Phase 4: 그래프 저장
|
|||
|
|
python -m ontology_platform.graph_builder --triples ontology.rdf
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
### 2️⃣ 그래프 분석
|
|||
|
|
```bash
|
|||
|
|
# Phase 5: 품질 분석
|
|||
|
|
python -m ontology_platform.analyzer --graph_id my_ontology
|
|||
|
|
|
|||
|
|
# 결과: 중복 제거, 커뮤니티 감지, 통계
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
### 3️⃣ API 서빙
|
|||
|
|
```bash
|
|||
|
|
# Phase 6: API 시작
|
|||
|
|
python -m uvicorn ontology_platform.api.phase6_app:app --reload
|
|||
|
|
|
|||
|
|
# http://localhost:8000/docs에서 확인
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
### 4️⃣ LLM 통합
|
|||
|
|
```python
|
|||
|
|
# Phase 6+: RAG 쿼리
|
|||
|
|
response = requests.post(
|
|||
|
|
"http://localhost:8000/api/v1/rag/query",
|
|||
|
|
json={"query": "Apple의 제품은?"}
|
|||
|
|
)
|
|||
|
|
|
|||
|
|
# LLM으로 프롬프트 전달
|
|||
|
|
llm_answer = call_llm(response["llm_prompt"])
|
|||
|
|
print(llm_answer)
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## 성능 특성
|
|||
|
|
|
|||
|
|
| 작업 | 규모 | 시간 |
|
|||
|
|
|------|------|------|
|
|||
|
|
| 웹 크롤링 | 1 URL | 5-30초 |
|
|||
|
|
| 데이터 검증 | 1000 후보 | < 2초 |
|
|||
|
|
| 벡터 임베딩 | 10K 엔티티 | 4초 |
|
|||
|
|
| 배치 저장 | 100K 노드/에지 | 28초 |
|
|||
|
|
| 2-hop 쿼리 | 10K 노드 | < 200ms |
|
|||
|
|
| 경로 찾기 | max_length=5 | < 300ms |
|
|||
|
|
| 중심성 계산 | top_n=100 | < 600ms |
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## 결론
|
|||
|
|
|
|||
|
|
이 **온톨로지 시스템 구축 플랫폼**은:
|
|||
|
|
|
|||
|
|
✅ **자동화**: 웹 데이터 → 구조화된 지식 자동 변환
|
|||
|
|
✅ **확장성**: 10K+ 노드 대규모 그래프 지원
|
|||
|
|
✅ **지능화**: 중복 제거, 패턴 분석, 중심성 계산
|
|||
|
|
✅ **통합성**: REST API, GraphQL, LLM 연계
|
|||
|
|
✅ **실용성**: 실제 비즈니스 문제 해결 가능
|
|||
|
|
|
|||
|
|
### 다음 단계
|
|||
|
|
- **Phase 7**: LLM 스트리밍 + 캐싱
|
|||
|
|
- **Phase 8**: 멀티테넌트 + 실시간 업데이트
|
|||
|
|
- **Production**: Docker/Kubernetes 배포
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
**플랫폼 버전**: 0.6.0
|
|||
|
|
**상태**: Phase 0-6 완료, Phase 7-8 계획
|
|||
|
|
**마지막 업데이트**: 2026-05-14
|