Archi
Expert
Posts: 19
Joined: Wed May 03, 2017 11:13 pm

Learning/Memorizing issues

Thu Jun 08, 2017 6:56 am

I'm trying to make use of learn and remember tags to make bot remember certain things. This works to some degree, but not the way I want to.

Basically I'm trying to make a very simple "remember that X is Y", but with a few important points that I have no idea how to proceed with.

1. I want to receive full file that I should save in Learning event.

Right now I'm getting only small segment that is being currently remembered. Shouldn't Syn.Bot merge that itself with other already remembered concepts/models and provide me with final file that I should save? Right now I'm not able to make <Learn> work with anything but the very last learn invocation, so in official learning example here, I can't teach bot that both apple and pineapple is a fruit - only last one is being saved in final XDocument that I'm receiving in an event.

2. I want to maintain unique patterns.

This is simple and requires above to be done first. If I say "apple is a fruit", I get one model. If I say "pineapple is a fruit", I'll get 2 models in the event - one with apple, one with pineapple. Now when I say again "apple is a vegetable", old apple model should get overwritten with vegetable now, while pineapple should still stay as a fruit (as opposed to creating 3rd model with apple once again).

3. Concepts that are being memorized should be user concepts.

I read that I should guess on my own which memorized file should be loaded to which user - this introduces extra pre-parsing hassle on the developer, for no real reason, because we have user concepts already available (and even users automatically being created now). If Syn.Bot expects us to load given memorized SIML file for given user, why it can't be user concept right away? This way we wouldn't need to know where to load what, parser would guess itself that it's memorized concept for given user.


Is above possible to do in Syn.Bot yet? I'm trying to make all of that possible at the same time, and while point 3 is rather misc and I can maintain proper hierarchy and loading myself, I have no idea how I should do point 1 and 2 without a bunch of code on my side that would not only merge old file with new XDocument, but also remove duplicates. I don't want to do that, since I believe that feature should be available in Syn.Bot itself as a base for making <Learn> tag useful, since in current form it's far too limited, to the point that developer must handle everything that Syn.Bot should - I believe that on the end we should only have a request to save given file.

Thank you in advance for looking into this. If what I'm asking for is already possible to do in one way or another, I'd appreciate help as well :).

User avatar
Leslie
Lead Software Architect
Posts: 375
Joined: Fri Sep 14, 2012 12:20 pm
Contact: Website

Re: Learning/Memorizing issues

Fri Jun 09, 2017 4:07 am

1. I want to receive full file that I should save in Learning event.

Well, the SIML decision tree is hybrid in nature and gets composed of tons of static and dynamic nodes after a Knowledge-Base is loaded. The graph stores a lot of pre-processed node information to the extent where deserialization is not possible. This is one of the many reasons why there isn't any magical SaveToPackage() option.

However, addressing Learnt concepts shouldn't be a hassle. We could add a new MergeWith(XDocument) option that would essentially append the learnt Model to the SIML document and return the newly generated SIML document. But it won't delete/remove duplicate entries. This is intentional as we plan to address that via an SimlOptimizer class which would play an important role within the interpreter and Bot Studio. Moreover, duplicate entries aren't junk clusters in memory as the interpreter disregards overlapping nodes.

In your case, you prefer files on disk while others prefer storing SIML Models in database. I wish we could cherry-pick preferred mode of storing learnt Models but we can't. The interpreter, for the moment, is going to stick with XDocuments instead of files on disk due to the fact that XDocument is the lowest common denominator when it comes to cross platform APIs.

2. I want to maintain unique patterns.

Although I am not very certain, you could try adding the bot variable "Override-Pattern" and set its value to "true".

SIML Code

<Variable Name="override-pattern" Value="true"/>
.

This tells the interpreter to replace existing Response nodes if Pattern nodes overlap.

3. Concepts that are being memorized should be user concepts

A good catch. As the SIML specification doesn't intervene with the memorizing procedure, it should relatively be easy to add a User attribute to the generated document prior to raising the Memorizing event. Although I am going to leave it on the team to decide if and when the aforementioned features are committed, this one's a must for the next iteration.

Archi
Expert
Posts: 19
Joined: Wed May 03, 2017 11:13 pm

Re: Learning/Memorizing issues

Fri Jun 09, 2017 4:35 am

This sounds good enough for me. MergeWith(XDocument) would already be much better than nothing, since I could create my own XDocument composed of what bot has learned already, and then update it according to new model in learning event, so yeah that would solve the issue I'm having :).

