Kirsle's Web Blog
I'm working on an experimental new feature for the Python version of RiveScript: compiling your source files to binary for better performance!
It uses Google's Protocol Buffers under the hood. When the Python RiveScript module is loading your RS source files from disk, instead of loading it directly into memory it will build up a Protocol Buffer and save it to disk at the end as a
.rivec file. These work just like Python's
.pyc files do: in the future when your bot loads your RiveScript replies on disk, it will load them directly from the compiled binary
.rivec file instead of parsing your code again. But, if you make a change to your source file, RiveScript will re-compile it.
This brings the benefit of having your replies able to be loaded from disk much more quickly. The binary format is very close to the internal format RiveScript uses when it loads the replies into memory, so it's a very straightforward process for it to load the binary version.
I did some benchmarks to compare the speed difference. I loaded the A.L.I.C.E. reply set (AliceRS-0.03.tar.gz from here).
On the old version of Python RiveScript, it took about 40 seconds to load A.L.I.C.E.'s replies from disk. With the new version, on the first load it takes longer (~78 seconds) because it's busy compiling them down to binary, but on subsequent loads it only takes 25 seconds!
If you were working on a bot the size of A.L.I.C.E., the increased loading speed would be really helpful. And as you're actively developing your source files, RiveScript would only need to re-compile the files you changed, instead of having to rebuild ALL the files.
Another nice side benefit is that it made the whole parsing code a bit simpler for me. Since it's not directly loading your plain text RiveScript documents into memory, there's less need for juggling around temporary variables (i.e. dealing with the
%Previous stuff), instead the parsing code just focuses on turning your plain text into a structured binary format that accurately represents the original text. Once that's all organized, it's then pretty straightforward (and simpler) to get it into memory for the bot to actually use it for chatting with people!
I just did my presentation about using RiveScript in web applications at the Chatbots 3.3 Conference in Philadelphia.
I'm working on a chatbot hosting service for RiveScript bots. This will enable you to get your own chatbot up and running without needing any programming experience. There will be a beta of this service up and running here in the near future.
Some early FAQ's about it:
Q: Will it be free?
A: Absolutely! Chatbots are a pretty difficult thing to monetize anyway, and I think the majority of my users will be running relatively "small" chatbots that won't put too much stress on my server anyway. However, I may introduce fees for hosting very large bots (ones with tens of thousands of custom responses) since these will require more resources to run on my server.
Q: Can I have an Alice clone?
A: Kind of. You will have a choice of a "Base Brain" to use for your bot. Alice will be one of the options for the base brain.
Q: How do Base Brains work?
A: You'll be able to create custom responses for your bot, for example you can say, "when the user says hello, the bot should say Hi there!". Whenever a user says something to your bot that matches one of your custom replies, they will get the reply you created. But, if they say something that doesn't match any of your custom replies, the Base Brain will be the one that provides them with a response instead. So, if you use Alice as your base brain, Alice will be the "fall back" source of responses for your bot.
Q: What are the options for Base Brains?
A: The options are going to be Alice (Dr. Wallace's Alice, who has about 90,000 responses), and Eliza (the classic therapist bot by Joseph Weizenbaum). However, you can elect to not use a base brain at all, in which case your bot's custom responses will be the only source of replies.
Q: How many custom replies can I have?
A: To start out with, there will be a limit of several thousand custom replies. This, I think, is more than enough for the majority of users. Alice has about 90,000 custom replies, and it takes a RiveScript interpreter several seconds to load that many responses from disk. If everybody who runs a RiveScript bot were to upload their own individual copies of Alice, this would put the server under a lot of stress for each message the bots receive. The limit will probably be about 10,000 custom responses.
Q: How is the Alice base brain going to work then?
A: The Alice base brain will run as a background service on the server. This way she only needs to be loaded from disk once and will be able to serve as the backup reply source for many bots simultaneously.
Q: Will there be a way to host bots as large as Alice?
A: We'll cross that bridge when we get to it. One idea I have will be to run large custom bots as background services like the Alice base brain.
Q: Will my bots be able to sign on to AIM, MSN, or Yahoo?
A: The bot hosting service, at least to begin with, will only host web-based bots (ones where you chat with them via a web browser). However, there will be an API (Application Programming Interface) for third party developers to be able to hook their apps into the hosting service. So, somebody could write an AIM bot for example that uses the RiveScript hosting service to get responses for users over instant messenger.
Q: What will the limitations be?
I think that should cover it for now. Stay tuned!
There is a demo available right here. That will let you chat with the standard RiveScript brain that tends to ship with all the libraries.
If you're feeling more adventurous, I also have a demo where you can chat with Dr. Wallace's A.L.I.C.E.! Be warned though, Alice is a large A.I. and you'll be running her entirely in your web browser. On my system though she runs just fine, and can respond instantly -- even faster than the Perl and Python RiveScript libraries!
What's so great about RiveScript.js? With this, you can easily add a chatbot to your website, and it doesn't even require any fancy server-side setting up! Unlike the Perl, Python and Java versions of RiveScript, this one will run in your end user's web browser. All your server needs to do is host your RiveScript source files!
Disclaimer: this library is very recent. While it seems to work and it passes the whole test suite, there may be--and probably are--some bugs. If you find any, let me know so I can fix them!
I've written a RiveScript tutorial! You can see it here. It covers just about everything you can do with RiveScript, but it doesn't go in-depth with topic inheritence and inclusion (as these are advanced subjects). The initial version is released, so if you've been wanting to learn RiveScript, give it a read-through and let me know if any parts of it are confusing or need to be expanded on some more.