AI Notes
Master KBs for AI. Semantic networks, ontologies, knowledge graphs. AI fundamentals 2024.
What is a Knowledge Base?
A knowledge base (KB) is a structured repository of facts, rules, and relationships that an AI system uses for reasoning and problem-solving. Unlike a traditional database that stores raw data, a knowledge base stores information with semantic meaning—it knows not just that "Paris" and "France" exist, but that "Paris is the capital of France" and can infer that "Paris is in Europe" through reasoning.
Knowledge bases are the foundation of expert systems, question-answering systems, semantic web applications, and modern knowledge graphs. They bridge the gap between raw data and intelligent reasoning by providing structured, queryable, machine-interpretable representations of domain knowledge.
Types of Knowledge Bases
Fact-Based KB
Stores explicit statements about the world:
Rule-Based KB
Contains inference rules alongside facts:
Rules
IF capital(X, Y) THEN city(Y)
IF continent(X, Europe) AND member_of(X, EU) THEN eu_country(X)
IF population(X, P) AND P > 50_million THEN large_country(X)
Derived facts (via inference)
city(Paris) ← from rule 1 + capital(France, Paris)
eu_country(France) ← from rule 2
large_country(France) ← from rule 3
Ontological KB
Defines concepts, their properties, and relationships hierarchically:
Concept Hierarchy
Entity
├── Living_Thing
│ ├── Animal
│ │ ├── Mammal
│ │ └── Bird
│ └── Plant
└── Non_Living
├── Natural_Object
└── Artifact
├── Vehicle
└── Building
Properties propagate down
Living_Thing → has(metabolism), has(lifecycle)
Animal → can(move), needs(food)
Mammal → has(warm_blood), has(fur_or_hair)
Building a Knowledge Base
Knowledge Acquisition Methods
| "Einstein was born in 1879" | born(Einstein, 1879) |
| Wikidata | millions of contributors |
| OpenCyc | community-built common sense KB |
Knowledge Representation Languages
First-Order Logic
∀x (Human(x) → Mortal(x))
Description Logic (OWL)
Human ⊑ Mortal
Human ⊑ ∃hasPart.Heart
RDF Triples (Semantic Web)
<Einstein> <bornIn> <Ulm>
<Ulm> <locatedIn> <Germany>
Production Rules (Expert Systems)
IF symptom(X, fever) AND symptom(X, rash)
THEN suspect(X, measles)
Inference Over Knowledge Bases
Closed-World Assumption (CWA)
| KB contains | flies(eagle), flies(sparrow) |
| Query | flies(penguin)? |
| Answer | No (not stated, therefore false under CWA) |
| Used in | Databases, Prolog, most expert systems |
| Problem | Missing information = negative information |
Open-World Assumption (OWA)
| KB contains | flies(eagle), flies(sparrow) |
| Query | flies(penguin)? |
| Answer | Unknown (not enough information) |
| Used in | Semantic Web (OWL), medical KBs |
Reasoning Types
| Deductive: General rules | specific conclusions |
| All mammals breathe air. Dogs are mammals. | Dogs breathe air. |
| Inductive: Specific observations | general rules |
| Swan 1 is white. Swan 2 is white. ... | All swans are white? |
| Abductive: Observations | best explanation |
| Patient has fever and cough | probably has flu (best explanation) |
| Analogical: Similar cases | similar conclusions |
| Disease X treated by drug A. Disease Y similar to X | try drug A? |
Knowledge Base Operations
Query Processing
| Simple query | What is the capital of France? |
| Pattern match: capital(France, ?X) | ?X = Paris |
| Conjunctive query | Which European countries have >50M people? |
| Result | {France, Germany, Italy, ...} |
| Path query | How are Paris and NATO related? |
| capital(France, Paris) ← | member_of(France, NATO) |
| Path: Paris ←capital← France | member_of→ NATO |
Knowledge Base Consistency
Consistency checks
- No contradictions: NOT(P AND ¬P)
- Type constraints: age must be positive integer
- Cardinality: country has exactly one capital
- Temporal: birth_date < death_date
When inconsistency detected
- Reject the new fact
- Flag for human review
- Use paraconsistent logic (tolerate contradiction)
Modern Knowledge Bases
| System | Scale | Domain | Notable Feature |
|---|---|---|---|
| Wikidata | 100M+ items | General | Crowdsourced, multilingual |
| Google KG | Billions of facts | General | Powers search |
| UMLS | 4M+ concepts | Medical | 200+ source vocabularies |
| DBpedia | 6M+ entities | Wikipedia-derived | Linked open data |
| ConceptNet | 34M+ assertions | Common sense | Crowdsourced + games |
| Cyc | 24M+ rules | Common sense | 40+ years of development |
Knowledge Base vs. Database
| Aspect | Database | Knowledge Base |
|---|---|---|
| Stores | Data | Knowledge (data + semantics) |
| Schema | Fixed tables | Flexible ontology |
| Queries | SQL (retrieve) | Inference (derive new facts) |
| Relationships | Foreign keys | Semantic relations |
| Reasoning | None | Deduction, induction |
| Incompleteness | NULL values | Open/closed world |
Interview Questions
Q: What is the difference between a knowledge base and a knowledge graph? A: A knowledge graph is a specific type of knowledge base that represents knowledge as a graph of entities (nodes) connected by relationships (edges). It's stored as triples (subject, predicate, object). A knowledge base is the broader concept—it can use any representation: rules, frames, logic, or graphs.
Q: How do you handle conflicting information in a knowledge base? A: Approaches include: (1) Source credibility weighting—prefer more authoritative sources, (2) Temporal ordering—prefer newer information, (3) Specificity—prefer more specific facts over general rules, (4) Voting—majority of sources wins, (5) Flagging for human review.
Q: What is the knowledge acquisition bottleneck? A: The primary difficulty in building expert systems—extracting knowledge from human experts and encoding it formally. Experts often can't articulate their reasoning (tacit knowledge), interviews are expensive, and knowledge changes over time. Modern approaches use NLP to extract knowledge from text automatically.
Exam Focus
Revise definitions, diagrams, examples, and short-answer points for Knowledge Bases - Structured Knowledge.
Interview Use
Prepare one clear explanation, one practical example, and one common mistake for this Artificial Intelligence topic.
Search Terms
artificial-intelligence, artificial intelligence, artificial, intelligence, knowledge, representation, bases, knowledge bases - structured knowledge
Related Artificial Intelligence Topics