I know that duplicated nodes are not a problem for Syn.Bot itself, but due to the fact that program is going to automatically generate and update SIML file responsible for learning, I want to keep it clean not only due to size and parsing time, but also for eventual further edits by humans - this way we can easily take a look what Bot has learnt so far without digging through a gigantic mess of duplicated patterns and responses that are overlapped several times by some other ones.

Thank you a lot for the answer, I'm looking forward to MergeWith(XDocument) function that would solve the biggest obstacle I'm having right now :).

User avatar
Fantom
Help & Support
Posts: 312
Joined: Fri Oct 25, 2013 9:20 pm

Re: Learning/Memorizing issues

Sat Jun 10, 2017 4:03 pm

Released update v2.1.2

MergeWith option added for both Learning and Memorizing events. It also takes care of User ids.

The team is already working on the SIML optimization system that Leslie mentioned, that will intelligently release duplicate SIML models.

Archi
Expert
Posts: 19
Joined: Wed May 03, 2017 11:13 pm

Re: Learning/Memorizing issues

Sun Jun 11, 2017 2:47 am

I tested MergeWith as well as Override-Pattern, it works really decent and it already made a huge progress towards what I want to create, thank you a lot! I have a few remaining issues though :).

I tested MergeWith() and it currently works like this (with override-pattern):

1. Bot learns that XXX = YYY
^ XXX = YYY
2. Bot learns that XXX = ZZZ
^ XXX = ZZZ

This is because XXX = ZZZ is on the bottom, together with Override-Pattern this perfectly solves my "last declaration counts" and works right away after learning, as well as when bot reloads its brain from previously saved faile.

Things get a bit more difficult when there is more than one concept declared with same pattern.

1. Bot learns in concept 1 that XXX = YYY
^ XXX = YYY (concept 1 only)
2. Bot learns in concept 2 that XXX = ZZZ
^ XXX = ZZZ (concept 1 above, concept 2 below)
3. Bot learns in concept 1 that XXX = AAA
^ XXX = ZZZ (because concept 1 is still above, and concept 2 overrides it)

Is it possible to enhance MergeWith so it takes into account concept that is being merged and ensure that source concept will always stay on the bottom? Same like when bot learns totally new concept?

Also I gave your work-in-progress SimlOptimizer a try, and I already noticed that it removes default concept properties, that's really nice!

I have a request though, when you add duplicate models removal, would it be possible to make SimlOptimizer take in account Override-Pattern, or let us specify whether we want to take into account first one or last one as dupe? I'll explain: like in example above, I want to get most recent answer - this is what Override-Pattern does. But then I also want to optimize old now outdated model away, so I need (in the future), a way to tell SimlOptimizer that it should work like Override-Pattern and consider last model as the one that counts, and not first one.

But despite of that, I'm already super happy with available solutions, because as long as I don't declare the same pattern across 2 different learning concepts, everything works right away (with a bit messy file).

Thank you a lot for continuous support! 8-)

User avatar
Leslie
Lead Software Architect
Posts: 375
Joined: Fri Sep 14, 2012 12:20 pm
Contact: Website

Re: Learning/Memorizing issues

Sun Jun 11, 2017 12:35 pm

The MergeWith() simply checks if the new Model belongs to a concept that is already present in the source document if so then the model is appended to that concept. If not, a new concept is created and is appended to the document instead.

The reason why its appended and not inserted is to ensure that the patterns of the newly generated model are prioritized over the previous models just in case there's a pattern conflict.

The MergeWith function doesn't make use of any optimization. Which is supposed to be left on the SimlOptimzer. Its pretty much a barren implementation at the moment.

We already have an SimlAnalyzer that reads through an SIML document and finds discrepancies. The idea is that if the SimlAnalyser can find discrepancies and suggest possible modifications then we can simply plug-in the SImlOptimzer and provide an option that enables necessary (recommended) changes to be committed on the fly.

However, there's a catch. Not all cases can be automated. There's always a need for human intervention. For example, if there are 2 contextually similar Models in 2 different public concepts which one should the optimization system disregard ? Clearly, a call for human intervention.

The optimization process has to take lot into consideration before taking the liberty of prioritizing one model over the other. For instance, 2 Models with similar patterns but different contexts shouldn't be considered as overlapping models. An example would be Models with <Previous> tags attached to them.

Having said all that, I am seeing a lot of features lining up for Syn Bot framework so ofcourse your suggestion would play a role in the future implementation of the SimlOptimizer.

Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 1 guest