MegaHAL Turns Twenty-One
In 1993 I wrote a learning chatterbot called MegaHAL and put it online.
The Birth of MegaHAL
I was studying Markov processes, and remembered NIALL, a program that I’d played around with in 1991. It was written in AMOS by Matthew Peck, and was included on an Amiga Format coverdisk.
NIALL itself was based on DANI, written by Sean Davidson in 1987, and published in MSX Computing magazine as a type-in listing.
Inspired, I decided to hack together my own version.
MegaHAL on the Web
MegaHAL was written in C, and proved popular among my engineering classmates. During 1994 I discovered Mosaic and the secrets of writing CGI scripts, and towards the end of that year I got MegaHAL up-and-running on the nascent World Wide Web.
Over the course of 1995 I refined the algorithm. I would read through conversation transcripts each morning—hundreds of people were talking to MegaHAL each day—and I’d save my favourite quotes before making tweaks to improve performance where I thought it had fallen short.
Chat With MegaHAL
I have spent the past few weeks rewriting MegaHAL in Ruby and getting it back online, so you can once again talk to MegaHAL on the web.
Multiple Personalities
The MegaHAL gem features a command-line mode that enables you to talk with MegaHAL on your local machine. It includes several built-in personalities, such as Sherlock Holmes.
However, you can also teach this version of MegaHAL to learn from scratch.
Hacker News Announcement
I spent the last couple of weeks rewriting MegaHAL, and it’s finally online again after a brief absence.
You can talk with MegaHAL here: megahal.kranzky.com
All source is freely available on GitHub, unencumbered by a license.
The main MegaHAL repository is megahal. It includes a console application and eight built-in personalities, including Sherlock Holmes. And it’s easy to hook into its API if you want to build something else with it.
MegaHAL uses Sooth, which is a simple stochastic predictor, written in C but wrapped in a Ruby gem. It’s available at sooth. MegaHAL uses five separate Sooth predictors to do its thing. You could build other things with it.
Finally, the code for the server itself is available at megahal-server. It’s a Rails 4.2 app with a crappy Bootstrap theme. A basic REST api hooks things up, and a daemonized version of MegaHAL processes the queue of jobs coming in from the world.
Have fun, I’m looking forward to seeing how warped the online personality becomes, and how big the brain file grows.
Share and Enjoy!