0% found this document useful (0 votes)
68 views223 pages

Understanding AI and Intelligent Agents

The document provides an overview of Artificial Intelligence (AI), detailing its definition, types, and how it operates through data input, processing, and learning. It discusses various types of AI, including Narrow AI, General AI, and Superintelligent AI, as well as different agent types and their functionalities. Additionally, it covers concepts such as reinforcement learning, PEAS representation, and the characteristics of intelligent agents.

Uploaded by

larishaupadhyaya
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)
68 views223 pages

Understanding AI and Intelligent Agents

The document provides an overview of Artificial Intelligence (AI), detailing its definition, types, and how it operates through data input, processing, and learning. It discusses various types of AI, including Narrow AI, General AI, and Superintelligent AI, as well as different agent types and their functionalities. Additionally, it covers concepts such as reinforcement learning, PEAS representation, and the characteristics of intelligent agents.

Uploaded by

larishaupadhyaya
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

Introduction to

AI
Artificial Intelligence

● The field of computer science focused on creating systems capable of


performing tasks that typically require human intelligence, such as
reasoning, learning, and decision-making.
How AI Works

Input: Data is collected from various sources. This data is then sorted into categories.

Processing: The AI sorts and deciphers the data using patterns it has been programmed to
learn until it recognizes similar patterns in the data.

Outcomes: The AI can then use those patterns to predict outcomes.

Adjustments: If the data sets are considered a “fail,” AI learns from that mistake, and the
process is repeated under different conditions.

Assessments: In this way, AI is constantly learning and improving.


Types of AI

Narrow AI (ANI): AI systems designed for specific tasks, excelling in


their domain but unable to perform beyond their programmed
capabilities.

General AI (AGI): AI with human-like intelligence, capable of


understanding, learning, and applying knowledge across diverse
tasks, including novel problems.

Superintelligent AI (ASI): AI surpassing human intelligence in all


areas, demonstrating extraordinary problem-solving and creativity.
Conceptual Types
of AI
● Human AI
1. Thinking Humanly
2. Acting Humanly

● Rational AI
1. Thinking Rationally
2. Acting Rationally
Reinforcement
Learning
● focused on making decisions to
maximize cumulative rewards in a given
situation.
● Unlike supervised learning, which relies
on a training dataset with predefined
answers, RL involves learning through
experience.
● In RL, an agent learns to achieve a goal
in an uncertain, potentially complex
environment by performing actions and
receiving feedback through rewards or
penalties.
Reinforcement Learning

● Agent: The learner or decision-maker.


● focused on making decisions to
maximize cumulative rewards in each ● Environment: Everything the agent
situation. interacts with.
● Unlike supervised learning, which
relies on a training dataset with ● State: A specific situation in which the
predefined answers, RL involves agent finds itself.
learning through experience.
● In RL, an agent learns to achieve a ● Action: All possible moves the agent can
goal in an uncertain, potentially make.
complex environment by performing
actions and receiving feedback ● Reward: Feedback from the environment
through rewards or penalties. based on the action taken.
Working
● Reinforcement Learning (RL) is about learning optimal
behaviors through trial and error. The agent interacts
with the environment, takes actions, and receives
rewards or penalties. The goal is to maximize
cumulative rewards. Key elements include:
● Policy: Strategy to determine the next action based on
the current state.
● Reward Function: Feedback signal (reward or penalty)
based on the state and action.
● Value Function: Estimates the expected cumulative
reward from a given state.
● Model of the Environment: Represents the
environment to help predict future states and rewards.
● Through continuous interaction, the agent learns a
policy to maximize rewards.
Agent & Intelligent
Agent
Agent ● Human-Agent: A human agent has
eyes, ears, and other organs which work
for sensors and hand, legs, vocal tract
● An agent can be anything work for actuators.
that perceives its ● Robotic Agent: A robotic agent can
environment through have cameras, infrared range finder,
sensors and act upon that NLP for sensors and various motors for
environment through actuators.
actuators. ● Software Agent: Software agent can
● An Agent runs in the cycle have keystrokes, file contents as
sensory input and act on those inputs
of perceiving, thinking, and display output on the screen.
and acting.
Working of Agent
● Perception: AI agents start by perceiving their
environment using sensors or by receiving input from
various sources like cameras, microphones, and other
devices.
● Processing: The perceived data is processed using
algorithms, machine learning models, or other AI
techniques. This step involves analyzing and
interpreting the data to understand the environment.
● Decision Making: Based on the processed information,
the AI agent makes decisions by selecting an
appropriate action. This could involve rule-based
systems, optimization algorithms, or more advanced
techniques like deep learning.
● Action: The chosen action is then executed by the AI
agent. This could be anything from moving a robot arm
to generating a text response.
● Reactive agents: These agents act based
on what's happening around them right
now. For example, if a robot sees an
obstacle, it immediately changes direction
to avoid it.
Types of
Agents ● Proactive agents: These agents don’t just
react to things; they also plan ahead to
reach their goals. For example, a robot
might figure out the best path to clean an
entire room before it starts moving.
● Fixed environment: The rules and
conditions don’t change. Think of a simple
board game where the rules are always
the same.
Types of
Environment ● Dynamic environment: Things keep
changing, and the agent has to adjust. For
example, a self-driving car deals with
changing traffic and weather.
• AutoGPT is an AI agent that can generate
human-like text responses. It can
comprehend the context of the conversation
and generate relevant responses
accordingly.

• BabyAGI is an autonomous AI agent that


can independently learn and perform tasks
like understanding natural language,
Example analyzing images, identifying objects,
following simple commands, etc.

• AgentGPT is an intelligent virtual agent


designed to interact with customers and
provide them with personalized
recommendations. It can understand
natural language and provide relevant
responses based on customer queries.
Intelligent Agents

● An intelligent agent is an Rule 1: An AI agent must have the


autonomous entity that acts ability to perceive the
upon an environment using environment.
sensors and actuators to
Rule 2: The observation must be
achieve goals.
used to make decisions.
● An intelligent agent may
learn from the environment Rule 3: Decision should result in
to achieve their goals. an action.
● A thermostat is an example
of an intelligent agent. Rule 4: The action taken by an AI
agent must be a rational action.
Working of Intelligent Agent

● Sensor: Sensor is a device which detects the


change in the environment and sends the
information to other electronic devices. An agent
observes its environment through sensors.

● Actuators: Actuators are the component of


machines that converts energy into motion. The
actuators are only responsible for moving and
controlling a system. An actuator can be an
electric motor, gears, rails, etc.

● Effectors: Effectors are the devices which


affect the environment. Effectors can be legs,
wheels, arms, fingers, wings, fins, and display
screen.
PEAS Representation

● PEAS is a type of model on which an AI agent works upon. When we define an AI


agent or rational agent, then we can group its properties under PEAS
representation model. It is made up of four words:

