23
COM362 Knowledge Engineering Inferencing 1 Inferencing: Forward and Backward Chaining John MacIntyre 0191 515 3778 [email protected]

COM362 Knowledge Engineering Inferencing 1 Inferencing: Forward and Backward Chaining John MacIntyre 0191 515 3778 [email protected]

Embed Size (px)

Citation preview

COM362 Knowledge EngineeringInferencing

1

Inferencing: Forward and Backward Chaining

John MacIntyre0191 515 3778

[email protected]

COM362 Knowledge EngineeringInferencing

2

The Inference Process

Inference-based data processing relies on some form of moving through the rules in the KBS

The two main forms of inferencing are: FORWARD CHAINING BACKWARD CHAINING

However, there are other inferencing techniques

COM362 Knowledge EngineeringInferencing

3

A Review of Rules

Follow an IF...THEN... format In English language:

IF the Pump’s temperature is hotTHEN follow maintenance instructions

In AionDS this would be expressed as:IFMATCH

Pump with temperature is ‘hot’

THENsend (Print Maintenance to Pump)

END

COM362 Knowledge EngineeringInferencing

4

How Inferencing Works

The inference engine’s job is to decide which RULE ANTECEDENTS (the IF bit) are satisfied by the FACTS (the data)

FACTS can be stored in the knowledge base, inferred by the inference engine, or supplied by the user

Different types of problem can be better solved by different inference approaches

COM362 Knowledge EngineeringInferencing

5

Data vs Goal Driven A choice must be made Do we drive the inference based on the

DATA, or Do we drive the inference based on the

GOALS of the process?

COM362 Knowledge EngineeringInferencing

6

Data vs Goal Driven

Data driven starts with the data, and fires rule to infer new information

Usually achieved by forward chaining Goal driven starts with the goal of a

required solution and tries to match the facts to the solution

Usually achieved by backward chaining

COM362 Knowledge EngineeringInferencing

7

Forward Chaining

A simplified view of forward chaining is as follows:1. Enter new data2. Fire forward-chaining rules3. Rule actions infer new data values4. Go to Step 25. Repeat until no new data can be inferred6. If no solution, rule base is insufficient

COM362 Knowledge EngineeringInferencing

8

...continued1

Get some new data

Fire Forw ardChaining Rules

2

3

4

Infer new data valuesfrom rule actions

Add new data values toknow ledge base

COM362 Knowledge EngineeringInferencing

9

Cascading Rules

Only applicable in forward chaining Rule executes causing inference of new

data New data is added to knowledge base New data causes other rules to fire The process may repeat - hence a

‘cascade’ effect through the knowledge base

COM362 Knowledge EngineeringInferencing

10

Cascading ExampleRULE 1:

IF a driver is assigned ANDa forklift operator is assigned ANDa foreman is assigned THEN all workers have been assigned to the shift

RULE2:IF all workers have been assigned to the shift ANDday is Saturday ANDovertime is authorisedTHEN work can begin

COM362 Knowledge EngineeringInferencing

11

Driving with Data In forward chaining, data is entered ‘up

front’, usually in the user’s interaction with the knowledge base

This is usually best done form-by-form, rather than question-by-question

Necessary to devise input displays with relevant groups of questions

Forward-chaining rules can only fire when all information in the antecedent is available

COM362 Knowledge EngineeringInferencing

12

...continued

Inference engine will not try automatically to source unknown information

If it is likely that the system will require information from the user at run-time, then backward chaining may be more appropriate

Therefore need to analyse the implementation to decide on inference mechanism most appropriate

COM362 Knowledge EngineeringInferencing

13

...continued

Small amounts of data can trigger a large number of new assertions

Remember, forward chaining rules cannot fire until all the conditions in the premise are satisfied

Rule priorities can be used to change the order in which rules are fired

COM362 Knowledge EngineeringInferencing

14

Why Forward Chain?Reasons to Forw ard Chain

You want to know everyth ingthat can possib ly be concludedabout a set o f da ta

M any conclusions are possib lefrom a s ingle data item

It is im portant to com m unica tenew conclusions to the userim m edia te ly

Examples

M onitoring for m echanica lprob lem s on a production line

Scanning a new loanapp lica tion for prob lem areas

F ilte ring sensor da ta

Advice to shut down fau ltym achines

D ata-entry errors

COM362 Knowledge EngineeringInferencing

15

Backward Chaining

A simplified view of backward chaining is as follows:1. State a goal2. Find rules which resolve the goal3. At run-time, answer questions to satisfy the

antecedents of the rules as required4. Obtain a result: goal is resolved or not

COM362 Knowledge EngineeringInferencing

16

...continued1

State primary goal to source

Fire BackwardChaining Rules

2

3

4

Sourcesub-goals

Primarygoal

sourced

COM362 Knowledge EngineeringInferencing

17

Driving with Goals In backward chaining, the process is

trying to satisfy a goal or sub-goal The results of executing backward

chaining rules is the determination of a value for the initiating goal

Backward chaining rules search for supporting data on an ‘as needed’ basis

Rules unrelated to the chain of reasoning are not used

COM362 Knowledge EngineeringInferencing

18

Input to BC Rules

Input for backward chaining may come from: Pre-existing values in the KB Questions asked of the user Accessing values from an external database Execution of external calculations

COM362 Knowledge EngineeringInferencing

19

Output from BC Rules

Can usually be phrased as a question:“What is the value?”

BC rules often used to achieve multiple goals during a single execution of the inference process

If the value for the goal is not found, then BC concludes that these particular rules cannot find the value, not that the value does not exist

COM362 Knowledge EngineeringInferencing

20

Why Backward Chain?Reasons to Backward Chain

There is a c lear se t o fsta tem ents which m ust beconfirm ed or den ied

A large num ber o f questionscould be asked of the user, buttyp ica lly on ly a few arenecessary to reso lve asituation

It is desirab le to haveinteractive d ia logue w ith theuser

Rule execution depends ondata gathering which m ay beexpensive or d ifficu lt

Examples

W hich m achine is causing th isquality contro l prob lem ?

Processing o f a m otor c la imfor vandalism , not necessaryto know about personal in juries

Asking m achine operatordeta iled questions aboutsuspect m achine

Real-tim e observations by theuser

COM362 Knowledge EngineeringInferencing

21

Choosing FC or BC

The criteria which you must consider when choosing FC or BC are: The logical reasoning process Design features of the system What are the inputs, and where do they

come from? What are the outputs, and where do they

go? How do these map to FC or BC?

COM362 Knowledge EngineeringInferencing

22

...continued

Most problems can be solved using either FC or BC

However, almost always one or the other is preferable (more efficient, more robust)

Therefore worthwhile considering which is the most appropriate, and using it

COM362 Knowledge EngineeringInferencing

23

A Rough(!) GuideUse Forward Chaining

Sensor ind icates m achine fa ilure -want to find out what w ill happennext

User types erroneous input forinsurance cla im - want to a lertuser

S tock va lue suddenly drops -want to pred ict m arket response

Use Backward Chaining

Defect observed in product - wantto locate fau lty m achine

Suspect an overpaym ent - wantto check form for erroneous input

FTSE industria ls drop - want toknow which stocks w ill beaffected