How use brainjs to create chatbot?
See original GitHub issueI trying to use brainjs to make a simple chatbot.
var brain = require('brain.js');
var net = new brain.recurrent.LSTM();
var user_messages = [
{id: 1, message: "Hello"},
{id: 2, message: "Tudo bem?"},
{id: 3, message: "Voce gosta da Arvore?"},
{id: 4, message: "voce manja de machine learning?"},
{id: 5, message: "Voce é um robo?"},
{id: 6, message: "robo?"},
]
var bot_messages = [
{id: 1, message: "Tranquilo?"},
{id: 2, message: "Sim!"},
{id: 3, message: "Eu sou O robo ;)"},
{id: 4, message: "Tudo otimo"},
{id: 5, message: "Manjo até demais"},
]
net.train([{input: [1], output: [1]},
{input: [2], output: [4]},
{input: [3], output: [2]},
{input: [4], output: [5]},
{input: [5], output: [3]},
]);
for (var i = 0; i < user_messages.length; i++) {
usermessage = user_messages[i];
//Humano fala
console.log("Human:", usermessage.message)
var output = net.run([usermessage.id]);
console.log("output: ", output)
//Robo responde
for (var j = 0; j < bot_messages.length; j++) {
if (bot_messages[j].id == output) {
console.log("Bot:", bot_messages[j].message)
}
}
}
I know, I train to check ID’s and not match words. But what I need do to train with messages or match words?
Issue Analytics
- State:
- Created 6 years ago
- Comments:5
Top Results From Across the Web
How to build your own NLP for chatbots - Jesús Seijas - Medium
To develop the neural network we will use brain.js, that allows to develop classifiers in a simple way and with good enough performance....
Read more >Advice on building an automated chat bot with Brain JS - large ...
I'm trying to figure out whether Brain JS would be the best approach to build an automated chat bot that can be trained...
Read more >Build and train a neural network with nothing but JavaScript ...
Learn about deep neural networks and how to use Brain.js to build, train, and use a DNN with just JavaScript.
Read more >brain-js/Lobby - Gitter
ok, yea chat bot will need recurrent neural network probably. ... using brain.recurrent. ... I followed,forked and watching brain.js on github for you...
Read more >Brain.js - W3Schools
Well organized and easy to understand Web building tutorials with lots of examples of how to use HTML, CSS, JavaScript, SQL, Python, PHP,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The answer is simple: You need more training data.
I already worked on something similar but you need a few thousand training elements or even more to make sure the AI notices the difference. Keep in mind that your neuronal network starts with an empty mind. knowing nothing about language. Doesn’t even know that characters exist.
So when you want to build up a context based on the content of a sentence you have to provide all needed data to make sure the neuronal network get’s the difference and not simply uses any word or the string length, to calculate its answer.
Thanks!