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 exposes the same API in both native and WASI builds. The main package prefers native modules in Node; its browser entry uses the multi-threaded WASI package. Install the package your environment needs:

Native module (Node, servers, and CLIs):

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

Single-threaded WASI Preview 1 (wasm32-wasip1):

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

Multi-threaded WASI Preview 1 (wasm32-wasip1-threads, published as wasm32-wasi):

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

The multi-threaded build is deprecated. It remains available in this release and is planned for removal in the next release. Use the single-threaded package above for new WASI integrations.

import { computeParameters } from '@open-spaced-repetition/binding'

To select single-threaded WASI explicitly, import from @open-spaced-repetition/binding-wasm32-wasip1. Both WASI packages can run in Node or a browser Worker.

COOP/COEP and threading

The single-threaded build does not need Cross-Origin-Opener-Policy or Cross-Origin-Embedder-Policy headers. The multi-threaded build still requires a crossOriginIsolated page served with COOP and COEP headers. Only the runtime is ever multi-threaded. The multi-threaded package does not make training run in the background.

computeParameters and evaluateWithTimeSeriesSplits return Promises. The native binding runs them as background tasks. Both WASI Preview 1 targets (wasm32-wasip1 and wasm32-wasip1-threads) compute synchronously on the calling thread and then wrap the result in a Promise. In browsers, you should call them from a dedicated Worker to keep the page responsive; the Worker can forward progress callbacks to the page with postMessage.

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.