How to plug a scheduling algorithm into Anki

Recently, I've seen a lot of discussion about improving anki scheduling algorithm. In this post, I intend to explain how any developper can do it; at least as long as they know what scheduling rules they want to use. I'll also discuss the limit I see.

How to do it

In this section, I'll assume you only want to review cards on the computer. I'll discuss other devices in last section.

Take a look at my repo anki-schedule. You can clone it, change the function scheduler in It should be a function which takes as input a card and return the interval (in seconds between the last review and the next review. Remarks that the next review could well be in the past. For example if you return 3600, it means the interval should be an hour. If the last review was more than one hour ago, the due time is already passed.

If you install this add-on, and in the main window, select "tools>Reschedule", then it'll do mostly what you are looking. Each card will be scheduled according to your algorithm. If the interval is passed, the card will be set to be reviewed now. If the interavl is more than two days, I assume we can set the due date as a day and don't care about the exact minute anymore. Otherwise, the exact time is used.

When a card is reviewed or saved in general, the review is logged as usual, and then its new due date is computed.


This method as been used by a client of mine. As far as I know he discovered that the scheduling he wanted to use was not actually as good as he expected. Alas, my add-on allow you to use your scheduler you want, it does not solve the far bigger problem of designing a good scheduler.

Data that you can use

All of the data available is given anki anki database structure page. This page is not official, but as far as I know, it is accurate. However, let me recap what you probably want to use:

  • for each review, with the time of the review, the button pressed (between 1 and 4), how much time was taken to answer (capped to 60 seconds usually), what was its previous state (learn, review, relearn, cram)
  • for each card: its creation time (which may be later than the note), its note, which card type it is, it's deck
  • for each note: its tags (which could be used to relate cards together), its fields, it's creation time

Any add-on can also save its own data. That is particularly important if you use machine learning techniques; you certainly would want to save precomputation somewhere.


Alas, there are many limits. And they are only partially solvable

Breaking everything

If you change all due date, and your scheduler was broken, you are going to break you entire review process. That's actually not as bad as it sounds, since in theory you can use the very same technic to compute back the original due date. Simply, no one did the "schedule" function to do it, so it would require some works. Or you can also use your backup. Or use yet another scheduling algorithm, overriding the broken one.

Other devices

Add-ons works only on anki desktop. The good news is that my add-on reschedule cards, so that as soon as you sync with your computer, you can compute the correct interval. If my add-on were to be really used, then I should automatize the application of the new scheduler to nsynchronized cards. Right now, you need to tell anki to do it by clicking on "reschedule" in the menu. There are still two obvious limits. For cards in relearning, you are stuck with anki relearning the way anki does it. The good news is that ankidroid is free, and it would not actually be hard to fork it and add a new scheduler if you are willing to pay for it (and I can be hired to do it). The limit here is that AnkiDroid is in java, and so you can't directly use the python code you use in the add-on.


Currently, anki allows to have between two and four buttons during review. You can't easily tell anki to add more buttons and log them. However, you can limit the number of buttons to be two. Under each button, the interval you'd obtain is shown. In this case, the interval will be false since it'll use the old scheduler data.

Of course, if someone is really interested, the buttons problem can be solved; but I believe that to prototype a new scheduler, it's not a priority

Computation time:

Of course, a big limit is the computation time. Your code can takes as much time as you want. But if you need .1 seconds by cards and have 100 000 cards, then you'll need 10 000 seconds to recompute everything, that is 2h45 !

Shared information

One main advantage of centralized system such as duolingo is that once people have trained their algoritm, the training can be used for new users. If you create your own cards and decks, of course, you can train the scheduling algorithm with other people. But if you use a shared decks, which is often the case in medicine, language... then the data exists. The problem being that the data is based on thousands of different computers and on ankiweb.

I highly doubt Damien Elmes, author of Anki, would accept either to share the data, or to run a training algorithm over them. At the very least because he have some european user, and it would be a RGPD nightmare. And probably because of thousands of other legal reasons. And maybe even ethical reason. So if we want to do this, we would need to convince people to share their data. An add-on can be created to ensure that data is shared when they install it. Syncing review data is not hard. But it's going to be a huge work to convince people to install those add-ons. Especially since no one can promise them that they'll obtain any advantage when they share their data, since no one can promise honestly that they are sure that the data will allow to create a better scheduling algorithm.


  • Reschedule during sync and full sync
  • select card in browser and reschedule them only
  • Add a best control to the number of button, and show the right interval
  • Add a "training" button (for ML based algorithm, it would state to do the training again)

How hard can it be to code a feature to let users resize images in a software.


In this post, I expect to show you why it may be difficult to create a seemingly simple program. In particular, to do it well. I'll show case with the last program I wrote, an add-on for Anki. More precisely, the most wanted add-on for Anki, according to the vote of users of Anki's subreddit: being able to resize image in the editor. This seems to be a simple add-on; after all, resizing by dragging corner has been done in every editing software for decades[1]. In this post, I intend to document all of the things which made me loose time when I created the add-on "Resize image" for Anki. I also created a video showing how the add-on works.

I'm going to mostly consider the code problem relating to add-ons. This is going to be technical, but I'm going to try to give intuition to people who don't code. I'm going to consider changes in order I made them.


[1] Appart from LaTeX, but let's not consider it.

Continue reading

How I learn lyrics with anki

After years of using anki, I finally found a nice way to learn lyrics. I think I tried three different methods before finding one which works for me. More precisely, I found it a few months ago, and after testing it, I can finally way I found something which works.

Continue reading

Learning how to play music with anki

I've been playing music for half of my life. But while I was enjoying sight reading partitions, and sometime practiced a little bit the boring part (scales, arpeggios), I have been stuck. Here is a list of what changed:

  • The most frustrating thing for me being that I relied on partitions. Which means that if you gave me a piano or guitar without a partition, I wasn't able to play anything. I found that ridiculous, and anki helped me solve that.
  • Similarly, I played classical guitar, and I didn't know how to read tab. Because, honestly, they are so many chords, I keep forgetting them. Which means that, if you give me a song with tab, as they are hundred of thousands of them, I couldn't play it, because it was not written in a way I can easily read. I don't know every single chord yet (and I'll probably never know them all), I know far more chords today than what I knew before I started anki, and it clearly helps learning songs and doing improv.

