0% found this document useful (0 votes)
191 views144 pages

Woldia University: Department of Computer Science

Uploaded by

Roha Cbc
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)
191 views144 pages

Woldia University: Department of Computer Science

Uploaded by

Roha Cbc
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/ 144

Woldia University

Department of Computer Science

Advanced Artificial Intelligence (CoSc5182 )

Ayalew Belay (PhD)


[email protected]
Content
 Artificial Intelligence Programming
 Common Lisp programming
 Symbols, lists, strings, arrays, and other built-in data
structures
 Structures and the Common Lisp Object System (CLOS)
 Functions and macros
 Recursion and higher-order functions
 Symbolic knowledge representation techniques
 Hierarchically organized frame systems
 Horn-style deductive reasons
 Test-driven development
Content…
 Artificial Intelligence Programming
 Semantics and the Web
 Web clients and servers in Lisp
 XML-RPC clients and servers in Lisp
 XML and knowledge representations
 Introduction to Robotics
 Robotic systems and their functions
 Homogeneous vector, plane, and transformation
 points, planes, coordinate frames, position, and
orientation transformations
Content…
 Artificial Intelligence Programming
 Rotation transformation (Read)
 general one-axis rotation, Euler rotation, and RPY
rotation
 Kinematics (Read)
 joint coordinate frames and kinematic parameters of a
multi-joint robot, forward kinematics representing
position and orientation of a robot
 Inverse Kinematic Solutions (Read)
 techniques of finding inverse kinematics of various
types of robots
Content…
 Artificial Intelligence Programming
 Differential relationships between different
coordinates, Jacobian and inverse Jacobian relation
 Mobile Robots - kinematics and motion planning.
 Path and trajectory planning - joint path planning
and Cartesian path planning
 Dynamics
 Lagrangian formulation, computation of inertial forces,
centripetal and Coriolois forces and gravity forces.
 Robot task planning, programming, and control
Read
Content…
 Artificial Intelligence Programming
 Design of Problem Solvers
 Searching and problem spaces
 Pattern-directed inference systems
 Fundamentals of truth maintenance systems
 Logic-based TMS
 Assumption-based TMS
Building problem solvers by Kenneth D. Forbus

Read
Content…
 Reasoning with large knowledge bases
 Integrating special-purpose reasoning engines
 Analogical reasoning
 Other topics TBD
 Conversational Interface
 Introduction
 Basics of Conversational Assistants
 Survey of historical Efforts
 Introduction to first set of tools

Building problem solvers by Kenneth D. Forbus Read


Content…
 Conversational Interface
 Psychology of Dialogue
 Common Ground
 Principles of dialogue
 Chatbot,Collaborative problem solving model,
dialogue acts
 Architecture for dialogue system
 Pipelines behind common assistant programs
 Cognitive architecture
Content…
 Conversational Interface
 Question Answering
 Sources of Knowledge
 IBM’s Deep Q-A approach
 Eldercare use case (Social Robots)
 Information Kiosk use case (Mudd Kiosk)
Content…
 Machine perception of Music and
Audio
 Pure tones, power and Intensity and loudness
 Perception of periodic complex sounds, auditory filters,
critical bands
 Musical measures of frequency, pitch perception, MP3
encoding
 Representation of Audio: spectrograms, cepstrograms
 Music theory (chords, scales, time signature) and MIDI
 Beat tracking, finding rhythms
 Picth tracking, melody transcription
Content…
 Machine perception of Music and
Audio
 Source separation and scene analysis
 Audio fingerprinting, query by humming, melody
maching
 Music recommendation systems, current research in
MIR

 Image formation
 Introduction
 Binary image processing
 Color and color segmentation
Content…
 formation
 Region segmentation
 Edge, contour, Hough transform and texture
 3D Geometry, claiberation, pose and stereo
 Lighting and application
 Motion and Tracking

Textbook and Reference :


 Artificial Intelligence: A modern approach by Stuart Russell and Peter Norvig. Second edition,
Prentice Hall, 2003.
 Artificial Intelligence, second Edition, by Elaine Rich, and Kevin Knight, McGraw-Hill, Inc,
1991.
 Artificial Intelligence structures and strategies for complex problem Solving. Third Edition.
 George F. Luger and William A. Stubblefield.