● P: Performance measure
● E: Environment
● A: Actuators
● S: Sensors
PEAS for Self
Driving Car
● Performance: Safety, time,
legal drive, comfort
● Environment: Roads, other
vehicles, road signs, pedestrian
● Actuators: Steering,
accelerator, brake, signal, horn
● Sensors: Camera, GPS,
speedometer, odometer,
accelerometer, sonar.
Example of
Agents with
their PEAS
representati
on
Types of Environments
1. Fully Observable vs Partially 2. Deterministic vs Stochastic
Observable • Deterministic: Actions always
• Fully Observable: Agent sees have predictable outcomes.
the entire environment. Example: Chess, Tic-Tac-Toe.
Example: Chess, Checkers. • Stochastic: Actions can have
• Partially Observable: Agent unpredictable outcomes due to
sees only part of the randomness.
environment, leading to Example: Dice Games,
uncertainty. Real-Time Strategy Games.
Example: Poker, Maze
Navigation.
3. Competitive vs Collaborative 4. Single-Agent vs Multi-Agent
• Competitive: Agents compete • Single-Agent: Only one agent
to win. interacts with the environment.
Example: Chess, Soccer. Example: Solitaire, Maze
• Collaborative: Agents work Solving.
together to achieve a goal. • Multi-Agent: Multiple agents
Example: Robot teamwork, interact, compete or cooperate.
Multiplayer Online Games. • Example: Football, Traffic
Management.
5. Static vs Dynamic 6. Discrete vs Continuous
• Static: Environment doesn’t • Discrete: Finite and countable
change unless acted upon. actions/states.
Example: Chess, Sudoku. Example: Tic-Tac-Toe, Chess.
• Dynamic: Environment changes • Continuous: Infinite
over time or independently. possibilities and smooth
Example: Self-Driving Cars, changes.
Video Games. Example: Robot Movement,
Autonomous Driving.
7. Episodic vs Sequential 8. Known vs Unknown
• Episodic: Decisions are • Known: Rules and dynamics
independent; no future impact. are fully understood.
Example: Image Example: Chess, Puzzles.
Classification, Tetris. • Unknown: Rules are unclear,
• Sequential: Current actions requiring learning.
affect future outcomes. Example: Mars Exploration,
Example: Chess, Robot Drone Navigation.
Navigation.
Simple Reflex Agents
Model-Based Reflex Agents
Goal-Based Agents
Types of Utility-Based Agents
Agents
Learning Agent
Multi-agent systems
Hierarchical agents
Simple Reflex Agent
● It relies only on the current percept
& disregards percept history
● They operate using
condition-action rules: if a
condition holds, the corresponding
action is executed.
● These agent platforms work well
in fully observable environments
● In partially observable
environments, they often fall into
infinite loops.
● Randomizing actions can help
them avoid infinite loops.
Problems in Simple
Reflex Agents

● Very limited intelligence.


● No knowledge of non-perceptual parts of the state.
● Usually too big to generate and store.
● If there occurs any change in the environment, then
the collection of rules needs to be updated.
Pseudocode for Simple Reflex Agent

● SimpleReflexAgent(percept):
Receives sensor input, interprets the
environment's state, applies rules,
determines the action, and returns
the decision.
● InterpretePercept(percept):
Analyzes percept to identify key
features, determines the current
state, and returns it.
● Rules(state): Uses predefined rules
to guide the decision-making
process based on the current state,
ultimately determining the agent's
action.
1. Vacuum Cleaning Robots: Vacuum cleaning robots efficiently
navigate simple environments with few locations and dirt
sensors by reacting to dirt presence.

2. Thermostats: HVAC thermostats act as simple reflex agents


by sensing temperature and activating heating or cooling based
Applications on set thresholds.

of Simple 3. Automatic Doors: Reflex agents in automatic doors detect


people in front and open, staying closed if no one is present.
Reflex
4. Traffic Light Control: In a basic traffic management system,
Agents Traffic lights change signals as reflex agents, following rules
like time intervals or sensor inputs.

5. Elevator Control: Simple reflex agents in small buildings or


low-traffic areas manage elevator systems by responding to
button presses and sensor inputs.
Model-Based Reflex Agents

● It finds a rule whose condition matches the current


situation.

● A model-based agent handles partial observability


by using a world model.

● The internal state is updated by each percept and


depends on percept history, representing unseen
parts of the world.

● Updating this state needs knowledge of how the


