Files
2nd/10_Wiki/Topics/Computer_Science_and_Theory/Knowledge-Graph-Foundations.md
T
2026-05-10 22:08:15 +09:00

4.1 KiB

id, title, category, status, canonical_id, aliases, duplicate_of, source_trust_level, confidence_score, verification_status, tags, raw_sources, last_reinforced, github_commit, tech_stack
id title category status canonical_id aliases duplicate_of source_trust_level confidence_score verification_status tags raw_sources last_reinforced github_commit tech_stack
wiki-2026-0508-knowledge-graph-foundations Knowledge Graph Foundations 10_Wiki/Topics verified self
KG Foundations
Semantic Web Foundations
none A 0.9 applied
knowledge-graph
foundations
rdf
ontology
2026-05-10 pending
language framework
python rdflib, owlready2

Knowledge Graph Foundations

매 한 줄

"매 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 로 결합.

매 핵심

매 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

매 Reasoning

  • forward chaining: rules → derived triples
  • backward chaining: query-driven inference
  • DL reasoning (Description Logic): subsumption, consistency

매 응용

  1. DBpedia, Wikidata: 매 large-scale public KG.
  2. Schema.org: 매 web markup ontology.
  3. Bio2RDF: 매 life sciences integration.

💻 패턴

RDF graph build

from rdflib import Graph, Namespace, URIRef, Literal, RDF, RDFS

EX = Namespace("http://example.org/")
g = Graph()
g.bind("ex", EX)

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")

OWL ontology with owlready2

from owlready2 import *

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]

claude = LLM("Claude")
anthropic = Organization("Anthropic")
claude.creator.append(anthropic)
sync_reasoner()  # HermiT reasoner

SPARQL federated query

from SPARQLWrapper import SPARQLWrapper, JSON

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())

SHACL validation

from pyshacl import validate
conforms, _, report = validate(
    data_graph=g,
    shacl_graph="shapes.ttl",
    inference="rdfs",
)

Forward chaining inference

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

🤖 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