Assessment/Evaluation & Grading System
This course is assessed by written exams, lab assignments, presentation and mini projects.
Artificial Intelligence Programming
 Common Lisp programming
 Lisp was developed by John McCarthy in 1958.
 Lisp is derives from List Processing Language.
 The first version of Lisp is called
“Pure Lisp”.
 Lisp is a functional programming language.
 Lisp is the second-oldest high-level programming
language.
Artificial Intelligence Programming
 Common Lisp programming
 Features of Common LISP
 machine-independent
 uses iterative design methodology, and easy
extensibility.
 allows updating the programs dynamically.
 provides high level debugging.
 advanced object-oriented programming.
 provides a convenient macro system.
 It provides wide-ranging data types like, objects,
structures, lists, vectors, adjustable arrays, hash-
tables, and symbols.
Artificial Intelligence Programming
 Common Lisp programming
 Features of Common LISP
 provides an object-oriented condition system.
 provides a complete I/O library.
 provides extensive control structures
 Applications Built in LISP
 Large successful applications built in Lisp.
 Emacs
 G2
 AutoCad
 Igor Engraver
 Yahoo Store
Artificial Intelligence Programming
 Two dialects of LISP are now commonly used are
Scheme and Common Lisp
 These Common Lisp programming are:
 Scheme is suited to educational application
such as courses in functional programming and
general introductions to programming
 Common Lisp was created in an effort to
combined the features of several dialects of
Lisp.
Artificial Intelligence Programming
 Common Lisp programming
 Language Structure
 Lisp has only two kinds of data structure: atoms
and lists.
 Atoms are either symbols, which have the form of
identifiers or numeric literals.
 Lists are specified by delimiting their elements with
parentheses.
Artificial Intelligence Programming
 Common Lisp programming
 Language Structure
 LISP expressions are called symbolic expressions or
s-expressions.
 s-expressions are composed of three valid objects,
atoms, lists and strings
 Symbolic atoms are composed of letters, numbers
and non alphanumeric characters including * + - /
@ > < % $ & and soon.
Artificial Intelligence Programming
 Common Lisp programming
 Language Structure
 Examples of Lisp atoms
 1000
 X
 3.41
 *some-global*
 hello-from-tutorials-point
 etc
 A string is a group of characters enclosed in double quotation
marks.
 Example : "a ba c d efg #$%^&!"
 The semicolon symbol (;) is used for indicating a comment
line.
 Example: (write-line "Hello World") ; greet the world
Artificial Intelligence Programming
 Common Lisp programming
 Language Structure
 LISP evaluates everything including the function arguments and list
