knowledgespaces — Knowledge Space Theory for Python

A Python library for Knowledge Space Theory (Doignon & Falmagne, 1999) covering the pipeline from item analysis to adaptive assessment.

Structures

Build knowledge structures and spaces from prerequisite relations.

Knowledge Structures and Relations
Query Experts

Derive structures by querying human experts or LLMs.

Querying Experts
CB-KST

Derive structures from skill maps and competence models.

Competence-Based KST (CB-KST)
Assessment

Adaptive assessment with BLIM and Expected Information Gain.

Adaptive Assessment
Parameter Estimation

Estimate BLIM parameters from response data via EM.

Parameter Estimation (EM)
Command Line

ks inspect, ks query, ks assess for non-programmers.

Command Line Interface
MCP Server

Use KST via LLM — tools, docs, and guided workflows.

MCP Server
API Reference

Full API documentation generated from source code.

API Reference

Quick example

import knowledgespaces as ks

# Build a knowledge structure
structure = ks.space_from_prerequisites(
    ["add", "sub", "mul"],
    [("add", "sub"), ("sub", "mul")],
)

# Assess a student
result = ks.assess(structure, {"add": True, "sub": True, "mul": False})
print(result["state"])        # {'add', 'sub'}
print(result["outer_fringe"]) # {'mul'} — what to learn next

Install

pip install knowledgespaces