25
  Quick Itroduction to the ACT-R Cognitive Architecture Łukasz Stafiniak, Instytut Informatyki Uniwersytetu Wrocławskiego My notes after reading the ACT-R 6 tutorials.

Łukasz Stafiniak, Instytut Informatyki Uniwersytetu ...lukstafi/pmwiki/uploads/AGI/ACT-R.pdf · RHS1, RHS2 can request such buffer, and if RHS1 does, LHS2 can at most query it for

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Łukasz Stafiniak, Instytut Informatyki Uniwersytetu ...lukstafi/pmwiki/uploads/AGI/ACT-R.pdf · RHS1, RHS2 can request such buffer, and if RHS1 does, LHS2 can at most query it for

  

Quick Itroduction to the ACT­R Cognitive Architecture

Łukasz Stafiniak, Instytut Informatyki Uniwersytetu Wrocławskiego

My notes after reading the ACT-R 6 tutorials.

Page 2: Łukasz Stafiniak, Instytut Informatyki Uniwersytetu ...lukstafi/pmwiki/uploads/AGI/ACT-R.pdf · RHS1, RHS2 can request such buffer, and if RHS1 does, LHS2 can at most query it for

  

ACT­R is a Production System

Procedural Knowledge: production / transition rules Manipulating named attribute­value structures: 

mutable chunks with physical identity (like objects) Patterns match the AV structures, which can have other 

chunks as constants in slots

State factorized into a fixed set of modules and their associated buffers: for any number of modules LHS queries a module or matches a chunk in a buffer,  RHS requests action from a module or modifies a chunk 

in a buffer; modules can repeat in both LHS and RHS.

Page 3: Łukasz Stafiniak, Instytut Informatyki Uniwersytetu ...lukstafi/pmwiki/uploads/AGI/ACT-R.pdf · RHS1, RHS2 can request such buffer, and if RHS1 does, LHS2 can at most query it for

  

ACT­R Production Syntax (P prod­name =module1> attribute =variable ?module2> query value ==> =module1> attribute new­value +module2> request =variable) prod­name ID for displaying and manipulation =variable binds a value across multiple occurrences 

in both LHS and RHS, must occur in LHS =module1> in LHS matches a chunk in buffer of 

module named ”module1” and binds it to variable =module1; in RHS modifies the chunk =module1

?module2> asks ”module2” about query

+module2> requests action from ”module2”

Page 4: Łukasz Stafiniak, Instytut Informatyki Uniwersytetu ...lukstafi/pmwiki/uploads/AGI/ACT-R.pdf · RHS1, RHS2 can request such buffer, and if RHS1 does, LHS2 can at most query it for

  

ACT­R Retrieval Module: Memory

Declarative Knowledge is a store of chunks Put an AV structure to the right of +retrieval> 

to get from it a chunk with at least those AV pairs A copy – different chunk – goes into the retrieval buffer

Some time later (another production can fire in the meanwhile) you can match the chunk with =retrieval>

When a chunk is removed from any buffer, it goes into the retrieval store: removed = memorized Merged with a structurally equal chunk if already there

Page 5: Łukasz Stafiniak, Instytut Informatyki Uniwersytetu ...lukstafi/pmwiki/uploads/AGI/ACT-R.pdf · RHS1, RHS2 can request such buffer, and if RHS1 does, LHS2 can at most query it for

  

More on ACT­R Productions

­,<,>,<=,>= before an AV pair on LHS means ”different than” (any value), arithmetic comparison

­ before a buffer identifier on RHS means ”remove the chunk from the buffer”, e.g. ­retrieval> By default, if a chunk is matched on LHS but not on 

RHS, it is harvested – automatically removed A chunk can be modified and memorized in one step

After matching a buffer with =module>, use =module to refer to its chunk

On RHS, !output! (Writes out =text)

Page 6: Łukasz Stafiniak, Instytut Informatyki Uniwersytetu ...lukstafi/pmwiki/uploads/AGI/ACT-R.pdf · RHS1, RHS2 can request such buffer, and if RHS1 does, LHS2 can at most query it for

  

ACT­R Goal and Imaginal Modules

They are just buffers to build and manipulate chunks goal> is for control state, immediate effects imaginal> is a scratchpad, creation/modification 

takes time (to match experimental data) Remember you have to match a buffered chunk =module> on LHS before you can modify it (RHS)

With harvesting on (default), to keep a chunk in a buffer without modifying it, put =module>, without any AV structure, on RHS

Page 7: Łukasz Stafiniak, Instytut Informatyki Uniwersytetu ...lukstafi/pmwiki/uploads/AGI/ACT-R.pdf · RHS1, RHS2 can request such buffer, and if RHS1 does, LHS2 can at most query it for

  

