CACS410 Artificial Intelligence

Artificial IntelligenceUnit 511 min read

Expert Systems: Architecture, Knowledge Bases & Applications

Unit 5 of Artificial Intelligence explores expert systems—how they mimic human expertise using rule-based reasoning, their core components (knowledge base, inference engine, user interface), and real-world applications in healthcare, finance, and diagnostics. Learn architectures, development stages, and why they matter

TAKEAWAYS:

  • Expert systems are AI programs that solve complex problems using domain-specific knowledge and logical inference.
  • Their architecture consists of four key components: knowledge base, inference engine, working memory, and user interface.
  • Knowledge can be represented using rules (IF-THEN), frames, semantic networks, or object-oriented methods.
  • Forward chaining (data-driven) and backward chaining (goal-driven) are the two primary inference strategies.
  • Expert systems excel in domains like medical diagnosis, financial forecasting, and technical troubleshooting.
  • Challenges include knowledge acquisition bottlenecks, brittleness, and lack of common-sense reasoning.

What is an Expert System?

An expert system is a computer program designed to emulate the decision-making abilities of a human expert in a narrow, specialized domain. Unlike general AI, it relies on structured knowledge (rules, facts) rather than learning from data. Think of it as a digital consultant—for example, a doctor diagnosing diseases or a bank approving loans.

Key Characteristics

  • Domain-specific: Works only in areas like medicine, law, or engineering.
  • Rule-based: Uses IF-THEN logic (e.g., "IF fever > 101°F AND cough, THEN likely pneumonia").
  • Explainable: Can justify its conclusions (unlike black-box AI like deep learning).
  • Autonomous: Operates without human intervention during problem-solving.

Why Are Expert Systems Important in AI?

  1. Preserve expertise: Capture knowledge from retiring experts (e.g., a geologist’s oil-drilling rules).
  2. Consistency: Eliminates human errors (e.g., a bank’s loan approval system applies the same rules every time).
  3. Accessibility: Makes expert-level advice available 24/7 (e.g., a farmer using an agricultural expert system via a smartphone).
  4. Cost-effective: Reduces need for human experts in routine tasks (e.g., NTC’s network fault diagnosis system).

Architecture of an Expert System

An expert system follows a modular design with four core components:

Applies rulesUpdates factsDisplaysAccepts inputKnowledgeBaseInferenceEngineWorkingMemoryUserInterface
Data flow between components (arrows show direction of information)
classDiagram
    class KnowledgeBase {
        +Facts
        +Rules (IF-THEN)
        +Heuristics
    }
    class InferenceEngine {
        +Forward Chaining
        +Backward Chaining
        +Conflict Resolution
    }
    class WorkingMemory {
        +Current Facts
        +Hypotheses
    }
    class UserInterface {
        +Explanation Facility
        +Query Input
        +Output Display
    }
    KnowledgeBase --> InferenceEngine : "Applies rules to"
    InferenceEngine --> WorkingMemory : "Updates with"
    WorkingMemory --> UserInterface : "Displays results to"
    UserInterface --> KnowledgeBase : "Accepts new facts from"

1. Knowledge Base (KB)

Stores domain-specific knowledge in structured formats:

  • Production Rules (IF-THEN):
    IF (patient.symptom = "chest pain") AND (patient.blood_pressure > 140)
    THEN (diagnosis = "hypertension")
    
  • Frames/Objects: Organize knowledge hierarchically (e.g., Animal → Mammal → Dog).
  • Semantic Networks: Nodes represent concepts, edges represent relationships (e.g., Doctor → treats → Patient).

2. Inference Engine

The "brain" of the system that applies reasoning strategies:

  • Forward Chaining (Data-Driven):
    • Starts with known facts → applies rules → derives new conclusions.
    • Example: A fire-alarm system triggering when smoke is detected.
  • Backward Chaining (Goal-Driven):
    • Starts with a hypothesis → works backward to confirm/disprove.
    • Example: A medical diagnostic system checking if symptoms match a disease.

Worked Example: Loan Approval System (Backward Chaining) Goal: Approve a loan for a customer. Rules:

  1. IF (income > 50,000) AND (credit_score > 700) THEN approve.
  2. IF (income ≤ 50,000) AND (savings > 200,000) THEN approve.
  3. ELSE reject.

Trace:

Step Query Rule Applied Outcome
1 Is income > 50,000? No Check Rule 2
2 Is savings > 200,000? Yes Approve

3. Working Memory

Temporarily holds:

  • Facts provided by the user.
  • Intermediate conclusions.
  • Hypotheses being tested.

4. User Interface

  • Input: Accepts queries (e.g., symptoms, financial data).
  • Output: Displays conclusions + explanations (e.g., "Loan approved because savings = 250,000").
  • Explanation Facility: Shows the reasoning path (critical for trust).

Knowledge Representation in Expert Systems

Method Description Example
Production Rules IF-THEN statements. Simple but can lead to rule explosion. IF (engine.oil_low) THEN (alert_mechanism.trigger)
Frames Objects with slots and default values. Good for hierarchical data. Car → make: "Toyota", model: "Corolla"
Semantic Networks Nodes = concepts; edges = relationships. Visual and intuitive. Doctor → "prescribes" → Medicine
Object-Oriented Classes and inheritance. Scalable for large systems. Vehicle → Car → ElectricCar