world evolves and how the agent’s actions affect
it.
Pseudocode
● MODEL-BASED-REFLEX-AGENT(percept):
Takes a percept as input and returns an action.
● Persistent Variables:
○ state: The agent’s internal state.
○ model: The model of the environment.
○ rules: The set of condition-action rules.
○ action: The most recent action taken.
● UPDATE-STATE: Updates the internal state
using the current state, previous action,
percept, and the model.
● RULE-MATCH: Finds a matching
condition-action rule based on the current
state
● Action Selection: The matching rule’s action is
selected and returned.
Goal-Based
Agents
● Goal-based agents choose actions
that minimize the distance to their
desired goal.
● They search and plan to find the
best path to the goal among
multiple options.
● Their knowledge is explicit and can
be modified, making them flexible.
● Changing the goal easily alters
their behavior.
Pseudocode
●UPDATE-STATE is a function that
updates the agent’s current state
based on the last action, the
current percept, and the goal.
●RULE-MATCH is a function that
selects a rule from the set of rules
based on the current state and the
goal.
●GET-ACTION is a function that
determines the action to take based
on the matched rule.
Utility-Based Agents
1. Utility Function
• Assigns a numerical score to each possible outcome, showing how “good” or “desirable” it is.
• Higher scores indicate better outcomes for the agent.
2. Goal Achievement + Optimization
• Unlike simple goal-based agents, utility-based agents seek not only to reach a goal but to optimize overall
performance.
• They consider different paths to achieve the goal and pick the one with the highest utility.
3. Decision-Making with Trade-Offs
• Utility-based agents handle conflicts (e.g., speed vs. resource usage) by balancing factors through the utility
function.
• This helps them choose the best possible compromise in complex scenarios.
4. Rational Action Selection
• They continuously estimate how each action affects their utility and choose the one with the highest expected
utility.
• This approach makes them more adaptable and effective in uncertain environments.
5. Adaptability
• As they gain new information, they update their decisions to maintain the highest utility outcome.
Utility-Based
Agents
● Utility-based agents determine actions by
assigning a “happiness” (utility) value to
each possible outcome.
● Achieving a goal alone might not be
enough; agents often seek a faster, safer,
or cheaper path.
● The “utility” reflects how “happy” the
agent is with each result.
● Given uncertainty, the agent selects the
action that maximizes expected utility.
● A utility function maps a state to a real
number representing its associated
“happiness” value.
Pseudocode
● Initialization: The agent starts with an initial
state and a utility function for evaluating states.
● Loop: The agent continuously senses (percepts)
from the environment.
● State Update: The agent updates its internal
state based on new percepts.
● Action Generation the current state.
● Utility Calculation: For each action, the agent
predicts the outcome and applies the utility
function to measure desirability.
● Select Best Action: The agent chooses the
action with the highest utility score.
● Execute Action & Repeat: The agent executes
the chosen action and repeats the cycle, adapting
as conditions change.
Learning Agent
● Definition: A learning agent in AI can
learn from past experiences, starting with
minimal knowledge and adapting
automatically over time.
● Key Components:
● Learning Element: Improves the agent
by learning from the environment.
● Critic: Provides feedback on
performance relative to a fixed
standard.
● Performance Element: Selects external
actions.
● Problem Generator: Suggests new,
informative experiences for further
learning.
Pseudocode
● Initialization: Get all the agent’s pieces set up. The agent’s
knowledge_base could be rules, a Q-table, or the weights of a
neural network.
● Observation: The agent checks its current situation in the
environment, calling it the state S.
● Action Selection: The performance_element picks which action A
to do, using what’s in the agent’s knowledge_base.
● Execute & Feedback: The agent carries out the chosen action A.
The environment then gives some response or feedback F (like a
score or a reward).
● Evaluation (Critic): The critic checks how effective the action was in
that situation (how much it helped or hurt).
● Learning: The learning_element updates or improves the
knowledge_base using the critic’s feedback. This is the core of how
the agent learns from its experiences.
● Problem Generation: The agent might create new goals or
sub-goals to explore. This spurs it to discover better ways of doing
things.
● Repeat: The process keeps cycling until the agent finishes its task
or runs out of time/episodes.
Multi Agents

For example, in a video


game, different characters or
Sometimes, many agents teams might need to
work together to achieve a cooperate to complete a
common goal. This is called mission. These agents talk to
a multi-agent system. each other and share
information to work better
together.
Multi Agents
● Definition: Multi-agent systems (MAS) involve multiple agents interacting to achieve a common goal. Agents can be
autonomous or semi-autonomous, perceive their environment, make decisions, and take actions.
● Applications: MAS are used in transportation, robotics, social networks, etc., improving efficiency, reducing costs, and
increasing flexibility in complex scenarios.
● Classification:
1. Goals: Agents may share the same goal or have different goals.
2. Collaboration: Agents can be cooperative (working together) or competitive (pursuing individual goals). Some
systems combine both.
3. Homogeneity:
Homogeneous: Agents have the same capabilities and behaviors.
Heterogeneous: Agents differ in capabilities and behaviors, offering more flexibility but making coordination harder.
● Techniques:
1. Game Theory: Analyzes strategic interactions and predicts agent behavior.
2. Machine Learning: Trains agents to improve decision-making over time.
3. Agent-Based Modeling: Simulates complex systems to study agent interactions.
● Benefit: MAS help solve complex problems and boost efficiency in diverse AI applications
Multi Agent
Hierarchical Agents
● Definition: Hierarchical agents are organized into levels, with high-level agents overseeing
lower-level agents.
● Roles:
1. High-Level Agents: Set goals and constraints based on the overall system objectives.
2. Low-Level Agents: Execute specific tasks (e.g., managing traffic flow or meeting
production targets).
● Application: Robotics, manufacturing, transportation—especially when coordinating many
tasks and sub-tasks.
● Structure: Can range from simple two-level (high/low) setups to multi-level arrangements
with intermediate agents.
● Advantages:
1. Efficient resource use and task allocation.
2. Faster, more organized decision-making.
3. Improved system performance through clearer task hierarchy and goal setting.
Hierarchical
Agent
Problems Solving by
Searching
1. Ignorable Problems
• Definition: Minor errors/issues with
minimal impact on overall
performance.