ACT­R as a Software System

ACT­R is a Lisp software with a Tcl­Tk graphical interface, to write models: cog. psych. experiments, and simulate the ACT­R theory agent on them

Start with (load ”./load­act­r­6.lisp”) In another shell, cd actr6/environment/gui ; wish starter.tcl

(start­environment)

(Re)load models and step/inspect from GUI, but (run­experiment) and observe trace in Lisp

Experiments often have their own GUI window

Page 8: Łukasz Stafiniak, Instytut Informatyki Uniwersytetu ...lukstafi/pmwiki/uploads/AGI/ACT-R.pdf · RHS1, RHS2 can request such buffer, and if RHS1 does, LHS2 can at most query it for

  

Programming in ACT­R

Chunks are typed, declare with (chunk­type tyname attrib1 attrib2 ...)

Attribute isa specifies chunk’s type, unspecified attributes of a created chunk have value nil, variable in a pattern cannot match nil

Add (e.g. initial) chunks to the store with (add­dm (chunk­name isa tyname attr1 val1...) ...)

Set initial contents of the goal buffer with    (goal­focus chunk­name)

Page 9: Łukasz Stafiniak, Instytut Informatyki Uniwersytetu ...lukstafi/pmwiki/uploads/AGI/ACT-R.pdf · RHS1, RHS2 can request such buffer, and if RHS1 does, LHS2 can at most query it for

  

ACT­R Vision Module

The vision module has a ”visual­location” buffer for location chunks of to­be­attended­to objects,

and a ”visual” buffer for details of attended objects. The ”protocol” is: (a point is a separate production)

request location +visual­location> isa visual­location AV­details about­loc

request attention  =visual­location> isa visual­location ?visual> state free ==> +visual> isa move­attention screen­pos =visual­location

get information about object from =visual>

Page 10: Łukasz Stafiniak, Instytut Informatyki Uniwersytetu ...lukstafi/pmwiki/uploads/AGI/ACT-R.pdf · RHS1, RHS2 can request such buffer, and if RHS1 does, LHS2 can at most query it for

  

ACT­R Vision Module Details

location details  :attended nil location of recently unattended obj.

attributes starting with : are not part of the chunk, they’re transferred directly to the module as request parameters

screen­x and screen­y coordinates in the window height, width (in pixels), color (e.g. black) and kind (e.g. text) of the object

you can pick or compare with constants, variables, relative values lowest and highest, the corresponding attribute of the currently attended object current, RHS­only variables e.g. &x, an object :nearest another location (current or stored)

Page 11: Łukasz Stafiniak, Instytut Informatyki Uniwersytetu ...lukstafi/pmwiki/uploads/AGI/ACT-R.pdf · RHS1, RHS2 can request such buffer, and if RHS1 does, LHS2 can at most query it for

  

ACT­R Vision Module Details object details: isa kind (e.g. text, line, oval), screen­pos location chunk, value (e.g. ”string” for text), color, height, width

buffer stuffing puts an :attended new (object that just appeared) location into an empty visual location buffer, so that +visual­location> is not needed when expecting an object (reactivity)

finsts: the visual module’s :attended and retrieval module’s :recently­retrieved hold true only for a small fixed­length queue of elements

there’s an auditory module: aural­location etc

Page 12: Łukasz Stafiniak, Instytut Informatyki Uniwersytetu ...lukstafi/pmwiki/uploads/AGI/ACT-R.pdf · RHS1, RHS2 can request such buffer, and if RHS1 does, LHS2 can at most query it for

  

ACT­R Motor Module

Only concerned with ”hand movements”. ”Protocol” e.g.: ?manual> state free ==> +manual> isa press­key key =letter

This module can also control mouse pointer and other devices.

There’s a ”vocal” module that pretends to speak:     ?vocal> state free ==> +vocal> isa speak string =val; it can also subvocalize (a time waster to tune into experimental data)

Page 13: Łukasz Stafiniak, Instytut Informatyki Uniwersytetu ...lukstafi/pmwiki/uploads/AGI/ACT-R.pdf · RHS1, RHS2 can request such buffer, and if RHS1 does, LHS2 can at most query it for

  

Base and Spreading Activation Enable subsymbolic computations (sgp :esc t) A chunk with maximal activation among those that 

match will be retrieved; noise is  /( + (( -1 1 exp t E )/ ))A s

otherwise, retrieval failure, t– threshold (sgp :rt t) time of retrieval= * (- )F exp A , time of failure= * (- )F exp t

A = B(how often retrieved) + Spr(parent or sibling of a buffered chunk) + Partial match + Noise

