For AI agents: the complete documentation index is available at https://open-spaced-repetition.github.io/ts-fsrs/llms.txt, the full documentation bundle is available at https://open-spaced-repetition.github.io/ts-fsrs/llms-full.txt, and this page is available as Markdown at https://open-spaced-repetition.github.io/ts-fsrs/guide/optimizer/index.md.

Optimizer overview

FSRS ships default model weights, but you can retrain them from your own review logs so the intervals match the people you serve. The Optimizer runs on @open-spaced-repetition/binding, which converts review-log CSV into training items, estimates parameters, and reports how well the result predicts held-out reviews. The trained weights plug straight back into DefaultScheduler or a custom defineScheduler through weights. See Model for what weights mean and Scheduler for where they are applied.

Use the same modelVersion ('FSRS-7' by default, or 'FSRS-6') for CSV conversion, training, evaluation, and scheduling. Pass it as the fourth argument to convertCsvToFsrsItems and in the training/evaluation options, then call DefaultScheduler({ version: modelVersion, weights }). FSRS-7 produces 34 weights and preserves fractional and same-day intervals normalized by the actual local study-day duration; FSRS-6 produces 21 weights and uses whole study days. Same-day follow-up reviews can therefore contribute to FSRS-7 training.

Beta

The Optimizer is currently in beta, and its API methods may change at any time.

For your Agent
Implement or explain FSRS weight training

Copy this prompt to keep an AI agent inside the Optimizer contract: review-log CSV in, trained weights out, through the shared binding.

One package, two runtimes

The binding ships one API, and loading resolves the build for your environment automatically: it searches for an available native package and, in a browser or Worker, falls back to a WebAssembly build. Install the package your environment needs:

Native module (Node, servers, and CLIs):

npm
yarn
pnpm
bun
deno
npm install @open-spaced-repetition/binding

WASI Preview 1 (wasip1) WebAssembly:

npm
yarn
pnpm
bun
deno
npm install @open-spaced-repetition/binding-wasm32-wasip1

wasm32-wasi WebAssembly:

npm
yarn
pnpm
bun
deno
npm install @open-spaced-repetition/binding-wasm32-wasi
import { computeParameters } from '@open-spaced-repetition/binding'

Your environment resolves the matching build: a server or CLI uses the native module, and a browser or Web Worker uses a wasm build.

COOP/COEP and threading

WebAssembly runs threadless or threaded. Threadless wasm needs no Cross-Origin-Opener-Policy or Cross-Origin-Embedder-Policy headers and reports progress through Worker messages rather than shared memory. A threaded build requires the page to be crossOriginIsolated, that is, served with COOP and COEP headers.

The review-log pipeline

Training follows a short pipeline, each step a binding call:

  1. convertCsvToFsrsItems turns review-log CSV into a list of FSRSItems.
  2. computeParameters trains weights from those items and returns the weight array.
  3. evaluateWithTimeSeriesSplits measures how well the parameters predict held-out reviews.

You can also ask the binding to recommend learning and relearning steps with computeOptimalSteps. Walk through each call in Train and evaluate, or run a real training in the trainer on the Playground page.