Anki SRS algorithm: spaced repetition explained with code

Anki SRS Algorithm

Humans remember or learn things more easily when studied multiple times over a long period of time (spaced presentation), rather than studied repeatedly over a short period of time.

— Hermann EbbinghausGerman psychologist who introduced the Forgetting Curve

Forgetting is the key to learning. Forgetting is what separates what is useful from what is not. Sometimes we want to make a knowledge stay in memory despite what our memory thinks. Spaced repetition is an effective solution to this problem and Anki is the most popular OSS tool to help you.

What you will learn

What is the history of SRS algorithms?

How the Anki SRS algorithm is implemented.

How the Anki SRS algorithm differs from other known implementations.

How the Anki SRS algorithm can be improved.

Anki's source code is released under AGPL v3. The code presented in this article has been lightly adapted for learning and readability.

Prerequisites

I assume you have used Anki before. All of the code examples use the Python language, mainly because Anki was only implemented in Python until recently, and also because it's a great language for novice programmers. You don't need to have a solid understanding of the language to follow the article as the code uses basic Python syntax.

SRS primer

The role of any Spaced Repetition System (SRS) algorithm is to determine what the user should review now, or say differently when the next review should occur for each memorized item. The goal of any implementation is to counteract the effect of the forgetting curve:

forgetting curve

As soon as we learn or revise knowledge, decay begins. SRS algorithms must determine the optimal interval between two notices to ensure that it has not been completely forgotten (memory retention = 0%) while trying to limit the number of notices as much as possible. In practice, most algorithms use 10% for the forgetting index (= 90% of items are remembered correctly) so that we don't have too many items to review while keeping a number of revisions close to 1. 'optimal.

The details of the different algorithms differ greatly from system to system. We'll start by reviewing the most popular ones in history before showing you Anki's solution.

The Leitner system (1970-)

While Hermann Ebbinghaus is credited with the original research behind SRS, the Leiter system is often cited as the first algorithm. This system uses a physical box as shown by the following illustration:

Anki SRS algorithm: spaced repetition explained with code
Anki SRS Algorithm

Humans remember or learn things more easily when studied multiple times over a long period of time (spaced presentation), rather than studied repeatedly over a short period of time.

— Hermann EbbinghausGerman psychologist who introduced the Forgetting Curve

Forgetting is the key to learning. Forgetting is what separates what is useful from what is not. Sometimes we want to make a knowledge stay in memory despite what our memory thinks. Spaced repetition is an effective solution to this problem and Anki is the most popular OSS tool to help you.

What you will learn

What is the history of SRS algorithms?

How the Anki SRS algorithm is implemented.

How the Anki SRS algorithm differs from other known implementations.

How the Anki SRS algorithm can be improved.

Anki's source code is released under AGPL v3. The code presented in this article has been lightly adapted for learning and readability.

Prerequisites

I assume you have used Anki before. All of the code examples use the Python language, mainly because Anki was only implemented in Python until recently, and also because it's a great language for novice programmers. You don't need to have a solid understanding of the language to follow the article as the code uses basic Python syntax.

SRS primer

The role of any Spaced Repetition System (SRS) algorithm is to determine what the user should review now, or say differently when the next review should occur for each memorized item. The goal of any implementation is to counteract the effect of the forgetting curve:

forgetting curve

As soon as we learn or revise knowledge, decay begins. SRS algorithms must determine the optimal interval between two notices to ensure that it has not been completely forgotten (memory retention = 0%) while trying to limit the number of notices as much as possible. In practice, most algorithms use 10% for the forgetting index (= 90% of items are remembered correctly) so that we don't have too many items to review while keeping a number of revisions close to 1. 'optimal.

The details of the different algorithms differ greatly from system to system. We'll start by reviewing the most popular ones in history before showing you Anki's solution.

The Leitner system (1970-)

While Hermann Ebbinghaus is credited with the original research behind SRS, the Leiter system is often cited as the first algorithm. This system uses a physical box as shown by the following illustration:

What's Your Reaction?

like

dislike

love

funny

angry

sad

wow