cognarium
Run cognitive science experiments on language models and other learners. A standard experiment takes a few lines: cognarium builds the trials, runs them through the model, scores the effect the paradigm is known for, and saves everything needed to reproduce it. The same paradigms work on Hugging Face models, LSTMs, exemplar learners and Bayesian learners, on CPU, MPS or CUDA.
Status
This is version 0.1.0. It has three learning paradigms, each of which also runs on exemplar and Bayesian learners as baselines. It has CSV and JSON conversion, a registry of open datasets pinned by checksum, comparison with human data, per-trial logits, the logit lens, hidden-state datasets, resumable runs, and information, classification, signal detection, geometry, statistics and naming metrics. Quantization and multi-GPU sweeps come next.
Experiments
| Paradigm | What it does | Built on |
|---|---|---|
IteratedLearning |
Each generation learns from the previous generation's answers and passes its own on, for the Shepard structures or any category system or function | Kirby, Cornish and Smith (2008); Kalish, Griffiths and Lewandowsky (2007); Griffiths and Kalish (2007); Imel and Zaslavsky (2026) |
CategoryLearning |
Learns the Shepard structures, any category system or a function from corrective feedback, block by block | Shepard, Hovland and Jenkins (1961); Nosofsky et al. (1994) |
ArtificialGrammar |
Studies strings from a finite-state grammar, then judges new ones, with grammaticality and chunk strength crossed, or compares them by string probability | Reber (1967); Knowlton and Squire (1996); Hu and Levy (2023) |
The paradigms page explains each one, how it maps onto the human task, what it can't capture, and results on GPT-2 and Qwen3.5-4B-Base, with full references.
Install
From a clone of this repository:
uv pip install .
For development, and to build the docs:
uv sync --extra dev --extra docs
uv run mkdocs serve
Quickstart
import cognarium as cg
subject = cg.load("gpt2", device="auto")
results = cg.run(cg.paradigms.ArtificialGrammar(), subject)
results.score()
results.to_pandas()
results.metrics("accuracy", "entropy")
score() gives one row per effect the paradigm declares, with a bootstrap interval over
items and a permutation test. Where a measure stands in for a human one, such as
surprisal for reaction time, the table names it in proxy_for.
Each run writes to runs/<paradigm>/<key>/. Running the same call again continues after
the last saved step, and a folder that holds a different run is refused.
Documentation
The docs cover installing, a longer quickstart, the concepts, writing your own paradigm, recording hidden states, metrics, data and reproducibility. Each paradigm's section says how it maps onto the human task, the work it builds on, and what it can't capture.
Contents
src/cognarium/: the libraryparadigms/: the baseParadigmclass and the three built-in experimentstasks/: what a paradigm presents, such as the Shepard structures or any mapping from items to a fixed set of labelssubjects/: Hugging Face models, custom modules, exemplar and Bayesian learnersmodels/: the bundled LSTM and its tokenizerrecording/: layer maps, state capture, the state store and the logit lensmetrics/: plain metric functions, human comparison, and the measures behindResults.metricsdata/: CSV and JSON conversion, the dataset registry and its downloadsrunner.py:run, which saves each step as it finishesresults.py:Results, which reads a run back
examples/: runnable scripts: a tour that runs every built-in paradigm on one model, iterated learning on every kind of subject, the six Shepard types against the human order, grammar learning with both tests, the iterated function learning design of Kalish, Griffiths and Lewandowsky (2007), and in-context iterated learning of colour names on the World Color Survey chips (Imel and Zaslavsky, 2026)docs/: the documentation sitetests/: the test suite, which also runs every code block in the docs
Reproducing
uv run python examples/paradigm_tour.py --model gpt2 --device auto
uv run pytest
Every run's manifest.json holds its settings, seeds, library versions, model revision,
dataset checksums, and the device and batch size of each session. Exact numeric equality
across devices isn't guaranteed.
Metadata
Release files for cognarium 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| cognarium-0.1.0.tar.gz | 437.7 kB | With provenance | Details for cognarium-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cognarium-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for cognarium-0.1.0-py3-none-any.whl |
Total release size: 590.8 kB
Release files / cognarium-0.1.0.tar.gz
| Download URL | cognarium-0.1.0.tar.gz |
|---|---|
| Size | 437.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f67f4ad077cc94eefd3a7c48af3a5308d1e94f3e5c0cd97f70afef2add8e50bf
|
|
BLAKE2b-256 checksum How to use checksums |
6840131193c09b216317f9f2e0007d5933d88048a27f0318763adf5c21de601b
|
| 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 8, 2026.
Transparency logRelease files / cognarium-0.1.0-py3-none-any.whl
| Download URL | cognarium-0.1.0-py3-none-any.whl |
|---|---|
| Size | 153.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a159af97709164f2af4e3d82447abcc3eb2bdb18115b7891f6466105affbf894
|
|
BLAKE2b-256 checksum How to use checksums |
fd61e1806c716a7c18f6d2f4ab3302b39a892b63736e5f197f61d2edff0025cd
|
| 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 8, 2026.
Transparency logSecurity for cognarium 0.1.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.
Attestation for cognarium-0.1.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 8, 2026.
Transparency logA 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.