members.

 (write '(* 2 3))


 (write (* 2 3))
Artificial Intelligence Programming
 Common Lisp programming
 Syntax
 LISP programs run either on an interpreter or as
compiled code
 Lisp's syntax is a model of simplicity.Program and
data have exactly the same form: parenthesized
lists.
 For example :
(A B C D )
When interpreted as data, it is a list of four elements.
When viewed as code, it is the application of the
function named A to the three parameters B C and D.
Artificial Intelligence Programming
 Common Lisp programming
 Example
 The following code defines a Lisp predicate function that take
two lists as arguments and returns true if the two lists are
equal, and NIL (false) otherwise.

( DEFUN equal_lists ( lis1 lis2 )


( COND
( ( ATOM lis1 ) ( EQ lis1 lis2 ) )
( ( ATOM lis2 ) NIL )
( ( equal_lists ( CAR lis1 ) ( CAR lis2 ) )
( equal_lists ( CDR lis1 ) ( CDR lis2 ) ) )
( T NIL )
)
)
Artificial Intelligence Programming
 All function calls in LISP follow the
pattern
 (function_name arg1 arg2 arg3 ...)
 Imperative language: f(x)
 LISP: (f x)
 Means apply function f to argument x
 > (+ 2 3)
 5
 > (- 5 7)
 -2
 > (* 6 7)
 42
Artificial Intelligence Programming
Artificial Intelligence Programming

 Lists
 In a list, first element is expected to be a
function which uses remaining elements as
arguments
 List is sequence of atoms or other lists
separated by blank.
 Example
 ( i am a list)
 (a ( a b c) d e fgh)
 (father tom ( susan bill joe))
 (sun mon tue wed thur fri sat)
 ()
Artificial Intelligence Programming

 Lists
 In a list, first element is expected to be a
function which uses remaining elements as
arguments
 List is sequence of atoms or other lists separated by
blank and enclosed in parentheses
 Example
 ( i am a list)
 (a ( a b c) d e fgh)
 (father tom ( susan bill joe))
 (sun mon tue wed thur fri sat)
 ()
Artificial Intelligence Programming

 Lists
 The cons Record Structure
 A cons is a record structure containing two
components called the car and the cdr
 Cons cells or cons are objects are pairs of
values that are created using the function
cons
 The cons function takes two arguments and
returns a new cons cell containing the two
values. These values can be references to any
kind of object.
Artificial Intelligence Programming
 Lists
 The cons Record Structure
 The car function is used to access the first value
and the cdr function is used to access the second
value.
Artificial Intelligence Programming
 Lists
 The cons Record Structure
 Although cons cells can be used to create lists, the
list function is rather used for creating lists in LISP
 The first and rest functions give the first element
and the rest part of a list.
Artificial Intelligence Programming
 Lists
 LISP allows to assign properties to symbols
 A property list is implemented as a list with
an even number (possibly zero) of
elements
 When a symbol is created, its property list
is initially empty. Properties are created by
using get within a setf form
Artificial Intelligence Programming
 Lists
Artificial Intelligence Programming
 Reading Input from Keyboard
 The read function is used for taking input
from the keyboard. It may not take any
argument.
 For example, consider the code snippet −
(write ( + 15.0 (read)))
Artificial Intelligence Programming

 The Output Functions


 All output functions, Write , Print in LISP
take an optional argument called output-
stream, where the output is sent
Artificial Intelligence Programming

 Macros
 A macro is a function that takes an s-expression as arguments
and returns a LISP Form, which is then evaluated.
 Used to extend the syntax of standard
LISP
 named macro is defined using another macro named defmacro
 (defmacro macro-name (parameter-list)
"Optional documentation string."
body-form)
Artificial Intelligence Programming

 Global Variables
 Global variables are generally declared
using the defvar construct
 (defvar x 234)
(write x)
 As there is no type declaration for variables
in LISP, you need to specify a value for
a symbol directly with the setq construct
 >(setq x 10)
 The symbol-value function allows you to
extract the value stored at the symbol
storage place
Artificial Intelligence Programming

 Global Variables
(setq x 10)
(setq y 20)
(format t "x = ~2d y = ~2d ~%" x y)
(setq x 100)
(setq y 200)
(format t "x = ~2d y = ~2d" x y)
Artificial Intelligence Programming

 Local Variables
 Like the global variables, local variables
can also be created using the setq
construct.
 There are two other constructs - let and
prog for creating local variables.
Artificial Intelligence Programming
 Local Variables
 Example:
(prog ((x '(a b c))(y '(1 2 3))(z '(p q 10)))
(format t "x = ~a y = ~a z = ~a" x y z))
 Constants are declared using the defconstant
construct.
(defconstant PI 3.141592)
(defun area-circle(rad)
(terpri)
(format t "Radius: ~5f" rad)
(format t "~%Area: ~10f" (* PI rad rad)))
(area-circle 10)
Artificial Intelligence Programming

 Operator
 An operator is a symbol that tells the
compiler to perform specific mathematical
or logical manipulations
 The operations allowed on data could be
categorized as −
 Arithmetic Operations
 Comparison Operations
 Logical Operations
 Bitwise Operations
Artificial Intelligence Programming
 Program Control
 require the programmer specify one or more conditions
to be evaluated or tested by the program

 (setq a 10)
 (cond ((> a 20)
 (format t "~% a is greater than 20"))
 (t (format t "~% value of a is ~d " a)))
Artificial Intelligence Programming
 Program Control
Artificial Intelligence Programming
 Program Control
Artificial Intelligence Programming

 Functions in LISP
 The macro named defun is used for
defining functions
 Syntax:
(defun name (parameter-list) "Optional
documentation string." body)
Artificial Intelligence Programming

 Functions in LISP
Artificial Intelligence Programming

 Array in LISP
 LISP allows you to define single or multiple-
dimension arrays using the make-array
function.
 (setf my-array (make-array '(10)))
 (aref my-array 9) to access array
Artificial Intelligence Programming

 Array in LISP
Artificial Intelligence Programming
 Structure
 Structures are one of the user-defined data
type, which allows you to combine data items
of different kinds.
 The defstruct macro in LISP allows you to
define an abstract record structure
(defstruct book
title
author
subject
book-id
)
Artificial Intelligence Programming
 Structure
Artificial Intelligence Programming
 Structure
Artificial Intelligence Programming
 Common Lisp Object System (CLOS)
 Common LISP predated the advance of
object-oriented programming by couple of
decades
 The defclass macro allows creating user-
defined classes. It establishes a class as a
data type. It has the following syntax −

(defclass class-name (superclass-name*)


(slot-description*)
class-option*))
Artificial Intelligence Programming
 Common Lisp Object System (CLOS)
Artificial Intelligence Programming

 Common Lisp Object System (CLOS)


 Creating Instance of a Class
 (make-instance class {initarg value}*)
Artificial Intelligence Programming

 Common Lisp Object System (CLOS)


 Defining a Class Method
 The defmethod macro allows you to define a
method inside the class.
Artificial Intelligence Programming

 Common Lisp Object System (CLOS)


 Defining a Class Method
 The defmethod macro allows you to define a
method inside the class.
Artificial Intelligence Programming

 Recursion in LISP
 Recursion is a programming technique in
which a function calls itself repeatedly until
a certain condition is met
 Syntax
(defun function_name(parameters);
body-of-function
if(base-condition)
return;
body-of-function
function_name(parameters)

)
Artificial Intelligence Programming

 Recursion in LISP
(defun power (x y)
( if (= y 0)
1
(* x (power x(- y 1)))
)
)

(format t "3 to power 4 is : ~D" (power 3 4))


Artificial Intelligence Programming

 Recursion in LISP
(defun factorial (n)
(if (= n 0)
1
(* n (factorial (- n 1))) ) )

(loop for i from 0 to n


do (format t "~A! = ~A~%" i (factorial i)) )
Artificial Intelligence Programming

 Recursion in LISP
(* 5 (factorial 4))
(* 5 (* 4 (factorial 3)))
(* 5 (* 4 (* 3 (factorial 2))))
(* 5 (* 4 (* 3 (* 2 (factorial 1)))))
(* 5 (* 4 (* 3 (* 2 (* 1 (factorial 0))))))
(* 5 (* 4 (* 3 (* 2 (* 1 1)))))
(* 5 (* 4 (* 3 (* 2 1))))
(* 5 (* 4 (* 3 2)))
(* 5 (* 4 6))
(* 5 24)
---> 120
Artificial Intelligence Programming

 Higher Order Functions


 Higher order functions are functions that
takes functions as arguments. They are
used for mapping, filtering, folding, and
sorting of lists.
(sort '(7883 9099 6729 2828 7754 4179 5340
2644 2958 2239) <)

(sort '(7883 9099 6729 2828 7754 4179 5340 2644 2958 2239)
(lambda (x y) (< (modulo x 100) (modulo y 100))))

Result: (2828 6729 2239 5340 2644 7754 2958 4179 7883 9099)
Artificial Intelligence Programming

 Higher Order Functions


 Map
; Adding each item of '(1 2 3) and '(4 5 6).
(map + '(1 2 3) '(4 5 6))
 ⇒ (5 7 9)

; Squaring each item of '(1 2 3)


(map (lambda (x) (* x x)) '(1 2 3))
 ⇒ (1 4 9)
Artificial Intelligence Programming

 Higher Order Functions


 Map
(define sum 0)
(for-each (lambda (x) (set! sum (+ sum x)))
'(1 2 3 4))
sum
 ⇒ 10
Artificial Intelligence Programming

Thank You!
Artificial Intelligence Programming

 Symbolic knowledge representation


techniques
 Knowledge Representation in Artificial
Intelligence refers to that concept where
ways are identified to provide machines
with the knowledge that humans possess
so that AI systems can become better
Artificial Intelligence Programming

 Symbolic knowledge representation


techniques
 What to represent?
 Objects
 Events
 Performance
 Facts
 Meta-Knowledge
 Knowledge-base
Artificial Intelligence Programming

 Symbolic knowledge representation


techniques
 Types of knowledge
 Declarative Knowledge
 Based on facts
 Procedural Knowledge
 Based on rules
 Meta Knowledge
 Knowledge about other type of knowledge
 Heuristic Knowledge
 Knowledge by experts
 Structural Knowledge
 With relationship of objects and concepts
Artificial Intelligence Programming

 Symbolic knowledge representation


techniques
 Cycle of Knowledge Representation
Artificial Intelligence Programming

 Symbolic knowledge representation


techniques
 There are basically four ways of knowledge
representation techniques
 Logical Representation
 Semantic Network Representation
 Frame Representation
 Production Rules
•c) 3+3= 7(False proposition)

Artificial Intelligence Programming

 Symbolic knowledge representation


techniques
 Logical Representation
 Drawing a conclusion based on numerous criteria
is referred to as logical representation.
 the most basic form of representing knowledge to
machines where a well-defined syntax with proper
rules is used
 Propositional Logic- True or Fasle
 First-order Logic- uses for all , some of
•c) 3+3= 7(False proposition)

Artificial Intelligence Programming

 Symbolic knowledge representation


techniques
 Semantic Network Representation
 represent knowledge in the form of graphical
networks
 The representation consist of two types of
relations:
 IS-A relation (Inheritance)
 Kind-of-relation
•c) 3+3= 7(False proposition)

Artificial Intelligence Programming

 Symbolic knowledge representation


techniques
 Semantic Network Representation
Artificial Intelligence Programming
 Symbolic knowledge representation
techniques
 Frame Representation
 A frame is a record like structure that consists of
a collection of attributes and values to describe
an entity in the world.
 These are the AI data structure that divides
knowledge into substructures by representing
stereotypes situations
Artificial Intelligence Programming
 Symbolic knowledge representation
techniques
 Production Rules
 In this technique, agent checks for the condition
and if the condition exists then production rule
fires and corresponding action is carried out.
 The condition part of the rule determines which
rule may be applied to a problem. Whereas, the
action part carries out the associated problem-
solving steps.
Artificial Intelligence Programming

 Symbolic knowledge representation


techniques
 Horn-style deductive reasoning
 Deductive reasoning following one or more factual
statements (i.e. premises) through to their logical
conclusion.
All men are mortal. (First premise)
Socrates is a man. (Second premise)
Therefore Socrates is mortal. (Conclusion)
 Types of deductive reasoning:
 Syllogism
 Modus ponens
 Modus tollens (Read)
Artificial Intelligence Programming
 Symbolic knowledge representation
techniques
 Test-driven development
 Test-Driven Development (TDD) is a technique for
building software that guides software
development by writing tests.
 involves three steps
 Write a test for the functionality you want to
add.
 Write the functional code until the test passes.
 Refactor all code to make it well structured.
 Machine learning models (AI applications) must be
validated before being deployed.
 These validations, or tests, ensure that models are
delivering high-quality predictions
Artificial Intelligence Programming
 Semantics and the Web
 The Semantic Web, sometimes known as Web
3.0 (not to be confused with Web3), is an
extension of the World Wide Web through
standards set by the World Wide Web Consortium
(W3C).
 The goal of the Semantic Web is to make Internet
data machine-readable.
 To enable the encoding of semantics with the data,
technologies such as Resource Description
Framework (RDF) and Web Ontology Language
(OWL) are used.
 These technologies are used to formally represent
metadata
Artificial Intelligence Programming
 Semantics and the Web
 Web clients and servers in Lisp
 A web client is just a machine connected to the Internet,
running a computer program that sends requests for
content to web servers, and processes what comes
back, typically HTML files
 There are two packages of code available for Lisp that
make it easy to write simple web clients:
 the net.aserve.client package that comes with the
function do-http-request that sends a request to a
URL and returns the content as a string.
 the open-source net.html.parser package, defines a
parse-html function that can parse the string returned
by do-http-request into Lisp-friendly nested list.
Artificial Intelligence Programming

 Semantics and the Web


 Web clients and servers in Lisp
 do-http-request
(net.aserve.client:do-http-request "http://www.cs.aau.edu.et/")

 parse-html
(net.html.parser:parse-html "<html><body>Hello</body></html>")

(:html (:body "Hello")


Artificial Intelligence Programming
 Semantics and the Web
 XML-RPC clients and servers in Lisp
 XML-RPC is a very simple standard XML-based protocol
for calling web services.
 XML-RPC is a much smaller protocol than the other
leading XML-based web service protocol, SOAP.
 To test the XML-RPC in Lisp install the resources from
the site below
https://courses.cs.northwestern.edu/325/readings/xml-
rpc.php#get
Artificial Intelligence Programming
 Introduction to Robotics
 a re-programmable, multifunctional manipulator
designed to move material, parts, tools or
specialized devices through variable programmed
motion for a variety of tasks
 Possess certain characteristics
– mechanical arm
– sensors to respond to input
– Intelligence to make decisions
Artificial Intelligence Programming
 Introduction to Robotics
 Tasks
Artificial Intelligence Programming
 Introduction to Robotics
 Automation vs. robots
Artificial Intelligence Programming
 Introduction to Robotics
 Terminologies
 Robot - Mechanical device that performs
human tasks, either automatically or by
remote control.
 Robotics - Study and application of robot
technology.
 Telerobotics - Robot that is operated
remotely
Artificial Intelligence Programming
 Introduction to Robotics
 Laws of Robotics
 Law 1: A robot may not injure a human being or
through inaction, allow a human being to come to
harm.
 Law 2: A robot must obey orders given to it by
human beings, except where such orders would
conflict with the first law.
 Law 3: A robot must protect its own existence as
Artificial Intelligence Programming

 Homogeneous vector, plane, and transformation


 Orientation is defined by angular displacement
 Orientation can be described in terms of point or
frame rotation
 In point rotation, the coordinate system is static
and the point moves.
 In frame rotation, the point is static and the
coordinate system moves.
 a given axis and angle of rotation, point rotation
and frame rotation define equivalent angular
displacement but in opposite directions.
Artificial Intelligence Programming

 Homogeneous vector, plane, and transformation


Artificial Intelligence Programming

 Homogeneous vector, plane, and transformation


Artificial Intelligence Programming

 Homogeneous vector, plane, and transformation


 Kinematics and Inverse Kinematics (Read)
Dialogue System
Introduction
 Dialog systems seek to provide a natural
conversational interaction between the user
and the computer system
 Spoken input from the human user ->
meaning of the utterance -> results of the
operation to the user
 Two-way flow of information
 User-to-system
 System-to-user

89
Introduction

 Types of Dialogue Systems


 System-initiative
 User-initiative
 Mixed-initiative

90
Example of Dialogue Systems
 Saplen system 1997 [R. López-Cózaret et
al. Eurospeech1997]: Food ordering
system
 Let’s Go! Bus Information System [Raux
et. al. Eurospeech 2000]
 ITSpoke: Intelligent Tutoring SDS [Litman
and Silliman HLT-NAACL 2004]

91
Dialogue System Architecture

Recognition Lang. Understand.

Dialog Manag. Back-end

Synthesis Lang. Generation

92
Parser
The parser parses the word sequence
into a set of semantic frames
Parser
Phoenix - Parser
Dialog Task Specification

 Hierarchical plan for the dialog


 Tree of dialog agents
 Non-terminals - Dialog Agencies
 Terminals - Fundamental Dialog Agents
 Inform
 Request 96

 Expect and Execute


Dialog Agents
 Concepts – associated with agents
 Concepts have pre-defined types
 Set of value/confidence pairs
 Structure of an agent
 Execute routine – dependent on the
agent type
 Preconditions
 Success/Failure criteria
 Trigger conditions/ Trigger commands
97
Artificial Intelligence Chatbot
Chatbots
 are simulations that can understand
human language, process it, and interact
back with humans while performing
specific tasks.
 Joseph Weizenbaum created the first
chatbot in 1966, named Eliza.
 started when Alan Turing published an
article named “Computer Machinery and
Intelligence” and raised an intriguing
question, “Can machines think?” 99
Chatbots…
 The advancements have led us to an era
where conversations with chatbots have
become as normal and natural as with
another human.
 Companies have chatbots to engage
their users and serve customers by
catering to their queries
Chatbots…
 Types of Chatbots
 Text-based chatbot: In a text-based
chatbot, a bot answers the user’s questions
via a text interface.
 Voice-based chatbot: In a voice or
speech-based chatbot, a bot answers the
user’s questions via a human voice interface.
Chatbots…
 Approaches used to design the chatbots
 Rule-based approach, a bot answers
questions based on some rules on which it is
trained on. The rules defined can be very
simple to very complex.
 Self-learning bots are the ones that use
some Machine Learning-based approaches
and are definitely more efficient than rule-
based bots. These bots can be further
classified into two types: Retrieval Based
or Generative.
Chatbots…
 Depending on the complexity bots can be
 Traditional chatbots: are driven by system
and automation, mainly through scripts with
minimal functionality and the ability to
maintain only system context.
 Current chatbot: are driven by back-and-
forth communication between the system
and humans. They have the ability to
maintain both system and task contexts.
Chatbots…
 Depending on the complexity bots can be
 Future chatbot: can communicate at
multiple levels with automation at the
system level.
 have the ability to maintain the system, task,
and people contexts.
 There is a possibility of introducing of master
bots and eventually a bot OS.
Chatbots…
 Applications
 Virtual reception assistant
 Virtual help desk assistant
 Virtual tutor or teacher
 Virtual driving assistant
 Virtual email, complaints, or content
distributor
 Virtual home assistant example: Google
Home
Chatbots…
 Applications
 Virtual operations assistant, example: Jarvis
from the movie Iron Maiden
 Virtual entertainment assistant, example:
Amazon Alexa
 Virtual phone assistant, example: Apple Siri
 Assist the visually impaired person in
describing the surroundings
 Can help a warehouse executive in locating
the stocked product
Chatbots…
 Architecture of chatbots
 Consists of
 Chat window/session/front end application
interface
 The deep learning model for Natural Language
Processing [NLP]
 Corpus or training data for training the NLP
model
 Application Database for processing actions to
be performed by the chatbot
Chatbots…
Chatbots…
 Corpus or Training Data
 data that could be used to train the NLP
model to understand the human language as
text or speech and reply using the same
medium
 can be designed using one of the following
methods:
 Manual
 Accumulated over time in an organized fashion.
 components of a corpus:
 Input pattern, Output pattern, Tag
Chatbots…
 Corpus or Training Data
 sample corpus for helpdesk chatbot can
manually designed as
 Pairs: Collection of all transactions, Input and
Output to be used for training the chatbot.
 Read/patterns: Patterns that are or could be
expected as inputs from end-users.
 Response: Patterns that are or could be
delivered as outputs from the chatbot to end-
users
 Regular Expressions: Patterns that are used
to generalize patterns for reading and response.
Chatbots…
 Corpus or Training Data
 sample corpus for helpdesk chatbot can
manually designed as
 Tag: To group similar text instances and use
the same as targeted outputs to train neural
networks
Chatbots…
 Text-based Chatbot
 Input the corpus
 Perform data pre-processing on corpus:
 cleaning the text data. Extraction of useful
information from the pre-processed text.
 Text case [upper or lower] handling
 Tokenization
 converts a sequence of characters into a
sequence of tokens
 Stemming
 reduce words to their base form
 Generate BOW [Bag of Words]
 representation of text that describes the
occurrence of words within a document
Chatbots…
 Text-based Chatbot
 Generate one hot encoding for the target column
 represent categorical variables as numerical
values in a machine learning model
 Design a neural network to classify the words with
TAGS as target outputs
 Design a chat utility as a function to interact with
the user till the user calls a “quit”
 Support for re doing
 Run the chat utility function

 Voice-based Chatbot
 Input the corpus
 Perform data pre-processing on corpus:
 Text case [upper or lower] handling
Chatbots…
 Voice-based Chatbot
 Tokenization
 Stemming
 Generate BOW [Bag of Words]
 Generate one hot encoding for the target column
 Design a neural network to classify the words with
TAGS as target outputs
 Design a function to speak the output text
 Design a function for listening to the user and
convert the spoken words into text
 Design a chat utility as a function to interact with
the user till they call a “quit”
 Run the chat utility function
Question Answering
What is Question Answering?

Type of information retrieval. Given a


collection of documents ,the system
should be able to retrieve answers to
questions posed in natural language.
Generic QA Architecture

3/13/2023
Question and Answering

Was developed by Boris Katz at MIT's


Artificial Intelligence Laboratory

Was first connected to the World Wide


Web in December, 1993

Key technique is "natural language


annotation"
Two basic foundations

Sentence level Natural Language


Processing capabilities

Natural Language Annotations


Natural Language Annotations

 Computer analyzable collections of natural language


sentences and phrases that describe the contents of
various information segments

 A pointer is associated with sentences which points to


the information segment summarized by the
annotations.

 Instead of producing just the sentence as answer START


follows the pointer and gives the text segment with the
answer sentence.
Process of Question
Interpretation
 Co reference resolution
 Resolve personal, possessive and
demonstrative pronouns

 Question Normalization
 Drops punctuation and quotation
marks
 Stems verbs and nouns

 Semantic Parsing of Questions


 Question is transformed into a
statement
 Semantic Role Labeling is done

 Query Generation and Expansion


 Keyword queries
 Term queries
 Predicate queries
Question: In what year was the CMU  Reformulation queries
campus at the west coast established?
Search Module
 The search module
consists of two kind of
searchers

 Knowledge Miners:
Answer
searches from
Candidates unstructured data

 Knowledge Annotators:
they provide semi-
structured information,
ex. Gazetteer web service
Answer Extraction
 Two ways to extract answers
 Answer Type analysis
 Pattern Learning approach

 Answer Type Analysis


 Consists of a set of 154 answer types
 Uses features to classify answers
 Lexical Features: UNIGRAM
 Syntactic Features: MAIN_VERB, WH_WORD
 Semantic Features: FOCUS_TYPE
 Patterns are associated with the types
 Example Named Entity Type: Weekday
 Example Pattern: (what|which|name) (.*)?(day of
(the)?week|weekday)
 Has high precision but fails for answers that cannot be
tagged
Joint Answer Ranking

A graphical model based


method.

Estimates the correctness of


individual answers.

Gives corelation between the


answers.
Candidate Generation

Document retrieval

Question analysis

Answer extraction

Issues with Candidates

Answer Relevence

Answer Similarity
Algorithm

Create empty answer pool.

Estimate joint probablity of all answer


candidates.

Calculate the marginal probability that


an individual answer candidate is
correct.

Choose the answer candidate whose


marginal probability is highest, and
move it to the answer pool.
For the remaining answer
candidates :
Calculate the conditional probability of
individual answers given the chosen
answer(s).

Calculate the score of each answer


candidate from the marginal and
conditional probability.

Choose the answer whose Score(Aj) is


maximum, and move it to the answer
pool.
Example

 Question : Who have been the U.S.


presidents since 1993?

 Answer :-
P(correct(William J. Clinton)) = 0.758
P(correct(Bill Clinton)) = 0.755l
P(correct(George W. Bush) = 0.617
Example …

 P(correct(Bill Clinton)|correct(William
J. Clinton)) = 0.803

 P(correct(George W.
Bush)|correct(William J. Clinton)) =
0.617
Artificial Intelligence Programming
 Prolog
 Prolog as the name itself suggests, is the
short form of LOGical PROgramming. It is a
logical and declarative programming
language
 It is one major example of the fourth
generation language that supports the
declarative programming paradigm
 involve symbolic or non-numeric
computation
 Which is the main reason to use Prolog as the programming
language in Artificial Intelligence, where symbol
Artificial Intelligence Programming
 Prolog
 Prolog language basically has three
different elements −
 Facts − The fact is predicate that is true,
for example, if we say, “Tom is the son of
Jack”, then this is a fact.
 Rules − Rules are extinctions of facts that
contain conditional clauses. To satisfy a rule
these conditions should be met

Artificial Intelligence Programming
 Prolog
 for X to be the grandfather of Y, Z should be a parent of Y and X
should be father of Z fundamental tasks

 Applications of Prolog
 Intelligent Database Retrieval
 Natural Language Understanding
 Specification Language
 Machine Learning
 Robot Planning
 Automation System
 Problem Solving
Artificial Intelligence Programming
 Official Website
 http://www.gprolog.org/
 Syntax
 The syntax for facts is as follows −
 relation(object1,object2...).
Artificial Intelligence Programming
 Rules
 We can define rule as an implicit
relationship between objects.
 facts are conditionally true.
 when one associated condition is true,
then the predicate is also true
 Lili is happy if she dances.
 Tom is hungry if he is searching for food.
 Jack and Bili are friends if both of them love to
play cricket.
 will go to play if school is closed, and he is free.
Artificial Intelligence Programming
Artificial Intelligence Programming
Artificial Intelligence Programming
 Knowledge Base
 There are three main components in
logic programming − Facts, Rules and
Queries.
 These three if we collect the facts and
rules as a whole then that forms a
Knowledge Base.
 the knowledge base is a collection of
facts and rules.
Artificial Intelligence Programming
 Knowledge Base
Artificial Intelligence Programming
 Relations in Prolog
 Coming soon

You might also like