0% found this document useful (0 votes)
12 views23 pages

W06- Knowledge Representation in AI

Uploaded by

KaNika TH11
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views23 pages

W06- Knowledge Representation in AI

Uploaded by

KaNika TH11
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 23

KNOWLEDGE

REPRESENTATION IN AI
By: SEK SOCHEAT
Lecturer Artificial Intelligence
2023 – 2024
Mobile: 017 879 967 MSIT – AEU
Email: [email protected]
TABLE OF CONTENTS
Knowledge Representation in AI

1. Introduction

2. Visualization of the Semantic Network

3. Applications of Knowledge Representation

4. Building a Simple Semantic Network in Python


2
1. INTRODUCTION
1. INTRODUCTION

What is Knowledge Representation?

Knowledge Representation (KR) is the field of AI concerned with how knowledge


can be represented symbolically and manipulated in an automated way by
reasoning programs.

Importance of KR in AI:

• Facilitates understanding, reasoning, and decision-making.

• Critical for developing intelligent systems that can perform tasks such as

4
diagnosis, learning, and language understanding.
2. VISUALIZATION OF THE SEMANTIC NETWORK
2. VISUALIZATION OF THE SEMANTIC NETWORK
Types of Knowledge Representation
1. Semantic Networks:
• Semantic networks are a way to represent knowledge using a graph structure.
• Semantic networks help in representing complex relationships and hierarchies in a visual and intuitive
way.
• They are widely used in artificial intelligence for knowledge representation, natural language processing,
and more.
They consist of nodes and edges:
• Nodes (Concepts): These are the individual entities or concepts in the network. Each node represents
a specific item, idea, or concept.
• Edges (Relationships): These are the connections between nodes that define the relationships or
associations between the concepts. Edges can have labels to specify the type of relationship.
6
2. VISUALIZATION OF THE SEMANTIC NETWORK
Types of Knowledge Representation

Example: Relationships Between Animals,


Mammals, and Birds

Let’s build a simple semantic network to


represent the relationships between animals,
mammals, and birds.

1. Nodes: (Animal, Mammal, Bird, Dog, Cat,


Sparrow, Penguin)

2. Edges: (“is a type of” and “has


characteristic”)
7
2. VISUALIZATION OF THE SEMANTIC NETWORK
Types of Knowledge Representation

A. Building the Network:


1. Animal is the top-level concept.
2. Mammal and Bird are subcategories of
Animal.
3. Dog and Cat are specific types of
Mammals.
4. Sparrow and Penguin are specific types of
Birds.
5. Characteristics like “has fur” or “can fly”
can be connected to the respective nodes.
8
2. VISUALIZATION OF THE SEMANTIC NETWORK
Types of Knowledge Representation

Here's a simplified visual representation: Explanation:


1. Animal is the general category.
B. Adding Characteristics
2. Mammal and Bird are subcategories, connected to
To make it more detailed, we can add Animal with “is a type of” edges.
characteristics:
3. Dog and Cat are specific examples of Mammals.
1. Mammal has the characteristic “has fur.”
4. Sparrow and Penguin are specific examples of Birds.
2. Bird has the characteristic “has feathers.” 5. Dog and Cat are connected to “has fur” to indicate a
3. Sparrow has the characteristic “can fly.” characteristic of mammals.
6. Sparrow is connected to “can fly” while Penguin is
4. Penguin has the characteristic “cannot
connected to “cannot fly” to indicate their flying
fly.” abilities.
9
2. VISUALIZATION OF THE SEMANTIC NETWORK
Types of Knowledge Representation

2. Frames Explanation:

1. Name: The restaurant's name.


Frames are data structures used to represent
stereotypical situations by organizing 2. Location: Address of the restaurant.
information into slots (attributes) and 3. Menu: List of food and drinks.
values (data).
4. Waiter: Information about the waiter (e.g., name, experience).
For example, a “Restaurant” frame might 5. Customer: Details about the customer (e.g., name, party size).
include slots like Name, Location, Menu, 6. Table: Information about the table (e.g., number, reservation status).
Waiter, Customer, Table, Order, Bill,
7. Order: Items ordered by the customer.
Payment Method, and Rating.
8. Bill: Total amount to be paid.
This structured approach helps AI systems
9. Payment Method: How the customer pays.
understand and process complex scenarios
10
efficiently. 10. Rating: Customer's rating of the experience.
2. VISUALIZATION OF THE SEMANTIC NETWORK
Types of Knowledge Representation

3. Rules and Logic


Example: Medical Diagnosis System
• If-Then Rules in Expert Systems
1. If-Then Rules: Basic decision structure (e.g., “If
condition, Then action”). 5. Rules:
2. Expert Systems: Use these rules to make decisions • “If fever, Then consider infection.”
based on a knowledge base and inference engine. • “If rash, Then consider allergy.”
• Propositional and Predicate Logic • “If fever AND rash, Then consider
measles.”
3. Propositional Logic: Deals with true/false
statements using operators (AND, OR, NOT). 6. Application: Uses rules to diagnose
4. Predicate Logic: Uses predicates and quantifiers diseases based on symptoms.
(e.g., “For all x, if x is a bird, then x can fly”).
11
2. VISUALIZATION OF THE SEMANTIC NETWORK
Types of Knowledge Representation

4. Ontologies 5. Properties (Attributes):


