✨ A modern Anki custom scheduling based on Free Spaced Repetition Scheduler algorithm ✨
- FSRS4Anki
- Introduction
- 1 Quick Start
- 2 Advanced Usage
- 3 Using the Helper Add-on
- FAQ
- Compatibility
- Contribute
- Stargazers over time
FSRS4Anki consists of two main parts: scheduler and optimizer.
The scheduler is based on a variant of the DSR (Difficulty, Stability, Retrievability) model, which is used to predict memory states. The scheduler aims to achieve the requested retention for each card and each review.
The optimizer applies Maximum Likelihood Estimation and Backpropagation Through Time to estimate the stability of memory and learn the laws of memory from time-series review logs. Then, it can find the optimal retention to minimize the repetitions via the stochastic shortest path algorithm.
For more detail on the mechanism of the FSRS algorithm, please see my papers: A Stochastic Shortest Path Algorithm for Optimizing Spaced Repetition Scheduling (free access) and Optimizing Spaced Repetition Schedule by Capturing the Dynamics of Memory (submit request).
FSRS4Anki Helper is an Anki add-on that supports the FSRS4Anki Scheduler. It has six features:
- Reschedule cards based on their entire review histories.
- Postpone due cards whose retention is higher than your target.
- Advance undue cards whose retention is lower than your target.
- Balance the load during rescheduling.
- No Anki on Free Days (such as weekends).
- Disperse Siblings (cards with the same note) to avoid interference & reminder.
中文版请见:FSRS4Anki 使用指北
Preferences > Review > Enable V3 Scheduler
In the deck options, find the Advanced Settings column, and paste the code in fsrs4anki_scheduler.js into the Custom Scheduling field:
Idealy, you've now started using the FSRS4Anki Scheduler. If you're unsure, you can change this part of the code:
const display_memory_state = false;
to:
const display_memory_state = true;
Then open any deck for review and you'll see:
This shows that your FSRS is running normally. You can then change the code back and the message will no longer display.
You can generate parameters in a variety of ways depending on which method you prefer.
For the most up to date methods please check the releases.
Open the optimizer's notebook and click on Open in Colab to run the optimizer on Google Colab. You don't need to configure the coding environment yourself and you can use Google's machines for free (you'll need to register a Google account):
After opening it in Colab, switch to the folder tab. Once the Optimizer connects to Google's machine, you can right-click to upload your deck file/collection file. When exporting these files, make sure to tick "Include scheduling information" and "Support older Anki versions".
After it's uploaded, change the filename
in the notebook to the name of your uploaded file. And set your timezone
and next_day_starts_at
.
Then click "Run All".
Wait for the code to finish in section 2.3, then copy the personalized parameters that were output.
Replace the parameters in the FSRS code you copied earlier.
Simply upload your exported decks to this website and it will optimise it for you.
https://huggingface.co/spaces/open-spaced-repetition/fsrs4anki_app
There is a python package for the optimizer. This package has torch as a dependency so note it might take about half a gigabyte of space.
Install this package with the command:
python -m pip install fsrs4anki_optimizer
Export your deck and cd into the folder in which you exported it.
Then you can run:
python -m fsrs4anki_optimizer "package.(colpkg/apkg)"
There are certain options which are as follows
options:
-h, --help show this help message and exit
-y, --yes, --no-yes If set automatically defaults on all stdin settings.
-o OUT, --out OUT File to APPEND the automatically generated profile to.
Please note that this does not support multiple files in one command / wildcards so for that functionality use a for loop.
Download and install this version of the anki helper addon either by git cloning it into the anki addons folder or downloading it as a zip and extracting the zip into the anki addons folder.
Install the optimizer locally.
Please pay attention to the popup.
After that has downloaded and installed you should be able to run the optimizer from within anki.
Press the cog next to any given deck and hit the optimize option.
Anki may then hang a small while while it loads the optimizer.
Hit yes to find the optimum retention, Hit no to not or hit cancel to pick a different deck.
If all is well you should then get a toolbar popup which tells you the progress of the optimization.
You should then get the stats in a format which is easy to copy into the javascript scheduler.
These values are saved in the addons config file which can be found and edited in anki if you want to change the retention manually for example.
If there are any issues with this please mention them on this pull request here.
You can also generate different parameters for different decks and configure them separately in the code. In the default configuration, deckParams
already contains three groups of parameters.
The group "global config for FSRS4Anki" is global parameters.
The group "MainDeck1" are the parameters applied to the deck "MainDeck1" and its sub-decks.
Similarly, the third group is the parameters applied to the deck "MainDeck2::SubDeck::SubSubDeck" and its sub-decks. You can replace these with the decks you want to configure. If you need more, feel free to copy and add them.
const deckParams = [
{
// Default parameters of FSRS4Anki for global
"deckName": "global config for FSRS4Anki",
"w": [0.4, 0.6, 2.4, 5.8, 4.93, 0.94, 0.86, 0.01, 1.49, 0.14, 0.94, 2.18, 0.05, 0.34, 1.26, 0.29, 2.61],
// The above parameters can be optimized via FSRS4Anki optimizer.
// For details about the parameters, please see: https://github.com/open-spaced-repetition/fsrs4anki/wiki/The-Algorithm
// User's custom parameters for global
"requestRetention": 0.9, // recommended setting: 0.8 ~ 0.9
"maximumInterval": 36500,
// FSRS only modifies the long-term scheduling. So (re)learning steps in deck options work as usual.
// I recommend setting steps shorter than 1 day.
},
{
// Example 1: User's custom parameters for this deck and its sub-decks.
"deckName": "MainDeck1",
"w": [0.6, 0.9, 2.9, 6.8, 4.72, 1.02, 1, 0.04, 1.49, 0.17, 1.02, 2.15, 0.07, 0.35, 1.17, 0.32, 2.53],
"requestRetention": 0.9,
"maximumInterval": 36500,
},
{
// Example 2: User's custom parameters for this deck and its sub-decks.
// Don't omit any keys.
"deckName": "MainDeck2::SubDeck::SubSubDeck",
"w": [0.6, 0.9, 2.9, 6.8, 4.72, 1.02, 1, 0.04, 1.49, 0.17, 1.02, 2.15, 0.07, 0.35, 1.17, 0.32, 2.53],
"requestRetention": 0.9,
"maximumInterval": 36500,
}
];
If there are some decks you don't want to use FSRS with, you can add their names to the skip_decks
list.
const skip_decks = ["MainDeck3", "MainDeck4::SubDeck"];
Please see: FSRS4Anki Helper
Here collect some questions from issues, forums, and others: FAQ
Some add-ons modify the scheduling of Anki, which would cause conflict with FSRS4Anki scheduler.
Add-on | Compatible? | Comment |
---|---|---|
Advanced Review Bottom Bar | Yes✅ | Please use the latest version. |
Incremental Reading v4.11.3 (unofficial clone) | No❌ | It shows the interval given by Anki's built-in scheduler, not the custom scheduler. |
Auto Ease Factor | Yes✅ | Ease Factor doesn't affect the interval given by FSRS. |
Delay siblings | Yes✅ | Delay siblings will modify the interval give by FSRS. |
autoLapseNewInterval | Yes✅ | New Interval doesn't affect the interval given by FSRS. |
Straight Reward | Yes✅ | Ease Factor doesn't affect the interval given by FSRS. |
Pass/Fail | Yes✅ | Pass is the equivalent of Good . |
Let me know via issues if I miss any add-ons.
You can contribute to FSRS4Anki by beta testing, submitting code, or sharing your data. If you want to share your data with me, please fill this form: https://forms.gle/KaojsBbhMCytaA7h8