Skip to content

The Optimal Retention

Jarrett Ye edited this page Mar 15, 2024 · 34 revisions

Definition

When we talk about spaced repetition, two things really matter:

  1. How many flashcards will I remember? (knowledge acquisition)
  2. How long will it take? (workload in minutes of studying per day)

We want to remember as much as possible while spending as little time as possible. In FSRS, both minimizing the workload and maximizing the rate of knowledge acquisition can be achieved by choosing the right value of desired retention.

Imagine we’re adding new cards constantly every day and doing reviews on time. Our knowledge acquisition will be high if we set a high desired retention.

$knowledge = \sum\limits_{i=1}^n R_i$,

where $n$ is how many cards we’ve learned, and $R_i$ is the probability we can recall the i-th card. Simply put, it's the sum of all probabilities of recall.

But high desired retention means we have to review cards more often, which increases our workload. When we lower our desired retention, both our workload and how much we remember go down. However, if the desired retention is really low, we forget a lot and have to relearn cards, making our workload go up again. There are two "forces" at play here:

  1. As desired retention increases, intervals become shorter, and therefore the number of reviews per day increases.
  2. As desired retention decreases, we forget more and therefore have to re-learn more of our material.

As a result, if we plot the workload as a function of desired retention, it will be U-shaped.

image

The same is true if we divide workload by knowledge (the formula in the beginning of this article), which tells us how much we will have to study relative to how much we will remember. However, the exact value of desired retention that corresponds to the minimum is now slightly different.

image

Simulation

With FSRS, it's possible to simulate the learning process in Anki.

Code: https://github.com/open-spaced-repetition/fsrs-rs/blob/0634cb08b08fecb96b0b8a9caba4a5e6938e85bb/src/optimal_retention.rs#L107-L407

Here's a step-by-step overview of the simulation:

  1. Initialization and Configuration Reading:

    • Extract various parameters from the SimulatorConfig configuration, such as deck size, learning span, maximum cost per day, etc. Here and hereafter "cost" refers to seconds of studying.
    • Initialize the card_table as a zero matrix, then fill it with initial values based on the configuration (like learning span and very small values for difficulty and stability).
  2. Initialize Daily Counters and Cost Arrays:

    • Initialize arrays for daily review counts, learning counts, memorized counts, and total daily costs.
  3. Simulation Loop:

    • For each day (within the learning span, "Days to simulate"), perform the following steps:
      • Calculate the elapsed days since last review (delta_t) and retrievability for learned cards based on the card's stability and last review date.
      • Determine which cards need to be reviewed and generate random values for these cards to later decide if they are forgotten. The probability that a user will press Good/Hard/Easy is estimated from the user's review history.
      • Based on retrievability and random values, determine which cards are forgotten and assign ratings to cards that need to be reviewed.
      • Update the cost of cards based on whether they are forgotten, their review ratings, and the cost parameters defined in the configuration. Cost parameters, such as how much time the user spends per card when he answers "Good" or "Again", are estimated from the user's review history.
      • Compute the cumulative sum of costs to determine which cards will be reviewed. Due to the daily maximum cost and review limits, not all cards can always be reviewed.
      • Determine which new cards need to be reviewed for the first time.
      • Randomly generate ratings for newly learned cards, update their stability and difficulty.
      • Update cards' last_date, stability, difficulty, interval, and due fields.
      • Update daily review counts, learning counts, memorized counts, and total costs.
  4. Return Results:

    • Return arrays of memorized counts, review counts, learning counts, and daily total costs.

The memorized count is the total knowledge acquired from the first day to the current day in the simulation. The review count is the number of cards reviewed during the current day. The learn count is the number of new cards learned during the current day. The daily total cost is time spent reviewing cards and learning new cards during the current day.

Optimization

With the simulator, it's possible to predict the workload for each desired retention level. The optimizer uses Brent's method to find the optimal retention.

Code: https://github.com/open-spaced-repetition/fsrs-rs/blob/0634cb08b08fecb96b0b8a9caba4a5e6938e85bb/src/optimal_retention.rs#L478-L589

Note: Before Anki 24.04, the goal was maximizing the knowledge​ acquisition, but in Anki 24.04 and newer, the goal is minimizing ​workload/knowledge.