Skip to main content

Adaptive Learning Engine

A lightweight, model-driven engine for personalised learning.
Knows what you know, predicts when you'll forget it, and picks what to study next.

Tests PyPI version Python 3.10+ NumPy Bayesian knowledge tracing Spaced repetition MIT license

It combines Bayesian Knowledge Tracing, spaced-repetition modelling, learner-specific forgetting curves, item difficulty estimation, response-time signals, knowledge transfer, study-budget optimisation and dropout-risk modelling to decide what a learner should study next.

Learner answers            right or wrong, response time, which wrong option was picked
      ↓
Knowledge state            bkt.py, hesitation.py, related.py
      ↓
Memory prediction          srs.py, personalize.py (this learner's k and g)
      ↓
Difficulty + ability       difficulty.py
      ↓
Daily load                 dropout.py (a lighter day when quitting looks likely)
      ↓
Time constraints           budget.py (most recall per second)
      ↓
NEXT BEST STUDY ACTION     recommend.py

Quick start

pip install adaptive-learning-engine
from adaptive_learning_engine import AdaptiveLearner

learner = AdaptiveLearner()
learner.add_items(["spanish_001", "spanish_002", "spanish_003"])

learner.record_answer("spanish_001", correct=True, response_time=2.4)   # seconds

plan = learner.recommend(available_time=900)                            # 15 minutes
plan.next           # Action(kind="learn", item_id="spanish_002", reason="new", ...)
plan.reviews        # due reviews, most valuable first, each with a reason

AdaptiveLearner keeps one learner's state in memory and runs the whole pipeline for you. Save it with to_dict() (JSON-safe) and load it again with AdaptiveLearner.from_dict(). Every stage is also a module of plain functions, so you can use any model on its own. The only dependency is numpy.

API

AdaptiveLearner(daily_new=10): one learner, for one subject.

Method What it does
add_item(item_id, level="Beginner", difficulty=None, related=()) Add an item (an int or str id). New items are introduced in the order added. difficulty is an Elo rating if you have one; related is (other_id, similarity) pairs.
add_items(ids, level="Beginner") Add several items.
link_related({id: text}) Link items by tf-idf text similarity, so known items give related new ones a head start.
record_answer(item_id, correct, response_time=None, choices=None, when=None, confused_with=None) Record an answer. response_time is in seconds; choices is the number of multiple-choice options (None means free recall); when is a date or datetime (default today); confused_with is the item whose answer was given instead. Returns an AnswerResult with p_learned, stability, next_review and hesitation.
recommend(available_time=None, when=None) A Plan with next, reviews, new_items, due, new_quota, quit_risk, light_day and estimated_minutes. available_time is in seconds.
due(when=None) Item ids due for review on that day.
memory The fitted memory model: factor (k), growth (g), their 80% ranges, and observations.
ability, confusions(min_times=2), typical_response_time(choices=None) What the engine has learned about this learner.
to_dict(), AdaptiveLearner.from_dict(data) Save and restore everything.

Bad input raises a clear TypeError, ValueError or KeyError: for example an unknown item, a negative response time, one-option multiple choice, or answers recorded out of date order.

recommend(items, learner, today, minutes=None) is the stateless version, for when you keep state in your own database. You pass a list of Item records and a Learner summary, and get back the same Plan.

Item difficulty is a cross-learner estimate. One learner's answers update their own ability, not the items' ratings. To rate items, run difficulty.update over all your learners' answers and pass the results in as difficulty=.

Examples

  • examples/quickstart.py: each model on its own, then recommend(), using world capitals.
  • examples/times_tables.py: a simulated student learning the 6–9 times tables for three weeks, in 5-minute sessions, driven by AdaptiveLearner.

Development

uv sync
uv run pytest                       # 102 tests
uv run python examples/times_tables.py
uv run python sim/simulate.py       # about 5 minutes; --seed and --learners to vary it

Tests run on Python 3.10, 3.11, 3.12 and 3.13 for every push.

The models

Module What it does
bkt.py Bayesian Knowledge Tracing. After each answer, Bayes' rule updates P(learned), allowing for lucky guesses and careless slips, then adds the chance the item was learned during that attempt.
srs.py Spaced repetition on a forgetting curve: recall after t days is 0.9^(t/S). A right answer after a gap grows stability S, and a miss shrinks it.
personalize.py Personal memory model. Fits k (how fast this learner forgets) and g (how much each review strengthens memory) from their own reviews, using a Bayesian 2-D grid with priors centred on the default model. Next review is in k · g^n · S days.
hesitation.py Response time as evidence. A right answer at 1.5–4× the learner's own usual time counts as weaker evidence and grows stability less, like Anki's "hard" grade.
difficulty.py Item difficulty and learner ability, Elo / one-parameter IRT style: P(correct) = guess + (1−guess)·σ(ability − difficulty + ease). Hard items start with lower confidence and come back sooner.
related.py Related items by tf-idf cosine similarity. Items you already know raise the starting confidence of similar new ones (knowledge transfer).
budget.py Short on time? Scores each due review by how much it raises recall a week from now, per second it takes, and fills a time budget greedily (knapsack).
dropout.py Quit risk. Logistic regression on study gaps, recent activity and accuracy trend, refitted as a Bayesian (MAP) model with a prior on hand-set starting weights.
recommend.py The pipeline. Fits the memory model, checks quit risk to set the day's load, finds due reviews, ranks them by recall gained per second within the time budget, and adds new items with starting confidence from difficulty and related known items. Reviews come first.
scheduler.py, grading.py Daily new-item allowance from test scores; harder question types as confidence rises; typed answers that accept small typos.

Does it work? A simulation

The results below come from uv run python sim/simulate.py with its defaults (--seed 7 --learners 300). The simulation is deterministic, so the same seed always gives the same numbers, and a test checks that.

sim/simulate.py creates 300 simulated learners. Each one has a hidden forgetting curve per item and their own memory strength. They learn 10 items a day for 30 days, and each review schedule is scored on day 60.

Schedule Recall at day 60 Reviews
Personalised (k and g) 91.7% 2,380
Personalised (k only) 85.3% 2,052
One shared model for everyone (control) 93.5% 2,663
Default model, not personalised 70.1% 1,698
Every day 100.0% 13,350
Every 3 days 97.4% 4,350
Every 7 days 68.5% 1,780
Ladder 1-3-7-14-30 54.1% 1,250

What personalising does is spend reviews where they're needed. It keeps every quarter of learners, from weakest to strongest, near the 90% recall target (90.7–92.1%). One shared model gives strong learners 96% recall, but with 30% more reviews than they need. Overall, personalising uses 11% fewer reviews than the shared model, for 1.8 points less recall.

The model's predictions also match the simulated reality more closely. It predicted 4% more correct reviews than actually happened. The k-only version was 9% too optimistic, and the default model 23%.

Limits:

  • k is genuinely personal: fitted k correlates 0.87 with each learner's true memory strength.
  • g mostly isn't: its correlation with each learner's true growth is only 0.19. It mainly corrects the default growth rate for everyone.
  • I wrote the simulator's memory model, so these results are a sanity check, not proof. In it, the default model is far too optimistic (median fitted k is 0.29), and real learners may differ.
  • Only the memory model is simulated. Response time, difficulty, related items, time budgets and quit risk are tested for correct behaviour, but showing they improve learning needs real users.
  • Difficulty and quit risk learn across users, so with very few users they stay close to their starting values.
  • Related-item links compare the surface of words. In Spanish, haces ("you do") and hace ("it makes", used for weather) end up linked.

Using the models directly

Every model is plain functions on numbers:

from datetime import date
from adaptive_learning_engine import bkt, srs, personalize

params = bkt.params_for("Beginner")
p = bkt.update(params.p_init, correct=True, params=params, p_guess=0.25)   # 4-option multiple choice

stability = srs.grow(1.0, p, days_since_last=3)
fit = personalize.fit(observations)            # this learner's past reviews
next_day = srs.next_review(date.today(), fit.scale(successes) * stability)

License

MIT

Metadata

Release files for adaptive-learning-engine 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for adaptive-learning-engine 0.2.0
File Size Uploaded Provenance Actions
adaptive_learning_engine-0.2.0.tar.gz 32.0 kB With provenance Details for adaptive_learning_engine-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for adaptive-learning-engine 0.2.0
File Interpreter ABI Platform Actions
adaptive_learning_engine-0.2.0-py3-none-any.whl Python 3 none any Details for adaptive_learning_engine-0.2.0-py3-none-any.whl

Total release size: 61.0 kB

Release files / adaptive_learning_engine-0.2.0.tar.gz

Download URL adaptive_learning_engine-0.2.0.tar.gz
Size 32.0 kB
Tags Source
SHA-256 checksum
How to use checksums
4cfd50372ca2574f725b9385c7229268e299a7167781e81fcbb4e17229ab3c14
BLAKE2b-256 checksum
How to use checksums
bade7e3dffdc08ac0a4f5d3432f904e6dc4991888f79508f162db2329151b624
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.

Transparency log

Release files / adaptive_learning_engine-0.2.0-py3-none-any.whl

Download URL adaptive_learning_engine-0.2.0-py3-none-any.whl
Size 29.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2fd56d918a620dc34a1bd2d3e7e9c0f9edfa7f5cfd2f7d6cfdc9b067f556c279
BLAKE2b-256 checksum
How to use checksums
79b94c32586c8dbeb605e1a8a79dfcfb28863ee14c20dc0a6f94ab8ea0df0d17
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.

Transparency log

Security for adaptive-learning-engine 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for adaptive_learning_engine-0.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page