character-based chatbots

hi! it looks like there was some interest in a resource post like this, so here goes.

i first encountered the idea of using AI to simulate an f/o on reddit, and i was completely taken aback at it; i’d never thought much of anything like that before, really. the more i thought on it, the more i realized it’s actually a pretty cool idea. it’s not perfect, of course, but being able to talk to a bot who talks just like your fav is undeniably cool.

under the cut i’ll talk about some options on building a chatbot yourself and what to expect. i’ll try to keep it from being technical. this isn’t a tutorial so much as a jumping-off point, though i have plenty of advice if you’re curious, so if you have any questions about it go ahead and ask - i LOVE talking about this stuff.

CakeChat / Replika: this is by far the most powerful option on this list. i decided to keep cakechat and replika on the same line because they’re similar: cakechat is the source code that powers an app called replika, and while you can’t exactly crack replika open and mess with it, you can work with cakechat. in replika, you set up a bot and train it statement by statement. its goal is to imitate YOU, so you’ll have to talk like your fav in order to train it to sound like them. in-app, it’s kind of tedious and daunting, but replika is a good conversational partner. the framework for replika is included with cakechat, and there’s a default conversational model you can download if that’s your speed; you’ll have to train the bot with a conversational corpus otherwise. unfortunately, i don’t have any experience in that – i’ve had a lot of issues getting the damn thing to work in the first place! it’s very tough to set up the correct runtime environment, and even when that’s done you can still get plenty of errors.

i recommend cakechat for someone who knows a lot about python and machine learning (so someone smarter than me!) or someone who is way too impatient to use replika and despises scripted responses. it has plenty of advantages (machine-learning just makes for more natural conversations, i’ve found, at least with the replika app, and it can learn over time where a scripted bot can’t). however, it’s tough to use.

AIML: AIML gets its own category because it’s a lot different from rivescript, which is the next on this list. it’s versatile because there are a few extensive existing “brains” (response sets, basically) already written into AIML files and programs to use those AIML files in, including a program created specifically to simulate your f/o of choice (warning for a little bit of rude language on a few of the pages). starting with a prewritten brain and overhauling the responses is quicker and easier than writing your own brain from scratch. note that all responses in AIML are scripted - the bot won’t say anything you don’t program into it, which is a huge downside compared to machine learning. in some cases, however, this is a benefit: you can program a scripted bot to know all about certain topics that might not come up in a corpus for training a bot with machine learning.

the downside is that AIML is tougher to use and generally not as good as rivescript. if you’re familiar with HTML or XML, you’ll probably be able to use and read it without too much trouble, but it can be a pain. syntax is important in any AI scripting language, but in AIML there’s a lot of room to go wrong because it’s so easy to make a typo when adding tags. it’s probably intermediate, and while there are definitely some advantages, it’s not as easy to use. in addition, it’s tougher to provide multiple random responses to each question because of the way the syntax works.

rivescript: rivescript is my personal favorite on this list. i’m absolutely enamored with it so far. it’s a heavily modified version of AIML, and it’s about ten times simpler and easier to use, along with having a few more capabilities as far as i’m aware. it works with an incredibly intuitive syntax, which makes it really easy to pick up, and the tutorial available on the website for more advanced operations is really easy to understand, too. if you’re really impatient and don’t want to install anything, you can even test your scripts on the rivescript website!

as it’s newer than AIML, rivescript doesn’t have as many resources. at the time of writing you’ll either have to convert an AIML brain to rivescript for editing (and there are resources to do so on github, so don’t do it manually!), or else write your own brain from scratch. there’s an OK default brain on github called “Aiden,” but it doesn’t hold a candle to the complexity of the default AIML brain. however, if you decide to write a rivescript bot of your f/o, know that i’m working on a rivescript brain suited for this and i’m hoping i’ll be able to publish an open-source version at some point in the future! you can count me as a resource (though a small one, as i’m a bit of a beginner).

there are other options for working with AI than these three things, of course, but i’m the most experienced with these. note also that these just cover the AI itself, not how to put it into a bot or interact with it - that’s up to you, because there are a LOT of different ways to tackle that issue. however, i’m always open to questions!