https://github.com/open-spaced-repetition/fsrs-rs
FSRS for Rust, including Optimizer and Scheduler
https://github.com/open-spaced-repetition/fsrs-rs
fsrs machine-learning rust spaced-repetition-algorithm
Last synced: 3 months ago
JSON representation
FSRS for Rust, including Optimizer and Scheduler
- Host: GitHub
- URL: https://github.com/open-spaced-repetition/fsrs-rs
- Owner: open-spaced-repetition
- License: bsd-3-clause
- Created: 2023-08-16T16:40:37.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2025-04-01T12:11:49.000Z (3 months ago)
- Last Synced: 2025-04-02T12:53:31.525Z (3 months ago)
- Topics: fsrs, machine-learning, rust, spaced-repetition-algorithm
- Language: Rust
- Homepage: https://crates.io/crates/fsrs
- Size: 954 KB
- Stars: 219
- Watchers: 9
- Forks: 24
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Citation: CITATION.cff
Awesome Lists containing this project
- awesome-fsrs - fsrs-rs
README
# FSRS for Rust
[](https://crates.io/crates/fsrs) 
This crate contains a Rust API for training FSRS parameters, and for using them to schedule cards.
The Free Spaced Repetition Scheduler ([FSRS](https://github.com/open-spaced-repetition/fsrs4anki)) is a modern spaced repetition algorithm. It is based on the [DSR model](https://supermemo.guru/wiki/Three_component_model_of_memory) proposed by [Piotr Wozniak](https://supermemo.guru/wiki/Piotr_Wozniak), the creator of SuperMemo.
FSRS-rs is a Rust implementation of FSRS. It is designed to be used in [Anki](https://apps.ankiweb.net/), a popular spaced repetition software. [Anki 23.10](https://github.com/ankitects/anki/releases/tag/23.10) has already integrated FSRS as an alternative scheduler.
For more information about the algorithm, please refer to [the wiki page of FSRS](https://github.com/open-spaced-repetition/fsrs4anki/wiki/The-Algorithm).
---
## Quickstart
Read up [this](https://github.com/open-spaced-repetition/fsrs4anki/wiki/The-Optimal-Retention) to determine the optimal retention for your use case.
```rust
// Pick to your liking (see above)
let optimal_retention = 0.75;
// Use default parameters/Weights for scheduler
let fsrs = FSRS::new(Some(&[]))?;// Create a completely new card
let day1_states = fsrs.next_states(None, optimal_retention, 0)?;// Rate as `hard` on first day
let day1 = day1_states.hard;
dbg!(&day1); // scheduled as `in 4 days`// Now we review the card 2 days later
let day3_states = fsrs.next_states(Some(day1.memory), optimal_retention, 2)?;// Rate as `good` this time
let day3 = day3_states.good;
dbg!(day3);
```## Online development
go to
## Local development
add
```sh
#!/bin/sh
cargo fmt
cargo clippy -- -D warnings
git add .
```to `.git/hooks/pre-commit`, then `chmod +x .git/hooks/pre-commit`
## Bindings
- python
- nodejs
- dart## Q&A
- What is the difference with [rs-fsrs](https://github.com/open-spaced-repetition/rs-fsrs)
If you want to schedule the card, use \[lang\]-fsrs or the [bindings](https://github.com/open-spaced-repetition/rs-fsrs?tab=readme-ov-file#bindings),
If you do the optimization, use this crate or its bindings.
- Why not in one crate but two?
Calculating the weight involves tensor operations. So the initial data type is different(Tensor vs Vec/Slice). In one crate means use `cfg` to change type, which is tedious, so here we keep two versions.
Another reason is, other languages will be hard to port their version when `Tensor` is used.
- What about the name?
At first, there are `go-fsrs` and other libraries, so `rs-fsrs` is used.
Then we want to port the torch version to rust so everyone can calculate on their own devices (tch-rs use libtorch which is too heavy), since the algorithm is called `fsrs`, add `-rs`.