Types of • Examples:
• Small prediction inaccuracies that
Problems don’t affect the larger goal.
• Minor data preprocessing errors
with negligible impact on results.
• Handling: Typically no intervention
needed; can be safely overlooked in
real-time systems.
2. Recoverable Problems 3. Irrecoverable Problems
• Definition: Issues the AI system • Definition: Critical failures that
can overcome through manual permanently damage system
fixes or built-in mechanisms. performance.
• Examples: • Examples:
• Missing data that can be • Completely corrupted training
imputed. data causing irreversible model
• Biased or incorrect training bias.
data that can be corrected or • Security vulnerabilities
retrained. allowing adversarial attacks.
• System crashes recoverable via • Extreme overfitting preventing
checkpoints or retraining. generalization.
• Handling: Requires • Handling: Often necessitates a full
action—automated or manual. system overhaul or redesign (e.g.,
Systems should be designed with rebuilding datasets, retraining
fault tolerance and error-correcting models).
features.
Steps of Problem Solving in AI

Problem Definition: Specify the inputs and acceptable solutions,


providing a clear foundation for analysis and resolution.

Problem Analysis: Examine the problem’s components, constraints, and


implications to identify viable solutions.

Knowledge Representation: Gather detailed information and outline


applicable techniques, ensuring a thorough understanding of the context.

Problem Solving: Select and compare algorithms or approaches to


determine the most effective method to address the problem.
Components of Problem Formulation in AI

Initial State: The starting context for the AI agent, possibly including any initial
problem-solving methods.

Action: Identifies all possible actions from the initial state, each moving the system closer to
the goal.

Transition: Links actions to the next state, showing how each choice affects outcomes.

Goal Test: Checks if the goal is reached using the transitions. If successful, the process
stops, and attention shifts to cost.

Path Costing: Assigns a numerical value to reaching the goal, accounting for hardware,
software, and human resource expenses.
Problem Solving by Searching
Best First Search
A* Algorithm
Trade off Between Search Complexity &
Heuristic Complexity
Search Complexity:
This refers to the overall effort (in time and space) required by the search algorithm to find a solution. A more effective heuristic can
significantly prune the search space, leading to fewer node expansions and faster search times.

Heuristic Complexity:
This is the computational cost of evaluating the heuristic function at each node. A highly informed, complex heuristic might be expensive
to compute, potentially offsetting the savings from reducing the search space.

The Trade-off:

● Accurate but Expensive Heuristic:


A complex heuristic that closely approximates the true cost to the goal can dramatically reduce the number of nodes expanded.
However, if computing this heuristic is very resource-intensive, the overall benefit might diminish because each node evaluation
becomes costly.
● Simple but Inexpensive Heuristic:
A simpler heuristic is faster to compute, which means each node evaluation is cheap. However, if it is less informed, the search
algorithm might explore many more nodes, potentially leading to a higher overall search cost.

Optimal Balance:
The ideal scenario is to design or choose a heuristic that provides enough guidance to prune the search space effectively while
remaining computationally light. The optimal balance depends on the specific problem domain and the available computational
resources.
Expert System

