Projects

TorfsBot

Twitterbot automatically imitating Rik Torfs (ex-rector KU Leuven), which accidentally became Belgium's most popular Twitterbot

View TorfsBot Code Cite

TorfsBot cover

TorfsBot was a bot that automatically imitated the tweets of Rik Torfs on Twitter. I launched it in 2016, and it got its first hundred followers in a single night.

Rik Torfs’ Twitter style

The bot imitated the writing style of professor Rik Torfs, a canon lawyer and the former rector of KU Leuven. His tweets are aphorisms: short, often with a quip, in complex sentences with uncommon words and sometimes unusual grammar. That often makes them sound deeper than they are, which helps a bot that only strings his words together. Some example tweets of the real Rik Torfs himself:

Rik Torfs @torfsrik
Het mooie van God is dat hij het iedereen van harte gunt niet in hem te geloven.
Rik Torfs @torfsrik
Ik zou ook wel links willen zijn. Maar daarvoor zie ik mensen te graag, en wantrouw de mensheid te zeer.

This style is sometimes imitated by Twitter users on the hashtag #tweetenzoalsrik. Rik also regularly writes columns in national newspapers, which, along with his tweets, served as the training data for the bot.

TorfsBot tweets

TorfsBot tweeted about five times a day, at random moments. It wrote its tweets in two ways: like the autocomplete of your phone, predicting one word after another from the words Rik Torfs used after the previous ones, or by swapping words in one of Rik’s tweets for words from his columns. TorfsBot preferred shorter tweets, since these are usually more interesting.

Robot Torfs @TorfsBot
Het waardevolle antwoord op onzin is stilzwijgen.
Robot Torfs @TorfsBot
Verklaar mij gek, maar ik heb wel gesproken.
Robot Torfs @TorfsBot
Beste, gevolgd door een komma. Mails om niet te herinneren.
Robot Torfs @TorfsBot
Vreemd hoe, in onze tijd van profane meningen, kerkjurist met competentie wordt verward.
Robot Torfs @TorfsBot
Denken is vaak een vorm van verliezen.

TorfsBot also “read” Flemish news sources, so it could comment on the news just like the real Rik Torfs.

Robot Torfs @TorfsBot
”De stad verkiest grijs boven groen” Terwijl een zonsondergang gratis is.

Replies

While the real Rik Torfs almost never replies to tweets, TorfsBot answered almost everyone who replied to it or tagged it. (Twitter’s rules only let a bot reply to people who interacted with it first.) To reply, TorfsBot

  1. looked for the key words of the conversation: the words in it that are rare in general,
  2. generated a thousand possible replies with its autocomplete,
  3. and picked the reply that shared the most key words with the conversation and suited the length of the last tweet.
Joël De Ceulaer @jdceulaer
Ziezo. Zonet het grote #dubbelinterview met twee van de #invloedrijkste #intellectuelen van #Vlaanderen gefinaliseerd. Zaterdag in #DeMorgen, morgenavond alreeds online voor de schrandere #abonnees.
Patrick Anthonis @panthonis replying to @jdceulaer
@torfsrik en @TorfsBot ?
Robot Torfs @TorfsBot replying to @panthonis
Het plezier van de twee.

You can see TorfsBot pick up on the words “erger” and “ik” to reply to the tweet commenting on Rik Torfs’ rector re-election loss:

Jeroen Baert @jbaert
Ik vind het eigenlijk nog erger voor @TorfsBot.
Robot Torfs @TorfsBot replying to @jbaert
Het kan erger: ik had ook in de trein had kunnen zitten.

Discussions with real Rik Torfs

With a low probability, TorfsBot also replied to tweets of Rik Torfs himself, giving rise to interesting (albeit one-sided) “discussions” between the two.

Rik Torfs @torfsrik
Hoe meer mensen door de coronacrisis in moeilijkheden komen of financieel afhankelijk geraken, hoe sterker de voedingsbodem voor extremistische partijen. En hoe lastiger het wordt om samenleving en economie weer op gang te krijgen.
Robot Torfs @TorfsBot replying to @torfsrik
Integendeel, dat verenigt hen. Lastiger is dat spoorstakingen of de panda’s.

