Brain.js: How to do chat bot?

Created on 9 Jun 2018  路  11Comments  路  Source: BrainJS/brain.js

Why it didn't work? I tried set sents in [], same problem
Can anyone show example how make simple chat bot?

var brain = require('brain.js');
var net = new brain.recurrent.LSTM();
net.train([
    {input: "hello", output: "Hi!"},
    {input: "How are you?", output: "Super!"},
    {input: "Where are you?", output: "Next to you"}
], { log: true });

console.log(net.run("Hello!"));

Sometimes it crash with errors like

Error: unrecognized character "Hello!"
at DataFormatter.toIndexes (/home/node/neural/node_modules/brain.js/dist/utilities/data-formatter.js:85:17)
at DataFormatter.toIndexesInputOutput (/home/node/neural/node_modules/brain.js/dist/utilities/data-formatter.js:103:23)
at LSTM.formatDataIn (/home/node/neural/node_modules/brain.js/dist/recurrent/rnn.js:769:35)
at LSTM.run (/home/node/neural/node_modules/brain.js/dist/recurrent/rnn.js:381:24)
at Object. (/home/node/neural/index.js:9:17)
at Module._compile (internal/modules/cjs/loader.js:702:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:713:10)
at Module.load (internal/modules/cjs/loader.js:612:32)
at tryModuleLoad (internal/modules/cjs/loader.js:551:12)
at Function.Module._load (internal/modules/cjs/loader.js:543:3)

Sorry for my bad English

bug help wanted

Most helpful comment

We really need to handle the case of a generic non-understood value so that the net can essentially just skip that value.

All 11 comments

This is because in thestring Hello! is not equal or similar to hello. The neural network is "case-sensitive"

We really need to handle the case of a generic non-understood value so that the net can essentially just skip that value.

I'm working on v2 stuff, anyone want to try and handle this?

Can I? 馃敘

What needs to happen: The formatter just needs an extra character detection.

The formatter: https://github.com/BrainJS/brain.js/blob/master/src/utilities/data-formatter.js
The exception being thrown: https://github.com/BrainJS/brain.js/blob/88b0dda9429653d0d688a8ecadb2952be703e70a/src/utilities/data-formatter.js#L63
We simply just want to use a general character for cases the character isn't understood.

If you allow me to suggest one more thing to be changed/added(which would help making a chatbot, so kinda the topic of the post... right?): It would be interesting to be able to train new data to the NN, without having to train everything again, as it may cost performance

I agree, this should be solved soon.

@robertleeplummerjr Faced the issue too. Will appreciate a fix :+1:

Try again and let us know, this should be resolved now at least for using strings directly.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

VEXLife picture VEXLife  路  4Comments

shopsoy picture shopsoy  路  3Comments

dan-ryan picture dan-ryan  路  4Comments

sts-ryan-holton picture sts-ryan-holton  路  4Comments

AkashGutha picture AkashGutha  路  5Comments