---
title: "Lynne Teaches Tech: How do mstdn-ebooks bots work?"
author: Lynne
categories: [Lynne Teaches Tech, Originally from the Fediverse]
tags: [Lynne Teaches Tech]
---

the ebooks bots (the ones i using [the code i made](https://github.com/Lynnesbian/mstdn-ebooks), anyway) use something called [markov chains](https://en.wikipedia.org/wiki/Markov_chain). markov chains are a mathematical concept, and in computer science (computers are the only thing i know about), they are generally used for predictive text. when you type "how are" on your phone and the keyboard recommends "you", that's (usually) markov chains at work! as you type, your keyboard makes a database of everything you've ever typed and uses it to predict what you'll type next. keyboard generally come with a built-in database of common phrases, and then additionally learn from you as you type. this is why your brand new phone already knows to suggest "you" after "how are", before you've ever even said that before.

mstdn-ebooks use markov chains too! every time they're asked to post, they use a random selection of 10,000 posts (they use less if you haven't made that many) to learn from and use them to generate a new one. that means when you reply, they receive your reply, randomly select a huge chunk of posts, train a markov chain on them, generate a reply, and post it -- all in less than a second! technology!!

a markov chain isn't intelligent. it doesn't know where sentences start and end, and it doesn't understand grammar -- it doesn't know anything apart from "when you say this word, you usually say this one next". markov chains don't care if the input is words or colours or images or DNA sequences, they just have a database of items and probabilities and use them to create posts. they often make things that don't make sense, or just feel like two posts slammed together, but occasionally, they come up with gold (such as "[have these ancap nerds even played Super Mario 64](https://fedi.lynnesbian.space/web/statuses/100987016408210808)").

[view original post](https://fedi.lynnesbian.space/web/statuses/101548793919202772)

