2. Knowledge engineering (KE)
• KE is the process of building a knowledge base through
extracting the knowledge from the human expert.
• Knowledge engineering is the process of
–Extracting the knowledge from the human expert.
–Choose knowledge representation formalism
–Choose reasoning and problem solving strategy.
• A knowledge engineer is someone who investigates a
particular domain, determines what concepts are important in
that domain, and creates a formal representation of the
objects and relations in the domain.
–A KE has to decide what objects and relations are worth representing,
and which relations hold among which objects
Interview
human expert
Knowledge
acquisition
(Extract the
knowledge)
Knowledge
Representation
(choose KR Method &
reasoning strategy)
3. The two main tasks of KE
•Knowledge acquisition: The knowledge engineer
interview the real human experts to be educated
about the domain and to elicit the required
knowledge, in a process called knowledge acquisition
•Knowledge Representation techniques such as
logic are a powerful tool for KR and reasoning.
However, such techniques consists of only the
syntax, semantics and proof theory.
–KR techniques do not offer any guidance as to what facts
should be expressed, nor what vocabulary should be used to
express them
•Knowledge base is used to store facts and rules.
4. Database vs. knowledgebase
•Database is a collection of stored facts that needs to be
accessed. A DBMS is a system designed to manipulate and
maintain control of any database.
–DBMS are concerned with the storage, manipulation, and retrieval of data
facts available in the system in explicit form.
–Features: The information does not appear as natural language text but
is available instead in the form of specific data elements stored in tables.
•Knowledge base is a collection of rules and facts about domain
knowledge.
–knowledge base is simply a type of database. It differs from most
databases in that it contains rules about facts rather than just facts which
makes it an intelligent database. Knowledge-based systems are designed
that reason over extensive knowledge base. KBSs:
• have more intelligence
• initiate itself for learning
Example: while a database might be able to tell us whether an inventory
item has reached its reorder point, KB could help us decide what the
reorder point should be. Similarly, a database may tell us whether a
student has got ‘A’ this semester, but KB suggests alternative course of
action to be taken if the student's grade-point average is below a C
5. Properties of Good KB
• A KB should be clear, correct, expressive, concise, context-
insensitive and effective.
–The relations that matter should be defined, and the irrelevant details
should be suppressed
• Separate the KB from inference procedure.
–This allows the KE (creator of the KB) to focus on the content of the KB,
and not about how it will be used by the inference procedure
• Define a generally applicable KB.
–Every KB has two potential consumers: human readers and inference
procedure
–A common mistake is to choose predicate names that are meaningful to
the human readers, and then assume that the name is somehow
meaningful to the inference procedure as well
E.g. consider the sentence: BearOfVerySmallBrain(Lilly)
Will the Inference procedure be able to infer from this sentence:
Lilly is a bear or Lilly has a very small brain; that he has a
brain at all
–Such very long names do not scale up well
– In a properly designed KB, facts that were entered for one situation
should be used in new situations as well
6. Most general KB design
•In a good KB, BearOfVerySmallBrain(Lilly) would
be replaced by the following
–Lilly is a bear; bears are animals; animals are physical things
•Bear(Lilly)
•x bear(x) animal(x)
•y animal(y) physicalThing(y)
–Lilly has a very small brain
•relativeSize(BrainOf(Lilly), BrainOf(typicalBear)) = very(small)
–All animals have a brain, which is a part of the animal
•z animal(z) brain(brainOf(z))
•x partOf(brainOf(x),x)
–If something is part of a physical thing, then it is also a
physical thing
•x,y part-of(x,y) ^ physicalThing(y) physicalThing(x)
7. Expert Systems
•An expert system is a computer program that simulates the
reasoning of a human expert in a certain domain.
–Expert systems perform specific tasks almost as well as human experts
•The aim was to develop an expert systems that capture
specialist human expertise, so the system could be deployed
where experts were unavailable (or in short supply). Example,
–Medical expertise
–Computer configuration expertise.
–Oil exploration expertise.
•Provide access in a natural language setting.
–User questions may be received in natural language from, and system
responses may also be furnished as natural language form.
•The task of the expert system consists in (i) analyzing the user
query, (ii) comparing the analyzed query with the stored
knowledge (rules and facts), and (iii) assembling a suitable
response from the apparently relevant facts
8. But what is expertise?
• Much more than just facts..
• Includes
– knowledge of procedures, and when different procedures apply.
– strategies for finding solutions to problems.
– “Rules of thumb” based on experience, allowing experts to rapidly
home in on likely solutions.
– Knowledge of which unknown information we can easily find the
answer to.
• Hard to extract
Designing an expert system
• Only a fairly small range of problems are appropriate
– Cost of knowledge acquisition and cost of interaction with experts,
users and customers are bigger than benefit of expert system.
– No problems require physical skill
– No problems which require common-sense knowledge
• If simple methods will do, don’t use expert systems
10. Expert System Architecture
•Knowledge base: The system uses a KB containing facts, and rules
–Common approach is to have knowledge represented as if-then rules.
•Inference Engine: carries out reasoning using its knowledge to
solve problems, generate new facts and make decisions
–Use Reasoning strategy such as forward or backward chaining.
•User Interface
–It is a way for an expert system to interact with users; such that users
query the system, supply information, receive advice, etc.
–It enables users to communicate with the system in natural language form.
•Explanation facilities
–We can ask the system “Why” it asks certain questions & “How” it arrived
at a certain conclusion.
–Assume we type “Why?” after the question of the alarm:
•SYSTEM: “I’m trying to prove that there has been a cold.
•Knowledge base editors and other instruments
–Methods for building and updating the KB. System building tools acquire,
encode, debug and learn knowledge within the KB
–Such tools include sensors, KB editors, debugger, compilers, …
11. Knowledge Representation
• Logic can be used for representing knowledge. But it lacked
some facilities:
– Packaging of data and procedures into KB
– Built-in inheritance
• There are other methods which are less general, but more
natural, and arguably easier to work with:
– Semantic Nets
– Frames
– Production rules
• To some extent modern OOP has superceded the first two,
with the ability to represent knowledge in the object structures
of your programming language.
• Semantic nets and frames allow you to define relations
between objects, including class relations (X is-a Y).
• Only restricted inference supported by the methods –
basically based on inheritance.
Example: Fido is a dog, dogs have 4 legs, so Fido has 4 legs.
12. Semantic networks (SNs)
•SNs capture knowledge as association of concepts in a
hierarchical manner.
•Basic Components
–Nodes: Each node in SN represents objects, concepts, or situations.
Nodes can be instances (individual objects) or classes (generic nodes)
–Edge: Each edge represent relationships: the relationships contain the
structural information of the knowledge to be represented. without
relationships, knowledge is an unrelated collection of facts. This allows
the generation of meaningful new knowledge through reasoning, i.e.
generation of new facts and new relationships
•Relations used: IS A, IS PART OF, CAUSE OF, MEASURES, CO-OCCURS,…
–Labels for nodes and arcs: the label indicates the type of relationship.
age
Girma 5
Hirut
age
mother
mother(Hirut, Girma)
age(Girma,5)
wife(Hirut,Peter)
age(Peter,34)
...
34
father
Peter
age
Knowledge is
represented as a
network or
directed graph.
13. Example
•A semantic network is a simple representation scheme that
uses a graph of labeled nodes and labeled, directed arcs to
encode knowledge.
Example:
A bird is a kind of animal
Flying is the normal moving method of birds
An albatross is a bird
Albert is an albatross, and so is Ross
Directionality:
the direction of
the arrows
matters
14. Non - Unary Predicates
• A predicate can specify the relationship between 2 objects (or
groups of objects), for example, in the sentence:
weight(John, 180) weight(Bill, 100) Greater(John,Bill)
• Changing predicates symbols (like weight) into object
constants is called reification.
– We can always go back to reification (converting predicates to objects)
– Some arcs define new entities, some relate existing entities.
– We can create new nodes to support relationships between the
attributes of 2 entities.
John
180
value
W1 W2
Bill
weight
weight
greater-than
15. Another Example
• Build a semantic net that represents the following
knowledge:
Man(Marcus)
Married(Marcus, Madonna)
GaveTo(Madonna, Marcus, Measles)
Madonna
Measles G17
Marcus
Man
instance married
getter
giver
Thing given
16. Inferences with Semantic Nets
CAN-FLY
BIRD
property
YELLOW
CANARY
colour
is-A
SYLVESTER
TWEETY
owns
is-A
TWEETY is YELLOW
CAN-FLY (CANARY )
CAN-FLY (TWEETY)
SYLVESTER owns a CANARY
SYLVESTER owns a BIRD
SYLVESTER owns Something
that can fly
•Facts can be either explicitly stated in the SN or inherited.
•Semantic networks differ in how they handle the case of
inheriting multiple different values.
•Semantic networks are typically used with a special set of
accessing procedures which perform “reasoning”
• A typical built-in principle of inference is inheritance of values and
relationships
Example: Birds fly
An albatross is a bird
Therefore: Is albatrosses fly ?
17. Inference more example
•BUT: Meaning of SNs was not always well defined.
–Are all Elephants large, or just typical elephants?
–Do all Elephants live in the “same” Africa?
–Do all animals have the same head?
•For machine processing these things must be defined clearly.
Animal
Reptile
Elephant
Nellie
Mammal
apples
large
head
is-a is-a
has-part
is-a
is-a
likes
size
Africa
livesin
By traversing
network we can
find that :
• Nellie has a head
(by inheritance)
• certain concepts
related in certain
ways (e.g., apples
and elephants).
18. Frame system
•Frames provide a method of combining declarations and
procedures within KR environment.
•Frames are a way of organizing as well as packaging
knowledge
–Frames are organized into hierarchies or networks to ease inheritance of
information
–Frames package both data and procedures into knowledge structures
•A frame is a lot like the notion of an object in OOP
–Frames can be used to implement much of the functionality of objects.
Knowledge is represented by a set of objects, their attributes, and
relationships between objects.
–A frame system is a collection of objects. Each object contains a number of
slots. A slot represents an attribute or a relation to another frame (or value).
–The essential feature of a frame is containing slots that can be filled with
values.
•The structure of frames consists of:
–The frame name: provides label
–The parents of the frame
–Frame slot: slot name (a unique name for each slot) and slot value
•Since slots are local to frames, different frames may have the same slot name
19. Inference Processes in Frames
•Frames are organized using
hierarchy or network
–allows the use of inheritance: each
element at a lower level inheriting
the properties of the elements at a
higher level
–a frame inherits the properties of its
parents. Given an object that
contains an Instance of subclass
slot:-
•The properties of the objects of the
named parent class are inherited.
•Each frame inherit all slots of all its
ancestors
Example: John inherits the value male
(sex) from its parent Man
Frame: person
Parent: thing
Slot: Age value:
Slot: sex value:
Frame: man
Parent: Person
Slot: sex value: male
Frame: woman
Parent: Person
Slot: sex value: Female
Frame: John
Parent: Man
Slot: Age value: 25
20. More Example on Inference
Frame: Car
Parent: Vehicle
Slot: Engine Type value: Gas-Powered
Frame: Ford
Parent: Car
Slot: Wheels value: 4
Frame: Auto
Parent: Car
Slot: Wheels value: 3
Frame: Mustang
Parent: Ford
Slot: Price value: 15000
Query:
X = (Engine Type of Ford) ?
X = (Wheels of Mustang) ?
X = (Engine Type of Mustang) ?
21. Multiple Inheritance
• Each frame may have more than one parent as a result of
which a frame may inherit slots, and related values from
multiple parents.
• The main question is:-
–What happened if two parents include the same slot name ?
–The issue of which parent should be inherited first is decided by the
designer of the system: select the first slot found or ignore incase of
multiple inheritance happen
Exceptions
• For instance, all birds fly
–But there are a number of species of birds that do not fly
• Frames provide exception handling by allowing redefinition of
the value of an inherited slot
Frame: Bird
Parent: Living Creature
Slot: Has wings value: yes
Slot: Flies value: yes
Frame: Penguin
Parent: Bird
Slot: Flies value: no
22. Rule-Based Systems (Production rules)
•Frequently used to formulate the knowledge in expert systems
•In Logic (and frames) we represent knowledge in a
declarative, static way, as some facts and rules that are true.
–Rules in logic say what is TRUE given some conditions
•Knowledge is represented in rule based systems as a series
of If - then rules:
IF premise P THEN conclusion C
IF condition S THEN action A
IF proposition p1 and proposition p2 are true THEN proposition p3 is true
Rule-based System Architecture
E.g. Fire
Condition-Action Rules
R1: IF hot AND smoky THEN ADD fire
R2: IF alarm_beeps THEN ADD smoky
R3: IF fire THEN ADD switchOnCooler
Facts
alarm_beeps
hot
Inference Mechanism (Reasoning)
23. Reasoning with Rule based systems
•Rule-based systems provide way of reasoning on
knowledge based on if-then rules.
Two Basic Ways of Reasoning/Inference:
•Backward chaining (goal-driven inference): starts with the
goal, and looks for rules that will help in answering it.
Reason from the then-part to the if-part
1. Start with a hypothesis
2. Reason backwards, according to the rules in the KB
•Forward chaining (data-driven inference): starts with the
facts, and sees what rules apply (and hence what should be
done).
Reason from the if-part to the then-part
1. Start with some confirmed findings (rules and facts)
2.Reason forwards and infer the conclusion
24. Forward chaining Example
Algorithm:
–Repeat Until no rules can fire, or “halt” symbol added to working memory
•Find all rules which have satisfied conditions given facts in working memory.
•Choose one, using conflict resolution strategies.
•Perform actions in conclusion, probably modifying working memory.
Example: “fire” from earlier:
–Working memory initially contains: alarm_beeps, hot
•Following the algorithm: First cycle:
–Find all rules with satisfied conditions: R2
–Choose one (R2), and Perform actions: ADD smoky.
–Working memory now contains: alarm_beeps, hot, smoky
•Next cycle:
–Find all rules with conditions satisfied: R1
–Choose one and apply action: ADD fire
–Working memory now contains alarm_beeps, hot, smoky, fire.
•Then:
–Rules with conditions satisfied: R3
–apply action: ADD switchOnCooler
25. Backward Chaining Example
Basic algorithm: (Start with possible hypothesis)
•To prove goal G:
–If G is in the initial facts, it is proven.
–Otherwise, find a rule which can be used to conclude G, and try to prove
each of that rule’s conditions.
Example: Should we switch on the cooler? Set as a goal.
•G1: switchOnCooler
–Is it in initial facts? No.
–Is there a rule which adds this as a conclusion? Yes, R3
–Set condition of R3 as new goal to prove: G2: fire
•G2: fire.
–Is it in initial facts? No.
–Is there Rule? Yes, R1
–Set conditions as new goals: G3: hot, G4: smoky.
•G3: hot. In initial facts.
•G4: smoky. Conclusion of rule
•G5: alarm_beeps. In initial facts, so all done
Proved hypothesis switchOnCooler
26. Example
Conclude that ‘A fire hazard is present’ from the given KB
Fine cutlery contains silver
Radiator coolant contains Ethylene-Glycol
Silver interacts with Ethylene-Glycol
Fine cutlery comes in contact with Radiator coolant
R1: If ‘x’ contains ‘A’ and ‘y’ contains ‘B’ and ‘A’ interacts with ‘B’
Then ‘x’,’y’ are a flammable mixture
R2: If ‘x’,’y’ are a flammable mixture and ‘x’ comes in contact with ‘y’
Then A fire hazard is present
27. Example
Suppose that we have the following facts and rules. Use either
backward or forward chaining that suits: (i) to update facts
and (ii) to conclude “Investor invests in Silver”
Facts:
Broker-A recommends Gold
Broker-B recommends Silver
Broker-B recommends Gold
Gold is overpriced
Silver is undervalued
R1: Investor invests in ‘x’
If Broker-A recommends ‘x’
and Broker-B recommends ‘x’
and not ‘x’ is overpriced
R2: Investor invests in ‘x’
If Broker-A recommends ‘x’
and not ‘x’ is undervalued
28. Expert Systems Applications
MYCIN : The MYCIN system was designed for diagnosis and therapy
recommendation for infectious diseases.
– It is an early and simple system which used a backward chaining rule-based
system is MYCIN.
– Helped physicians diagnose bacterial infections.
The medical knowledge is represented as a set of production rules.
For example
IF: The infection is primary-bacteremia
The site of the culture is one of the sterile sites
The suspected portal of entry of the organism is the gastrointestinal tract
THEN there is a suggestive evidence (0.7) that the identity of the organism is
bacteroides.
When trying to prove a goal through backward chaining, system could ask
user certain things. This results in following style of dialogue:
• MYCIN: Has the patient had neurosurgery?
USER: No.
MYCIN: Is the patient a burn patient?
USER: No
• MYCIN: It could be Diplococcus..
29. • PROSPECTOR system has been developed to
assist geologists in mineral exploration.
– It matches given data against internal models describing
important types of ore deposits.
– Like MYCIN, it can reason with uncertain and incomplete
data. It is capable of explaining its reasoning processes.
– The geological knowledge is represented in semantic
networks. New knowledge is acquired through the KAS
knowledge acquisition system.
• MACSYMA: The MACSYMA system has been
designed for solving mathematical problems.
– For example integration, differentiation, solution of
equations and systems of equations, vector algebra and
matrix operations.
Expert Systems Applications