open-spaced-repetition/fsrs-rs

FSRS for Rust, including Optimizer and Scheduler

What it is A Rust programming language library that implements the Free Spaced Repetition Scheduler (FSRS), a modern algorithm for scheduling flashcard reviews. It is designed for developers building flashcard or learning apps.

Core Purpose It provides two main functions: scheduling when a user should next review a card, and optimizing the algorithm's internal parameters based on a user's past review history to make future scheduling more accurate. It also includes simulation tools for testing.

Key Capabilities

  • Schedule Reviews: Given a card's previous memory state and how many days have passed, it calculates the next review interval for each answer button (e.g., "Again", "Good", "Easy").
  • Optimize Parameters: Takes a log of a user's past reviews (dates and ratings) and computes the best algorithm settings for that specific user. A memory-efficient version (CardPrefixes) is available that uses far less RAM for long histories.
  • Migrate from SM-2: Can convert data from the older SM-2 algorithm (using its ease factor and interval) into the FSRS format, allowing a smooth transition for existing apps.
  • Cost ADR Policy: Includes an experimental optimizer for a more advanced policy that adjusts desired retention based on a daily time/cost limit, and can simulate its performance.

Technical Highlights

  • Written in pure Rust with SIMD (hardware-accelerated) kernels for fast computation and analytic gradients for training, avoiding heavy external dependencies like PyTorch.
  • Supports both FSRS-6 and FSRS-7 algorithm versions, automatically selected based on the number of parameters.

Ecosystem & Relationship to Other Tools

  • The project provides official bindings (wrappers) for C, Python, NodeJS, Dart, and PHP, so developers in those languages can use it too.
  • It is distinct from the rs-fsrs crate: rs-fsrs is for scheduling only, while this crate (fsrs-rs) is the one to use when you need to optimize parameters (though it also handles scheduling).

Getting Started Developers add it to a Rust project with cargo add fsrs. The README provides runnable examples for scheduling, optimizing, migrating, and running the Cost ADR simulation, which can be executed with cargo run --example <name>.

Related

  • Project
  • Project
  • Project
  • Project
  • Project