how spaced repetition actually works: the sm-2 algorithm
most people study inefficiently.
we review things too early - wasting time. or too late - after we’ve already forgotten them.
the real question is simple: when is the optimal moment to review something?
in 1987, a polish researcher named piotr woźniak proposed a surprisingly simple answer. he built an algorithm that schedules reviews so that you see information just before you forget it. that algorithm is called sm-2, and variations of it power spaced-repetition tools used by millions of people today, including systems like anki.
the fascinating part is that the core idea is extremely small. the entire algorithm fits in a few variables and a short formula.
but to understand why it works, we first need to look at how memory behaves.
human memory decays quickly. in the late 19th century, psychologist hermann ebbinghaus studied how quickly people forget newly learned information. his experiments produced what we now call the “forgetting curve” - a model showing that memory retention drops rapidly over time unless the information is reinforced.
if you learn something today and never revisit it, the probability of remembering it decreases dramatically over the next few days. this means that reviewing information randomly is inefficient. review too early and you’re spending time on something you still remember well. review too late and you’ve already forgotten it.
the optimal strategy is to review something right before you forget it.
this idea is the foundation of spaced repetition.
instead of reviewing information repeatedly in a short period of time, spaced repetition increases the gap between reviews. a typical review schedule might look something like this:
day 0 → day 1 → day 3 → day 7 → day 16 → day 35 → day 90
each successful recall strengthens the memory, allowing the next review to be pushed further into the future.
however, there is a problem with using a fixed schedule. not all information has the same difficulty.
some facts stick instantly. others require repeated effort to remember. a system that treats all information the same will inevitably be inefficient.
this is where sm-2 becomes interesting.
instead of scheduling reviews globally, sm-2 assigns a small learning model to every flashcard. each card tracks a few pieces of information about your interaction with it, and the scheduling decisions are made based on that history.
the algorithm keeps track of three things.
- the repetition count, which is simply the number of successful reviews the card has had.
- the interval which represents how many days should pass before the card appears again.
- the easiness factor which represents how difficult the card is for you personally.
when a card is first introduced, its easiness factor usually starts at 2.5. this value will change over time depending on how well you recall the card.
whenever you review a card, you grade your recall using a score from 0 to 5.
- a score of 5 means the answer was recalled perfectly.
- a score of 4 means correct but with hesitation.
- a score of 3 means correct but difficult to recall.
- a score of 2 or lower indicates failure.
if the score is below 3, the algorithm assumes the card has effectively been forgotten. the repetition counter resets and the interval goes back to one day so that the card can be relearned quickly.
if the recall was successful, the interval grows.
the first successful review schedules the next review for 1 day later.
the second successful review schedules it for 6 days later.
after that, the interval is calculated using a simple rule:
i(n) = i(n−1) × ef
in other words, the next interval is the previous interval multiplied by the card’s easiness factor.
if the ef is 2.5, the intervals might look like this:
1 day → 6 days → 15 days → 37 days → 92 days
the intervals expand rapidly, reflecting the fact that well-learned information can be retained for much longer periods.
but the real cleverness of sm-2 lies in how the easiness factor itself is updated.
after each review, the ef is adjusted based on the recall quality using this formula:
ef = ef + (0.1 - (5 - q) × (0.08 + (5 - q) × 0.02))
here, q represents the quality score given during the review.
this formula has an intuitive effect. if a card is consistently recalled easily, the easiness factor increases slightly, causing intervals to grow faster. if a card is difficult to recall, the ef decreases, making the algorithm schedule reviews more frequently.
to prevent intervals from collapsing completely, the algorithm enforces a minimum value:
ef ≥ 1.3
with just these rules, the algorithm adapts the schedule for every card individually.
easy cards gradually disappear into long review intervals. difficult cards keep resurfacing until they stabilize.
the elegance of sm-2 is that it achieves this adaptive behavior with almost no complexity. the entire system requires only a few variables and a small update formula. there is no machine learning, no probabilistic modeling, and no large datasets involved.
despite that simplicity, it works remarkably well.
even decades after its creation, many spaced-repetition systems still rely on sm-2 or slight variations of it. newer algorithms attempt to model memory more precisely using statistical techniques, but sm-2 remains popular because it strikes a great balance between effectiveness and simplicity.
in fact, you can implement the entire scheduling logic in just a few lines of code. here is what that looks like in go:
type Card struct {
Repetition int
Interval int
EF float64
}
func Review(card *Card, quality int) {
if quality < 3 {
card.Repetition = 0
card.Interval = 1
return
}
if card.Repetition == 0 {
card.Interval = 1
} else if card.Repetition == 1 {
card.Interval = 6
} else {
card.Interval = int(float64(card.Interval) * card.EF)
}
card.Repetition++
ef := card.EF + (0.1 - float64(5-quality)*(0.08+float64(5-quality)*0.02))
if ef < 1.3 {
ef = 1.3
}
card.EF = ef
}
with this small piece of logic, you can build the core of a spaced-repetition scheduler.
sm-2 is a nice reminder that powerful systems don’t always require complicated algorithms. sometimes a simple model, applied consistently, is enough to produce surprisingly effective behavior.
in this case, a few lines of math ended up shaping how millions of people learn.