=B (∑ln - )=t^ d (∑ /ln 1 ),t  t–time since ith presentation B≈ ( )- . ( ),ln 2n 0 5ln L  n–# of presentations, L–lifespan In extras,  ( )= * ( - )+ , ( )= ( )+d i c e^m i 1 a m i B i noise

Page 14: Łukasz Stafiniak, Instytut Informatyki Uniwersytetu ...lukstafi/pmwiki/uploads/AGI/ACT-R.pdf · RHS1, RHS2 can request such buffer, and if RHS1 does, LHS2 can at most query it for

  

Base and Spreading Activation ( )=Spr i ∑ ∑ ( ) ( ),k j W kj S ji   ( )W kj – amount of 

activation from source j in buffer k, j – chunks in slots of chunk in buffer k

( )=S ji 0, j≠i and i is not a parent of j ( )= - ( ( ))S ji S ln fan j ,  ( )f an j – 1+ # of parents of j By default, activation only from the goal,   

( , )= /W goal j 1 n, n – # of slots, change e.g. (sgp :imaginal­activation 0.5)

( )=PartM i ∑ * ( , )l P M l i ,  ( , )M l i – similarity for slot l maximal similarity = 0, maximal difference = ­1

Page 15: Łukasz Stafiniak, Instytut Informatyki Uniwersytetu ...lukstafi/pmwiki/uploads/AGI/ACT-R.pdf · RHS1, RHS2 can request such buffer, and if RHS1 does, LHS2 can at most query it for

  

ACT­R Production Utilities Production with maximal utility among those that 

match will be selected; with noise, the prob. is ( )= ( ( )/Pr i exp U i ) / 2s ∑ j ( ( )/exp U j )2s

The difference learning is very simple ( )( )= ( )( - ) + Ui n Ui n 1 [ ( )( )- ( )( - )]Ri n Ui n 1

( )( )R i n – the closest reward after nth application of i minus the time that has passed from the application to the occurrence of the reward no dynamic programming – resembles ”Monte Carlo” RL all rewards are final ”additive” discounting

Page 16: Łukasz Stafiniak, Instytut Informatyki Uniwersytetu ...lukstafi/pmwiki/uploads/AGI/ACT-R.pdf · RHS1, RHS2 can request such buffer, and if RHS1 does, LHS2 can at most query it for

  

ACT­R Frustration Model Not distributed yet with ACT­R 6. Inspired by an experiment: one lever is reinforced 

until the monkeys fixate on pressing it, then reinforcement is switched to the other lever.

Long­term and short­term global estimates of rewards:  ( )= ( - )+SR n SR n 1 ( )[ ( )- ( - )], sr Rn SRn 1

( )= ( - )+( )[ ( )- ( - )], LRn LRn 1 l r Rn LRn 1 ( )= . , sr 0 008( )= . .l r 0001

Adjusting the noise parameter:  ( )= ( - )+s n s n 1 ( )s[ ( )- ( - )], ( )= ( , *( ( )- ( ))], F n s n 1 F n max 1 b LR n SR n( )= . , = . s 005 b 4 Increases noise when LR­SR>1/b

Worked great for monkeys, but so many parameters!

Page 17: Łukasz Stafiniak, Instytut Informatyki Uniwersytetu ...lukstafi/pmwiki/uploads/AGI/ACT-R.pdf · RHS1, RHS2 can request such buffer, and if RHS1 does, LHS2 can at most query it for

  

ACT­R Production Compilation

Composition of rules: (P p2 LHS2==>RHS2) fires right after (P p1 LHS1==>RHS1)

The compiled rule (P ”p1&p2” LHS==>RHS) LHS=Inst(LHS1)+CompL, RHS=CompR+Inst(RHS2)

Buffers classified into composition styles motor style buffers: they never hold a chunk; only one of 

RHS1, RHS2 can request such buffer, and if RHS1 does, LHS2 can at most query it for state busy

perceptual style buffers: if RHS1 makes a request on such buffer, then p2 cannot operate on the same buffer

Page 18: Łukasz Stafiniak, Instytut Informatyki Uniwersytetu ...lukstafi/pmwiki/uploads/AGI/ACT-R.pdf · RHS1, RHS2 can request such buffer, and if RHS1 does, LHS2 can at most query it for

  

ACT­R Production Compilation

Buffers classified into composition styles [cont] retrieval style buffer: declarative memory grows 

monotonically; RHS1 retrieval requests can be instantiated if LHS2 does not query retrieval failure

goal style buffer (goal and imaginal): LHS=LHS1+(LHS2­RHS1), RHS=(RHS1~RHS2)+RHS2 LHS2­RHS1: conditions not provided by actions RHS1~RHS2: actions that are not undone RHS1 and RHS2 cannot both make a request