The example in this post are related to ocarina, guitar, piano, harmonica and tin whistle. I will explain what differs and what is similar for all of those instruments. Some explanation may not always be clear, if you don't know the instruments I'm talking about. But don't worry, if you don't understand, just read the next paragraph, you should be able to get the general idea.

This article will be illustrated using almost only cards that I have really seen the day I was writing this article. You can find here my [piano], [guitar] and [ocarina] decks. They are far from being perfect, some typos may still be in them. But it may help you to understand what I write here. And maybe you can find them useful in your collection.

Continue reading

Anki and learning which require practice (origami, knot, instrument...)

I use anki to learn things which require practice. Origami, drawing, music, rope (nodes and shibari). Music will be considered in another text.

I consider two kinds of practical knowledge:

  • some practice requires making choices regularly (like drawing, or musical improv)
  • some practice requires learning and practicing some exact moves over and over. That may be the case when you want to learn a musical piece, or how to tie some particular note.

I don' have any idea how to deal with the first kind of knowledge, thus I'll only consider the second kind. I'll list here different methods, which depends on what I want to learn. I don't know in general how to decide which method is the best one.

Continue reading

Lists in anki: desiderata and partial solution

In this text, I assume you are familiar with anki, and in particular know what is a field, a card, a card's type (aka template), a note and a note's type (aka a model), and that you have an idea of what are the rules used by anki to decide which cards should be generated or not.

There is one big limitation in anki, it concerns lists[1]. Here I list my trouble, the existing work arounds I know, their limits, and the functionnality I would really want. Sadly, this functionnality seems to require such a big modification of anki's underlying model that I fear that no add-on can answer my request. In particular if I want this request to also be satisfied in smartphone's application, which does not allows to add add-ons.

Learning a list of things is hard, but it's something I sometime want to do. A poem/song is just a list of line. Sometime, a mathematical notions have 4 distinct names. E.g. a pullback is also called a fiber product, a fibered product and a Cartesian square. In some othe case, a mathematical objects admits many distinct definitions[2]. E.g. I've got 5 definitions of left-trivial monoids. And I'd also wanted to see if I can learn the list of the prime number less than 100. Mostly to see how hard it is to learn an arbitrary list.


[1] I assume here that sets are list, with an arbitrary order

[2] This is in general considered to be a proof that the object is really interesting

Continue reading

Note on an introduction on Anki given a 35C3

This post is a comment about a self-organised workshop Introduction to anki I gave at #35C3 (35th Chaos Communication Congress, a congress of 17k hackers). This workshop was announced on the anki's subredd where I asked for ideas. I received a lot of useful feedback from this subreddit and from the related discord server. The main audience of the current blog post is thus those person, already in anki's community. This post contains idea in random order.

Continue reading

The trolley problem, and what you should do if I'm on the tracks

Originally published in French and crossposted on LessWrong. Translation by Épiphanie.

Trigger warning: Death, suicide, and murder. Trolley problem.

This is quite the conventional and ethical conundrum: You are near train tracks, and a train is rolling down the hill. It is going to run over 4 people who are tied to the rails of the main track. However, you can change the train's direction to a secondary track by pulling a lever; so that it runs over only one guy, also tied down the rails. Should you pull the lever?

I do believe there is a more interesting way to frame it: What would you choose if you are yourself tied to the rails, alone, while the train is not heading toward you yet. My own answer is very simple: I want the person deciding where the train should go to have _no doubts_ they should pull the lever! Because, for lack of context, I assume that the other four people are just me, or rather copy of mes. That's a bit simplistic, of course they are not perfect clone. But as far as concrete predicates go, they are indistinguishable. That is to say I have odds of being on tracks alone of 1 in 5, and odds for being in the group of 4 in 5. And tell you what, I prefer dying with 20% probability because of what someone did, rather than to die with 80% probability because no one was ever willing to take the burden of responsibility.

Continue reading

Page top