The working mechanism of an expert system begins when a non-expert user submits a query through the user interface.
● This query is then processed by the inference engine, which applies logical rules and reasoning techniques to analyze the input.
● The inference engine interacts with the knowledge base, retrieving relevant facts, rules, and heuristics contributed by expert
users.
● Based on this structured knowledge, the system derives conclusions and formulates an appropriate response.
Forward Chaining
● Data-driven approach
● Starts with available facts, applies rules
to infer new facts until a goal is reached.
● Works well for prediction and
monitoring systems.
● Suitable for real-time systems like expert
systems in medicine (diagnosing
diseases).
● Breadth-first style of reasoning.

Example:
"If the temperature is above 100°F → The machine is overheating."
Forward chaining checks if the temperature is above 100°F and then infers the machine status.
Backward Chaining
● Goal-driven approach
● Starts with a hypothesis (goal) and
works backward to verify supporting
facts.
● Efficient for diagnostic systems or
problem-solving tasks.
● Suitable for rule-based AI in debugging,
troubleshooting, etc.
● Depth-first style of reasoning.

Example:
Goal: "Is the machine overheating?"
Backward chaining will trace back facts (temperature readings, error logs) to verify the goal.
How These Components Work Together?

Imagine a medical expert system designed to diagnose diseases:

1. Input: A patient reports symptoms like fever, cough, and fatigue through the user
interface.
2. Processing: The inference engine analyzes the symptoms using rules from the knowledge
base.
3. Output: The system suggests a possible diagnosis, such as pneumonia.
4. Explanation: The explanation module provides a detailed explanation, such as “The
diagnosis is based on the presence of fever, cough, and abnormal chest X-ray results.”
5. Update: The knowledge acquisition module adds new data, such as recent research on
pneumonia treatments, to keep the system up-to-date.
Conflict Resolution

1. What is Conflict Resolution?


It is the process of determining which rule to apply when multiple rules can be fired simultaneously in a rule-based AI
system.

2. Techniques for Conflict Resolution


● Specificity Ordering: The more specific rule is given priority over a general one.
○ Example: Rule involving multiple conditions is prioritized over a broader rule.
● Recency Ordering: The rule that was activated most recently gets priority.
○ Useful in dynamic environments.
● Rule Priority (Salience): Each rule is assigned a priority (weight or rank). Higher-priority rules are fired first.
● Context-based Resolution: The system evaluates the current context to decide the most relevant rule.
● Lexicographic Ordering: Rules are executed in a predefined sequence if they have the same conditions.

3. Challenges in Conflict Resolution


● Handling contradictory rules
● Managing real-time decision-making
● Balancing performance and accuracy
PSO Numerical
Forward Propagation
➔ The input data is fed in the forward direction At each neuron in a hidden or output layer, the
through the network. Each hidden layer processing happens in two steps:
accepts the input data, processes it as per
the activation function and passes to the 1. Preactivation: it is a weighted sum of inputs i.e.
successive layer. the linear transformation of weights w.r.t to inputs
➔ In order to generate some output, the input data available. Based on this aggregated sum and
should be fed in the forward direction only. activation function the neuron makes a decision
The data should not flow in reverse direction whether to pass this information further or not.
during output generation otherwise it would 2. Activation: the calculated weighted sum of inputs
form a cycle and the output could never be is passed to the activation function. An activation
generated. Such network configurations are function is a mathematical function which adds
known as feed-forward network. non-linearity to the network. There are four
➔ The feed-forward network helps in forward commonly used and popular activation functions
propagation. — sigmoid, hyperbolic tangent(tanh), ReLU and
Softmax.
1. Input Layer: The input data is fed into the input layer of the neural network.

2. Hidden Layers: The input data is processed through one or more hidden layers. Each neuron in

a hidden layer receives inputs from the previous layer, applies an activation function to the

weighted sum of these inputs, and passes the result to the next layer.

3. Output Layer: The processed data moves through the output layer, where the final output of the

network is generated. The output layer typically applies an activation function suitable for the

task, such as softmax for classification or linear activation for regression.

4. Prediction: The final output of the network is the prediction or classification result for the input

data.
Working of Forward Propagation (Maths)

You might also like