Knowledge Representation in AI What is Knowledge Representation? • Knowledge Representation in AI describes the representation of knowledge. • Basically, it is a study of how the beliefs, intentions, and judgments of an intelligent agent can be expressed suitably for automated reasoning. • One of the primary purposes of Knowledge Representation includes modeling intelligent behavior for an agent. What is Knowledge Representation? • Knowledge Representation and Reasoning (KR, KRR) represents information from the real world for a computer to understand and then utilize this knowledge to solve complex real-life problems like communicating with human beings in natural language. • Knowledge representation in AI is not just about storing data in a database, it allows a machine to learn from that knowledge and behave intelligently like a human being. What to Represent• The different kinds of knowledge that need to be represented in AI include: • Objects: all the facts about object in real world domain, For instance, a bus has wheels, and a guitar has strings, etc. • Events: incidents that have occurred in our world • Performance: describes behavior which involves knowledge about how to do things • Facts: reality of the actual world and what we stand for • Meta-Knowledge: knowledge about what we know • Knowledge-base: central component of knowledge-based agents, set of information about any discipline, field, etc., For example, a knowledge base on road construction. Different Types of Knowledge Knowledge is awareness gained by experiences of facts, data, and situations. Types of Knowledge • Declarative Knowledge – It includes concepts, facts, and objects and expressed in a declarative sentence. • Structural Knowledge – It is a basic problem-solving knowledge that describes the relationship between concepts and objects. • Procedural Knowledge – This is responsible for knowing how to do something and includes rules, strategies, procedures, etc. • Meta Knowledge – Meta Knowledge defines knowledge about other types of Knowledge. • Heuristic Knowledge – This represents some expert knowledge in the field or subject. Cycle of Knowledge Representation in AI • Artificial Intelligent Systems usually consist of various components to display their intelligent behavior. Some of these components include: Cycle of Knowledge Representation in AI • The Perception component retrieves data or information from the environment. • • • • retrieve data from the environment, find out the source of noises and check if the AI was damaged by anything. Also, it defines how to respond when any sense has been detected. • Then, there is the Learning Component that learns from the captured data by the perception component. The goal is to build computers that can be taught instead of programming them. Learning focuses on the process of self-improvement. In order to learn new things, the system requires knowledge acquisition, inference, acquisition of heuristics, faster searches, etc. Cycle of Knowledge Representation in AI • The main component in the cycle is Knowledge Representation and Reasoning which shows the humanlike intelligence in the machines. Knowledge representation is all about understanding intelligence. Also, it defines how automated reasoning procedures can make this knowledge available as needed. • The Planning and Execution components depend on the analysis of knowledge representation and reasoning. Here, planning includes giving an initial state, finding their preconditions and effects, and a sequence of actions to achieve a state in which a particular goal holds. Now once the planning is completed, the final stage is the execution of the entire process. Techniques of Knowledge Representation in AI Logical Representation • Logical representation is a language with some definite rules which deal with propositions and has no ambiguity in representation. • It represents a conclusion based on various conditions and lays down some important communication rules. • Also, it consists of precisely defined syntax and semantics which supports the sound inference. • Each sentence can be translated into logics using syntax and semantics. • Logical representation can be categorized into mainly two logics: • Propositional Logics • Predicate logics Logical Representation • Syntax: • Syntaxes are the rules which decide how we can construct legal sentences in the logic. • It determines which symbol we can use in knowledge representation. • How to write those symbols. • Semantics: • Semantics are the rules by which we can interpret the sentence in the logic. • Semantic also involves assigning a meaning to each sentence. • Advantages of logical representation: • Logical representation enables us to do logical reasoning. • Logical representation is the basis for the programming languages. • Disadvantages of logical Representation: • Logical representations have some restrictions and are challenging to work with. • Logical representation technique may not be very natural, and inference may not be so efficient. Semantic Network Representation • Semantic networks work as an alternative of predicate logic for knowledge representation. • In Semantic networks, you can represent your knowledge in the form of graphical networks. • This network consists of nodes representing objects and arcs which describe the relationship between those objects. Also, it categorizes the object in different forms and links those objects. • This representation consist of two types of relations: – IS-A relation (Inheritance) – Kind-of-relation Semantic Network Representation Semantic Network Representation • Drawbacks in Semantic representation: • Semantic networks take more computational time at runtime as we need to traverse the complete network tree to answer some questions. It might be possible in the worst-case scenario that after traversing the entire tree, we find that the solution does not exist in this network. • Semantic networks try to model human-like memory (Which has 1015 neurons and links) to store the information, but in practice, it is not possible to build such a vast semantic network. • These types of representations are inadequate as they do not have any equivalent quantifier, e.g., for all, for some, none, etc. • Semantic networks do not have any standard definition for the link names. • These networks are not intelligent and depend on the creator of the system. • Advantages of Semantic network: • Semantic networks are a natural representation of knowledge. • Semantic networks convey meaning in a transparent manner. • These networks are simple and easily understandable. 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. • Basically, it consists of a collection of slots and slot values of any type and size. • Slots have names and values which are called facets. Frame Representation • • • • • • • • • Facets: The various aspects of a slot is known as Facets. Facets are features of frames which enable us to put constraints on the frames. Example: IF-NEEDED facts are called when data of any particular slot is needed. A frame may consist of any number of slots, and a slot may include any number of facets and facets may have any number of values. A frame is also known as slot-filter knowledge representation in artificial intelligence. Frames are derived from semantic networks and later evolved into our modernday classes and objects. A single frame is not much useful. Frames system consist of a collection of frames which are connected. In the frame, knowledge about an object or event can be stored together in the knowledge base. The frame is a type of technology which is widely used in various applications including Natural language processing and machine visions. Frame Representation • Let's take an example of a frame for a book Slots Filters Title Artificial Intelligence Genre Computer Science Author Peter Norvig Edition Third Edition Year 1996 Page 1152 Frame Representation • Advantages of frame representation: • The frame knowledge representation makes the programming easier by grouping the related data. • The frame representation is comparably flexible and used by many applications in AI. • It is very easy to add slots for new attribute and relations. • It is easy to include default data and to search for missing values. • Frame representation is easy to understand and visualize. • Disadvantages of frame representation: • In frame system inference mechanism is not be easily processed. • Inference mechanism cannot be smoothly proceeded by frame representation. • Frame representation has a much-generalized approach. Production Rules • Production rules system consist of (condition, action) pairs which mean, "If condition then action". It has mainly three parts: • The set of production rules • Working Memory • The recognize-act-cycle • In production rules 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. And the action part carries out the associated problem-solving steps. This complete process is called a recognize-act cycle. • The working memory contains the description of the current state of problemssolving and rule can write knowledge to the working memory. This knowledge match and may fire other rules. • If there is a new situation (state) generates, then multiple production rules will be fired together, this is called conflict set. In this situation, the agent needs to select a rule from these sets, and it is called a conflict resolution. Production Rules • Example: • IF (at bus stop AND bus arrives) THEN action (get into the bus) • IF (on the bus AND paid AND empty seat) THEN action (sit down). • IF (on bus AND unpaid) THEN action (pay charges). • IF (bus arrives at destination) THEN action (get down from the bus). • Advantages: • The production rules are expressed in natural language. • The production rules are highly modular and can be easily removed or modified. • Disadvantages: • It does not exhibit any learning capabilities and does not store the result of the problem for future uses. • During the execution of the program, many rules may be active. Thus, rule-based production systems are inefficient. Approaches to Knowledge Representation in AI • Simple Relational Knowledge – It is the simplest way of storing facts which uses the relational method. Here, all the facts about a set of the object are set out systematically in columns. – Also, this approach of knowledge representation is famous in database systems where the relationship between different entities is represented. – Thus, there is little opportunity for inference. Approaches to Knowledge Representation in AI • Example of representing simple relational knowledge. Name Age Emp ID JSR 35 100071 HSB 43 100056 SKV 42 100042 Approaches to Knowledge Representation in AI • Inheritable Knowledge – In the inheritable knowledge approach, all data must be stored into a hierarchy of classes and should be arranged in a generalized form or a hierarchal manner. – Also, this approach contains inheritable knowledge which shows a relation between instance and class, and it is called instance relation. – In this approach, objects and values are represented in Boxed nodes. Approaches to Knowledge Representation in AI • Inheritable Knowledge Example Approaches to Knowledge Representation in AI • Inferential Knowledge • The inferential knowledge approach represents knowledge in the form of formal logic. Thus, it can be used to derive more facts. Also, it guarantees correctness. • Example: Statement 1: John is a cricketer. Statement 2: All cricketers are athletes. Then it can be represented as; – Cricketer(John) – ∀x = Cricketer (x) → Athelete (x) Approaches to Knowledge Representation in AI • Procedural knowledge Procedural knowledge approach uses small programs and codes which describes how to do specific things, and how to proceed. • In this approach, one important rule is used which is If-Then rule. • Example: IF: Person having cold AND fever. THEN: Viral Fever. • In this knowledge, we can use various coding languages such as LISP language and Prolog language. • We can easily represent heuristic or domain-specific knowledge using this approach. • But it is not necessary that we can represent all cases in this approach. Knowledge-Based Agent in Artificial intelligence • An intelligent agent needs knowledge about the real world for taking decisions and reasoning to act efficiently. • Knowledge-based agents are those agents who have the capability of maintaining an internal state of knowledge, reason over that knowledge, update their knowledge after observations and take actions. • Knowledge-based agents are composed of two main parts: • Knowledge-base and • Inference system. • A knowledge-based agent must be able to do the following: • • • • • An agent should be able to represent states, actions, etc. An agent Should be able to incorporate new percepts An agent can update the internal representation of the world An agent can deduce the internal representation of the world An agent can deduce appropriate actions. Architecture of knowledge-based agent Knowledge-Based Agent in Artificial intelligence • Knowledge base: • Knowledge-base is a central component of a knowledge-based agent, it is also known as KB. • It is a collection of sentences (here 'sentence' is a technical term, and it is not identical to sentence in English). These sentences are expressed in a language which is called a knowledge representation language. The Knowledge-base of KBA stores fact about the world. • Why use a knowledge base? • Knowledge-base is required for updating knowledge for an agent to learn with experiences and take action as per the knowledge. • Inference system • Inference means deriving new sentences from old. • Inference system allows us to add a new sentence to the knowledge base. A sentence is a proposition about the world. • Inference system applies logical rules to the KB to deduce new information. • Inference system generates new facts so that an agent can update the KB. Operations Performed by KBA • Following are three operations which are performed by KBA in order to show the intelligent behavior: 1.TELL: This operation tells the knowledge base what it perceives from the environment. 2.ASK: This operation asks the knowledge base what action it should perform. 3.Perform: It performs the selected action. • Algorithm : function KB_AGENT (percept) returns an action KB : knowledge base t : time ( counter initially 0) TELL(KB, MAKE_PERCEPT_SENTENCE (percept, t) ) action = ASK(KB, MAKE_ACTION_QUERY (t) ) TELL(KB, MAKE_ACTION_SENTENCE (action, t) ) t=t+1 return action Various levels of knowledge-based agent • A knowledge-based agent can be viewed at different levels which are given below: • Knowledge level • Knowledge level is the first level of knowledge-based agent, and in this level, we need to specify what the agent knows, and what the agent goals are. With these specifications, we can fix its behavior. • For example, suppose an automated taxi agent needs to go from a station A to station B, and he knows the way from A to B, so this comes at the knowledge level. • Logical level: • At this level, we understand that how the knowledge representation of knowledge is stored. At this level, sentences are encoded into different logics. At the logical level, an encoding of knowledge into logical sentences occurs. At the logical level we can expect to the automated taxi agent to reach to the destination B. • Implementation level: • This is the physical representation of logic and knowledge. At the implementation level agent perform actions as per logical and knowledge level. At this level, an automated taxi agent actually implement his knowledge and logic so that he can reach to the destination. Issues in Knowledge Representation • The fundamental goal of knowledge Representation is to facilitate inference (conclusions) from knowledge. • The issues that arise while using KR techniques are many. Some of these are explained below. • Important Attributed: – Any attribute of objects so basic that they occur in almost every problem domain? – There are two attributed “instance” and “isa”, that are general significance. These attributes are important because they support property inheritance. Issues in Knowledge Representation • Relationship among attributes: – Any important relationship that exists among object attributed? – The attributes we use to describe objects are themselves entities that we represent. – The relationship between the attributes of an object, independent of specific knowledge they encode, may hold properties like: • Inverse — This is about consistency check, while a value is added to one attribute. The entities are related to each other in many different ways. Issues in Knowledge Representation • Existence in an ISA hierarchy — – This is about generalization-specification, like, classes of objects and specialized subsets of those classes, there are attributes and specialization of attributes. – For example, the attribute height is a specialization of general attribute physical-size which is, in turn, a specialization of physical-attribute. – These generalization-specialization relationships are important for attributes because they support inheritance. Issues in Knowledge Representation • Technique for reasoning about values — – This is about reasoning values of attributes not given explicitly. – Several kinds of information are used in reasoning, like, height: must be in a unit of length, Age: of a person cannot be greater than the age of person’s parents. – The values are often specified when a knowledge base is created. Issues in Knowledge Representation • Single valued attributes — – This is about a specific attribute that is guaranteed to take a unique value. – For example, a baseball player can at time have only a single height and be a member of only one team. – KR systems take different approaches to provide support for single valued attributes. Issues in Knowledge Representation • Choosing Granularity: – At what level of detail should the knowledge be represented? – Regardless of the KR formalism, it is necessary to know: • At what level should the knowledge be represented and what are the primitives? • Should there be a small number or should there be a large number of low-level primitives or High-level facts. • High-level facts may not be adequate for inference while Low-level primitives may require a lot of storage. Issues in Knowledge Representation • Example of Granularity: • Suppose we are interested in following facts: • Raj spotted Rahul. • This could be represented as Spotted (agent(Raj),object (Rahul)) • Such a representation would make it easy to answer questions such are: Who spotted Rahul? • Suppose we want to know: Did Raj see Rahul? • Given only one fact, we cannot discover that answer. • We can add other facts, such as Spotted(x, y) -> saw(x, y) • We can now infer the answer to the question. Issues in Knowledge Representation • Set of objects: • How should sets of objects be represented? • There are certain properties of objects that are true as member of a set but not as individual; • Example: Consider the assertion made in the sentences: “A person is very strict in the department, but he is very calm at his home” • To describe these facts, the only way is to attach assertion to the sets representing people, department, and home. Issues in Knowledge Representation • Finding Right structure: – Given a large amount of knowledge stored in a database, how can relevant parts are accessed when they are needed? – This is about access to right structure for describing a particular situation. – This requires, selecting an initial structure and then revising the choice. Issues in Knowledge Representation • While doing so, it is necessary to solve following problems: – How to perform an initial selection of the most appropriate structure. – How to fill in appropriate details from the current situations. – How to find a better structure if the one chosen initially turns out not to be appropriate. – What to do if none of the available structures is appropriate. – When to create and remember a new structure.