Bayesian Knowledge Tracing
src/lib/knowledge-tracing.ts implements classic BKT with two modern extensions: temporal
decay and prerequisite-aware content selection.
The model
For each knowledge component, BKT maintains P(L) — the probability the learner has mastered it
— updated after every observation:
correct: P(L | obs) = P(L)·(1 − pSlip) / [ P(L)·(1 − pSlip) + (1 − P(L))·pGuess ]
incorrect: P(L | obs) = P(L)·pSlip / [ P(L)·pSlip + (1 − P(L))·(1 − pGuess) ]
then: P(L)' = P(L | obs) + (1 − P(L | obs))·pTransitDefault parameters
src/lib/knowledge-tracing.ts
export const DEFAULT_BKT_PARAMS: Readonly<BKTParams> = {
pL0: 0.1, // prior probability of initial mastery
pTransit: 0.15, // probability of learning per opportunity
pGuess: 0.25, // probability of guessing correctly without mastery
pSlip: 0.1 // probability of erring despite mastery
}Temporal decay
Mastery decays exponentially when no practice occurs, with a half-life of 14 days — a skill untouched for two weeks drops to half its estimated mastery contribution, prompting review.
Recommendation reasons
The selector explains why it recommends an item:
reason: 'low-mastery' | 'high-uncertainty' | 'prerequisite-gap' | 'decay'- low-mastery — P(L) below threshold
- high-uncertainty — too few observations to be confident
- prerequisite-gap — a prerequisite concept (from the concept graph) is weak
- decay — mastery has decayed since the last practice
These feed the Course View’s next-item selection and the DLP Monitor’s display.