1 / 20

Language Understanding and Rete Match

Language Understanding and Rete Match. Content of this lecture: Demo of Façade Language Understanding in Façade Efficiency of RA cycle The Rete Algorithm. Properties of game: Characters controlled by AI Two computer, one human player Bots talk, human types The story

rebekah
Télécharger la présentation

Language Understanding and Rete Match

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Language Understanding and Rete Match Content of this lecture: Demo of Façade Language Understanding in Façade Efficiency of RA cycle The Rete Algorithm

  2. Properties of game: Characters controlled by AI Two computer, one human player Bots talk, human types The story Trip and Grace have wedding anniversary Relation is not very good Human visitor influences developments DEMO: Video 8 minutes (YouTube 5) True interactive play interactivestory.net Façade: Interactive Plot Development Michael Mateas, Andrew Stern: Natural Language Understanding in Façade: Surface Text processing, LNCS 3105, pp3-13. Expert Systems 4

  3. Bert gaat naar de supermarkt. Bert vindt melk in in de koeling. Bert praat met Jolanda. Bert geeft Jolanda geld. Questions about this text: Why does Bert give the money? Why is Jolanda there? How much does Bert give? Answers require large amount of background knowledge. Language Understanding Expert Systems 4

  4. Syntax Level: structure What sentences are well-formed What is the role of each word in the sentence structure Challenge:Fruit flies like bananasTime flies like an arrow Semantic Level: meaning Assign a precise meaning to each word and construct Synthesize meaning of sentence (story) Three levels of Language Processing Pragmatic Level: goal • Map text to desire, opinion, statement, question … • Discourse act • - Do you have a pen?- Yes. Expert Systems 4

  5. Façade maps text to Discourse Acts Discourse Acts with one character attribute: • (DAAgree ?char) • (DADisagree ?char) • (DAThank ?char) • (DAFlirt ?char) • (DAGoodbye ?char) More Discourse Acts: • (DASysDontUnd) • (DAExpress ?ch ?tp) • (DACriticize ?ch ?lev) • (DAAdvice ?par ?ch) There exist 24 DA’s Examples of sentences: • (DAFlirt ?ch): “You look gorgeous”, “Kiss me”. • (DADisagree ?ch): “Fat chance”, “I don’t think …”. • (DACriticize ?ch ?lev): “You’re weird”, “Kiss off”. • (DAReferTo ?ch ?obj): “When did you get the couch?” Expert Systems 4

  6. Between text and Discourse Acts Intermediates group words into a meaning class • iIs fact generalizes am, are, is, seems, sounds • iPosDescr generalizes friend, good, big • iChar stands for a reference to a character Intermediates map word combinations to meaning • iChar + iIs + iPosDesc  iPraise Combinations of intermediates form Discourse Acts • (iChar ?ch) + iGreet  (DAGreet ?ch) It will be very easy to fool Façade… … but natural utterances receive natural response! Expert Systems 4

  7. Store input sentence in word occurrence facts: Ex: “Grace, kiss me” Template per iNtermediate Storage in Façade: CLIPS/JESS Template per DA: Expert Systems 4

  8. Recognize a flirt… • You are gorgeous • I find you more than gorgeous • You have gorgeous eyes (defrule rec-flirt (wo you ?s1 ?e1) (wo gorgeous ?s2 ?e2) (?e1 < ?s2) => (assert (iFlirt ?s1 ?e2)) ) Problems with this? • This is not how language HE thinks • What if I find you all but gorgious… Expert Systems 4

  9. The template language • (X Y): matches occurrence of X followed by Y • (X | Y): matches sentence with X or with Y • *: wildcard • (template ( you * (gorgeous | brilliant))) • Template conditions are automatically rewritten to true CLIPS conditions on wo and iNtermediate facts • Recognized iFacts are stored with position:(template ( you * iPositivePersonDesc)) Higher-order description of conditions facilitates knowledge acquisition from language expert. Expert Systems 4

  10. Not and other idiomatic expressions • Idiomatic rules match word combinations that change each other’s pragmatic meaning: (template (not iPositivePersonDesc)) => (assert iNegativePersDesc) • The idiomatic rules remove the recognized terms (retract iPositivePersonDesc) (retract not) • Gets rid of fruit fly problem…… if combination is recognizedin time!! Expert Systems 4

  11. Organization of Façade NLU Rule Base • Patterns and synonymsExample: iIs, iGreet, … • Idiomatic expressions (1000 rules!)Example: pisses me off, kiss off (vs. kiss me!!).Use retraction! • Negative wordsExample: not bad • Combination rules recognize combinations as (sub-) discourse acts • These classes are ordered by salience • The rule base reflects human (conscious) thinking about language • Anaphora resolution: store referent for it, he, she. Expert Systems 4

  12. 1: Match 2: Choose 3: Apply Efficiency of Recognize-Act Cycle • Actual work: Apply. • Interpreter spends >90% of time in Match! • Finds all matches to execute one rule:Partial matching • Matching processes the same facts over and over again: Redundancy! Within-cycle Between-cycleRete algorithm Expert Systems 4

  13. Partial construction of conflict set • Combine Match and Choose (into recognize) • Search for applicable rules and execute first found • Look for instantiations of rules in order of decreasing salience • For Recency: Match facts in order of decreasing time stamps. • For Breadth: order of increasing time stamps. Improvement may be significant Practical programs still run impractically ssslllooowww… Need: RETE Algorithm (Forgy, 1982) Expert Systems 4

  14. wo word=you word=gorgeous T1 T2 le.ep < ri.sp Conflict set for rec-flirt Flirting by Database • Recognize as iFlirt:(template (you * gorgeous)) • (wo (word you) (sp ?s1) (ep ?e1))(wo (word gorgeous) (sp ?s2) (ep ?e2))(?e1 < ?s2) • Describe as select and conditional join operations:T1 = SEL (word = you) [wo]T2 = SEL (word = gorgeous) [wo]CS = CJOIN (le.ep < ri.sp)[T1,T2] • Recognize as negation:(template (not gorgeous)) Expert Systems 4

  15. wo word=you word=gorgeous word=not T1 T2 T3 T2 le.sp = ri.ep+1 le.ep < ri.sp Conflict set for rec-flirt Conflict set for rec-neg Eliminate within-cycle redundancy • Build data flow network • Combine common paths • Each operation is executed only once • Less within-cycle redundancy • Some redundancy remains • Compute only once from program Expert Systems 4

  16. wo word=you word=gorgeous word=not T1 T2 T3 T2 le.sp = ri.ep+1 le.ep < ri.sp Conflict set for rec-flirt Conflict set for rec-neg Eliminate between-cycle redundancy • Retain tables of partial matches • Addition of fact:Propagate token through Rete graph • Removal of fact:Propagate negative token through graph Expert Systems 4

  17. wo word = you sp > 3 len = 4 Alpha C1 Alpha C2 Rete in CLIPS: Pattern Network • For each condition, CLIPS builds a pattern network • Condition 1:(wo (word you) (sp ?s1&>3) (ep ?e1&<?s2)) • Condition 2:(wo (word you) (sp ?s1&>3) (len 4) ) • Share patterns for conditions if first parts are the same Expert Systems 4

  18. Beta 0 Beta 1 Beta 2 Alpha C1 Alpha C2 Alpha C3 J1 J2 J3 Alpha C4 J4 ConfSet 2 Rete in CLIPS: Join Network • For each rule, CLIPS builds a JOIN network • One JOIN per condition • Rule 1:(defrule donop (C1) (C2) (C3) => ) • Rule 2:(defrule nopdo (C1) (C2) (C4) => ) • Left, right memoryAlpha, Beta memory • First Beta: dummy ConfSet 1 Expert Systems 4

  19. Facts matching condition i An eye on efficiency • Compare: #Ai #Bi (neigh ?x ?y)n-1 n-1(holds ?x ?a)n n-1(holds ?y ?b)n n-1 • To:(holds ?x ?a)n n(holds ?y ?b)n n2(neigh ?x ?y)n-1 n-1 • Put first: Conditions that rarely match facts • Put first: Conditions that restrict subsequent facts • Put last: Conditions matching volatile facts Fact combinations matching first i cond. #Bi < #Ai * #Bi-1 Expert Systems 4

  20. Summary and conclusions • Language processing in Façade:Pragmatic language level is important for intelligent reaction • Mapping to pragmatics is implemented with rules • Knowledge acquisition usually requires to represent knowledge at a level higher than rules • Interpreters spend their time in Matching • Rete Algorithm avoids within-cycle and between-cycle redundancy • Know and use its properties to tune for efficiency Expert Systems 4

More Related