Learning is a single ~560-line SQL statement that splits text, interns symbols, and updates two 5th-order Markov tries (forward and backward) using depth-unrolled writable CTEs. Inference is a recursive query that generates N candidate replies in parallel. It performs bidirectional weighted random walks, evaluates them for information-theoretic surprise, and formats the winner as a sentence-cased string.
I provided a `docker-compose.yml` and convenient Python driver script so you can try it out quickly, and there's also a web-based demo where I bundled it with PGlite (WASM PostgreSQL) at https://tgies.github.io/megahal-sql/. These are provided for convenience, but you can also just run the schema initialization SQL and `SELECT megahal_converse('hello from hn.');`
vunderba•35m ago