SoarWorkshopSemanticMemoryTutorial
NateDerbinsky
Whilewaiting…downloadWordNethttp://web.eecs.umich.edu/~soar/tutorial16
June72016 SemanticMemoryTutorial 1
Agenda
• Bigpicture• Basicusage• WordNet demo• Additionalresources
June72016 SemanticMemoryTutorial 2
Soar9
June72016 SemanticMemoryTutorial 3
SymbolicLong-TermMemories
SymbolicWorkingMemory
Procedural
Decision
Procedure
ChunkingReinforcementLearning
Action
Semantic
SemanticLearning
Episodic
EpisodicLearning
Spatial Visual SystemObject-basedcontinuousmetricspace
Perception
SoarBasicFunctions
1. Input fromenvironment2. Elaboratecurrentsituation:parallelrules3. Proposeoperatorsviaacceptable preferences4. Evaluateoperatorsviapreferences:Numericindifferentpreference5. Selectoperator6. Applyoperator:Modifyinternaldatastructures:parallelrules7. Output tomotorsystem[andaccesstolong-termmemories]
OperatorDecisionInput Output
StateElaboration
OperatorProposal
OperatorEvaluation
OperatorElaboration
OperatorApplication
June72016 EpisodicMemoryTutorial 4
SemanticMemory:BigPicture
Supportsdeliberatestorageandretrievaloflong-term“objects,”features,andrelations
June72016 SemanticMemoryTutorial 5
ArchitecturalIntegration
June72016 SemanticMemoryTutorial 6
ArchitecturalIntegrationStorage
June72016 SemanticMemoryTutorial 7
ArchitecturalIntegrationStorage
June72016 SemanticMemoryTutorial 8
ArchitecturalIntegrationStorage
June72016 SemanticMemoryTutorial 9
ArchitecturalIntegrationNon-Cue-Based Retrieval
June72016 SemanticMemoryTutorial 10
ArchitecturalIntegrationNon-Cue-Based Retrieval
June72016 SemanticMemoryTutorial 11
ArchitecturalIntegrationCue-BasedRetrieval
June72016 SemanticMemoryTutorial 12
ArchitecturalIntegrationCue-BasedRetrieval
June72016 SemanticMemoryTutorial 13
BasicUsage
• Working-memorystructure• Semantic-memoryrepresentation• Controllingsemanticmemory• Storingknowledge• Retrievingknowledge
June72016 SemanticMemoryTutorial 14
Working-MemoryStructure
Soarcreatesansmem structureoneachstate– SoarJavaDebugger
• step 5• print --exact (* ^smem *)• print s2
Eachsmem structurehasspecializedsubstructure– command:agent-initiatedactions– result:architecturalfeedback
June72016 SemanticMemoryTutorial 15
Semantic-MemoryRepresentation
Similartoworkingmemory:symbolictriples– Allidentifiersinsemanticmemoryarelong-term• Theletter-numberpair(e.g.S5orC7)ispermanentlyassociatedwiththeidentifier• Whenprinted,long-termidentifiersareprefacedwiththe@symbol(e.g.@S5or@C7)• Whendepicted,long-termidentifiersaredoublecircles
– Attributescannotbeidentifiers(currently)– Theresultinggraphisnotnecessarilyconnected
June72016 SemanticMemoryTutorial 16
ControllingSemanticMemory
Get/Setaparameter:– smem [-g|--get] <name>– smem [-s|--set] <name> <value>
SMem isdisabled bydefault.Toenableit…1. smem2. smem --set learning on3. smem
June72016 SemanticMemoryTutorial 17
StoringKnowledge
ManualMethodofappendingviacommandline(especiallyusefulforloadingexternalKBs)
AgentDeliberate(viarules)addition/modification
Note:bothmethodscanchange existingand/oraddnewknowledgeinsemanticmemory.
June72016 SemanticMemoryTutorial 18
ManualStorage
Syntax:similartoproductionRHS
smem --add {(<id1> ̂ attr1 val1 val2 ̂ attr2 val1 … )(<id2> ̂ attr3 <id1> val5 … )(<id3> ̂ attr4.attr5 <id3>)…
}
June72016 SemanticMemoryTutorial 19
ManualStorage:ExampleSoarJavaDebugger
1. smem --add {(<a> ^name alice ^friend <b>) (<b> ^name bob ^friend <a> <c>)(<c> ^name charley)}
2. smem --print
(@A1 ̂ friend @B1 ̂ name alice [+1.000])(@B1 ̂ friend @A1 @C4 ^name bob [+2.000])(@C4 ̂ name charlie [+3.000])
June72016 SemanticMemoryTutorial 20
AgentStorageSyntax
(<smem> ^command <cmd>)(<cmd> ^store <id1> <id2> …)
• Requires thatSMem isenabled (slide16)• Processedatendofphaseinwhichrulefires• Multiple identifiersmaybestoredatonce• Storageisnot recursive
Result(<smem> ^command <cmd> ^result <r>)(<cmd> ^store <id1> <id2> …)(<r> ^success <id1> <id2> …)
June72016 SemanticMemoryTutorial 21
AgentStorage:Example• SoarJavaDebugger
1. smem --set learning on2. watch 53. source4. run 4 -p5. print --depth 10 s2
sp {propose*init(state <s> ^superstate nil
-^name)-->
(<s> ̂ operator <op> +)(<op> ̂ name init)
}
sp {apply*init(state <s> ^operator.name init
^smem.command <cmd>)-->
(<s> ̂ name friends)(<cmd> ̂ store <a> <b> <c>)(<a> ̂ name alice ^friend <b>)(<b> ̂ name bob ̂ friend <a> <c>)(<c> ̂ name charley)
}
June72016 SemanticMemoryTutorial 22
ExaminingtheTrace=>WM: (30: C4 ^name charley)=>WM: (29: B1 ^friend A1)=>WM: (28: B1 ^friend C4)=>WM: (27: B1 ^name bob)=>WM: (26: A1 ^friend B1)=>WM: (25: A1 ^name alice)=>WM: (24: C2 ^store A1)=>WM: (23: C2 ^store B1)=>WM: (22: C2 ^store C4)=>WM: (21: S1 ^name friends)--- Change Working Memory (PE) ---=>WM: (33: R3 ^success @A1)=>WM: (32: R3 ^success @B1)=>WM: (31: R3 ^success @C4)
June72016 SemanticMemoryTutorial 23
Semantic-StoreStatistics
smem --stats• Nodes:numberoflong-termidentifiers• Edges:numberoffeatures/relations• Stores:numberofagentstores
June72016 SemanticMemoryTutorial 24
RetrievingKnowledgeNon-Cue-Based
Addthefeatures/relations ofaknownlong-term identifier toworkingmemory
Cue-BasedFindalong-term identifier thathasasetoffeatures/relations andaddittoworkingmemorywithitsfullfeature/relation set
Common Constraints:– Requires thatSMem isenabled (slide16)– Onlyoneperstateperdecision– Processed duringoutput phase– Onlyre-processed ifWMchangestocommands
• Meta-data(status,etc)automaticallycleanedbythearchitecture
June72016 SemanticMemoryTutorial 25
Non-Cue-BasedRetrievalSyntax
(<smem> ^command <cmd>)(<cmd> ^retrieve <long-term identifier>)
Result(<smem> ^command <cmd> ^result <r>)(<cmd> ^retrieve <long-term identifier>)(<r> ^<status> <long-term identifier>
^retrieved <long-term identifier>)
Where<status> is…– failure:<long-term identifier> isnotlong-term– success:else(addsallfeatures/relations toWM)
June72016 SemanticMemoryTutorial 26
Non-Cue-BasedRetrieval:Example• SoarJavaDebugger
1. smem --set learning on2. smem --add {
(@A1 ^name alice ^friend @B1)(@B1 ^name bob ^friend @A1 @C4)(@C4 ^name charley)}
3. sp {ncb(state <s> ^superstate nil
^smem.command <cmd>)-->
(<cmd> ^retrieve @B1)}4. run 5 -p5. print --depth 10 s26. smem --stats
June72016 SemanticMemoryTutorial 27
Non-Cue-BasedRetrieval:Debrief• Becautiousoflong-term identifiers inrules
– Onlylegalifalready insemanticstore– Willoccurviachunking
• Onlyfeatures/relations of@B1added toWM– Features/relations of@A1,@C4wouldrequireadditionalretrieve
commands
• Statisticskeptaboutnumberofretrieve commandsprocessed– smem --stats
• (“Retrieves”)
• Meta-datacleanedupduringoutput phase
June72016 SemanticMemoryTutorial 28
Cue-BasedRetrieval:Syntax(<smem> ^command <cmd>)(<cmd> ^query <q>)(<q> ^attr1 val1
^attr2 <val2> ^attr3 @V3 …)
Theaugmentationsofthequery formhardconstraint(s),baseduponthevaluetype…
• Constant:exactmatch• Long-Term ID:exactmatch• Short-Term ID:wildcard
June72016 SemanticMemoryTutorial 29
Cue-BasedRetrieval:Result(<smem> ^command <cmd> ^result <r>)(<cmd> ^query <q>)(<r> ^<status> <q>
^retrieved <long-term identifier>)
Where<status> is…– failure:nolong-termidentifiersatisfiestheconstraints– success:else(addsallfeatures/relationstoWM)
Tiesarebrokenbyabias(default:recency)– Seeactivation-mode parameterinManual– Whenyouexecutesmem -p,thebiasvalueisindicated
June72016 SemanticMemoryTutorial 30
Cue-BasedRetrieval:Example• SoarJavaDebugger
1. smem --set learning on2. smem --add {
(@A1 ^name alice ^friend @B1)(@B1 ^name bob ^friend @A1 @C4)(@C4 ^name charley)}
3. sp {cbr(state <s> ^superstate nil
^smem.command <cmd>)-->
(<cmd> ^query.name alice)}4. run 5 -p5. print --depth 10 s26. smem --stats
June72016 SemanticMemoryTutorial 31
Prohibition
Cue-basedretrievalscanoptionallyprohibittheretrievalofone-or-morelong-termidentifiers
Syntax(<smem> ^command <cmd>)(<cmd> ^prohibit <lti-1> <lti-2> …)
June72016 SemanticMemoryTutorial 32
Prohibition:Example• SoarJavaDebugger
1. smem --set learning on2. smem --add {
(@A1 ^name alice ^friend @B1)(@B1 ^name bob ^friend @A1 @C4)(@C4 ^name charley)}
3. sp {prohibit(state <s> ^superstate nil
^smem.command <cmd>)-->
(<cmd> ^query.name <some-name>^prohibit @A1 @C4)}
4. run 5 -p5. print --depth 10 s2
June72016 SemanticMemoryTutorial 33
AlsoUseful:ManualQuery
smem -q {(<cue> ^name charley)}
June72016 SemanticMemoryTutorial 34
WordNetDemohttps://github.com/SoarGroup/Domains-WordNet
• ScriptstoconvertWN-LEXICALtoSMem– Output:smem --add { …• >821Klong-termidentifiers,>3.97Medges,~88MB
– Source:~5-10minutes,~1GBmemory
• SMem usesaSQLitebackend– Hastheabilitytosavesemanticstorestodiskandusedisk-baseddatabases• smem --backup<filename>
June72016 SemanticMemoryTutorial 35
WordNet:MakeDiskStore• SoarJavaDebugger– source wn.soar
• ~5-10minutes– smem --stats– smem --backup path/to/filename.db
• ~10seconds
• SoarJavaDebugger– smem --set path path/to/filename.db– smem --set database file– smem --stats
June72016 SemanticMemoryTutorial 36
WordNet:Representation
June72016 SemanticMemoryTutorial 37
“sense”ofthe“verb”to“soar”
“gloss”withthe“synset-id”200155406
smem -q {(<c> ̂ isa s ^ss-type v ^word soar)}
(@S194181 ̂ isa s ^sense-number 4 ^ss-type v ^synset-id 200155406 ^tag-count 1 ^w-num 1 ^word soar ̂ word-lower soar [+194177.000])
smem -q {(<c> ̂ isa g ^synset-id 200155406)}
(@G270 ^gloss |go or move upward; 'The stock market soared after the
cease-fire was announced'| ^isa g ^synset-id 200155406 [+425386.000])
WordNet Taskwn-senses.soar
Findalldefinitions,givenlexicalword/POS– High-levelalgorithm
1. query:̂ isa s ^word lex ^ss-type pos
2. Ifsuccessfula) query:̂ isa g ^synset-id <sense ^synset-id>b) Ifsuccessful
» write <gloss ^gloss>c) prohibit: <sense>d) Loop
3. Elsea) (halt)
June72016 SemanticMemoryTutorial 38
Eaters!
June72016 SemanticMemoryTutorial 39
AdditionalResources
• Documentation• Readings
June72016 SemanticMemoryTutorial 40
Documentation
SeetheSoarManualandTutorial
AdditionalTopics– Detailsofintegrationwithothermechanisms– Retrievalbiases– Performance– Usage:commands,parameters,statistics,etc.…
June72016 SemanticMemoryTutorial 41
SelectReadingshttp://soar.eecs.umich.edu/Soar-RelatedResearch
2006– IntegratingSemanticMemoryintoaCognitiveArchitecture
• YongjiaWang,JohnE.Laird(TechnicalReport)
2010– ExtendingSoarwithDissociatedSymbolicMemories
• NateDerbinsky,JohnE.Laird(AISB)– TowardsEfficientlySupportingLargeSymbolicMemories
• NateDerbinsky,JohnE.Laird(ICCM)
2011– PerformanceEvaluationofDeclarativeMemorySystemsinSoar
• JohnE.Laird,NateDerbinsky,JonVoigt(BRIMS)– AFunctional Analysis ofHistoricalMemoryRetrievalBiasintheWord SenseDisambiguationTask.
• NateDerbinsky,JohnE.Laird(AAAI)
2012– Functional InteractionsbetweenMemoryandRecognitionJudgments
• JustinLi,NateDerbinsky,JohnE.Laird(AAAI)
2014– ACaseStudyofKnowledgeIntegrationAcrossMultipleMemoriesinSoar
• JohnE.Laird,Shiwali Mohan(BICA)
June72016 SemanticMemoryTutorial 42