Hierarchical Structuring of Knowledge • Course hasName: Name of the course (e.g., "Introduction
1. Hierarchical Structure: Organizes concepts into a to AI").
tree-like structure with parent-child relationships. • Course hasCreditHours: Number of credit hours (e.g., 3).
2. Nodes (Classes): Represent concepts. • Student hasName: Name of the student (e.g., "John Doe").
3. Edges (Relationships): Define connections between • Student hasID: Unique student ID (e.g., "12345").
concepts. • Instructor hasName: Name of the instructor (e.g., "Dr.
Smith").
Example: Domain: University Course Management • Instructor teachesCourse: Courses taught by the instructor.
4. Concepts (Classes):
6. Relationships:
• Course
• Student enrolledIn Course: Links students to the courses
• Student they are enrolled in.
• Instructor • Instructor teaches Course: Links instructors to the
12 courses they teach.
2. VISUALIZATION OF THE SEMANTIC NETWORK
Types of Knowledge Representation

4. Ontologies
Example Data:
Example: Domain: University Course Management
• John Doe (Student) is enrolled in "Introduction to AI" (Course).
7. Instances: • Dr. Smith (Instructor) teaches "Introduction to AI" (Course).
• Course: Introduction to AI
 hasName: "Introduction to AI" Summary:
 hasCreditHours: 3 • Ontologies in AI are used to represent knowledge within a specific
domain in a structured manner. They consist of concepts (classes),
• Student: John Doe properties (attributes), and relationships between those concepts.
 hasName: "John Doe" • A simple example in the university course management domain
 hasID: "12345" includes classes like Course, Student, and Instructor, with
relationships such as students enrolling in courses and instructors
• Instructor: Dr. Smith teaching courses.
 hasName: "Dr. Smith" • This structured approach facilitates data organization, retrieval, and
 teachesCourse: "Introduction to AI" reasoning within AI systems.
13
3. APPLICATIONS OF KNOWLEDGE REPRESENTATION
3. APPLICATIONS OF KNOWLEDGE REPRESENTATION

Natural Language Processing (NLP)

Understanding and Generating Human Example - Chatbots Using Semantic Networks:


Language:
• Semantic Networks: Represent words and their
• Understanding: KR helps NLP systems relationships, helping the chatbot understand the
comprehend the structure and meaning of context and meaning of user queries.
human languages by representing syntactic
and semantic rules. • Process: When a user asks a question, the
chatbot uses its semantic network to identify key
• Generating: KR enables the creation of
concepts and their relationships, generating a
meaningful and contextually appropriate
responses or text by using stored relevant and coherent response.
knowledge about language structure and
usage.
15
3. APPLICATIONS OF KNOWLEDGE REPRESENTATION

Expert Systems

Emulate Decision-Making Abilities Example - MYCIN:


of Human Experts:
• Early Expert System: Developed in the
• Knowledge Base: Stores expert 1970s for diagnosing bacterial infections
knowledge in the form of rules, and recommending treatments.
facts, and heuristics.
• Functionality: Used a set of if-then rules
• Inference Engine: Applies logical to diagnose diseases based on symptoms
rules to the knowledge base to make and lab results, significantly improving
decisions or solve problems as a diagnostic accuracy in the medical field.
human expert would.
16
3. APPLICATIONS OF KNOWLEDGE REPRESENTATION

Robotics

Navigation and Interaction: Example - Robot Using Frames to


Navigate an Office:
• Navigation: Robots use KR to
• Frames: Represent stereotypical office
understand their environment, plan scenarios, including objects like desks,
routes, and avoid obstacles. chairs, and pathways.

• Interaction: KR allows robots to • Process: The robot uses frames to


recognize and categorize different areas
interpret and respond to human and objects within the office, enabling it to
actions and commands navigate efficiently and perform tasks such
appropriately. as delivering documents or guiding
visitors.
17
4. BUILDING A SIMPLE SEMANTIC NETWORK IN PYTHON
4. EXERCISE

Title: Building and Visualizing a Simple Semantic Network in Python

Tasks: 3. Establish Relationships:

1. Define the Semantic Network Structure: • Define “is a type of” relationships to connect the hierarchy.

• Create a class to represent the semantic • Define “has characteristic” relationships to add specific
network. attributes.

• Define methods to add nodes and 4. Implement Network Display:


relationships.
• Create a method to visualize the network by printing the nodes
2. Add Nodes to the Network: and their relationships.

• Include nodes for “Animal”, “Mammal”, 5. Test the Network:


“Bird”, “Dog”, “Cat”, “Sparrow” and
• Build and display the network with the provided nodes and
“Penguin”.
19 relationships to ensure correctness.
4. EXERCISE

Title: Building and Visualizing a Simple Semantic Network in Python

Explanation:
2. Creating the Network:
1. Class Definition: • Create an instance of the SemanticNetwork.
• SemanticNetwork class with an • Add nodes for Animal, Mammal, Bird, Dog,
initializer to create an empty network. Cat, Sparrow, and Penguin.
• add_node method to add nodes. • Define relationships such as “is a type of” and
“has characteristic”.
• add_relationship method to define
relationships between nodes. 3. Displaying the Network:
• display_network method to print the • The display_network method prints each node
network. and its relationships.
20
SOLUTION:

21
SOLUTION:

Output

22
Thank You!
If you have any questions, please reach me!

You might also like