Created
November 5, 2021 19:15
-
-
Save emreavcilar/0d875cd7c856e2c7a3c3da72ff4d489d to your computer and use it in GitHub Desktop.
javascript ai
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Smallest #javascript code that uses #artificialintelligence | |
to create an #autocomplete bot for a chat app using #brainjs. | |
Visit their website at brain dot js dot org. | |
*/ | |
// provide training data | |
const data = [ | |
'Thank you.', | |
'I\'m not interested.', | |
'Call me later.' | |
]; | |
//create an AI model to be trained | |
const lstm = new brain.recurrent.LSIM(); | |
//train that model | |
const result = lstm.train(data,{ | |
iterations:1500, | |
log:details=>console.log(details), | |
errorThresh:0.011 | |
}); | |
//AI autocomplete is ready! | |
console.log('autocomplete ' + lstm.run('Call')); | |
// prints "Call me later." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment