Questions about nengo_spa module


#1

Hello.

I study Question-Answering system in SPA, and I have used Nengo.spa module not Nengo_spa so far.
I have some questions about nengo_spa modules.

Q1. How to define SP(Semantic Pointer) for sentences.
Especially, I’m interested in Question-Answering for sentence. In Nengo.spa module, I can define SP for sentence with vocab.add method as follows:

import nengo.spa as spa
vocab = spa.Vocabulary(dimensions=64)
vocab.add('Sentence1',vocab.parse('The_Dog*Agt_Chase + Chase*Verb + The_Boy*Theme_Chase').v)

Like this, in Nengo.spa module, I don’t have to declare individual phrase (like The_Dog, Agt_Chase, Chase, and so on) in advance. However, in Nengo_spa module, the following code causes error:

import nengo_spa as spa
vocab = spa.Vocabulary(dimensions=64)
vocab.add('Sentence1',vocab.parse('The_Dog*Agt_Chase + Chase*Verb + The_Boy*Theme_Chase').v)

and the error is:

SpaParseError: Error parsing expression 'The_Dog*Agt_Chase + Chase*Verb + The_Boy*Theme_Chase' with 64-dimensional vocab at 0x107826eb8: name 'The_Dog' is not defined

This error tells that SP for The_Dog is not defined. So, I must do

phrase = ['The_Dog','Agt_Chase','Chase','Verb','The_Boy','Theme_Chase']
vocab.populate(';'.join(phrase))

before using vocab.add method. So is there good way for defining SP for sentence?

Q2. Is there the way for clean-up of the SP which is the result of unbinding?
I try to get an appropriate phrase SP by unbinding a complex sentence SP with a cue SP.
For example, a complex sentence is :

A*B + C*D + E*(F*G + H*I + J*(K*L + M*N + O*P))

and unbind it with E*J*O to get P. Then, this is more difficult than unbinding with C to get D because of much noises.

Can I get appropriate SP P with clean-up, like “unbinding with E” → “clean-up” → "unbinding with J"→ “clean-up” → unbinding with O?
If so, I don’t know how to implement.

Q3. Finally, which is better nengo.spa module and nengo_spa module?

Thank you.


#2

Q1: I think you already figured it out? You just need to add all the individual phrases beforehand with populate. If you want the old behaviour, you can also declare the vocabulary with strict=False, but this can easily hide typos in the Semantic Pointer names.

Q2: Yes, if you now the set of possible vectors in each clean-up step. There are slightly different ways to do the clean-up, but essentially you will usually do a dot product of the unbound vector with all potential (clean) vectors and then choose the clean vector with the highest similarity for the next unbinding.

Q3: nengo_spa is better, despite a number of bugfixes, you can find a llist of new features here. The only reason not to switch might be that some parts of the API are still changing a little bit, though it has been getting more stable with every release.


#3

OK, I understand. Thank you!