Stages of Expert System Development

  1. Problem Identification

    • Define the domain (e.g., "diagnosing diabetes").
    • Ensure it’s well-structured (rules can be clearly defined).
  2. Knowledge Acquisition

    • Extract knowledge from experts via:
      • Interviews (structured questions).
      • Protocol Analysis (experts solve problems while thinking aloud).
      • Existing Documents (manuals, case studies).
    • Challenge: Bottleneck—experts may not articulate their reasoning well.
  3. Knowledge Representation

    • Choose a method (rules, frames, etc.) and encode the knowledge.
  4. System Design

    • Build the inference engine and user interface.
    • Example tools: CLIPS (rule-based), Prolog (logic programming).
  5. Testing & Validation

    • Unit Testing: Check individual rules.
    • Integration Testing: Test the entire system.
    • Validation: Compare performance with human experts.
  6. Deployment & Maintenance

    • Deploy in the target environment (e.g., hospitals, banks).
    • Update knowledge as new data emerges (e.g., new disease symptoms).

In the Real World

  1. eSewa (Nepal)

    • Idea Used: Rule-Based Expert System
    • How: eSewa’s fraud detection system uses IF-THEN rules to flag suspicious transactions (e.g., "IF transaction_amount > 50,000 AND location = 'unknown' THEN block").
  2. Ncell’s Network Fault Diagnosis

    • Idea Used: Backward Chaining + Semantic Networks
    • How: When a tower fails, the system works backward from symptoms (e.g., "no signal in Kathmandu") to diagnose hardware/software issues using a pre-built network topology.
  3. Google’s DeepMind Health (Global)

    • Idea Used: Hybrid Rule-Based + Machine Learning
    • How: Combines expert rules for rare diseases with ML for pattern recognition in medical images (e.g., "IF MRI shows pattern X AND rule says 'high risk' THEN flag for biopsy").

Worked Example: Agricultural Expert System for Nepal

Problem: Farmers in Kavrepalanchok struggle with potato blight. Expert System Design:

  1. Knowledge Base:
    • Rule 1: IF (leaf_spots = "black") AND (humidity > 80%) THEN (disease = "late_blight").
    • Rule 2: IF (disease = "late_blight") THEN (spray = "copper_fungicide").
  2. Inference Engine: Forward chaining (symptoms → diagnosis → solution).
  3. User Interface: Mobile app with photo upload (edge detection identifies spots).

Trace for a Farmer’s Query:

flowchart LR
    A["Farmer uploads photo"] --> B["System detects black spots"]
    B --> C["Humidity sensor reads 85%"]
    C --> D["Rule 1 fires: late_blight"]
    D --> E["Rule 2 fires: spray copper"]
    E --> F["App displays: 'Spray copper fungicide'"]

Advantages and Limitations

Advantages Limitations
High accuracy in narrow domains. Brittleness: Fails outside trained scope.
Explainable decisions. Knowledge acquisition bottleneck.
Works without real-time data. No common sense (e.g., can’t infer "patient is sick" from "missed work").
Low computational cost. Scalability issues for large KB.

Applications of Expert Systems

  1. Medical Diagnosis

    • Example: MYCIN (1970s) diagnosed bacterial infections.
    • Nepal Example: A TU-developed system for malaria diagnosis using symptom rules.
  2. Financial Forecasting

    • Example: Banks use expert systems to detect fraud (e.g., unusual transaction patterns).
  3. Technical Troubleshooting

    • Example: Daraz’s customer service chatbot uses rules to resolve order issues (e.g., "IF delivery_delay > 3 days THEN offer discount").
  4. Education

    • Example: AI tutors (e.g., Duolingo’s grammar checker) use rule-based feedback.
  5. Manufacturing

    • Example: NTC’s network repair system diagnoses cable faults using backward chaining.

Exam Tip

  1. Define Clearly: Always start with a precise definition of an expert system (e.g., "A rule-based AI program that mimics human expertise in a specific domain").
  2. Draw the Architecture: In exams, sketch the 4-component diagram (KB → Inference Engine → Working Memory → UI).
  3. Compare Chaining Methods:
    • Forward: Used for monitoring (e.g., alarms).
    • Backward: Used for diagnosis (e.g., medical tests).
  4. Real-World Tie-Ins: Link examples to Nepali contexts (e.g., eSewa, NTC, agricultural systems).
  5. Knowledge Representation: Be ready to write a rule or draw a semantic network on demand.
  6. Development Stages: Memorize the 6-step process—examiners love flow-based answers.

Common Pitfalls to Avoid

  • Overgeneralizing: Expert systems ≠ general AI. Specify the domain (e.g., "This system diagnoses diabetes, not all diseases").
  • Ignoring Knowledge Acquisition: Always mention it as a major challenge in development.
  • Confusing Inference Engines: Forward vs. backward chaining is a high-weight question—practice traces!
  • Assuming Perfect Rules: Explain brittleness (e.g., "If a new symptom emerges, the system fails unless updated").

Practice Question with Solution

Question: "Explain the architecture of an expert system with an example from Nepali daily life. How would you represent the knowledge for a traffic light control system?"

Solution:

  1. Architecture:

    • KB: Rules like "IF (vehicle_count > 10) THEN (green_light_duration = 45s)".
    • Inference Engine: Forward chaining (sensors → traffic density → light change).
    • Working Memory: Current sensor data (e.g., "lane_A: 8 cars").
    • UI: Traffic light display + emergency override button.
  2. Knowledge Representation:

    Rule 1: IF (time = "peak_hours") AND (pedestrian_count > 5)
            THEN (extend_walk_signal = True)
    Rule 2: IF (accident_detected = True)
            THEN (red_light_all_lanes = True)
    

    Semantic Network:

  3. Nepali Example:

    • Pathao’s Route Optimization: Uses expert rules to suggest routes based on traffic data (e.g., "IF (KTM traffic = 'heavy') THEN (avoid Ring Road)").

Based on the TU BCA syllabus for Artificial Intelligence (CACS410), unit 5.

Discussion

Loading…