Professional Documents
Culture Documents
AI-ML Module 1-2022
AI-ML Module 1-2022
AI-ML Module 1-2022
and
Machine Learning (18CS71)
Module 1
By,
Chaitra M
Asst. Professor,
Dept. Of CSE
SJBIT
fi
Introduction
• Arti cial Intelligence (AI) is a branch of Science which deals with
helping machines nding solutions to complex problems in a
more human-like fashion.
Tasks Domain of AI
AI tasks are categorized as-
Mundane Tasks
• Perception Expert Tasks
• Vision
• Engineering ( Design, Fault nding, Manufacturing
• Speech
planning)
• Natural Languages
• Scienti c Analysis
• Understanding
• Medical Diagnosis
• Generation
• Financial Analysis
• Translation
• Commonsense reasoning
• Robot Control
MT: Common things humans do everyday.
FT: Tasks having xed rules, here logics are applied.
Formal Tasks ET: Task that requires an expert person in every different
domain.
• Games
• Chess, checkers etc
• Mathematics
• Geometry, logic,Integral calculus, Proving properties
of programs
fi
fi
fi
Mundane Tasks
• Humans learn mundane (ordinary) tasks since their
birth.(They learn by perception, speaking, using • Perception
language)
• Vision
• Speech
• For humans, the mundane tasks are easiest to learn.
• Natural Languages
• Understanding
• The same was considered true before trying to • Generation
implement mundane task domain.
• Translation
• Commonsense
• Later, it turned out that the machine requires more reasoning
knowledge, complex knowledge representation and • Robot Control
complicated algorithms for handling mundane tasks.
Formal Tasks
• Games
• Chess, checkers etc
• Mathematics
• Geometry, logic,Integral calculus, Proving properties
of programs
ff
Expert Tasks
• Engineering ( Design, Fault nding, Manufacturing
planning)
• Scienti c Analysis
• Medical Diagnosis
• Financial Analysis
fi
Arti cial Intelligence Underlying Assumptions:
Making assumptions to simplify the problem.
Elaine Rich et al. and Newell and Simon [1976] believe that arti cial intelligence
believe in Physical symbol System hypothesis. They de ned Physical symbol
system hypothesis as follows:
Elaine Rich et al. and Newell and Simon de ne Physical symbol system
hypothesis as a physical symbol system that has necessary and su cient means
for general intelligent action.
fi
fi
fi
fi
fi
ffi
AI Technique
AI needs Intelligence, Intelligence needs knowledge.
• Intelligence requires Knowledge
• Voluminous
Tic-Tac-Toe
Tic-Tac-Toe Game Playing
• Two players - human, computer.
• The objective is to write a computer program in such a way that computer wins most of the
time.
• Complexity
• Use of generalization
• These approaches will move towards being representations of what we will call AI techniques
Problem-Tic-Tac-Toe
Program 1
The game Tic Tac Toe is also known as Noughts and Crosses or Xs and Os ,the player
needs to take turns marking the spaces in a 3x3 grid with their own marks,if 3 consecutive
marks (Horizontal, Vertical,Diagonal) are formed then the player who owns these moves
get won.
Assume ,
Player 1 - X
Player 2 - O
So,a player who gets 3 consecutive marks first,they will win the game .
Let's have a discussion about how a board's data structure looks and how the Tic Tac Toe
algorithm works.
Contd.
The cells could be represent as Center
• Board Data Structure
square,Corner,Edge as like below
Move Table
It is a vector of 3^9 elements, each element of which is a nine element vector
representing board position.
Total of 3^9(19683) elements in move table 1 2 3 456 7 8 9
Move Table
Index Current Board position New Board position 1
0 000000000 000010000 2
1 000000001 020000001 …
2 000000002 000100002
3 000000010 002000010 19683
.
.
Algorithm
To make a move, do the following:
1. View the vector (board) as a ternary number
and convert it to its corresponding decimal
number.
2. Use the computed number as an index into the
move table and access the vector stored there.
3. The vector selected in step 2 represents the way
the board will look after the move that should
be made. So set board equal to that vector.
Contd.
Let's start with empty board
Step 1:Now our board looks like 000 000 000 (tenary number) convert it into
decimal no.The decimal no is 0
Step 2:Use the computed number ie 0 as an index into the move table and access
the vector stored in
New Board Position.
The new board position is 000 010 000
Step 3:The vector selected in step 2(000 010 000 ) represents the way the board
will look after the move that should be made. So set board equal to that vector.
After complete the 3rd step your board looks like\
Flow chart:
This process continues until the player get win or tie.
• This program is very e cient in time.
Comments
• Disadvantages:
• Di cult to extend
Program 2 for Tic-Tac-Toe:Subprocedures
Posswin(p): How to find the next move?
Multiply the 3 values (on the data structure Board) of each of a row or a
column or a diagonal and check for specific values:
e.g.
1. If product = 18 = 3*3*2 then X can win
X X B
22
❑ Go(n): - Go to square n
- If Turn is odd, makes Board[n] = 3 (X)
If Turn is even, makes Board[n] = 5 (O)
- Increments Turn by 1
23
25
then
X O X
1 4 7
Go(Posswin(X))
else Go(Make2)
Here Posswin(X)<>0, Go(7).
▪ Turn=7(X)
O 2
If Posswin(X) is not 0 then
Go(Posswin(X)),
else if Posswin(O) is not 0
Go(Posswin(O))
else go anywhere that is blank
then
O X X
6 5 3
26
Go(Posswin(X))
else go anywhere that is blank
Here Posswin(X)<>0, Go(6).
▪ Turn=9(X) (same as Turn 7)
X
9 O O
2 8
If Posswin(X) is not 0 then
Go(Posswin(X)),
else if Posswin(O) is not 0 then
Go(Posswin(O))
else go anywhere that is blank
O X X
6 5 3
Algorithm:
Example
Algorithm - Computer plays rst
- C plays odd moves
fi
Algorithm - Human plays rst -
C plays even moves
fi
Complete Algorithm - odd moves or
even moves for C playing rst or second
fi
Comments
• Not as e cient as rst one in terms of time.
• It is memory e cient.
8 3 4
1 5 9
6 7 2
Note: Machine-First it will check, chance to win, or it will check the opponent of winning and
block the chances of winning. Here, machine will win.
8 3 4
1 5 9
6 7 2
Program 3 for Tic-Tac-Toe:Data Structures
Draw=0–will return zero to
parent.
Win=1–will return one to
parent
41
-Wikipedia
Applying BERT(Neural Network) to Question Answering
The Google BERT update is an arti cial intelligence language model, a pre
trained model, that Google now applies to search query results and featured
snippets. BERT stands for Bidirectional Encoder Representations from
Transformers.
fi
START
Motivation
Google Search
Question Answering System
http://start.csail.mit.edu/index.php
QA Different From Search
QA Search
● Program
(Converts i/p text into a structure internal form that attempts
to capture the meaning of sentences
● Program
(Here we not only consider the structured form of i/p text, but
also a structured form which describes objects and situations
involved in the text)
1
Question Answering
Let us consider Question Answering systems that accept
input in English and provide answers also in English.
For example, suppose that the input text were just the single sentence
Dialogue 1
• Q: Why did Russia do this?
• A: Because Russia thought that it could take political control of Czechoslovakia by sending
troops.
• A: The United States should denounce the Russian action in the United Nations.
ffi
fl
Problem: Question Answering
• Let us now see three variants of programs to question
answering. For example, consider the following
situation:
• Text
We will attempt to answer each of the following questions with each program.
• Question
Data Structures
• A set of templates that match common questions and produce patterns used to match
against inputs.
• In this algorithm, templates and patterns are paired, so that if a template matches
successfully against an input question then it’s associated text pattern are used to nd
the appropriate answer in the input text.
For example, the template what did x y generates x y z if a match occurs and z is the
answer to the question. The given text and the question are both stored as strings.
What did X Y What did Mary go shopping for?
Mary go shopping for Z
Z a new coat
fi
fi
Method 1
Algorithm
• Compare the template against the questions and store all successful
matches to produce a set of text patterns.
• Apply each of these patterns to the text; collect all the answers and then
print the answers.
Contd.
Example
• This is a very primitive approach basically not matching the criteria we set for
intelligence and worse than that, used in the game. Surprisingly this type of
Eliza, a natural language processing computer, was the rst chatbot. Developed at
MIT's Arti cial Intelligence Lab, it is a direct ancestor of the Siri, Alexa and other digital
assistants. Eliza could not talk like Alexa but communicated via text and was not capable
of learning from human conversations.
ffi
fi
fi
ELIZA
In brief: Method 1
Method 2- Using Linguistic Knowledge
Linguistic knowledge is represented as a system of constraints, a grammar, which
de nes all and only the possible sentences of the language
This program rst converts the input text into a structured internal form (It captures the
meaning of the sentence) that attempts to capture the meaning of the sentences. It also
converts questions into that form. It nds answers by matching structured forms against
each other.
Data Structures
EnglishKnow
A description of the words, grammar, and appropriate semantic interpretations of a large
enough subset of English to account for the input texts that the system will see.
InputText
The input text in character form.
StructuredText
InputQuestion
The input question in character form.
StructQuestion
A structured representation of the content of the user's question.
fi
fi
fi
Contd.
The structure attempts to capture the essential knowledge contained in the text.
• 3 knowledge representation systems.
Data Structures
• The system used here will be the slot and ller system.
fi
fi
fi
Method 2
Mary
Note: use a marker to indicate the substring (like ‘who’ or ‘what’) of the
structure, that should be returned as an answer. If a slot and ller system is
used a special marker can be placed in more than one slot.
3. Return as the answer those parts of the text that match the requested
segment of the question.
Examples
• The extra power given must be paid for by additional search time in the
knowledge bases.
• Mary walked up to the salesperson: she asked her if she needed any
help.
• Question
• This program converts the input text into a structured form that contains the meanings
of the sentences in the text, and then it combines that form with other structured
forms that describe prior knowledge about the objects and situations involved in the
text.
• The diagram shows how the system’s knowledge of shopping might be represented and
stored. This information is known as a script ( stereotypical events) and in this case is a
shopping script (See gure).
EnglishKnow
Same as in Program 2.
InputText
The input text in character form.
IntegratedText
A structured representation of the knowledge contained in the input text (similar to the
structured description of Program 2) but combined now with other background, related
knowledge.
InputQuestion
The input question in character form.
StructQuestion
• The number of possible structures will usually be greater now than it was in Program
2 because so much more knowledge is being used.
2.Match this structured form against IntegratedText. (Here the question which is
converted to a structured form is compared with the integrated text to nd
answer.)
3.Return as the answer those parts of the text that match the requested segment
of the question.
fi
Examples
Q1: Same as Program 2.
• The shopping script is instantiated for this text, and because of the last sentence, the
path through step 14 of the script is the one that is used in forming the representation of
this text. When the script is instantiated M' is bound to the structure representing the red
coat
• After the script has been instantiated, IntegratedText contains several events that are
taken from the script but that are not described in the original text, including the event
"Mary buys a red coat" (from step 10 of the script).
• Thus, using the integrated text as the basis for question answering allows the program
to respond "She bought a red coat."
• But this approach can handle, with some modi cations, questions of the following
form with the answer
• Example:—Saturday morning Mary went shopping. Her brother tried to call her
but she did not answer.
• Question: Why couldn’t ‘Mary’s brother reach her?
• Answer: Because she was not in. (The machine with reasoning ability must reply)
• This answer is derived because we have supplied an additional fact that a person
cannot be in two places at once. This patch is not su ciently general so as to
work in all cases and does not provide the type of solution we are really looking for.
fi
ffi
In brief: Method 3
• Question
• 1. What did Mary go shopping for?
• 2. What did Mary nd that she liked?
• 3. Did Mary buy anything?
fi
Conclusion
We have just examined two series of programs to solve two very di erent problems. The
two programs are slower to execute than the earlier ones in their respective series, but
they illustrate three important Al techniques:
ff
Level of AI Model
How should your model perform?
Preferably it should match human performance.
-Model the program that computer could easily solve.
-Model human performance.
To decide this we must ask questions-
• ‘What is our goal in trying to produce programs that do the intelligent things that people do?’
• Are we trying to produce programs that do the tasks the same way that people do?
OR
• Are we trying to produce programs that simply do the tasks the easiest way that is possible?
• Programs in the rst class attempt to solve problems that a computer can easily solve and do not
usually use AI techniques. AI techniques usually include a search, as no direct method is available,
the use of knowledge about the objects involved in the problem area and abstraction on which
allows an element of pruning to occur, and to enable a solution to be found in real time; otherwise,
the data could explode in size. Examples of these trivial problems in the rst class, which are now
of interest only to psychologists are EPAM (Elementary Perceiver and Memorizer) which
memorized garbage syllables.
fi
fi
Contd.
The second class of problems attempts to solve problems that are non-trivial for a
computer and use AI techniques. We wish to model human performance on these:
4. To exploit the knowledge gained by people who are best at gathering information.
This persuaded the earlier workers to simulate human behavior in the SB part of AISB
simulated behavior. Examples of this type of approach led to GPS (General Problem
Solver).
Contd.
• The second class of problems attempts to solve problems that are non-trivial for a
computer and use AI techniques. We wish to model human performance on
these:
Turing test
● Three participants
(Two humans and one machine)
Human 1: interrogator.
Human 2: participant.
Machine: participant.
End
79