How TorfsBot works

TorfsBot uses two different text generators at random to write its tweets. I explain the details in this paper, in this talk at ESSLLI and, in Dutch, in this talk at KU Leuven’s Metaforum (video). TorfsBot’s code is also available on GitHub.

Algorithm 1: autocomplete

Your phone’s keyboard can write a text by itself. Open a chat or a note, and keep tapping one of the words it suggests above the keys: after ten or twenty taps, you have a sentence that sounds a little like you. The keyboard can do that because it counted which words you usually type after which.

TorfsBot does the same with Rik Torfs’ tweets and columns. For every two to four words in a row in his texts, it counts which word came next:

Beste, gevolgd door “followed by”

Next wordTimes

  1. een a 4 50%
  2. zijn his, to be 2 25%
  3. iemand someone 1 12.5%
  4. acht eight 1 12.5%

After gevolgd door (“followed by”), Rik Torfs wrote een four times in his tweets and columns, zijn twice, and iemand and acht once. TorfsBot picks one of them at random, weighted by these counts: een half of the time.

To write a tweet, TorfsBot takes the first words of one of Rik’s sentences, and then keeps picking a next word from the words Rik used after the last few. Where Rik used a few words only once, there is only one way to go, so the bot copies him for a while. Where he used the same words in several texts, the bot can jump from one text to another:

TorfsBot Tweet, 2021

Beste, gevolgd door een komma. Mails om niet te herinneren.

“Dear, followed by a comma. Emails not to remember.”

After om niet te, Rik’s tweets go on with, among others: lezen.veroordelen.herinneren.sterven.slagen.

Rik Torfs Tweet, 2017

Beste, gevolgd door een komma. Mails om niet te lezen. Hoe kun je iemands beste zijn, zonder dat je zelfs maar een naam hebt?

“Dear, followed by a comma. Emails not to read. How can you be someone’s dear without even having a name?”

Rik Torfs Tweet, 2013

Rome, rechtvaardige stad. Miskende genieën zijn voor altijd vergeten. Stenen verstaan de kunst om niet te herinneren.

“Rome, righteous city. Unrecognized geniuses are forgotten forever. Stones master the art of not remembering.”

TorfsBot’s tweet starts as a tweet of Rik’s from 2017, up to om niet te (“not to”). Rik wrote other words after those three too, and the bot picked herinneren (“remember”), from a tweet about Rome. The new tweet got more likes than the two it came from together.

TorfsBot prefers looking back four words, which keeps it close to Rik’s own sentences, but sometimes looks back only three or two, which gives it more ways to go. Looking back at only door een (“by a”), it could also have written “Beste, gevolgd door een tweet.”, taking tweet from a tweet of Rik’s about replacing the thesis by a tweet. Mixing these lengths (an interpolated Markov chain) makes the bot copy less, without sounding too random.

Since every three words in a row usually appear somewhere in Rik’s writing, TorfsBot’s tweets are locally coherent. But the bot doesn’t know what it wrote more than a few words ago, so a tweet can easily derail.

You can try it yourself in the demo below, which I made for AI voor Iedereen, the interactive AI course I wrote for KU Leuven. It learned from Rik’s tweets (not his columns) which words follow every two words, and it speaks Dutch, like his tweets.

Click one of the suggested words to add it to the text, or press Willekeurig (“random”) to let the model finish the sentence. The Kansentabel (“probability table”) shows what it counted. Open this demo

Algorithm 2: keeping a tweet’s form

The second method keeps the form of one of Rik’s tweets, but swaps some of its key words for words from one of his columns (a dynamic template). It takes a random tweet and a random passage from a column, works out what kind of word each word is (its part of speech: a noun, a verb, an adjective…), and replaces key words in the tweet with words of the same kind from the column:

Rik Torfs Tweet

Zonder brilnoun zien we beter wat er niet is.

“Without glasses, we see better what isn’t there.”

Rik Torfs Column

Zijn twijfelnoun is methodisch, een manier om tot waarheid te komen.

“His doubt is methodical, a way to arrive at the truth.”

Swap in a word of the same kind

TorfsBot Tweet

Zonder twijfel zien we beter wat er niet is.

“Without a doubt, we see better what isn’t there.”

TorfsBot swapped the noun bril (“glasses”) in Rik’s tweet for the noun twijfel (“doubt”) from a passage about Descartes in one of his columns.

Such tweets have the form of a real Rik Torfs tweet, but the new words sometimes make odd combinations with the old ones.

Which one works best?

From June 2017 to June 2023, TorfsBot’s 8,000 tweets got 17,000 likes and retweets. On average, a tweet written by autocomplete got 35% more likes and retweets than a tweet that keeps the form of one of Rik’s: sounding right from word to word mattered more than the form of the whole tweet. The paper had found the same in 2019.

Fixing up

After generating a text with either method, TorfsBot cleans it up by

  • shortening too-long tweets by throwing out sentences in the middle
  • balancing out missing brackets and quote marks
  • replacing irrelevant names with people that appear in today’s news
  • updating dates to days that are in the near future

If the final text is not too long, and original enough compared to the texts it learned from, it is tweeted at a random moment.

TorfsBot Or Not?

The TorfsBot Or Not? banner: Rik Torfs facing his cyborg self, and "Was the tweet by Rik Torfs or by his robotic counterpart?"
The TorfsBot Or Not? banner: Rik Torfs facing his cyborg self, and "Was the tweet by Rik Torfs or by his robotic counterpart?"

In 2022, I launched TorfsBot Or Not?, a Twitterbot that posted a daily poll with a tweet from either Rik Torfs or TorfsBot. It asked its followers whether they thought the tweet came from Rik Torfs or from TorfsBot. Whenever most people thought a TorfsBot tweet was originally from Rik Torfs, it told everyone that TorfsBot had passed the Turing test that day.

Is de tweet van Rik Torfs of TorfsBot? @TorfsBotOrNot
Ideologie troost. Bijvoorbeeld de ideologie dat wij maar erg weinig weten.
Is de tweet van Rik Torfs of TorfsBot? @TorfsBotOrNot
🚨 Het was een tweet van TorfsBot! TorfsBot heeft de Turingtest doorstaan!
Robot Torfs@TorfsBotIdeologie troost. Bijvoorbeeld de ideologie dat wij maar erg weinig weten.

Over 602 polls, people cast 47,000 votes. 71% of the votes were right, and the majority was right in 87% of the polls: TorfsBot passed the test 68 times, and 12 real tweets of Rik Torfs were taken for TorfsBot’s. Tweets with more likes and retweets were more often taken for Rik’s: slightly for TorfsBot’s tweets, and more so for Rik’s own.

For more information, see the TorfsBot Or Not? project page or @TorfsBotOrNot on Twitter.

View TorfsBot

Talks about TorfsBot

In the press

Papers

Citation

 

What people say about TorfsBot

How to cite

Generating Philosophical Statements using Interpolated Markov Models and Dynamic Templates

@inproceedings{winters2019torfsbot,
    author = {Winters, T},
    booktitle = {31st European Summer School in Logic, Language and Information Student Session Proceedings},
    month = {Aug},
    pages = {181-189},
    organization = {Riga, Latvia},
    publisher = {ESSLLI},
    title = {Generating Philosophical Statements using Interpolated Markov Models and Dynamic Templates},
    year = {2019},
    startyear = {2019},
    startmonth = {Aug},
    startday = {5},
    finishyear = {2019},
    finishmonth = {Aug},
    finishday = {16},
    language = {English},
    conference = {European Summer School in Logic, Language and Information},
    day = {5},
    publicationstatus = {online-published},
}

All projects