Page 19: Łukasz Stafiniak, Instytut Informatyki Uniwersytetu ...lukstafi/pmwiki/uploads/AGI/ACT-R.pdf · RHS1, RHS2 can request such buffer, and if RHS1 does, LHS2 can at most query it for

  

ACT­R Production Compilation ”p1&p2” initial utility is 0, but each time it is 

recreated, it receives p1’s utility as a reward using the difference equation, so it approaches p1’s utility.

When ”p1&p2” starts firing on its own (due to noise), its utility can surpass that of p1, as it leads to rewards sooner.

Defining a production with P* you can use variable slot names but only if the slot variable is explicitly bound, e.g. a value of a named slot (1 level indirect).

A concise set of interpretation rules can compile declarative facts into specialized code (rules).

Page 20: Łukasz Stafiniak, Instytut Informatyki Uniwersytetu ...lukstafi/pmwiki/uploads/AGI/ACT-R.pdf · RHS1, RHS2 can request such buffer, and if RHS1 does, LHS2 can at most query it for

  

ACT­R Production Compilation

When declarative knowledge leaves many interpretation choices, production compilation leads to incremental search for high­utility programs.

But it does not fix scripts: productions are single actions.

I don’t like having space wasted on a slide ;­)

Page 21: Łukasz Stafiniak, Instytut Informatyki Uniwersytetu ...lukstafi/pmwiki/uploads/AGI/ACT-R.pdf · RHS1, RHS2 can request such buffer, and if RHS1 does, LHS2 can at most query it for

  

ACT­R Blending Module Generalization mechanism that produces contiuously 

varying answers. See extras/blending to turn it on. Retrieve best compromise value by integrating 

possible answers weighted by retrieval probability. = . ( ) V arg min V ∑ ( )*( - ( , ( ))i P i 1 Sim V V i ^2

Generalizes merging: the most active pool of identical AV structures. Could generalize partial matching, but see (*).

+blending> like +retrieve> but independent. The explicitly given values will be preserved. (*) The implementation uses the retrieval module to 

select candidates (without discarding low­activated).

Page 22: Łukasz Stafiniak, Instytut Informatyki Uniwersytetu ...lukstafi/pmwiki/uploads/AGI/ACT-R.pdf · RHS1, RHS2 can request such buffer, and if RHS1 does, LHS2 can at most query it for

  

ACT­R More Extras WNLexicon: a module for querying WordNet 3.0.

Based on the Prolog bindings.

Threads: multi­tasking Extends the goal buffer to hold multiple chunks, e.g.:

(P start­two­goals =goal> isa curr ==> +goal> isa next1 +goal> isa next2)

Multiple calls to goal­focus have the same effect. Use ­goal> to halt the current (i.e. matched) goal, other 

goals will still run. Style: check for empty buffer before requesting a chunk. 

(I.e. don’t act upon that you don’t need its old contents.)

Temporal: nonlinear clock / timer.

Page 23: Łukasz Stafiniak, Instytut Informatyki Uniwersytetu ...lukstafi/pmwiki/uploads/AGI/ACT-R.pdf · RHS1, RHS2 can request such buffer, and if RHS1 does, LHS2 can at most query it for

  

ACT­R Productions – More Details Queries specified for every buffer/module:

buffer: empty, full, requested, unrequested (e.g. stuffing)

state: free, busy, error; error: t, nil

Discouraged super­conditions/actions: !eval! (any lisp =code) – nil causes 

production to fail; ACT­R variables are instantiated ![mv­]bind! =var­name (code) – also binds 

the result[s]

buffer overwrite: e.g. =goal> =chunk, (from a slot), or =goal> =imaginal (from a buffer)

Page 24: Łukasz Stafiniak, Instytut Informatyki Uniwersytetu ...lukstafi/pmwiki/uploads/AGI/ACT-R.pdf · RHS1, RHS2 can request such buffer, and if RHS1 does, LHS2 can at most query it for

  

ACT­R Productions – More Details +retrieval> =chunk, the chunk is expanded 

to its AV structure. !safe­eval! like !eval!, allows compiling­out. Use !stop! as debug breakpoint. When P*­defined RHS has a slot­variable with 

value that does not belong to the chunk type, the chunk type is extended.

All parts or ACT­R are called modules: printing, naming, random, buffer trace, procedural, utility, production compilation, goal, imaginal, declarative, device, vision, audio, motor, speech.

Page 25: Łukasz Stafiniak, Instytut Informatyki Uniwersytetu ...lukstafi/pmwiki/uploads/AGI/ACT-R.pdf · RHS1, RHS2 can request such buffer, and if RHS1 does, LHS2 can at most query it for

  

References

All the documents in the ACT­R 6 distribution.